add file operation
This commit is contained in:
23
test.c
23
test.c
@@ -1,6 +1,7 @@
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "file.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -24,6 +25,7 @@ int main(void)
|
||||
char testpair[] = "asifdsfo=s1254124";
|
||||
char *keyName=NULL;
|
||||
char *keyValue=NULL;
|
||||
char *content=NULL;
|
||||
|
||||
keyName = malloc(MAX_LEN_SECTIONNAME);
|
||||
keyValue = malloc(MAX_LEN_SECTIONNAME);
|
||||
@@ -37,6 +39,26 @@ int main(void)
|
||||
}else{
|
||||
printf("error getNameValuePair: %d\n",ret);
|
||||
}
|
||||
|
||||
long neededSize=0;
|
||||
if((ret=getFile("config.cfg",NULL,0,&neededSize))==NO_ERROR)
|
||||
{
|
||||
printf("sucessfull retrieved size:%ld\n",neededSize);
|
||||
}
|
||||
else {
|
||||
printf("Error on getFile:%d\n",ret);
|
||||
}
|
||||
content = malloc(neededSize);
|
||||
if((ret=getFile("config.cfg",&content,neededSize,&neededSize))==NO_ERROR)
|
||||
{
|
||||
printf("Sucessfull read file into buffer:%s\n---\n",content);
|
||||
}
|
||||
else {
|
||||
printf("Error on getFile:%d\n",ret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
free(keyValue);
|
||||
free(keyName);
|
||||
@@ -44,3 +66,4 @@ int main(void)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user