diff options
| author | Michael Biebl <biebl@debian.org> | 2006-10-24 21:23:24 +0000 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2006-10-24 21:23:24 +0000 |
| commit | 28a4b40856f34de9dc8f4d1ef8825cc943379d81 (patch) | |
| tree | 49c59a3e3928a65947b555d395e76ba3f75dcbc9 /debian/patches | |
| parent | 8c51ad8783cedd385dcaea3d308e6e08389c9875 (diff) | |
Make the /e/n/i a bit more robust and easier to read.
git-svn-id: svn+ssh://svn.debian.org/svn/pkg-utopia/packages/unstable/networkmanager@1104 ceb527fc-18e6-0310-9fe2-813c157c29e7
Diffstat (limited to 'debian/patches')
| -rw-r--r-- | debian/patches/05-debian_backend.patch | 140 |
1 files changed, 107 insertions, 33 deletions
diff --git a/debian/patches/05-debian_backend.patch b/debian/patches/05-debian_backend.patch index 8a54e68e..8882e749 100644 --- a/debian/patches/05-debian_backend.patch +++ b/debian/patches/05-debian_backend.patch @@ -194,10 +194,25 @@ index 740572a..93c2914 100644 diff --git a/src/backends/interface_parser.c b/src/backends/interface_parser.c -index 53d6487..2fa559f 100644 +index 53d6487..b3ad300 100644 --- a/src/backends/interface_parser.c +++ b/src/backends/interface_parser.c -@@ -71,7 +71,8 @@ void add_data(const char *key,const char +@@ -50,11 +50,13 @@ void add_block(const char *type, const c + + void add_data(const char *key,const char *data) + { ++ if_data *ret; ++ + // Check if there is a block where we can attach our data + if (first == NULL) + return; + +- if_data *ret = (if_data*)calloc(1,sizeof(struct _if_data)); ++ ret = (if_data*) calloc(1,sizeof(struct _if_data)); + ret->key = g_strdup(key); + ret->data = g_strdup(data); + +@@ -71,14 +73,18 @@ void add_data(const char *key,const char //printf("added data '%s' with key '%s'\n",data,key); } @@ -207,65 +222,124 @@ index 53d6487..2fa559f 100644 void ifparser_init(void) { -@@ -105,36 +106,52 @@ void ifparser_init(void) - if (line[0]=='#' || line[0]=='\0') + FILE *inp = fopen(INTERFACES,"r"); + int ret = 0; ++ int pos; ++ int len; + char *line; +- char *space; ++ char *key; ++ char *data; + char rline[255]; + + if (inp == NULL) +@@ -89,7 +95,7 @@ void ifparser_init(void) + first = last = NULL; + while(1) + { +- line = space = NULL; ++ line = NULL; + ret = fscanf(inp,"%255[^\n]\n",rline); + if (ret == EOF) + break; +@@ -102,50 +108,71 @@ void ifparser_init(void) + line = rline; + while(line[0] == ' ') + line++; +- if (line[0]=='#' || line[0]=='\0') ++ if (line[0] == '#' || line[0] == '\0') continue; - SPACE_OR_TAB(line,space) -+ space = line; -+ while (!strchr(WS, space[0])) space++; +- if (space == NULL) ++ len = strlen(line); ++ pos = 0; ++ while (!strchr(WS, line[pos]) && pos < len) pos++; ++ ++ // terminate key string and skip further whitespaces ++ line[pos++] = '\0'; ++ while (strchr(WS, line[pos]) && pos < len) pos++; + - if (space == NULL) ++ if (pos >= len) { - nm_warning ("Error: Can't parse interface line '%s'\n",line); -+ nm_warning ("Error: Can't parse line '%s'\n",line); ++ nm_warning ("Error: Can't parse line '%s'\n", line); continue; } -+ -+ // terminate line string and skip further whitespaces - space[0] = '\0'; +- space[0] = '\0'; - -+ while (isspace(space[1])) space++; ++ key = &line[0]; ++ data = &line[pos]; + // There are four different stanzas: // iface, mapping, auto and allow-*. Create a block for each of them. - if (strcmp(line,"iface")==0) +- if (strcmp(line,"iface")==0) ++ if (strcmp(key, "iface") == 0) { - char *space2 = strchr(space+1,' '); -+ char *space2 = space+1; -+ while (!strchr(WS, space2[0])) space2++; +- if (space2 == NULL) ++ char *key2; ++ ++ while (!strchr(WS, line[pos]) && pos < len ) pos++; + - if (space2 == NULL) ++ // terminate first data string and skip further whitespaces ++ line[pos++] = '\0'; ++ while (strchr(WS, line[pos]) && pos < len) pos++; ++ if (pos >= len) { - nm_warning ("Error: Can't parse iface line '%s'\n",space+1); +- nm_warning ("Error: Can't parse iface line '%s'\n",space+1); ++ nm_warning ("Error: Can't parse iface line '%s'\n", data); continue; } -+ -+ // terminate space string and skip further whitespaces - space2[0]='\0'; -+ while (isspace(space2[1])) space2++; -+ - add_block(line,space+1); +- space2[0]='\0'; +- add_block(line,space+1); ++ key2 = &line[pos]; ++ ++ add_block(key, data); - if (space2[1]!='\0') +- if (space2[1]!='\0') ++ if (pos < len) { - space = strchr(space2+1,' '); -+ space = space2+1; -+ while (!strchr(WS, space[0])) space++; +- if (space == NULL) ++ ++ while (!strchr(WS, line[pos]) && pos < len ) pos++; + - if (space == NULL) ++ // terminate key2 string and skip further whitespaces ++ line[pos++] = '\0'; ++ while (strchr(WS, line[pos]) && pos < len) pos++; ++ if (pos >= len) { - nm_warning ("Error: Can't parse data '%s'\n",space2+1); +- nm_warning ("Error: Can't parse data '%s'\n",space2+1); ++ nm_warning ("Error: Can't parse inet line '%s'\n", key2); continue; } -+ // terminate space2 string and skip further whitespaces - space[0] = '\0'; -+ while (isspace(space[1])) space++; +- space[0] = '\0'; +- add_data(space2+1,space+1); ++ data = &line[pos]; + - add_data(space2+1,space+1); ++ add_data(key2, data); } } -@@ -198,6 +215,18 @@ if_block *ifparser_getif(const char* ifa +- else if (strcmp(line,"auto")==0) +- add_block(line,space+1); +- else if (strcmp(line,"mapping")==0) +- add_block(line,space+1); +- else if (strncmp(line,"allow-",6)==0) +- add_block(line,space+1); ++ else if (strcmp(key, "auto") == 0) ++ add_block(key, data); ++ else if (strcmp(key, "mapping") == 0) ++ add_block(key, data); ++ else if (strncmp(key, "allow-", 6) == 0) ++ add_block(key, data); + else +- add_data(line,space+1); ++ add_data(key, data); + + //printf("line: '%s' ret=%d\n",rline,ret); + } +@@ -198,6 +225,18 @@ if_block *ifparser_getif(const char* ifa return NULL; } |