14# define NS_tfopen _wfopen
15# define OPEN_MODE L"rb"
17# define NS_tfopen fopen
57static const char kNL[] =
"\r\n";
68 for (
d = delims; *
d !=
'\0'; ++
d)
99 for (
const char *
d = delims; *
d !=
'\0'; ++
d)
127 const char *
p = keyList;
130 if (strcmp(key,
p) == 0)
154 unsigned int numStrings,
164 if (fseek(fp, 0, SEEK_END) != 0)
167 long len = ftell(fp);
171 size_t flen = size_t(len);
177 if (fseek(fp, 0, SEEK_SET) != 0)
180 size_t rd = fread(fileContents,
sizeof(
char), flen, fp);
184 fileContents[flen] =
'\0';
186 char *buffer = fileContents;
187 bool inStringsSection =
false;
189 unsigned int read = 0;
193 if (token[0] ==
'#' || token[0] ==
';')
203 char const * currSection = token;
212 inStringsSection =
false;
217 inStringsSection = strcmp(currSection,
section) == 0;
219 inStringsSection = strcmp(currSection,
"Strings") == 0;
225 if (!inStringsSection)
238 int keyIndex =
find_key(keyList, key);
239 if (keyIndex >= 0 && (
unsigned int)keyIndex < numStrings)
255 const unsigned int kNumStrings = 2;
256 const char *kUpdaterKeys =
"Title\0Info\0";
AutoCharArray(size_t len)
#define READ_STRINGS_MEM_ERROR
static const char * NS_strspnp(const char *delims, const char *str)
static const char kWhitespace[]
static const char kRBracket[]
static char * NS_strtok(const char *delims, char **str)
static const char kEquals[]
static int find_key(const char *keyList, char *key)
Find a key in a keyList containing zero-delimited keys ending with "\0\0".
int ReadStrings(const NS_tchar *path, const char *keyList, unsigned int numStrings, char results[][MAX_TEXT_LEN], const char *section)
A very basic parser for updater.ini taken mostly from nsINIParser.cpp that can be used by standalone ...