diff options
author | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2004-02-01 19:37:40 +0000 |
---|---|---|
committer | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2004-02-01 19:37:40 +0000 |
commit | bd18f40ab4b208bbe3dfc1ac31c10236a6e46ee1 (patch) | |
tree | ee7946e5d5b4abcc9a3287f21818d934978aa1fc /plugin_netdev.c | |
parent | 92b42b9fa4a085cf62728379c144ccd6583895d6 (diff) | |
download | lcd4linux-bd18f40ab4b208bbe3dfc1ac31c10236a6e46ee1.tar.gz |
[lcd4linux @ 2004-02-01 19:37:40 by reinelt]
got rid of every strtok() incarnation.
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@352 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'plugin_netdev.c')
-rw-r--r-- | plugin_netdev.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/plugin_netdev.c b/plugin_netdev.c index edfe1c4..2d49e3f 100644 --- a/plugin_netdev.c +++ b/plugin_netdev.c @@ -1,4 +1,4 @@ -/* $Id: plugin_netdev.c,v 1.2 2004/01/29 04:40:02 reinelt Exp $ +/* $Id: plugin_netdev.c,v 1.3 2004/02/01 19:37:40 reinelt Exp $ * * plugin for /proc/net/dev parsing * @@ -23,6 +23,9 @@ * * * $Log: plugin_netdev.c,v $ + * Revision 1.3 2004/02/01 19:37:40 reinelt + * got rid of every strtok() incarnation. + * * Revision 1.2 2004/01/29 04:40:02 reinelt * every .c file includes "config.h" now * @@ -86,8 +89,9 @@ static int parse_netdev (void) line=0; while (!feof(stream)) { char buffer[256]; - char header[256]; + char header[256], *h, *t; char *head[32]; + char delim[]=" :|\t\n"; int col; if (fgets (buffer, sizeof(buffer), stream) == NULL) break; @@ -97,26 +101,29 @@ static int parse_netdev (void) // line 2 used for headers if (line==2) { - char *h; strncpy(header, buffer, sizeof(header)); RxTx=(strrchr(header, '|') - header); col=0; - h=strtok(header, "| \t\n"); + h=header; while (h!=NULL) { + while (strchr(delim, *h)) h++; + if ((t=strpbrk(h, delim))!=NULL) *t='\0'; head[col++]=h; - h=strtok(NULL, "| \t\n"); + h=t?t+1:NULL; } } else { char *h, *iface=NULL; col=0; - h=strtok(buffer, ":| \t\n"); + h=buffer; while (h!=NULL) { + while (strchr(delim, *h)) h++; + if ((t=strpbrk(h, delim))!=NULL) *t='\0'; if (col==0) { iface=h; } else { hash_set3 (iface, (h-buffer) < RxTx ? "Rx" : "Tx", head[col], h); } - h=strtok(NULL, "| \t\n"); + h=t?t+1:NULL; col++; } } |