Commit cc32a99b authored by rswindell's avatar rswindell
Browse files

Created strListInsertFile() - for use by iniReadFile() for !include'd files.

parent 1164252e
......@@ -349,7 +349,7 @@ void strListFree(str_list_t* list)
}
}
str_list_t strListReadFile(FILE* fp, str_list_t* lp, size_t max_line_len)
static str_list_t str_list_read_file(FILE* fp, str_list_t* lp, size_t max_line_len)
{
char* buf=NULL;
size_t count;
......@@ -364,7 +364,7 @@ str_list_t strListReadFile(FILE* fp, str_list_t* lp, size_t max_line_len)
lp=&list;
}
count = strListCount(*lp);
count=strListCount(*lp);
while(!feof(fp)) {
if(buf==NULL && (buf=(char*)malloc(max_line_len+1))==NULL)
return(NULL);
......@@ -380,6 +380,26 @@ str_list_t strListReadFile(FILE* fp, str_list_t* lp, size_t max_line_len)
return(*lp);
}
size_t strListInsertFile(FILE* fp, str_list_t* lp, size_t index, size_t max_line_len)
{
str_list_t list;
size_t count;
if((list=str_list_read_file(fp, NULL, max_line_len)) == NULL)
return(0);
count = strListInsertList(lp, list, index);
strListFree(&list);
return(count);
}
str_list_t strListReadFile(FILE* fp, str_list_t* lp, size_t max_line_len)
{
return str_list_read_file(fp,lp,max_line_len);
}
size_t strListWriteFile(FILE* fp, const str_list_t list, const char* separator)
{
size_t i;
......
......@@ -124,6 +124,7 @@ void strListFreeBlock(char*);
/* Read lines from file appending each line to string list */
/* Pass NULL list to have list allocated for you */
str_list_t strListReadFile(FILE*, str_list_t*, size_t max_line_len);
size_t strListInsertFile(FILE*, str_list_t*, size_t index, size_t max_line_len);
/* Write to file (fp) each string in the list, optionally separated by separator (e.g. "\n") */
size_t strListWriteFile(FILE*, const str_list_t, const char* separator);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment