src/safewriter.c File Reference

#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include "rdd.h"
#include "writer.h"

Include dependency graph for safewriter.c:

Go to the source code of this file.

Data Structures

struct  _RDD_SAFE_WRITER

Typedefs

typedef struct _RDD_SAFE_WRITER RDD_SAFE_WRITER

Functions

static int path_exists (const char *path, struct stat *info)
int rdd_open_safe_writer (RDD_WRITER **self, const char *path, rdd_write_mode_t wmode)
 Creates a writer that does not blindly overwrite existing files.
static int safe_close (RDD_WRITER *w)
static int safe_compare_address (RDD_WRITER *w, struct addrinfo *address, int *result)
static int safe_write (RDD_WRITER *w, const unsigned char *buf, unsigned nbyte)

Variables

static char copyright []
static RDD_WRITE_OPS safe_write_ops


Typedef Documentation


Function Documentation

static int path_exists ( const char *  path,
struct stat *  info 
) [static]

Definition at line 75 of file safewriter.c.

int rdd_open_safe_writer ( RDD_WRITER **  w,
const char *  path,
rdd_write_mode_t  overwrite 
)

Creates a writer that does not blindly overwrite existing files.

Parameters:
w output value: the new writer object
path the name of the file that the new writer will write to
overwrite indicates what to do when path exists
Returns:
Returns RDD_OK on success.
A safe writer behaves almost exactly like a file writer. The key difference is that a safe writer will only overwrite an existing file if overwrite equals RDD_OVERWRITE. Otherwise rdd_open_safe_writer() will fail.

Definition at line 81 of file safewriter.c.

References error(), _RDD_SAFE_WRITER::parent, _RDD_SAFE_WRITER::path, path_exists(), RDD_BADARG, RDD_EEXISTS, rdd_new_writer(), RDD_NO_OVERWRITE, RDD_NOMEM, RDD_OK, rdd_open_file_writer(), and _RDD_WRITER::state.

Here is the call graph for this function:

static int safe_close ( RDD_WRITER w  )  [static]

Definition at line 147 of file safewriter.c.

References _RDD_SAFE_WRITER::parent, _RDD_SAFE_WRITER::path, RDD_ECLOSE, RDD_OK, and rdd_writer_close().

Here is the call graph for this function:

static int safe_compare_address ( RDD_WRITER w,
struct addrinfo *  address,
int *  result 
) [static]

Definition at line 175 of file safewriter.c.

References RDD_BADARG, and RDD_OK.

static int safe_write ( RDD_WRITER w,
const unsigned char *  buf,
unsigned  nbyte 
) [static]

Definition at line 139 of file safewriter.c.

References _RDD_SAFE_WRITER::parent, rdd_writer_write(), and _RDD_WRITER::state.

Here is the call graph for this function:


Variable Documentation

char copyright[] [static]

Initial value:

"@(#) Copyright (c) 2002-2004\n\
    Netherlands Forensic Institute.  All rights reserved.\n"

Definition at line 34 of file safewriter.c.

Initial value:

Definition at line 60 of file safewriter.c.


Generated on Sun Feb 6 12:36:35 2011 for rdd by  doxygen 1.5.6