aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorM.Gergő2020-05-17 06:39:32 +0200
committerM.Gergő2020-05-17 06:39:32 +0200
commitcd28b1ec07c8ad615078a1ec55f4f9dfc6b92504 (patch)
treef4d82760e50427b27199a7bdcf9a2152a98f8c87 /src/main.c
parentc37572d6135b21fbb36ef4e28743eac5268224df (diff)
downloadlightconfini-cd28b1ec07c8ad615078a1ec55f4f9dfc6b92504.tar.gz
lightconfini-cd28b1ec07c8ad615078a1ec55f4f9dfc6b92504.zip
New Read function (Own)
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/main.c b/src/main.c
index 37ed4f5..3f7af09 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4,17 +4,28 @@
#include <ctype.h>
#include <stdbool.h>
-#include "inirw_internal.h"
+/* #include "inirw_internal.h" */
+#include "lightconfini.h"
#define main_c
-
+
+int lens=16, lenp=16, lenv=16, lenc=24, elen=55;
+
+
+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 \n", line, linelen, lens, section,sectionlen,
+ lenp, param, paramlen, lenv, value, valuelen, lenc, comment, commentlen, elen, error);
+}
+/*lcinimyReadFunc mylciniReadOutFunct=myfunct;*/
+lcinimyReadFunc mylciniReadOutFunct=NULL;
+
int main(int argc, char* argv[]){
-
+ int len;
char filename[4096] = "tests/test.ini", *buff1, *buff2, *buff3, *buff4, *buff5;
- lci_data *ini=NULL, *tmp=NULL;
- int len=0, elen=54, lens=0, lenp=0, lenv=0, lenc=0;
+ lcini_data *ini=NULL, *tmp=NULL;
FILE *fp;
if(argc > 1){
@@ -22,18 +33,11 @@ int main(int argc, char* argv[]){
/* snprintf(filename, 4096, "%s", argv[1]); */
sprintf(filename, "%s", argv[1]);
}
-
-
fp = fopen(filename, "rb");
- len = getFileMaxLineLen(fp)+1;
+ len = lciniFileMaxLineLen(fp)+1;
if(fp != NULL) { fclose(fp);}
/* len = 24000; */ /*Debug*/
- lens=16;
- lenp=16;
- lenv=16;
- lenc=44;
-
buff1 = calloc((len+100), sizeof(char));
buff2 = calloc((len+100), sizeof(char));
@@ -44,13 +48,9 @@ int main(int argc, char* argv[]){
printf("\nLineMax: %d\n\n",len);
- ini = iniReadOut(filename);
-
-
+ ini = lciniReadOut(filename);
tmp = ini;
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,14 +69,19 @@ int main(int argc, char* argv[]){
tmp=tmp->next;
}
-
free(buff1);
free(buff2);
free(buff3);
free(buff4);
free(buff5);
+ lciniDestroyNodes( ini);
+
+
+
+
+
+ lciniReadOutOwn(filename);
- destroyNodes( ini);
return 0;