diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/defs.h | 4 | ||||
-rw-r--r-- | src/io.c | 20 | ||||
-rw-r--r-- | src/main.c | 7 |
3 files changed, 24 insertions, 7 deletions
@@ -29,6 +29,8 @@ struct stream { int fd; int out; char *name; + int (*get)(struct stream *, size_t, struct entry_l *, int); + int (*put)(struct stream *, size_t, struct entry_l *, int); }; struct settings { @@ -39,8 +41,6 @@ struct settings { char *fileout; unsigned int flags; enum opmode opmode; - int (*get)(struct stream, size_t, struct entry_l *, int); - int (*put)(struct stream, size_t, struct entry_l *, int); }; #endif /* ALGOS_DEFS_H_INCLUDED */ @@ -10,6 +10,7 @@ #include <libgen.h> #include "io.h" #include "defs.h" +#include "datagen.h" static int stream_open_in(struct stream * const in, const struct settings * const s); static int stream_open_out(struct stream * const in, const struct settings * const s); @@ -83,6 +84,25 @@ early_err: return ret; } +int stream_get(struct stream *in, size_t idx, struct entry_l *data, int tag) +{ + int ret = 0; + + ret = in->get(in, idx, data, tag); + + return ret; +} + +int stream_put(struct stream *in, size_t idx, struct entry_l *data, int tag) +{ + int ret = 0; + + ret = in->put(in, idx, data, tag); + + return ret; +} + + static int stream_open_out(struct stream * const in, const struct settings * const s) { struct stat st; @@ -37,11 +37,8 @@ int main(int argc, char **argv) file_out.name = settings.fileout ? settings.fileout : settings.filein; - if ((ret = stream_open(&file_in, &settings))) { - goto out; - } - - if ((ret = stream_open(&file_out, &settings))) { + if ((ret = stream_open(&file_in, &settings)) || + (ret = stream_open(&file_out, &settings))) { goto out; } |