Skip to content
Snippets Groups Projects
Commit c69a4f98 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Add iniReadSString() as well.

parent cc333821
No related branches found
No related tags found
No related merge requests found
......@@ -1013,6 +1013,27 @@ char* iniReadString(FILE* fp, const char* section, const char* key, const char*
return(value);
}
char* iniReadSString(FILE* fp, const char* section, const char* key, const char* deflt, char* value, size_t sz)
{
char fval[INI_MAX_VALUE_LEN];
char *ret;
size_t pos;
ret = iniReadString(fp, section, key, deflt, value);
if (ret == NULL)
return ret;
if (sz < 1 || value == NULL)
return NULL;
for (pos = 0; fval[pos]; pos++) {
if (pos == sz - 1) {
value[pos] = 0;
break;
}
value[pos] = fval[pos];
}
return value;
}
/* Does NOT support string literals: */
char* iniReadValue(FILE* fp, const char* section, const char* key, const char* deflt, char* value)
{
......
......@@ -72,6 +72,8 @@ DLLEXPORT char* iniReadExistingValue(FILE*, const char* section, const char* k
/* These functions read a single key of the specified type */
DLLEXPORT char* iniReadString(FILE*, const char* section, const char* key
,const char* deflt, char* value);
DLLEXPORT char* iniReadSString(FILE* fp, const char* section, const char* key
,const char* deflt, char* value, size_t sz);
/* If the key doesn't exist, iniReadExistingString just returns NULL */
DLLEXPORT char* iniReadExistingString(FILE*, const char* section, const char* key
,const char* deflt, char* value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment