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
d6fcedd5b8
commit
12806c0853
@ -788,14 +788,7 @@ static inline xmlNodePtr __add_listener(client_t *client,
|
|||||||
|
|
||||||
xmlNewTextChild(node, NULL, XMLSTR("tls"), XMLSTR(client->con->tls ? "true" : "false"));
|
xmlNewTextChild(node, NULL, XMLSTR("tls"), XMLSTR(client->con->tls ? "true" : "false"));
|
||||||
|
|
||||||
switch (client->protocol) {
|
xmlNewTextChild(node, NULL, XMLSTR("protocol"), XMLSTR(client_protocol_to_string(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
34
src/client.c
34
src/client.c
@ -66,6 +66,40 @@
|
|||||||
|
|
||||||
static inline void client_send_500(client_t *client, const char *message);
|
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 {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* create a client_t with the provided connection and parser details. Return
|
/* 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
|
* 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
|
* client_t is returned just in case a message needs to be returned. Should
|
||||||
|
@ -139,6 +139,9 @@ struct _client_tag {
|
|||||||
int (*check_buffer)(source_t *source, client_t *client);
|
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);
|
int client_create (client_t **c_ptr, connection_t *con, http_parser_t *parser);
|
||||||
void client_complete(client_t *client);
|
void client_complete(client_t *client);
|
||||||
void client_destroy(client_t *client);
|
void client_destroy(client_t *client);
|
||||||
|
Loading…
Reference in New Issue
Block a user