diff options
author | Tharre <tharre3@gmail.com> | 2016-07-26 12:12:15 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2016-07-26 12:12:15 +0200 |
commit | ca1b481d6e8606db85e82c236c8edf29b49126c8 (patch) | |
tree | f2067117a75da2562b7acf9a2e52d42eff6e647f /src/DSV.h | |
parent | ca3cb1fd17adb1ec8c86372cd11333f6e345e013 (diff) | |
download | redo-ca1b481d6e8606db85e82c236c8edf29b49126c8.tar.gz redo-ca1b481d6e8606db85e82c236c8edf29b49126c8.tar.xz redo-ca1b481d6e8606db85e82c236c8edf29b49126c8.zip |
Implement new dependency storage system
Diffstat (limited to 'src/DSV.h')
-rw-r--r-- | src/DSV.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/DSV.h b/src/DSV.h new file mode 100644 index 0000000..6b0c315 --- /dev/null +++ b/src/DSV.h @@ -0,0 +1,41 @@ +/* build.h + * + * Copyright (c) 2016 Tharre + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +#ifndef __RDSV_H__ +#define __RDSV_H__ + +enum dsv_status { + E_SUCCESS = 0, + E_NO_NEWLINE_FOUND, + E_EMPTY_NEWLINE, + E_EMPTY_FIELD, + E_TOO_MANY_FIELDS, + E_TOO_FEW_FIELDS, + E_FREAD_ERROR, +}; + +struct dsv_ctx { + size_t processed; + size_t fields_count; + size_t offset; + size_t bufsize; + size_t buflen; + + char **fields; + char *buf; + + enum dsv_status status; +}; + +size_t encode_string(char *dest, const char *src); +void dsv_init(struct dsv_ctx *context, size_t fields_count); +void dsv_free(struct dsv_ctx *context); +int dsv_parse_next_line(struct dsv_ctx *context, const char *src, size_t len); +int dsv_parse_file(struct dsv_ctx *ctx, FILE *fp); + +#endif |