2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Replace usage of strsep with POSIX strtok_r()

This commit is contained in:
Ondřej Surý
2018-03-21 21:08:29 +00:00
parent b9552250cb
commit 921d05ddcf
17 changed files with 109 additions and 330 deletions

View File

@@ -1003,36 +1003,24 @@ named_os_gethostname(char *buf, size_t len) {
return ((n == 0) ? ISC_R_SUCCESS : ISC_R_FAILURE);
}
static char *
next_token(char **stringp, const char *delim) {
char *res;
do {
res = strsep(stringp, delim);
if (res == NULL)
break;
} while (*res == '\0');
return (res);
}
void
named_os_shutdownmsg(char *command, isc_buffer_t *text) {
char *input, *ptr;
char *last, *ptr;
pid_t pid;
input = command;
/* Skip the command name. */
ptr = next_token(&input, " \t");
if (ptr == NULL)
if ((ptr = strtok_r(command, " \t", &last)) == NULL) {
return;
}
ptr = next_token(&input, " \t");
if (ptr == NULL)
if ((ptr = strtok_r(NULL, " \t", &last)) == NULL) {
return;
}
if (strcmp(ptr, "-p") != 0)
if (strcmp(ptr, "-p") != 0) {
return;
}
#ifdef HAVE_LINUXTHREADS
pid = mainpid;