case insesitive file sections
This commit is contained in:
parent
19d37b565c
commit
5d1c7fb6b5
@ -27,7 +27,10 @@
|
|||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int
|
/* returns error
|
||||||
|
returns 0 if everything is ok
|
||||||
|
returns 1 if problem reading file */
|
||||||
|
int APP_CC
|
||||||
file_read_sections(int fd, struct list* names)
|
file_read_sections(int fd, struct list* names)
|
||||||
{
|
{
|
||||||
struct stream* s;
|
struct stream* s;
|
||||||
@ -37,7 +40,9 @@ file_read_sections(int fd, struct list* names)
|
|||||||
int in_it_index;
|
int in_it_index;
|
||||||
int len;
|
int len;
|
||||||
int index;
|
int index;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv = 0;
|
||||||
g_file_seek(fd, 0);
|
g_file_seek(fd, 0);
|
||||||
in_it_index = 0;
|
in_it_index = 0;
|
||||||
in_it = 0;
|
in_it = 0;
|
||||||
@ -70,12 +75,16 @@ file_read_sections(int fd, struct list* names)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (len < 0)
|
||||||
|
{
|
||||||
|
rv = 1;
|
||||||
|
}
|
||||||
free_stream(s);
|
free_stream(s);
|
||||||
return 0;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int
|
int APP_CC
|
||||||
file_read_line(struct stream* s, char* text)
|
file_read_line(struct stream* s, char* text)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -120,7 +129,7 @@ file_read_line(struct stream* s, char* text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int
|
int APP_CC
|
||||||
file_split_name_value(char* text, char* name, char* value)
|
file_split_name_value(char* text, char* name, char* value)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
@ -158,7 +167,7 @@ file_split_name_value(char* text, char* name, char* value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int
|
int APP_CC
|
||||||
file_read_section(int fd, char* section, struct list* names,
|
file_read_section(int fd, char* section, struct list* names,
|
||||||
struct list* values)
|
struct list* values)
|
||||||
{
|
{
|
||||||
@ -193,7 +202,7 @@ file_read_section(int fd, char* section, struct list* names,
|
|||||||
}
|
}
|
||||||
else if (c == ']')
|
else if (c == ']')
|
||||||
{
|
{
|
||||||
if (g_strcmp(section, text) == 0)
|
if (g_strncasecmp(section, text, 255) == 0)
|
||||||
{
|
{
|
||||||
file_read_line(s, text);
|
file_read_line(s, text);
|
||||||
while (file_read_line(s, text) == 0)
|
while (file_read_line(s, text) == 0)
|
||||||
|
@ -420,6 +420,7 @@ g_memcmp(void* s1, void* s2, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
/* returns -1 on error, else return handle or file descriptor */
|
||||||
int
|
int
|
||||||
g_file_open(char* file_name)
|
g_file_open(char* file_name)
|
||||||
{
|
{
|
||||||
@ -654,16 +655,16 @@ g_strdup(char* in)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int
|
int
|
||||||
g_strcmp(char* c1, char* c2)
|
g_strncmp(char* c1, char* c2, int len)
|
||||||
{
|
{
|
||||||
return strcmp(c1, c2);
|
return strncmp(c1, c2, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int
|
int
|
||||||
g_strncmp(char* c1, char* c2, int len)
|
g_strncasecmp(char* c1, char* c2, int len)
|
||||||
{
|
{
|
||||||
return strncmp(c1, c2, len);
|
return strncasecmp(c1, c2, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -884,6 +885,17 @@ g_setenv(char* name, char* value, int rewrite)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
char*
|
||||||
|
g_getenv(char* name)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return getenv(name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int
|
int
|
||||||
g_exit(int exit_code)
|
g_exit(int exit_code)
|
||||||
|
@ -112,10 +112,10 @@ g_strcat(char* dest, char* src);
|
|||||||
char*
|
char*
|
||||||
g_strdup(char* in);
|
g_strdup(char* in);
|
||||||
int
|
int
|
||||||
g_strcmp(char* c1, char* c2);
|
|
||||||
int
|
|
||||||
g_strncmp(char* c1, char* c2, int len);
|
g_strncmp(char* c1, char* c2, int len);
|
||||||
int
|
int
|
||||||
|
g_strncasecmp(char* c1, char* c2, int len);
|
||||||
|
int
|
||||||
g_atoi(char* str);
|
g_atoi(char* str);
|
||||||
int
|
int
|
||||||
g_pos(char* str, char* to_find);
|
g_pos(char* str, char* to_find);
|
||||||
@ -154,6 +154,8 @@ void
|
|||||||
g_clearenv(void);
|
g_clearenv(void);
|
||||||
int
|
int
|
||||||
g_setenv(char* name, char* value, int rewrite);
|
g_setenv(char* name, char* value, int rewrite);
|
||||||
|
char*
|
||||||
|
g_getenv(char* name);
|
||||||
int
|
int
|
||||||
g_exit(int exit_code);
|
g_exit(int exit_code);
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user