Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
Icecast-Server
Commits
7b608e27
Commit
7b608e27
authored
Sep 19, 2018
by
Philipp Schafft
🦁
Browse files
Feature: Added function to convert strings into auth results
parent
b3497e6e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/auth.c
View file @
7b608e27
...
...
@@ -62,40 +62,43 @@ static unsigned long _next_auth_id(void) {
return
id
;
}
static
const
struct
{
auth_result
result
;
const
char
*
string
;
}
__auth_results
[]
=
{
{.
result
=
AUTH_UNDEFINED
,
.
string
=
"undefined"
},
{.
result
=
AUTH_OK
,
.
string
=
"ok"
},
{.
result
=
AUTH_FAILED
,
.
string
=
"failed"
},
{.
result
=
AUTH_RELEASED
,
.
string
=
"released"
},
{.
result
=
AUTH_FORBIDDEN
,
.
string
=
"forbidden"
},
{.
result
=
AUTH_NOMATCH
,
.
string
=
"no match"
},
{.
result
=
AUTH_USERADDED
,
.
string
=
"user added"
},
{.
result
=
AUTH_USEREXISTS
,
.
string
=
"user exists"
},
{.
result
=
AUTH_USERDELETED
,
.
string
=
"user deleted"
}
};
static
const
char
*
auth_result2str
(
auth_result
res
)
{
switch
(
res
)
{
case
AUTH_UNDEFINED
:
return
"undefined"
;
break
;
case
AUTH_OK
:
return
"ok"
;
break
;
case
AUTH_FAILED
:
return
"failed"
;
break
;
case
AUTH_RELEASED
:
return
"released"
;
break
;
case
AUTH_FORBIDDEN
:
return
"forbidden"
;
break
;
case
AUTH_NOMATCH
:
return
"no match"
;
break
;
case
AUTH_USERADDED
:
return
"user added"
;
break
;
case
AUTH_USEREXISTS
:
return
"user exists"
;
break
;
case
AUTH_USERDELETED
:
return
"user deleted"
;
break
;
default:
return
"(unknown)"
;
break
;
size_t
i
;
for
(
i
=
0
;
i
<
(
sizeof
(
__auth_results
)
/
sizeof
(
*
__auth_results
));
i
++
)
{
if
(
__auth_results
[
i
].
result
==
res
)
return
__auth_results
[
i
].
string
;
}
return
"(unknown)"
;
}
auth_result
auth_str2result
(
const
char
*
str
)
{
size_t
i
;
for
(
i
=
0
;
i
<
(
sizeof
(
__auth_results
)
/
sizeof
(
*
__auth_results
));
i
++
)
{
if
(
strcasecmp
(
__auth_results
[
i
].
string
,
str
)
==
0
)
return
__auth_results
[
i
].
result
;
}
return
AUTH_FAILED
;
}
static
auth_client
*
auth_client_setup
(
client_t
*
client
)
...
...
src/auth.h
View file @
7b608e27
...
...
@@ -164,6 +164,8 @@ int auth_get_htpasswd_auth(auth_t *auth, config_options_t *options);
void
auth_initialise
(
void
);
void
auth_shutdown
(
void
);
auth_result
auth_str2result
(
const
char
*
str
);
auth_t
*
auth_get_authenticator
(
xmlNodePtr
node
);
void
auth_release
(
auth_t
*
authenticator
);
void
auth_addref
(
auth_t
*
authenticator
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment