aboutsummaryrefslogtreecommitdiffstats
path: root/src/lightconfini.h
blob: 748e1cd75fbd3427ae42469c9ea1816f226778f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef LIGHTCONFINI_H_INCLUDED
#define LIGHTCONFINI_H_INCLUDED
#include <stdint.h> /* int64_t*/
 
typedef struct lcini_data {
    enum nodeState {lcini_EMPTY, lcini_READY, lcini_CONTINUE, lcini_MULTILINE, lcini_ERROR, lcini_FLERROR } nodeState;
    int32_t  lineNum;
    int32_t  lineLen;

    uint8_t *section;
    int32_t  sectionLen; 
    int32_t  sectionStartPos;
    uint8_t *param;
    int32_t  paramLen;
    int32_t  paramStartPos;
    uint8_t *value;
    int32_t  valueLen;
    int32_t  valueStartPos;
    enum valueDraw {lcini_EMPTYVAL, lcini_SIMPLEVAL, lcini_MULTILINEVAL, lcini_DQUOTEDVAL} valueDraw;
    uint8_t *comment;
    int32_t  commentLen;
    int32_t  commentStartPos;
    uint8_t  commentSign;
    uint8_t *errorMsg;
    int32_t  errorMsgLen;

    struct lcini_data *next; 
} lcini_data;

 
typedef struct lcini_shortret{
    char *ret;
    int retlen;
    enum retType{lcini_shortretOK, lcini_shortretERROR, lcini_shortretEMPTY} retType;
} lcini_shortret;

/* Ha maga függvény van átpakolva, nevestül, testestül */
/* extern void (mylciniReadOutFunct)(int line, int linelen, char *section, int sectionlen, char *param, int paramlen, char *value, int valuelen, char *comment, int commentlen, char *error, int errorlen ) ; */
/* Ha csak egy fggvényre mutató ptr */
typedef void (*lcinimyReadFunc)(int line, int linelen, char *section, int sectionlen, char *param, int paramlen, char *value, int valuelen, char *comment, int commentlen, char *error, int errorlen ); 
extern lcinimyReadFunc mylciniReadOutFunct;


struct lcini_data *lciniReadOut(const char *filename); 
int lciniReadOutOwn(const char *filename);

lcini_data     *lciniGet(lcini_data *head, const char *section, const char *parameter); /* FETCH requested value TO an lcini_data object, FROM lcini_data list*/ 
int             lciniGetStr(lcini_data *head, const char *section, const char *parameter, char *dst, int dstlen); /* FETCH requested value TO null-terminated-string, FROM lcini_data list */
lcini_shortret *lciniGetShort(lcini_data *head, const char *section, const char *parameter, lcini_shortret *ret);    /* FETCH requested value TO shortret object, FROM lcini_data list*/
lcini_shortret *lciniGetFromFileShort(const char *filename, const char *section, const char *parameter, lcini_shortret *ret); /* FETCH requested value TO shortret object FROM file */
int             lciniGetFromFileStr(const char *filename, const char *section, const char *parameter, char *dst, int dstlen);




lcini_data *lciniDestroyNodes( lcini_data *head); 
lcini_data *lciniCreateNode( lcini_data *head, int lineLen );
size_t lciniFileMaxLineLen(FILE *tfd); 

lcini_shortret *lciniMKShortRet(int bufflen);
void lciniDestroyShortRet(lcini_shortret *dt);

#endif /* LIGHTCONFINI_H_INCLUDED */