28 this->name =
stredup(name, last);
29 str_validate(this->name, this->name + strlen(this->name));
63 this->name =
stredup(name, last);
64 str_validate(this->name, this->name + strlen(this->name));
111 if (!create)
return NULL;
114 return new IniItem(
this, name, NULL);
135 list_group_names(list_group_names),
136 seq_group_names(seq_group_names)
158 if (len == 0) len = strlen(name);
167 if (!create_new)
return NULL;
181 size_t len = strlen(name);
186 for (group = this->group; group != NULL; prev =
group, group = group->
next) {
187 if (strncmp(group->name, name, len) == 0) {
192 if (group == NULL)
return;
198 this->group = this->group->
next;
220 uint comment_size = 0;
221 uint comment_alloc = 0;
224 FILE *in = this->
OpenFile(filename, subdir, &end);
225 if (in == NULL)
return;
230 while ((
size_t)ftell(in) < end && fgets(buffer,
sizeof(buffer), in)) {
233 for (s = buffer; *s ==
' ' || *s ==
'\t'; s++) {}
236 char *e = s + strlen(s);
237 while (e > s && ((c = e[-1]) ==
'\n' || c ==
'\r' || c ==
' ' || c ==
'\t')) e--;
241 if ((group == NULL || group->
type !=
IGT_SEQUENCE) && (*s ==
'#' || *s ==
';' || *s ==
'\0')) {
242 uint ns = comment_size + (e - s + 1);
243 uint a = comment_alloc;
247 do a *= 2;
while (a < ns);
248 comment =
ReallocT(comment, comment_alloc = a);
250 uint pos = comment_size;
251 comment_size += (e - s + 1);
252 comment[pos + e - s] =
'\n';
253 memcpy(comment + pos, s, e - s);
265 group =
new IniGroup(
this, s, e - 1);
266 if (comment_size != 0) {
270 }
else if (group != NULL) {
284 for (t = s; *t !=
'\0' && *t !=
'\"'; t++) {}
285 if (*t ==
'\"') *t =
' ';
287 for (t = s; *t !=
'\0' && *t !=
'=' && *t !=
'\t' && *t !=
' '; t++) {}
292 if (comment_size != 0) {
298 while (*t ==
'=' || *t ==
' ' || *t ==
'\t') t++;
300 bool quoted = (*t ==
'\"');
305 if (e > t && e[-1] ==
'\"') e--;
317 if (comment_size > 0) {
318 this->comment =
stredup(comment, comment + comment_size - 1);