aboutsummaryrefslogtreecommitdiffstats
path: root/src/permission.c
diff options
context:
space:
mode:
authorAvuton Olrich <avuton@gmail.com>2006-07-20 16:02:40 +0000
committerAvuton Olrich <avuton@gmail.com>2006-07-20 16:02:40 +0000
commit29a25b9933b32800f58dd73d5d1fc21993071c92 (patch)
tree4f456a6f8e44d42acc289c35534ea3e59c0aa96f /src/permission.c
parent099f0e103f7591eef81183292d704b3a77a99018 (diff)
downloadmpd-29a25b9933b32800f58dd73d5d1fc21993071c92.tar.gz
mpd-29a25b9933b32800f58dd73d5d1fc21993071c92.tar.xz
mpd-29a25b9933b32800f58dd73d5d1fc21993071c92.zip
Add mpd-indent.sh
Indent the entire tree, hopefully we can keep it indented. git-svn-id: https://svn.musicpd.org/mpd/trunk@4410 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/permission.c')
-rw-r--r--src/permission.c97
1 files changed, 51 insertions, 46 deletions
diff --git a/src/permission.c b/src/permission.c
index 836ad3056..15a336a08 100644
--- a/src/permission.c
+++ b/src/permission.c
@@ -32,96 +32,99 @@
#define PERMISSION_CONTROL_STRING "control"
#define PERMISSION_ADMIN_STRING "admin"
-static List * permission_passwords;
+static List *permission_passwords;
static int permission_default;
-static int parsePermissions(char * string) {
+static int parsePermissions(char *string)
+{
int permission = 0;
- char * temp;
- char * tok;
+ char *temp;
+ char *tok;
- if(!string) return 0;
+ if (!string)
+ return 0;
- temp = strtok_r(string,PERMISSION_SEPERATOR,&tok);
- while(temp) {
- if(strcmp(temp,PERMISSION_READ_STRING)==0) {
+ temp = strtok_r(string, PERMISSION_SEPERATOR, &tok);
+ while (temp) {
+ if (strcmp(temp, PERMISSION_READ_STRING) == 0) {
permission |= PERMISSION_READ;
- }
- else if(strcmp(temp,PERMISSION_ADD_STRING)==0) {
+ } else if (strcmp(temp, PERMISSION_ADD_STRING) == 0) {
permission |= PERMISSION_ADD;
- }
- else if(strcmp(temp,PERMISSION_CONTROL_STRING)==0) {
+ } else if (strcmp(temp, PERMISSION_CONTROL_STRING) == 0) {
permission |= PERMISSION_CONTROL;
- }
- else if(strcmp(temp,PERMISSION_ADMIN_STRING)==0) {
+ } else if (strcmp(temp, PERMISSION_ADMIN_STRING) == 0) {
permission |= PERMISSION_ADMIN;
- }
- else {
- ERROR("unknown permission \"%s\"\n",temp);
+ } else {
+ ERROR("unknown permission \"%s\"\n", temp);
exit(EXIT_FAILURE);
}
- temp = strtok_r(NULL,PERMISSION_SEPERATOR,&tok);
+ temp = strtok_r(NULL, PERMISSION_SEPERATOR, &tok);
}
return permission;
}
-void initPermissions(void) {
- char * temp;
- char * cp2;
- char * password;
- int * permission;
- ConfigParam * param;
+void initPermissions(void)
+{
+ char *temp;
+ char *cp2;
+ char *password;
+ int *permission;
+ ConfigParam *param;
permission_passwords = makeList(free, 1);
- permission_default = PERMISSION_READ | PERMISSION_ADD |
- PERMISSION_CONTROL | PERMISSION_ADMIN;
+ permission_default = PERMISSION_READ | PERMISSION_ADD |
+ PERMISSION_CONTROL | PERMISSION_ADMIN;
param = getNextConfigParam(CONF_PASSWORD, NULL);
- if(param) {
- permission_default = 0;
+ if (param) {
+ permission_default = 0;
do {
- if(!strstr(param->value, PERMISSION_PASSWORD_CHAR)) {
+ if (!strstr(param->value, PERMISSION_PASSWORD_CHAR)) {
ERROR("\"%s\" not found in password string "
- "\"%s\", line %i\n",
- PERMISSION_PASSWORD_CHAR,
- param->value,
- param->line);
+ "\"%s\", line %i\n",
+ PERMISSION_PASSWORD_CHAR,
+ param->value, param->line);
exit(EXIT_FAILURE);
}
- if(!(temp = strtok_r(param->value,
- PERMISSION_PASSWORD_CHAR,&cp2))) {
- ERROR("something weird just happened in permission.c\n");
+ if (!(temp = strtok_r(param->value,
+ PERMISSION_PASSWORD_CHAR,
+ &cp2))) {
+ ERROR
+ ("something weird just happened in permission.c\n");
exit(EXIT_FAILURE);
}
-
password = temp;
permission = malloc(sizeof(int));
- *permission = parsePermissions(strtok_r(NULL,"",&cp2));
+ *permission =
+ parsePermissions(strtok_r(NULL, "", &cp2));
- insertInList(permission_passwords,password,permission);
- } while((param = getNextConfigParam(CONF_PASSWORD, param)));
+ insertInList(permission_passwords, password,
+ permission);
+ } while ((param = getNextConfigParam(CONF_PASSWORD, param)));
}
param = getConfigParam(CONF_DEFAULT_PERMS);
- if(param) permission_default = parsePermissions(param->value);
+ if (param)
+ permission_default = parsePermissions(param->value);
sortList(permission_passwords);
}
-int getPermissionFromPassword(char * password, int * permission) {
- void * foundPermission;
+int getPermissionFromPassword(char *password, int *permission)
+{
+ void *foundPermission;
- if(findInList(permission_passwords,password,&foundPermission)) {
+ if (findInList(permission_passwords, password, &foundPermission)) {
*permission = *((int *)foundPermission);
return 0;
}
@@ -129,10 +132,12 @@ int getPermissionFromPassword(char * password, int * permission) {
return -1;
}
-void finishPermissions(void) {
+void finishPermissions(void)
+{
freeList(permission_passwords);
}
-int getDefaultPermissions(void) {
+int getDefaultPermissions(void)
+{
return permission_default;
}