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++;
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) */
}
{
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++;
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++;