1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-23 06:25:24 +00:00

Update: Made error IDs an enum.

Thanks to ePirat for the suggestion.
This commit is contained in:
Philipp Schafft 2018-05-26 06:29:10 +00:00
parent a612d0c4a1
commit 097e62394f
4 changed files with 47 additions and 44 deletions

View File

@ -266,7 +266,7 @@ static inline void _client_send_error(client_t *client, int plain, const icecast
fserve_add_client (client, NULL);
}
void client_send_error_by_id(client_t *client, int id)
void client_send_error_by_id(client_t *client, icecast_error_id_t id)
{
const icecast_error_t *error = error_get_by_id(id);
const char *pref;

View File

@ -19,6 +19,7 @@
#ifndef __CLIENT_H__
#define __CLIENT_H__
#include "errors.h"
#include "connection.h"
#include "refbuf.h"
#include "acl.h"
@ -109,7 +110,7 @@ typedef struct _client_tag
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, int id);
void client_send_error_by_id(client_t *client, icecast_error_id_t id);
void client_send_101(client_t *client, reuse_t reuse);
void client_send_426(client_t *client, reuse_t reuse);
int client_send_bytes (client_t *client, const void *buf, unsigned len);

View File

@ -135,7 +135,7 @@ static const icecast_error_t __errors[] = {
.message = "XSLT problem"}
};
const icecast_error_t * error_get_by_id(int id) {
const icecast_error_t * error_get_by_id(icecast_error_id_t id) {
size_t i;
for (i = 0; i < (sizeof(__errors)/sizeof(*__errors)); i++) {

View File

@ -9,48 +9,50 @@
#ifndef __ERRORS_H__
#define __ERRORS_H__
#define ICECAST_ERROR_ADMIN_DEST_NOT_RUNNING 1
#define ICECAST_ERROR_ADMIN_METADAT_BADCALL 2
#define ICECAST_ERROR_ADMIN_METADAT_NO_SUCH_ACTION 3
#define ICECAST_ERROR_ADMIN_MISSING_PARAMETER 4
#define ICECAST_ERROR_ADMIN_missing_parameter 5 /* what is this? */
#define ICECAST_ERROR_ADMIN_MOUNT_NOT_ACCEPT_URL_UPDATES 6
#define ICECAST_ERROR_ADMIN_NO_SUCH_DESTINATION 7
#define ICECAST_ERROR_ADMIN_ROLEMGN_ADD_NOSYS 8
#define ICECAST_ERROR_ADMIN_ROLEMGN_DELETE_NOSYS 9
#define ICECAST_ERROR_ADMIN_ROLEMGN_ROLE_NOT_FOUND 10
#define ICECAST_ERROR_ADMIN_SOURCE_DOES_NOT_EXIST 11
#define ICECAST_ERROR_ADMIN_SOURCE_IS_NOT_AVAILABLE 12
#define ICECAST_ERROR_ADMIN_SUPPLIED_MOUNTPOINTS_ARE_IDENTICAL 13
#define ICECAST_ERROR_ADMIN_UNRECOGNISED_COMMAND 14
#define ICECAST_ERROR_AUTH_BUSY 15
#define ICECAST_ERROR_CON_CONTENT_TYPE_NOSYS 16
#define ICECAST_ERROR_CON_INTERNAL_FORMAT_ALLOC_ERROR 17
#define ICECAST_ERROR_CON_MISSING_PASS_PARAMETER 18
#define ICECAST_ERROR_CON_MOUNT_IN_USE 19
#define ICECAST_ERROR_CON_MOUNTPOINT_NOT_STARTING_WITH_SLASH 20
#define ICECAST_ERROR_CON_NO_CONTENT_TYPE_GIVEN 21
#define ICECAST_ERROR_CON_PER_CRED_CLIENT_LIMIT 22
#define ICECAST_ERROR_CON_rejecting_client_for_whatever_reason 23 /* ??? */
#define ICECAST_ERROR_CON_SOURCE_CLIENT_LIMIT 24
#define ICECAST_ERROR_CON_UNIMPLEMENTED 25
#define ICECAST_ERROR_CON_UNKNOWN_REQUEST 26
#define ICECAST_ERROR_CON_UPGRADE_ERROR 27
#define ICECAST_ERROR_FSERV_FILE_NOT_FOUND 28
#define ICECAST_ERROR_FSERV_FILE_NOT_READABLE 29
#define ICECAST_ERROR_FSERV_REQUEST_RANGE_NOT_SATISFIABLE 30
#define ICECAST_ERROR_GEN_BUFFER_REALLOC 31
#define ICECAST_ERROR_GEN_CLIENT_LIMIT 32
#define ICECAST_ERROR_GEN_CLIENT_NEEDS_TO_AUTHENTICATE 33
#define ICECAST_ERROR_GEN_HEADER_GEN_FAILED 34
#define ICECAST_ERROR_GEN_MEMORY_EXHAUSTED 35
#define ICECAST_ERROR_SOURCE_MOUNT_UNAVAILABLE 36
#define ICECAST_ERROR_SOURCE_STREAM_PREPARATION_ERROR 37
#define ICECAST_ERROR_XSLT_PARSE 38
#define ICECAST_ERROR_XSLT_problem 39
typedef enum {
ICECAST_ERROR_ADMIN_DEST_NOT_RUNNING,
ICECAST_ERROR_ADMIN_METADAT_BADCALL,
ICECAST_ERROR_ADMIN_METADAT_NO_SUCH_ACTION,
ICECAST_ERROR_ADMIN_MISSING_PARAMETER,
ICECAST_ERROR_ADMIN_missing_parameter, /* what is this? */
ICECAST_ERROR_ADMIN_MOUNT_NOT_ACCEPT_URL_UPDATES,
ICECAST_ERROR_ADMIN_NO_SUCH_DESTINATION,
ICECAST_ERROR_ADMIN_ROLEMGN_ADD_NOSYS,
ICECAST_ERROR_ADMIN_ROLEMGN_DELETE_NOSYS,
ICECAST_ERROR_ADMIN_ROLEMGN_ROLE_NOT_FOUND,
ICECAST_ERROR_ADMIN_SOURCE_DOES_NOT_EXIST,
ICECAST_ERROR_ADMIN_SOURCE_IS_NOT_AVAILABLE,
ICECAST_ERROR_ADMIN_SUPPLIED_MOUNTPOINTS_ARE_IDENTICAL,
ICECAST_ERROR_ADMIN_UNRECOGNISED_COMMAND,
ICECAST_ERROR_AUTH_BUSY,
ICECAST_ERROR_CON_CONTENT_TYPE_NOSYS,
ICECAST_ERROR_CON_INTERNAL_FORMAT_ALLOC_ERROR,
ICECAST_ERROR_CON_MISSING_PASS_PARAMETER,
ICECAST_ERROR_CON_MOUNT_IN_USE,
ICECAST_ERROR_CON_MOUNTPOINT_NOT_STARTING_WITH_SLASH,
ICECAST_ERROR_CON_NO_CONTENT_TYPE_GIVEN,
ICECAST_ERROR_CON_PER_CRED_CLIENT_LIMIT,
ICECAST_ERROR_CON_rejecting_client_for_whatever_reason, /* ??? */
ICECAST_ERROR_CON_SOURCE_CLIENT_LIMIT,
ICECAST_ERROR_CON_UNIMPLEMENTED,
ICECAST_ERROR_CON_UNKNOWN_REQUEST,
ICECAST_ERROR_CON_UPGRADE_ERROR,
ICECAST_ERROR_FSERV_FILE_NOT_FOUND,
ICECAST_ERROR_FSERV_FILE_NOT_READABLE,
ICECAST_ERROR_FSERV_REQUEST_RANGE_NOT_SATISFIABLE,
ICECAST_ERROR_GEN_BUFFER_REALLOC,
ICECAST_ERROR_GEN_CLIENT_LIMIT,
ICECAST_ERROR_GEN_CLIENT_NEEDS_TO_AUTHENTICATE,
ICECAST_ERROR_GEN_HEADER_GEN_FAILED,
ICECAST_ERROR_GEN_MEMORY_EXHAUSTED,
ICECAST_ERROR_SOURCE_MOUNT_UNAVAILABLE,
ICECAST_ERROR_SOURCE_STREAM_PREPARATION_ERROR,
ICECAST_ERROR_XSLT_PARSE,
ICECAST_ERROR_XSLT_problem
} icecast_error_id_t;
struct icecast_error_tag {
const int id;
const icecast_error_id_t id;
const int http_status;
const char *uuid;
const char *message;
@ -58,6 +60,6 @@ struct icecast_error_tag {
typedef struct icecast_error_tag icecast_error_t;
const icecast_error_t * error_get_by_id(int id);
const icecast_error_t * error_get_by_id(icecast_error_id_t id);
#endif /* __ERRORS_H__ */