#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"
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 struct _RDD_SAFE_WRITER RDD_SAFE_WRITER |
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.
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 |
RDD_OK
on success.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.
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().
static int safe_compare_address | ( | RDD_WRITER * | w, | |
struct addrinfo * | address, | |||
int * | result | |||
) | [static] |
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.
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.
RDD_WRITE_OPS safe_write_ops [static] |
Initial value:
Definition at line 60 of file safewriter.c.