summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5a7cdf2)
raw | patch | inline | side by side (parent: 5a7cdf2)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 10 Mar 2007 08:48:54 +0000 (09:48 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 10 Mar 2007 08:48:54 +0000 (09:48 +0100) |
src/apache.c | patch | blob | history | |
src/apcups.c | patch | blob | history | |
src/common.c | patch | blob | history | |
src/hddtemp.c | patch | blob | history |
diff --git a/src/apache.c b/src/apache.c
index 973ad8656ef4f3c3b288ae1db04a46ae7ee63e27..167ead1f2e6291a589a4e8ecd4ac9e25df2c0429 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
int i;
char *ptr;
+ char *saveptr;
char *lines[16];
int lines_num = 0;
}
ptr = apache_buffer;
- while ((lines[lines_num] = strtok (ptr, "\n\r")) != NULL)
+ saveptr = NULL;
+ while ((lines[lines_num] = strtok_r (ptr, "\n\r", &saveptr)) != NULL)
{
ptr = NULL;
lines_num++;
diff --git a/src/apcups.c b/src/apcups.c
index e23bc9e130b91053109e4dcea06785bd95a4481d..9fab78587440e961d33387372b4f2dc84e762bfe 100644 (file)
--- a/src/apcups.c
+++ b/src/apcups.c
int n;
char recvline[1024];
char *tokptr;
+ char *toksaveptr;
char *key;
double value;
printf ("net_recv = `%s';\n", recvline);
#endif /* if APCMAIN */
- tokptr = strtok (recvline, " :\t");
+ toksaveptr = NULL;
+ tokptr = strtok_r (recvline, " :\t", &toksaveptr);
while (tokptr != NULL)
{
key = tokptr;
- if ((tokptr = strtok (NULL, " :\t")) == NULL)
+ if ((tokptr = strtok_r (NULL, " :\t", &toksaveptr)) == NULL)
continue;
value = atof (tokptr);
else if (strcmp ("TIMELEFT", key) == 0)
apcups_detail->timeleft = value;
- tokptr = strtok (NULL, ":");
+ tokptr = strtok_r (NULL, ":", &toksaveptr);
} /* while (tokptr != NULL) */
}
diff --git a/src/common.c b/src/common.c
index fc34afe7fcbed19a85e6563b498b1310d6fe619a..922bd15e4406077b162b40c5052e07b3ebddd5eb 100644 (file)
--- a/src/common.c
+++ b/src/common.c
{
size_t i;
char *ptr;
+ char *saveptr;
i = 0;
ptr = string;
- while ((fields[i] = strtok (ptr, " \t")) != NULL)
+ saveptr = NULL;
+ while ((fields[i] = strtok_r (ptr, " \t", &saveptr)) != NULL)
{
ptr = NULL;
i++;
char *fields[16];
int fields_num;
char *ptr;
+ char *saveptr;
int last_is_file = 1;
int path_is_absolute = 0;
int len;
path_is_absolute = 1;
/*
- * Create a copy for `strtok' to destroy
+ * Create a copy for `strtok_r' to destroy
*/
strncpy (file_copy, file_orig, 512);
file_copy[511] = '\0';
* remove leading and trailing slashes..
*/
ptr = file_copy;
+ saveptr = NULL;
fields_num = 0;
- while ((fields[fields_num] = strtok (ptr, "/")) != NULL)
+ while ((fields[fields_num] = strtok_r (ptr, "/", &saveptr)) != NULL)
{
ptr = NULL;
fields_num++;
diff --git a/src/hddtemp.c b/src/hddtemp.c
index 03990f223d5d2892829aa36a24021d1cacc70d2a..353fbe3cae4196a07005a613286a403f761060f6 100644 (file)
--- a/src/hddtemp.c
+++ b/src/hddtemp.c
char buf[1024];
char *fields[128];
char *ptr;
+ char *saveptr;
int num_fields;
int num_disks;
int i;
if (hddtemp_query_daemon (buf, sizeof (buf)) < 0)
return (-1);
- /* NB: strtok will eat up "||" and leading "|"'s */
+ /* NB: strtok_r will eat up "||" and leading "|"'s */
num_fields = 0;
ptr = buf;
- while ((fields[num_fields] = strtok (ptr, "|")) != NULL)
+ saveptr = NULL;
+ while ((fields[num_fields] = strtok_r (ptr, "|", &saveptr)) != NULL)
{
ptr = NULL;
num_fields++;