From fd289dd5b673abe5aa0ee3fda961ac50071af60e Mon Sep 17 00:00:00 2001 From: M.Gergő Date: Sun, 17 May 2020 01:16:40 +0200 Subject: backport c89 --- src/inirw_internal.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/inirw_internal.h (limited to 'src/inirw_internal.h') diff --git a/src/inirw_internal.h b/src/inirw_internal.h new file mode 100644 index 0000000..a75a70b --- /dev/null +++ b/src/inirw_internal.h @@ -0,0 +1,79 @@ +#ifndef INI_READ_H_INCLUDED +#define INI_READ_H_INCLUDED +/* #include "deftypes.h" */ +#include /* int64_t*/ + + + +typedef struct lci_data { + + enum nodeState {lci_EMPTY, lci_READY, lci_CONTINUE, lci_MULTILINE, lci_ERROR } nodeState; + int32_t lineNum; + int32_t lineLen; + + char *section; + int32_t sectionLen; + int32_t sectionStartPos; + char *param; + int32_t paramLen; + int32_t paramStartPos; + char *value; + int32_t valueLen; + int32_t valueStartPos; + enum valueDraw {lci_EMPTYVAL, lci_SIMPLEVAL, lci_MULTILINEVAL, lci_DQUOTEDVAL} valueDraw; + char *comment; + int32_t commentLen; + int32_t commentStartPos; + char commentSign; + char *errorMsg; + int32_t errorMsgLen; + + struct lci_data *next; +} lci_data; + + + +struct lci_data *iniReadOut(const char *filename); +/* int64_t getFileMaxLineLen(FILE *tfd); */ +char *strResize(char *ptr, size_t oldsize, size_t newsize); +lci_data *destroyNodes( lci_data *head); +lci_data *createNode( lci_data *head, int64_t lineLen ); +size_t getFileMaxLineLen(FILE *tfd); + + +#if defined(ini_read_c) || defined(ini_write_c) +enum ini_states {Start, BgnSp, CommEndW, SectEndW, SectEndD, EqW1, EqW2, ValPSP, ValW, ValFSP, DqmW, Bslsh, Error, Stop }; +size_t strNullLen(const char *str); +struct lci_data *iniFSM(struct lci_data *data, const unsigned char *in, int32_t len); +int eescape(int c); +int isascalnum(int c); /* Check if input is ASCII Alpha-numeric */ +int checkspace(int c); /* Only for ASCII characters */ + + + +#ifdef ini_read_c +int unescape(int c); +#endif /* ini_read_c */ +#ifdef ini_write_c +//static const char* komment = ";#"; +#endif /*ini_write_c*/ +#endif /* ini_read_c, ini_write_c*/ + + + +char *lciGETtoStr( const char *section, const char *param, char *dest, size_t dstlen ); +/*int lciGETtoStrlen(const char *section, const char *param, ...); */ +int8_t lciGETtoInt8( const char *filename, const char *section, const char *param); +int16_t lciGETtoInt16(const char *filename, const char *section, const char *param); +int32_t lciGETtoInt32(const char *filename, const char *section, const char *param); +int64_t lciGETtoInt64(const char *filename, const char *section, const char *param); + +double lciGETtoDlb(const char *filename, const char *section, const char *param); +float lciGETtoFlt(const char *filename, const char *section, const char *param); +long int lciGETtoLng(const char *filename, const char *section, const char *param); + + + + +#endif /* INI_READ_H_INCLUDED */ + -- cgit v1.2.3