aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-03 13:20:10 +0100
committerMax Kellermann <max@duempel.org>2009-01-03 13:20:10 +0100
commit5b543e8fa6de8c599affddbe6804d0b3f1db5aa6 (patch)
treefb05f5bbdf9cc3dc249c825a365f6e7c728b8883
parent6507bcccd3cf8bce201ca2cde3bed26f3599027a (diff)
downloadmpd-5b543e8fa6de8c599affddbe6804d0b3f1db5aa6.tar.gz
mpd-5b543e8fa6de8c599affddbe6804d0b3f1db5aa6.tar.xz
mpd-5b543e8fa6de8c599affddbe6804d0b3f1db5aa6.zip
permission: use g_strsplit() instead of strtok_r()
g_strsplit() is more portable than strtok_r().
Diffstat (limited to '')
-rw-r--r--src/permission.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/permission.c b/src/permission.c
index 260d2669a..6972ecf81 100644
--- a/src/permission.c
+++ b/src/permission.c
@@ -38,17 +38,18 @@ static GHashTable *permission_passwords;
static unsigned permission_default;
-static unsigned parsePermissions(char *string)
+static unsigned parsePermissions(const char *string)
{
unsigned permission = 0;
- char *temp;
- char *tok;
+ gchar **tokens;
if (!string)
return 0;
- temp = strtok_r(string, PERMISSION_SEPERATOR, &tok);
- while (temp) {
+ tokens = g_strsplit(string, PERMISSION_SEPERATOR, 0);
+ for (unsigned i = 0; tokens[i] != NULL; ++i) {
+ char *temp = tokens[i];
+
if (strcmp(temp, PERMISSION_READ_STRING) == 0) {
permission |= PERMISSION_READ;
} else if (strcmp(temp, PERMISSION_ADD_STRING) == 0) {
@@ -60,10 +61,10 @@ static unsigned parsePermissions(char *string)
} else {
FATAL("unknown permission \"%s\"\n", temp);
}
-
- temp = strtok_r(NULL, PERMISSION_SEPERATOR, &tok);
}
+ g_strfreev(tokens);
+
return permission;
}
@@ -85,7 +86,7 @@ void initPermissions(void)
permission_default = 0;
do {
- char *separator =
+ const char *separator =
strchr(param->value, PERMISSION_PASSWORD_CHAR);
if (separator == NULL)