Commit b3359a24 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Merge branch 'ph3-header-cleanup'

parents 6136810f 059bfdc7
Pipeline #210 passed with stage
in 43 seconds
......@@ -5,6 +5,7 @@ SUBDIRS = common/avl common/net common/thread common/httpp common/log common/tim
bin_PROGRAMS = icecast
noinst_HEADERS = \
icecasttypes.h \
admin.h \
main.h \
cfgfile.h \
......
......@@ -16,6 +16,7 @@
#include "acl.h"
#include "admin.h"
#include "util.h"
#include <stdio.h>
......
......@@ -18,10 +18,7 @@
#include <libxml/tree.h>
#include "common/httpp/httpp.h"
struct acl_tag;
typedef struct acl_tag acl_t;
#include "admin.h"
#include "icecasttypes.h"
typedef enum acl_policy_tag {
/* Error on function call */
......
......@@ -23,6 +23,8 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
#include "admin.h"
#include "compat.h"
#include "cfgfile.h"
#include "connection.h"
#include "refbuf.h"
......@@ -30,16 +32,15 @@
#include "source.h"
#include "global.h"
#include "stats.h"
#include "compat.h"
#include "xslt.h"
#include "fserve.h"
#include "admin.h"
#include "errors.h"
#include "format.h"
#include "logging.h"
#include "auth.h"
#include "acl.h"
#ifdef _WIN32
#define snprintf _snprintf
#endif
......
......@@ -16,24 +16,9 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <stdint.h>
/* Command IDs */
typedef int32_t admin_command_id_t;
/* formats */
typedef enum {
ADMIN_FORMAT_AUTO,
ADMIN_FORMAT_RAW,
ADMIN_FORMAT_TRANSFORMED,
ADMIN_FORMAT_PLAINTEXT
} admin_format_t;
#include "icecasttypes.h"
#include "compat.h"
#include "refbuf.h"
#include "client.h"
#include "source.h"
#include "auth.h"
/* types */
#define ADMINTYPE_ERROR (-1)
......
......@@ -18,15 +18,14 @@
#include <config.h>
#endif
struct source_tag;
typedef struct auth_tag auth_t;
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include "cfgfile.h"
#include "client.h"
#include "common/thread/thread.h"
#include "common/httpp/httpp.h"
#include "icecasttypes.h"
/* implemented */
#define AUTH_TYPE_ANONYMOUS "anonymous"
......@@ -58,7 +57,7 @@ typedef enum
typedef struct auth_client_tag
{
client_t *client;
auth_result (*process)(struct auth_tag *auth, struct auth_client_tag *auth_user);
auth_result (*process)(auth_t *auth, struct auth_client_tag *auth_user);
void (*on_no_match)(client_t *client, void (*on_result)(client_t *client, void *userdata, auth_result result), void *userdata);
void (*on_result)(client_t *client, void *userdata, auth_result result);
void *userdata;
......@@ -89,11 +88,11 @@ struct auth_tag
auth_result (*release_client)(auth_client *auth_user);
/* auth state-specific free call */
void (*free)(struct auth_tag *self);
void (*free)(auth_t *self);
auth_result (*adduser)(struct auth_tag *auth, const char *username, const char *password);
auth_result (*deleteuser)(struct auth_tag *auth, const char *username);
auth_result (*listuser)(struct auth_tag *auth, xmlNodePtr srcnode);
auth_result (*adduser)(auth_t *auth, const char *username, const char *password);
auth_result (*deleteuser)(auth_t *auth, const char *username);
auth_result (*listuser)(auth_t *auth, xmlNodePtr srcnode);
mutex_t lock;
int running;
......
......@@ -18,6 +18,7 @@
#include <string.h>
#include "auth.h"
#include "cfgfile.h"
#include "client.h"
#include "logging.h"
......
......@@ -72,6 +72,7 @@
#include "source.h"
#include "client.h"
#include "cfgfile.h"
#include "connection.h"
#include "common/httpp/httpp.h"
#include "logging.h"
......
......@@ -27,15 +27,13 @@
#include <libxml/parser.h>
#include "common/thread/thread.h"
#include "cfgfile.h"
#include "global.h"
#include "refbuf.h"
#include "client.h"
#include "logging.h"
#include "util.h"
#include "auth.h"
#include "event.h"
#include "tls.h"
/* for config_reread_config() */
#include "yp.h"
......@@ -43,6 +41,7 @@
#include "stats.h"
#include "connection.h"
#include "main.h"
#include "slave.h"
#define CATMODULE "CONFIG"
#define CONFIG_DEFAULT_LOCATION "Earth"
......
......@@ -22,37 +22,13 @@
#define MAX_YP_DIRECTORIES 25
struct _mount_proxy;
#include <libxml/tree.h>
#include "common/thread/thread.h"
#include "common/avl/avl.h"
#include "slave.h"
#include "connection.h"
#include "icecasttypes.h"
#define XMLSTR(str) ((xmlChar *)(str))
typedef enum _operation_mode {
/* Default operation mode. may depend on context */
OMODE_DEFAULT = 0,
/* The normal mode. */
OMODE_NORMAL,
/* Mimic some of the behavior of older versions.
* This mode should only be used in transition to normal mode,
* e.g. to give some clients time to upgrade to new API.
*/
OMODE_LEGACY,
/* The struct mode includes some behavior for future versions
* that can for some reason not yet be used in the normal mode
* e.g. because it may break interfaces in some way.
* New applications should test against this mode and developer
* of software interacting with Icecast on an API level should
* have a look for strict mode behavior to avoid random breakage
* with newer versions of Icecast.
*/
OMODE_STRICT
} operation_mode;
typedef enum _http_header_type {
/* static: headers are passed as is to the client. */
HTTP_HEADER_TYPE_STATIC
......@@ -79,12 +55,12 @@ typedef struct ice_config_dir_tag {
struct ice_config_dir_tag *next;
} ice_config_dir_t;
typedef struct _config_options {
struct _config_options {
char *type;
char *name;
char *value;
struct _config_options *next;
} config_options_t;
config_options_t *next;
};
typedef enum _mount_type {
MOUNT_TYPE_NORMAL,
......@@ -184,7 +160,7 @@ typedef struct _config_tls_context {
char *cipher_list;
} config_tls_context_t;
typedef struct ice_config_tag {
struct ice_config_tag {
char *config_filename;
char *location;
......@@ -260,7 +236,7 @@ typedef struct ice_config_tag {
int yp_url_timeout[MAX_YP_DIRECTORIES];
int yp_touch_interval[MAX_YP_DIRECTORIES];
int num_yp_directories;
} ice_config_t;
};
typedef struct {
rwlock_t config_lock;
......
......@@ -42,6 +42,7 @@
#include "logging.h"
#include "util.h"
#include "acl.h"
/* for ADMIN_COMMAND_ERROR */
#include "admin.h"
......
......@@ -19,16 +19,12 @@
#ifndef __CLIENT_H__
#define __CLIENT_H__
typedef struct _client_tag client_t;
#include "common/httpp/httpp.h"
#include "common/httpp/encoding.h"
#include "icecasttypes.h"
#include "errors.h"
#include "connection.h"
#include "refbuf.h"
#include "acl.h"
#include "cfgfile.h"
#include "admin.h"
#include "common/httpp/httpp.h"
#include "common/httpp/encoding.h"
#define CLIENT_DEFAULT_ADMIN_FORMAT ADMIN_FORMAT_TRANSFORMED
......@@ -96,19 +92,19 @@ struct _client_tag {
unsigned int pos;
/* auth used for this client */
struct auth_tag *auth;
auth_t *auth;
/* Format-handler-specific data for this client */
void *format_data;
/* function to call to release format specific resources */
void (*free_client_data)(struct _client_tag *client);
void (*free_client_data)(client_t *client);
/* write out data associated with client */
int (*write_to_client)(struct _client_tag *client);
int (*write_to_client)(client_t *client);
/* function to check if refbuf needs updating */
int (*check_buffer)(struct source_tag *source, struct _client_tag *client);
int (*check_buffer)(source_t *source, client_t *client);
};
int client_create (client_t **c_ptr, connection_t *con, http_parser_t *parser);
......
......@@ -20,6 +20,10 @@
* Solaris.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
......
......@@ -33,34 +33,30 @@
#include <winsock2.h>
#endif
#include "compat.h"
#include "common/thread/thread.h"
#include "common/avl/avl.h"
#include "common/net/sock.h"
#include "common/httpp/httpp.h"
#include "compat.h"
#include "connection.h"
#include "cfgfile.h"
#include "global.h"
#include "util.h"
#include "connection.h"
#include "refbuf.h"
#include "client.h"
#include "errors.h"
#include "stats.h"
#include "logging.h"
#include "xslt.h"
#include "fserve.h"
#include "sighandler.h"
#include "slave.h"
#include "yp.h"
#include "source.h"
#include "format.h"
#include "format_mp3.h"
#include "admin.h"
#include "auth.h"
#include "matchfile.h"
#include "tls.h"
#include "acl.h"
#define CATMODULE "connection"
......@@ -144,7 +140,7 @@ void connection_shutdown(void)
_initialized = 0;
}
void connection_reread_config(struct ice_config_tag *config)
void connection_reread_config(ice_config_t *config)
{
get_tls_certificate(config);
}
......
......@@ -19,30 +19,12 @@
#include "tls.h"
#include "icecasttypes.h"
#include "compat.h"
#include "common/httpp/httpp.h"
#include "common/thread/thread.h"
#include "common/net/sock.h"
struct _client_tag;
struct source_tag;
struct ice_config_tag;
typedef enum _tlsmode_tag {
/* no TLS is used at all */
ICECAST_TLSMODE_DISABLED = 0,
/* TLS mode is to be detected */
ICECAST_TLSMODE_AUTO,
/* Like ICECAST_TLSMODE_AUTO but enforces TLS */
ICECAST_TLSMODE_AUTO_NO_PLAIN,
/* TLS via HTTP Upgrade:-header [RFC2817] */
ICECAST_TLSMODE_RFC2817,
/* TLS for transport layer like HTTPS [RFC2818] does */
ICECAST_TLSMODE_RFC2818
} tlsmode_t;
typedef struct connection_tag
{
struct connection_tag {
unsigned long id;
time_t con_time;
......@@ -55,20 +37,20 @@ typedef struct connection_tag
tlsmode_t tlsmode;
tls_t *tls;
int (*send)(struct connection_tag *handle, const void *buf, size_t len);
int (*read)(struct connection_tag *handle, void *buf, size_t len);
int (*send)(connection_t *handle, const void *buf, size_t len);
int (*read)(connection_t *handle, void *buf, size_t len);
char *ip;
} connection_t;
};
void connection_initialize(void);
void connection_shutdown(void);
void connection_reread_config(struct ice_config_tag *config);
void connection_reread_config(ice_config_t *config);
void connection_accept_loop(void);
int connection_setup_sockets(struct ice_config_tag *config);
int connection_setup_sockets(ice_config_t *config);
void connection_close(connection_t *con);
connection_t *connection_create(sock_t sock, sock_t serversock, char *ip);
int connection_complete_source(struct source_tag *source, int response);
int connection_complete_source(source_t *source, int response);
void connection_queue(connection_t *con);
void connection_uses_tls(connection_t *con);
......
......@@ -11,6 +11,7 @@
#endif
#include "curl.h"
#include "cfgfile.h"
#include "logging.h"
#define CATMODULE "curl"
......
......@@ -20,6 +20,9 @@
#include "event_url.h"
#include "logging.h"
#include "admin.h"
#include "connection.h"
#include "client.h"
#include "cfgfile.h"
#define CATMODULE "event"
......
......@@ -9,18 +9,13 @@
#ifndef __EVENT_H__
#define __EVENT_H__
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include "common/httpp/httpp.h"
#include "cfgfile.h"
#include "client.h"
#include "source.h"
#include "common/thread/thread.h"
#include "icecasttypes.h"
/* implemented */
#define EVENT_TYPE_LOG "log"
......
......@@ -22,6 +22,7 @@
#include "event.h"
#include "global.h"
#include "source.h"
#include "logging.h"
#define CATMODULE "event_exec"
......
......@@ -13,6 +13,8 @@
#include <string.h>
#include "event.h"
#include "util.h"
#include "cfgfile.h"
#include "logging.h"
#define CATMODULE "event_log"
......
......@@ -14,6 +14,8 @@
#include "curl.h"
#include "event.h"
#include "cfgfile.h"
#include "util.h"
#include "logging.h"
#define CATMODULE "event_url"
......
......@@ -20,13 +20,12 @@
#include <vorbis/codec.h>
#include "icecasttypes.h"
#include "client.h"
#include "refbuf.h"
#include "cfgfile.h"
#include "common/httpp/httpp.h"
struct source_tag;
struct _mount_proxy;
typedef enum _format_type_tag
{
FORMAT_ERROR, /* No format, source not processable */
......@@ -47,13 +46,13 @@ typedef struct _format_plugin_tag
uint64_t read_bytes;
uint64_t sent_bytes;
refbuf_t *(*get_buffer)(struct source_tag *);
refbuf_t *(*get_buffer)(source_t *);
int (*write_buf_to_client)(client_t *client);
void (*write_buf_to_file)(struct source_tag *source, refbuf_t *refbuf);
int (*create_client_data)(struct source_tag *source, client_t *client);
void (*write_buf_to_file)(source_t *source, refbuf_t *refbuf);
int (*create_client_data)(source_t *source, client_t *client);
void (*set_tag)(struct _format_plugin_tag *plugin, const char *tag, const char *value, const char *charset);
void (*free_plugin)(struct _format_plugin_tag *self);
void (*apply_settings)(client_t *client, struct _format_plugin_tag *format, struct _mount_proxy *mount);
void (*apply_settings)(client_t *client, struct _format_plugin_tag *format, mount_proxy *mount);
/* meta data */
vorbis_comment vc;
......@@ -64,16 +63,16 @@ typedef struct _format_plugin_tag
format_type_t format_get_type(const char *contenttype);
char *format_get_mimetype(format_type_t type);
int format_get_plugin(format_type_t type, struct source_tag *source);
int format_get_plugin(format_type_t type, source_t *source);
int format_generic_write_to_client (client_t *client);
int format_advance_queue (struct source_tag *source, client_t *client);
int format_check_http_buffer (struct source_tag *source, client_t *client);
int format_check_file_buffer (struct source_tag *source, client_t *client);
int format_advance_queue (source_t *source, client_t *client);
int format_check_http_buffer (source_t *source, client_t *client);
int format_check_file_buffer (source_t *source, client_t *client);
void format_send_general_headers(format_plugin_t *format,
struct source_tag *source, client_t *client);
source_t *source, client_t *client);
void format_set_vorbiscomment(format_plugin_t *plugin, const char *tag, const char *value);
......
......@@ -32,6 +32,7 @@
#include "refbuf.h"
#include "source.h"
#include "client.h"
#include "connection.h"
#include "stats.h"
#include "format.h"
......@@ -55,7 +56,7 @@ static refbuf_t *mp3_get_no_meta (source_t *source);
static int format_mp3_create_client_data (source_t *source, client_t *client);
static void free_mp3_client_data (client_t *client);
static int format_mp3_write_buf_to_client(client_t *client);
static void write_mp3_to_file (struct source_tag *source, refbuf_t *refbuf);
static void write_mp3_to_file (source_t *source, refbuf_t *refbuf);
static void mp3_set_tag (format_plugin_t *plugin, const char *tag, const char *in_value, const char *charset);
static void format_mp3_apply_settings(client_t *client, format_plugin_t *format, mount_proxy *mount);
......@@ -715,7 +716,7 @@ static void free_mp3_client_data (client_t *client)
}
static void write_mp3_to_file (struct source_tag *source, refbuf_t *refbuf)
static void write_mp3_to_file (source_t *source, refbuf_t *refbuf)
{
if (refbuf->len == 0)
return;
......
......@@ -60,7 +60,7 @@ static void format_ogg_free_plugin(format_plugin_t *plugin);
static int create_ogg_client_data(source_t *source, client_t *client);
static void free_ogg_client_data(client_t *client);
static void write_ogg_to_file(struct source_tag *source, refbuf_t *refbuf);
static void write_ogg_to_file(source_t *source, refbuf_t *refbuf);
static refbuf_t *ogg_get_buffer(source_t *source);
static int write_buf_to_client(client_t *client);
......@@ -563,7 +563,7 @@ static int write_buf_to_client(client_t *client)
}
static int write_ogg_data (struct source_tag *source, refbuf_t *refbuf)
static int write_ogg_data (source_t *source, refbuf_t *refbuf)
{
int ret = 1;
......@@ -578,7 +578,7 @@ static int write_ogg_data (struct source_tag *source, refbuf_t *refbuf)
}
static void write_ogg_to_file (struct source_tag *source, refbuf_t *refbuf)
static void write_ogg_to_file (source_t *source, refbuf_t *refbuf)
{
ogg_state_t *ogg_info = source->format->_state;
......
......@@ -47,6 +47,8 @@
#include "common/httpp/httpp.h"
#include "common/net/sock.h"
#include "fserve.h"
#include "compat.h"
#include "connection.h"
#include "global.h"
#include "refbuf.h"
......@@ -58,9 +60,6 @@
#include "cfgfile.h"
#include "util.h"
#include "admin.h"
#include "compat.h"
#include "fserve.h"
#undef CATMODULE
#define CATMODULE "fserve"
......
......@@ -14,7 +14,8 @@
#define __FSERVE_H__
#include <stdio.h>
#include "cfgfile.h"
#include "icecasttypes.h"
typedef void (*fserve_callback_t)(client_t *, void *);
......
......@@ -22,8 +22,8 @@
#include "common/thread/thread.h"
#include "common/avl/avl.h"
#include "slave.h"
#include "common/net/sock.h"
#include "icecasttypes.h"
typedef struct ice_global_tag
{
......@@ -38,9 +38,9 @@ typedef struct ice_global_tag
avl_tree *source_tree;
/* for locally defined relays */
struct _relay_server *relays;
relay_server *relays;
/* relays retrieved from master */
struct _relay_server *master_relays;
relay_server *master_relays;
cond_t shutdown_cond;
} ice_global_t;
......
/* Icecast
*
* This program is distributed under the GNU General Public License, version 2.
* A copy of this license is included with this source.
*
* Copyright 2018, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
*/
#ifndef __ICECASTTYPES_H__
#define __ICECASTTYPES_H__
#include "compat.h"
/* ---[ client.[ch] ]--- */
typedef struct _client_tag client_t;
/* ---[ source.[ch] ]--- */
typedef struct source_tag source_t;
/* ---[ admin.[ch] ]--- */
/* Command IDs */
typedef int32_t admin_command_id_t;
/* formats */
typedef enum {
ADMIN_FORMAT_AUTO,
ADMIN_FORMAT_RAW,
ADMIN_FORMAT_TRANSFORMED,
ADMIN_FORMAT_PLAINTEXT
} admin_format_t;
/* ---[ acl.[ch] ]--- */
typedef struct acl_tag acl_t;
/* ---[ auth.[ch] ]--- */
typedef struct auth_tag auth_t;
/* ---[ cfgfile.[ch] ]--- */
typedef struct ice_config_tag ice_config_t;
typedef struct _config_options config_options_t;
typedef enum _operation_mode {
/* Default operation mode. may depend on context */
OMODE_DEFAULT = 0,
/* The normal mode. */
OMODE_NORMAL,
/* Mimic some of the behavior of older versions.
* This mode should only be used in transition to normal mode,
* e.g. to give some clients time to upgrade to new API.
*/
OMODE_LEGACY,
/* The struct mode includes some behavior for future versions
* that can for some reason not yet be used in the normal mode
* e.g. because it may break interfaces in some way.
* New applications should test against this mode and developer
* of software interacting with Icecast on an API level should
* have a look for strict mode behavior to avoid random breakage
* with newer versions of Icecast.
*/
OMODE_STRICT
} operation_mode;
/* ---[ connection.[ch] ]--- */
typedef struct connection_tag connection_t;
typedef enum {
/* no TLS is used at all */
ICECAST_TLSMODE_DISABLED = 0,
/* TLS mode is to be detected */
ICECAST_TLSMODE_AUTO,
/* Like ICECAST_TLSMODE_AUTO but enforces TLS */
ICECAST_TLSMODE_AUTO_NO_PLAIN,
/* TLS via HTTP Upgrade:-header [RFC2817] */
ICECAST_TLSMODE_RFC2817,
/* TLS for transport layer like HTTPS [RFC2818] does */
ICECAST_TLSMODE_RFC2818
} tlsmode_t;
/* ---[ slave.[ch] ]--- */
typedef struct _relay_server relay_server;
#endif
......@@ -22,13 +22,13 @@
#include "common/thread/thread.h"
#include "common/httpp/httpp.h"
#include "logging.h"
#include "connection.h"
#include "refbuf.h"
#include "client.h"
#include "compat.h"
#include "cfgfile.h"
#include "logging.h"
#include "util.h"
#ifdef _WIN32
......
......@@ -14,10 +14,10 @@
#ifndef __LOGGING_H__
#define __LOGGING_H__
#include "cfgfile.h"
#include "client.h"
#include "common/log/log.h"