aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c56
1 files changed, 43 insertions, 13 deletions
diff --git a/src/main.c b/src/main.c
index 04c911a..71b4d3c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -10,6 +10,7 @@
#define main_c
+/* int lens=46, lenp=36, lenv=56, lenc=74, elen=65; */
int lens=16, lenp=16, lenv=16, lenc=24, elen=55;
lcinimyReadFunc mylciniReadOutFunct=myfunct;
/*lcinimyReadFunc mylciniReadOutFunct=NULL;*/
@@ -21,17 +22,18 @@ lcinimyReadFunc mylciniReadOutFunct=myfunct;
void myfunct(int line, int linelen, char *section, int sectionlen, char *param, int paramlen, char *value, int valuelen, char *comment, int commentlen, char *error, int errorlen ){
- printf("LN: %d,\tLL: %d,\tSC: %*s,%2d P: %*s,%2d V: %*s,%2d C: %*s,%2d ER: %*s,%2d\n", line, linelen, lens, section,sectionlen,
+ printf("LN: %d,\tLL: %d, \tSC: %*s,%2d P: %*s,%2d V: %*s,%2d C: %*s,%2d ER: %*s,%2d\n", line, linelen, lens, section,sectionlen,
lenp, param, paramlen, lenv, value, valuelen, lenc, comment, commentlen, elen, error, errorlen);
}
int main(int argc, char* argv[]){
- int len;
- char filename[4096] = "tests/test.ini", *buff1, *buff2, *buff3, *buff4, *buff5;
+ int len,r;
+ char filename[4096] = "tests/test.ini", *buff1, *buff2, *buff3, *buff4, *buff5, *buff6;
lcini_data *ini=NULL, *tmp=NULL;
FILE *fp;
+ lcini_shortret *sret;
if(argc > 1){
memset(filename, 0, 4096);
@@ -49,13 +51,15 @@ int main(int argc, char* argv[]){
buff3 = calloc((len+100), sizeof(char));
buff4 = calloc((len+100), sizeof(char));
buff5 = calloc((elen+100),sizeof(char));
+ buff6 = calloc(100, sizeof(char));
printf("\nLineMax: %d\n\n",len);
+ printf("FUNC: lciniReadOut() \n\n");
ini = lciniReadOut(filename);
tmp = ini;
- while(tmp != NULL){
+ while(tmp != NULL){
/* snprintf(buff1, len+3, "'%s' %3ld",tmp->section, tmp->sectionLen);
snprintf(buff2, len+3, "'%s' %3ld",tmp->param, tmp->paramLen);
snprintf(buff3, len+3, "'%s' %3ld",tmp->value, tmp->valueLen);
@@ -69,25 +73,51 @@ int main(int argc, char* argv[]){
sprintf(buff5, "'%s' %3d",tmp->errorMsg, tmp->errorMsgLen);
- printf("LN: %d,\tLL: %d,\tSC: %*s,%2d P: %*s,%2d V: %*s,%2d C: %*s,%2d ER: %*s \n", tmp->lineNum, tmp->lineLen, lens, buff1,tmp->sectionStartPos,
- lenp, buff2, tmp->paramStartPos, lenv, buff3, tmp->valueStartPos, lenc, buff4, tmp->commentStartPos, elen, buff5);
+ printf("LN: %d,\tLL: %d, \tSC: %*s,%2d P: %*s,%2d V: %*s,%2d C: %*s,%2d ER: %*s \n", tmp->lineNum, tmp->lineLen, lens, buff1,tmp->sectionStartPos, lenp, buff2, tmp->paramStartPos, lenv, buff3, tmp->valueStartPos, lenc, buff4, tmp->commentStartPos, elen, buff5);
+ /* myfunct(tmp->lineNum, tmp->lineLen, (char*)tmp->section, tmp->sectionLen, (char*)tmp->param, tmp->paramLen, (char*)tmp->value, tmp->valueLen, (char*)tmp->comment, tmp->commentLen, (char*)tmp->errorMsg, tmp->errorMsgLen); */
tmp=tmp->next;
}
- free(buff1);
- free(buff2);
- free(buff3);
- free(buff4);
- free(buff5);
- lciniDestroyNodes( ini);
+
+
+ printf("\n\nFUNC: lciniReadOutOwn()\n\n");
+ lciniReadOutOwn(filename);
+ printf("\n\n FUNC: lciniGet()\n\n");
+ tmp = lciniGet(ini, "bom_section", "mmm");
+ printf("X->0x%x\n", tmp);
+ if(tmp){
+ printf("x->S: '%s', x->P: '%s', x->V: '%s', x->E: '%s'\n",tmp->section, tmp->param, tmp->value, tmp->errorMsg);
+ }
+ printf("\n\n FUNC: lciniGetStr()\n\n");
+ r=lciniGetStr(ini, "bom_section", "mmm", buff6, 100);
+ printf("r: %d, R: '%s' \n",r,buff6);
+
- lciniReadOutOwn(filename);
+ printf("\n\n FUNC: lciniGetShort()\n\n");
+ sret = lciniGetShort(ini, "bom_section", "key");
+ printf("SR: '%s', %d, t: ",sret->ret,sret->retlen);
+ if(sret->retType == lcini_shortretEMPTY){
+ printf("sret_empty\n");
+ }else if(sret->retType == lcini_shortretERROR){
+ printf("sret_err\n");
+ } else {
+ printf("sret_ok\n");
+ }
+ lciniDestroyShortRet(sret);
+ lciniDestroyNodes(ini);
+ free(buff1);
+ free(buff2);
+ free(buff3);
+ free(buff4);
+ free(buff5);
+ free(buff6);
+ printf("\n");
return 0;
}