10 char teststr[] =
"sdafsdfsdf[12345asdfddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd]";
12 char *sectionName=NULL;
22 printf(
"checkSection sucessfull\nsectionName=%s\n",sectionName);
27 printf(
"an error occured:%d\n",ret);
31 char testpair[] =
"asifdsfo=s1254124";
46 printf(
"keyname:%s Value: %s\n",keyName,keyValue);
48 printf(
"error getNameValuePair: %d\n",ret);
54 printf(
"sucessfull retrieved size:%ld\n",neededSize);
57 printf(
"Error on getFile:%d\n",ret);
60 content = malloc(neededSize);
61 printf(
"allocate buffer for filecontent size:%ld\n",neededSize);
65 printf(
"MALLOC: %d\n",error);
68 memset(content,0,neededSize);
69 if((ret=
getFile(
"config-segfault.cfg",&content,neededSize,&neededSize))==
NO_ERROR)
74 printf(
"Error on getFile:%d\n",ret);
87 printf(
"MALLOC: %d\n",error);
90 ret =
parseConfig(content,&entry,count,&returnedCount);
93 printf(
"Error on parseConfig:%d\nReallocate from size %d, to %d\n",ret,count,returnedCount);
95 if(returnedCount > count)
104 printf(
"Error on parseConfig:%d\nReallocate from size %d, to %d\n",ret,count,returnedCount);
105 if((entry=realloc(entry,returnedCount*
sizeof(
struct configEntry)))==NULL)
107 printf(
"error could not reallocate from size %d to %d \n",count,returnedCount);
110 ret =
parseConfig(content,&entry,returnedCount,&returnedCount);
113 printf(
"Error on parseConfig:%d\n",ret);
116 printf(
"returnedCount:%d\n",returnedCount);
123 for(i=0;i<returnedCount;i++)
125 printf(
"i:%d/%d, struct section: %s, keyname: %s, keyvalue: %s\n",i,returnedCount,entry[i].
sectionName,entry[i].
keyName,entry[i].
keyValue);
int getStrAtPos(char *str, int fromPos, int toPos, char **name, int sizeName)
Here we get / cut from fromPos to toPos and write it to an address.
int checkSection(char *str, char delimiterLeft, char delimiterRight, char **sectionName)
Here we check if the given string contains a section for example [SECTIONName] here delimiterLeft is ...
int getNameValuePair(char *str, char leftDelimiterPos, char rightDelimiterPos, char **name, char **value, int sizeName, int sizeValue)
Input: