From df3657b2a99ef20da99ac3c6c02f43cc23e70fca Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Fri, 20 Jan 2017 22:19:09 +0100 Subject: Moving towards a server/clients structure. --- src/file/data_input.c | 98 --------------------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 src/file/data_input.c (limited to 'src/file/data_input.c') diff --git a/src/file/data_input.c b/src/file/data_input.c deleted file mode 100644 index e31d33b..0000000 --- a/src/file/data_input.c +++ /dev/null @@ -1,98 +0,0 @@ -#define _POSIX_C_SOURCE 200809L -#include -#include -#include /* defines SIZE_MAX */ - -#include "error.h" - -#include "data_input.h" - -int ZoO_data_input_open -( - struct ZoO_data_input di [const static 1], - const char filename [const restrict static 1] -) -{ - /* prevents di [restrict] */ - ZoO_strings_initialize(&(di->string)); - - di->file = fopen(filename, "r"); - - if (di->file == (FILE *) NULL) - { - ZoO_ERROR - ( - "Could not open file '%s' in readonly mode.", - filename - ); - - return -1; - } - - return 0; -} - -int ZoO_data_input_read_line -( - struct ZoO_data_input di [const static 1], - ZoO_index const punctuations_count, - const ZoO_char punctuations [const restrict static punctuations_count] -) -{ - size_t line_size, i, w_start; - ZoO_char * line; - - /* prevents di [restrict] */ - ZoO_strings_finalize(&(di->string)); - - line = (ZoO_char *) NULL; - line_size = 0; - - /* XXX: assumed compatible with ZoO_char */ - - if (getline(&line, &line_size, di->file) < 1) - { - free((void *) line); - - return -1; - } - - line_size = strlen(line); - line[line_size - 1] = '\0'; - - --line_size; /* removed '\n' */ - - if - ( - ZoO_strings_parse - ( - &(di->string), - line_size, - line, - punctuations_count, - punctuations - ) < 0 - ) - { - free((void *) line); - - return -1; - } - - free((void *) line); - - return 0; -} - -void ZoO_data_input_close (struct ZoO_data_input di [const static 1]) -{ - if (di->file != (FILE *) NULL) - { - fclose(di->file); - - di->file = (FILE *) NULL; - } - - /* prevents di [restrict] */ - ZoO_strings_finalize(&(di->string)); -} -- cgit v1.2.3-70-g09d2