mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Update: Added client_protocol_from_string() and client_protocol_to_string()
This commit is contained in:
parent
f567b6240a
commit
aa321374ec
12
src/admin.c
12
src/admin.c
@ -688,17 +688,7 @@ static inline xmlNodePtr __add_listener(client_t *client,
|
||||
|
||||
xmlNewTextChild(node, NULL, XMLSTR("tls"), XMLSTR(client->con->tls ? "true" : "false"));
|
||||
|
||||
switch (client->protocol) {
|
||||
case ICECAST_PROTOCOL_HTTP:
|
||||
xmlNewTextChild(node, NULL, XMLSTR("protocol"), XMLSTR("http"));
|
||||
break;
|
||||
case ICECAST_PROTOCOL_SHOUTCAST:
|
||||
xmlNewTextChild(node, NULL, XMLSTR("protocol"), XMLSTR("icy"));
|
||||
break;
|
||||
case ICECAST_PROTOCOL_GOPHER:
|
||||
xmlNewTextChild(node, NULL, XMLSTR("protocol"), XMLSTR("gopher"));
|
||||
break;
|
||||
}
|
||||
xmlNewTextChild(node, NULL, XMLSTR("protocol"), XMLSTR(client_protocol_to_string(client->protocol)));
|
||||
|
||||
return node;
|
||||
}
|
||||
|
39
src/client.c
39
src/client.c
@ -58,6 +58,45 @@
|
||||
|
||||
static inline void client_send_500(client_t *client, const char *message);
|
||||
|
||||
/* This returns the protocol ID based on the string.
|
||||
* If the string is invalid for any reason we return ICECAST_PROTOCOL_HTTP.
|
||||
*/
|
||||
protocol_t client_protocol_from_string(const char *str)
|
||||
{
|
||||
if (!str) {
|
||||
ICECAST_LOG_ERROR("No protocol string given. Returning ICECAST_PROTOCOL_HTTP.");
|
||||
return ICECAST_PROTOCOL_HTTP;
|
||||
}
|
||||
|
||||
if (strcasecmp(str, "http") == 0) {
|
||||
return ICECAST_PROTOCOL_HTTP;
|
||||
} else if (strcasecmp(str, "icy") == 0 || strcasecmp(str, "shoutcast") == 0) {
|
||||
return ICECAST_PROTOCOL_SHOUTCAST;
|
||||
} else if (strcasecmp(str, "gopher") == 0) {
|
||||
return ICECAST_PROTOCOL_GOPHER;
|
||||
} else {
|
||||
ICECAST_LOG_ERROR("Unknown protocol \"%H\" string given. Returning ICECAST_PROTOCOL_HTTP.", str);
|
||||
return ICECAST_PROTOCOL_HTTP;
|
||||
}
|
||||
}
|
||||
|
||||
const char * client_protocol_to_string(protocol_t protocol)
|
||||
{
|
||||
switch (protocol) {
|
||||
case ICECAST_PROTOCOL_HTTP:
|
||||
return "http";
|
||||
break;
|
||||
case ICECAST_PROTOCOL_SHOUTCAST:
|
||||
return "icy";
|
||||
break;
|
||||
case ICECAST_PROTOCOL_GOPHER:
|
||||
return "gopher";
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create a client_t with the provided connection and parser details. Return
|
||||
* 0 on success, -1 if server limit has been reached. In either case a
|
||||
* client_t is returned just in case a message needs to be returned. Should
|
||||
|
@ -128,6 +128,9 @@ struct _client_tag {
|
||||
int (*check_buffer)(source_t *source, client_t *client);
|
||||
};
|
||||
|
||||
protocol_t client_protocol_from_string(const char *str);
|
||||
const char * client_protocol_to_string(protocol_t protocol);
|
||||
|
||||
int client_create (client_t **c_ptr, connection_t *con, http_parser_t *parser);
|
||||
void client_destroy(client_t *client);
|
||||
void client_send_error_by_id(client_t *client, icecast_error_id_t id);
|
||||
|
Loading…
Reference in New Issue
Block a user