config.h 2.78 KB
Newer Older
Jack Moffitt's avatar
Jack Moffitt committed
1 2 3 4 5 6
#ifndef __CONFIG_H__
#define __CONFIG_H__

#define CONFIG_EINSANE -1
#define CONFIG_ENOROOT -2
#define CONFIG_EBADROOT -3
7
#define CONFIG_EPARSE -4
Jack Moffitt's avatar
Jack Moffitt committed
8

9 10
#define MAX_YP_DIRECTORIES 25

11

Michael Smith's avatar
Michael Smith committed
12
#include "thread/thread.h"
13 14
#include "avl/avl.h"
#include "global.h"
Michael Smith's avatar
Michael Smith committed
15

Jack Moffitt's avatar
Jack Moffitt committed
16 17 18
typedef struct ice_config_dir_tag
{
	char *host;
19
	int touch_interval;
Jack Moffitt's avatar
Jack Moffitt committed
20 21 22
	struct ice_config_dir_tag *next;
} ice_config_dir_t;

Michael Smith's avatar
Michael Smith committed
23 24 25 26
typedef struct _relay_server {
    char *server;
    int port;
    char *mount;
27
    char *localmount;
28
    int mp3metadata;
Michael Smith's avatar
Michael Smith committed
29 30 31
    struct _relay_server *next;
} relay_server;

32 33 34 35 36 37 38 39 40 41 42 43 44 45
typedef struct _mount_proxy {
    char *mountname; /* The mountpoint this proxy is used for */

    char *username; /* Username and password for this mountpoint. If unset, */
    char *password; /* falls back to global source password */

    char *dumpfile; /* Filename to dump this stream to (will be appended). NULL
                       to not dump. */
    int max_listeners; /* Max listeners for this mountpoint only. -1 to not 
                          limit here (i.e. only use the global limit) */
    char *fallback_mount;
    struct _mount_proxy *next;
} mount_proxy;

46 47 48 49 50
typedef struct {
    int port;
    char *bind_address;
} listener_t;

Jack Moffitt's avatar
Jack Moffitt committed
51 52
typedef struct ice_config_tag
{
Michael Smith's avatar
Michael Smith committed
53 54
    char *config_filename;

Jack Moffitt's avatar
Jack Moffitt committed
55 56 57 58 59
	char *location;
	char *admin;

	int client_limit;
	int source_limit;
60
    long queue_size_limit;
Jack Moffitt's avatar
Jack Moffitt committed
61 62 63
	int threadpool_size;
	int client_timeout;
	int header_timeout;
64
	int source_timeout;
65
    int ice_login;
66
    int fileserve;
Jack Moffitt's avatar
Jack Moffitt committed
67 68

	char *source_password;
69 70
    char *admin_username;
    char *admin_password;
Jack Moffitt's avatar
Jack Moffitt committed
71

72
	int touch_interval;
Jack Moffitt's avatar
Jack Moffitt committed
73 74 75
	ice_config_dir_t *dir_list;

	char *hostname;
76 77 78 79
    int port;

    listener_t listeners[MAX_LISTEN_SOCKETS];

80 81 82
	char *master_server;
	int master_server_port;
    int master_update_interval;
83
    char *master_password;
Jack Moffitt's avatar
Jack Moffitt committed
84

Michael Smith's avatar
Michael Smith committed
85 86
    relay_server *relay;

87 88
    mount_proxy *mounts;

Jack Moffitt's avatar
Jack Moffitt committed
89 90
	char *base_dir;
	char *log_dir;
91
	char *webroot_dir;
Jack Moffitt's avatar
Jack Moffitt committed
92 93 94

	char *access_log;
	char *error_log;
95
    int loglevel;
96 97 98 99 100

    int chroot;
    int chuid;
    char *user;
    char *group;
101 102 103
    char *yp_url[MAX_YP_DIRECTORIES];
    int	yp_url_timeout[MAX_YP_DIRECTORIES];
    int num_yp_directories;
Jack Moffitt's avatar
Jack Moffitt committed
104 105
} ice_config_t;

Michael Smith's avatar
Michael Smith committed
106 107 108 109 110 111
typedef struct {
    mutex_t config_lock;
    mutex_t relay_lock;
    mutex_t mounts_lock;
} ice_config_locks;

Jack Moffitt's avatar
Jack Moffitt committed
112 113 114
void config_initialize(void);
void config_shutdown(void);

Michael Smith's avatar
Michael Smith committed
115 116
int config_parse_file(const char *filename, ice_config_t *configuration);
int config_initial_parse_file(const char *filename);
Jack Moffitt's avatar
Jack Moffitt committed
117
int config_parse_cmdline(int arg, char **argv);
Michael Smith's avatar
Michael Smith committed
118 119
void config_set_config(ice_config_t *config);
void config_clear(ice_config_t *config);
Jack Moffitt's avatar
Jack Moffitt committed
120 121 122

int config_rehash(void);

Michael Smith's avatar
Michael Smith committed
123 124
ice_config_locks *config_locks(void);

Jack Moffitt's avatar
Jack Moffitt committed
125
ice_config_t *config_get_config(void);
Michael Smith's avatar
Michael Smith committed
126 127 128 129
void config_release_config(void);

/* To be used ONLY in one-time startup code */
ice_config_t *config_get_config_unlocked(void);
Jack Moffitt's avatar
Jack Moffitt committed
130 131 132 133 134

#endif  /* __CONFIG_H__ */