00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef lint
00043 static char copyright[] =
00044 "@(#) Copyright (c) 2002\n\
00045 Netherlands Forensic Institute. All rights reserved.\n";
00046 #endif
00047
00048 #ifdef HAVE_CONFIG_H
00049 #include <config.h>
00050 #endif
00051
00052 #include <assert.h>
00053 #include <sys/types.h>
00054 #include <sys/stat.h>
00055 #include <unistd.h>
00056 #include <fcntl.h>
00057 #include <errno.h>
00058 #include <string.h>
00059
00060 #include "rdd.h"
00061 #include "rdd_internals.h"
00062 #include "error.h"
00063 #include "writer.h"
00064 #include "filter.h"
00065 #include "writer.h"
00066
00067 typedef struct _RDD_WRITE_STREAM_FILTER {
00068 RDD_WRITER *writer;
00069 } RDD_WRITE_STREAM_FILTER;
00070
00071 static int write_input(RDD_FILTER *f, const unsigned char *buf, unsigned nbyte);
00072 static int write_close(RDD_FILTER *f);
00073
00074 static RDD_FILTER_OPS write_ops = {
00075 write_input,
00076 0,
00077 write_close,
00078 0,
00079 0
00080 };
00081
00082 int
00083 rdd_new_write_streamfilter(RDD_FILTER **self, RDD_WRITER *writer)
00084 {
00085 RDD_FILTER *f;
00086 RDD_WRITE_STREAM_FILTER *state;
00087 int rc;
00088
00089 rc = rdd_new_filter(&f, &write_ops, sizeof(RDD_WRITE_STREAM_FILTER), 0);
00090 if (rc != RDD_OK) {
00091 return rc;
00092 }
00093 state = (RDD_WRITE_STREAM_FILTER *) f->state;
00094
00095 state->writer = writer;
00096
00097 *self = f;
00098 return RDD_OK;
00099 }
00100
00101 static int
00102 write_input(RDD_FILTER *f, const unsigned char *buf, unsigned nbyte)
00103 {
00104 RDD_WRITE_STREAM_FILTER *state = (RDD_WRITE_STREAM_FILTER *) f->state;
00105
00106 return rdd_writer_write(state->writer, buf, nbyte);
00107 }
00108
00109 static int
00110 write_close(RDD_FILTER *f)
00111 {
00112 return RDD_OK;
00113 }