diff options
author | M.Gergő | 2020-05-13 19:49:38 +0200 |
---|---|---|
committer | M.Gergő | 2020-05-13 19:49:38 +0200 |
commit | 802157d15c9d0adc37621c4f32ed8083dcaf8303 (patch) | |
tree | 9d9dfe1ef27b2e49112435d645ebe48575318200 /src/main.c | |
parent | 1ed4114bb3b9e701dcf6b2d8f1c6da2b47979d4d (diff) | |
download | lightconfini-802157d15c9d0adc37621c4f32ed8083dcaf8303.tar.gz lightconfini-802157d15c9d0adc37621c4f32ed8083dcaf8303.zip |
INI example
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 47 |
1 files changed, 18 insertions, 29 deletions
@@ -6,21 +6,24 @@ #include <linux/limits.h> /* PATH_MAX*/ #include "ini_rw.h" -#define main_c +#define main_c int main() { - char filename[] = "tests/test0.ini", *buff1, *buff2, *buff3, *buff4, *buff5; + char filename[] = "tests/test.ini", *buff1, *buff2, *buff3, *buff4, *buff5; lci_data *ini=NULL, *tmp=NULL; - int len=0, elen=50, lens=0, lenp=0, lenv=0, lenc=0; + int len=0, elen=64, lens=0, lenp=0, lenv=0, lenc=0; FILE *fp; fp = fopen(filename, "rb"); len = getFileMaxLineLen(fp); fclose(fp); +//len = 24000; + + buff1 = malloc((len+3)*sizeof(char)); buff2 = malloc((len+3)*sizeof(char)); buff3 = malloc((len+3)*sizeof(char)); @@ -32,34 +35,15 @@ memset(buff3, 0, (len+3)*sizeof(char)); memset(buff4, 0, (len+3)*sizeof(char)); memset(buff5, 0, (elen+3)*sizeof(char)); - char *aa, *bb, *cc; - aa = (char *) malloc(20*sizeof(char)); - aa[0] = 'q'; - aa[1] = 'w'; - aa[2] = 'e'; - aa[3] = '\0'; - bb = (char *) malloc(30*sizeof(char)); - - cc=aa; - strncpy(bb,aa,20); - free(aa); - free(NULL); - - printf("\n%s\n", bb); - - - - - printf("\nLineMax: %d\n\n",len); ini = iniReadOut(filename); - lens=18; - lenp=18; - lenv=18; + lens=16; + lenp=16; + lenv=16; lenc=44; @@ -70,16 +54,21 @@ memset(buff5, 0, (elen+3)*sizeof(char)); snprintf(buff2, len+3, "'%s' %3ld",tmp->param, tmp->paramLen); snprintf(buff3, len+3, "'%s' %3ld",tmp->value, tmp->valueLen); snprintf(buff4, len+3, "'%s' %3ld",tmp->comment, tmp->commentLen); - snprintf(buff5, elen, "'%s' %3ld", tmp->errorMsg, tmp->errorMsgLen); + snprintf(buff5, elen, "'%s' %3ld",tmp->errorMsg, tmp->errorMsgLen); - printf("LN: %ld,\tLL: %ld,\tSE: %*s,%2ld P: %*s,%2ld V: %*s,%2ld C: %*s,%2ld 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: %ld,\tLL: %ld,\tSE: %*s,%2ld P: %*s,%2ld V: %*s,%2ld C: %*s,%2ld 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); tmp=tmp->next; } - +free(buff1); +free(buff2); +free(buff3); +free(buff4); +free(buff5); + destroyNodes( ini); return 0; |