config.h 2.66 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

Michael Smith's avatar
Michael Smith committed
11 12
#include "thread/thread.h"

Jack Moffitt's avatar
Jack Moffitt committed
13 14 15
typedef struct ice_config_dir_tag
{
	char *host;
16
	int touch_interval;
Jack Moffitt's avatar
Jack Moffitt committed
17 18 19
	struct ice_config_dir_tag *next;
} ice_config_dir_t;

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

29 30 31 32 33 34 35 36 37 38 39 40 41 42
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;

Jack Moffitt's avatar
Jack Moffitt committed
43 44
typedef struct ice_config_tag
{
Michael Smith's avatar
Michael Smith committed
45 46
    char *config_filename;

Jack Moffitt's avatar
Jack Moffitt committed
47 48 49 50 51
	char *location;
	char *admin;

	int client_limit;
	int source_limit;
52
    long queue_size_limit;
Jack Moffitt's avatar
Jack Moffitt committed
53 54 55
	int threadpool_size;
	int client_timeout;
	int header_timeout;
56
	int source_timeout;
57
    int ice_login;
58
    int fileserve;
Jack Moffitt's avatar
Jack Moffitt committed
59 60

	char *source_password;
61
    char *relay_password;
62 63
    char *admin_username;
    char *admin_password;
Jack Moffitt's avatar
Jack Moffitt committed
64

65
	int touch_interval;
Jack Moffitt's avatar
Jack Moffitt committed
66 67 68 69 70
	ice_config_dir_t *dir_list;

	char *hostname;
	int port;
	char *bind_address;
71 72 73
	char *master_server;
	int master_server_port;
    int master_update_interval;
74
    char *master_password;
Jack Moffitt's avatar
Jack Moffitt committed
75

Michael Smith's avatar
Michael Smith committed
76 77
    relay_server *relay;

78 79
    mount_proxy *mounts;

Jack Moffitt's avatar
Jack Moffitt committed
80 81
	char *base_dir;
	char *log_dir;
82
	char *webroot_dir;
Jack Moffitt's avatar
Jack Moffitt committed
83 84 85

	char *access_log;
	char *error_log;
86
    int loglevel;
87 88 89 90 91

    int chroot;
    int chuid;
    char *user;
    char *group;
92 93 94
    char *yp_url[MAX_YP_DIRECTORIES];
    int	yp_url_timeout[MAX_YP_DIRECTORIES];
    int num_yp_directories;
Jack Moffitt's avatar
Jack Moffitt committed
95 96
} ice_config_t;

Michael Smith's avatar
Michael Smith committed
97 98 99 100 101 102
typedef struct {
    mutex_t config_lock;
    mutex_t relay_lock;
    mutex_t mounts_lock;
} ice_config_locks;

Jack Moffitt's avatar
Jack Moffitt committed
103 104 105
void config_initialize(void);
void config_shutdown(void);

Michael Smith's avatar
Michael Smith committed
106 107
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
108
int config_parse_cmdline(int arg, char **argv);
Michael Smith's avatar
Michael Smith committed
109 110
void config_set_config(ice_config_t *config);
void config_clear(ice_config_t *config);
Jack Moffitt's avatar
Jack Moffitt committed
111 112 113

int config_rehash(void);

Michael Smith's avatar
Michael Smith committed
114 115
ice_config_locks *config_locks(void);

Jack Moffitt's avatar
Jack Moffitt committed
116
ice_config_t *config_get_config(void);
Michael Smith's avatar
Michael Smith committed
117 118 119 120
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
121 122 123 124 125

#endif  /* __CONFIG_H__ */