Added gm_mcp_parse_list, added gm_mcp_list_free, changed definition of gm_mcp_process_key_values (line arg is now const), fixed gm_mcp_process_key_values
This commit is contained in:
parent
dfb9048733
commit
ee341f1b60
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "gm-mcp.h"
|
||||
#include "../gm-support.h"
|
||||
#include "../gm-debug.h"
|
||||
#include "../gm-string.h"
|
||||
|
||||
gdouble
|
||||
gm_mcp_get_version(gdouble client_min, gdouble client_max, gdouble server_min,
|
||||
|
@ -92,10 +94,10 @@ gm_mcp_un_escape(gchar *line) {
|
|||
return line;
|
||||
}
|
||||
|
||||
gchar *
|
||||
gm_mcp_process_keyval(GList **info, gchar *line) {
|
||||
gchar *keystart;
|
||||
gchar *valuestart;
|
||||
gchar const *
|
||||
gm_mcp_process_keyval(GList **info, gchar const *line) {
|
||||
gchar const *keystart;
|
||||
gchar const *valuestart;
|
||||
int keylen, valuelen;
|
||||
GmKeyValuePair *newKeyValue;
|
||||
|
||||
|
@ -159,7 +161,7 @@ gm_mcp_process_keyval(GList **info, gchar *line) {
|
|||
}
|
||||
|
||||
GList *
|
||||
gm_mcp_process_key_values(gchar *line) {
|
||||
gm_mcp_process_key_values(gchar const *line) {
|
||||
GList *result = NULL;
|
||||
|
||||
while (line && *line != '\0') {
|
||||
|
@ -261,3 +263,47 @@ gm_mcp_destroy_fields(GList *fields) {
|
|||
|
||||
g_list_free(fields);
|
||||
}
|
||||
|
||||
void
|
||||
gm_mcp_list_free(GList *list) {
|
||||
gm_g_list_free_simple(list);
|
||||
}
|
||||
|
||||
GList *
|
||||
gm_mcp_parse_list(gchar const *s) {
|
||||
GList *result = NULL;
|
||||
gchar item_mem[strlen(s) + 1];
|
||||
gchar *item;
|
||||
gunichar c, cn;
|
||||
gchar *next_char;
|
||||
|
||||
while (*s != '\0') {
|
||||
gm_string_skip_space(&s);
|
||||
item = item_mem;
|
||||
*item = '\0';
|
||||
|
||||
while (*s != '\0') {
|
||||
c = g_utf8_get_char(s);
|
||||
next_char = g_utf8_next_char(s);
|
||||
cn = g_utf8_get_char(next_char);
|
||||
|
||||
if (g_unichar_isspace(c)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == '\\' && cn != '\0') {
|
||||
c = cn;
|
||||
next_char = g_utf8_next_char(next_char);
|
||||
}
|
||||
|
||||
item += g_unichar_to_utf8(c, item);
|
||||
s = next_char;
|
||||
}
|
||||
|
||||
|
||||
*item = '\0';
|
||||
result = g_list_append(result, g_strdup(item_mem));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Reference in New Issue