staticint
file_read_ini_line(struct stream *s, char *text, int text_bytes);
/*****************************************************************************/ /* look up for a section name within str (i.e. pattern [section_name]) *ifasectionnameisfound,thisfunctionreturn1andcopythesection
* inplace of str. */ staticint
line_lookup_for_section_name(char *str, int str_bytes)
{ int name_index_start; int index; char c;
name_index_start = -1;
index = 0; while ((c = str[index]) != 0)
{ if (c == '[')
{
name_index_start = index + 1;
} elseif (c == ']' && name_index_start > 0)
{ if (name_index_start + index >= str_bytes)
{ return0;
} for (index = index - name_index_start; index > 0; index--)
{
str[0] = str[name_index_start];
str++;
}
str[0] = 0; return1;
}
++index;
} return0;
}
/*****************************************************************************/ /* returns error returns0ifeverythingisok
returns 1 if problem reading file */ staticint
l_file_read_sections(int fd, int max_file_size, struct list *names)
{ struct stream *s; char text[FILE_MAX_LINE_BYTES]; int len; int rv;
/*****************************************************************************/ /* Read a line in the stream 's', removing comments. *returnserror *returns0ifeverythingisok
* returns 1 if problem reading file */ staticint
file_read_ini_line(struct stream *s, char *text, int text_bytes)
{ int i; int skip_to_end; int at_end; char c;
skip_to_end = 0;
if (!s_check_rem(s, 1))
{ return1;
}
i = 0;
in_uint8(s, c);
while (c != 10 && c != 13)
{ /* these mean skip the rest of the line */ if (c == '#' || c == ';')
{
skip_to_end = 1;
}
if (!skip_to_end)
{
text[i] = c;
i++; if (i >= text_bytes)
{ return1;
}
}
if (s_check_rem(s, 1))
{
in_uint8(s, c);
} else
{
c = 0; break;
}
}
if (c == 10 || c == 13)
{
at_end = 0;
while (c == 10 || c == 13)
{ if (s_check_rem(s, 1))
{
in_uint8(s, c);
} else
{
at_end = 1; break;
}
}
if (!at_end)
{
s->p--;
}
}
text[i] = 0;
return0;
}
/*****************************************************************************/ /* returns error */ staticint
file_split_name_value(char *text, char *name, char *value)
{ int len; int i; int value_index; int name_index; int on_to;
/*****************************************************************************/ /* returns error returns0ifeverythingisok
returns 1 if problem reading file */ /* 32 K file size limit */ int
file_read_sections(int fd, struct list *names)
{ return l_file_read_sections(fd, 32 * 1024, names);
}
/*****************************************************************************/ /* return error */ /* this function should be preferred over file_read_sections because it can
read any file size */ int
file_by_name_read_sections(constchar *file_name, struct list *names)
{ int fd; int file_size; int rv;
/*****************************************************************************/ /* return error */ /* 32 K file size limit */ int
file_read_section(int fd, constchar *section, struct list *names, struct list *values)
{ return l_file_read_section(fd, 32 * 1024, section, names, values);
}
/*****************************************************************************/ /* return error */ /* this function should be preferred over file_read_section because it can
read any file size */ int
file_by_name_read_section(constchar *file_name, constchar *section, struct list *names, struct list *values)
{ int fd; int file_size; int rv;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.