aboutsummaryrefslogtreecommitdiffstats
path: root/src/interface.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-10-28 05:14:55 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-10-28 05:14:55 +0000
commit58dbe4bb5d974c34335d6906a9ce930f07cd1db4 (patch)
tree9a6aee08b21100cb74e809f0620d81466f6067df /src/interface.c
parent8f40569aeeafe4a36e3d719c1df97de42606ea76 (diff)
downloadmpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.tar.gz
mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.tar.xz
mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.zip
merge shank-rewrite-config changes
git-svn-id: https://svn.musicpd.org/mpd/trunk@2375 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/interface.c')
-rw-r--r--src/interface.c81
1 files changed, 56 insertions, 25 deletions
diff --git a/src/interface.c b/src/interface.c
index 196ff7706..4282b89be 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -47,12 +47,18 @@
#define INTERFACE_LIST_MODE_BEGIN "command_list_begin"
#define INTERFACE_LIST_OK_MODE_BEGIN "command_list_ok_begin"
#define INTERFACE_LIST_MODE_END "command_list_end"
-#define INTERFACE_DEFAULT_OUT_BUFFER_SIZE 4096
-
-int interface_max_connections = 0;
-int interface_timeout;
-unsigned long long interface_max_command_list_size;
-unsigned long long interface_max_output_buffer_size;
+#define INTERFACE_DEFAULT_OUT_BUFFER_SIZE 4096
+#define INTERFACE_TIMEOUT_DEFAULT 60
+#define INTERFACE_MAX_CONNECTIONS_DEFAULT 10
+#define INTERFACE_MAX_COMMAND_LIST_DEFAULT (2048*1024)
+#define INTERFACE_MAX_OUTPUT_BUFFER_SIZE_DEFAULT (2048*1024)
+
+static int interface_max_connections = INTERFACE_MAX_CONNECTIONS_DEFAULT;
+static int interface_timeout = INTERFACE_TIMEOUT_DEFAULT;
+static size_t interface_max_command_list_size =
+ INTERFACE_MAX_COMMAND_LIST_DEFAULT;
+static size_t interface_max_output_buffer_size =
+ INTERFACE_MAX_OUTPUT_BUFFER_SIZE_DEFAULT;
typedef struct _Interface {
char buffer[INTERFACE_MAX_BUFFER_LENGTH+2];
@@ -420,33 +426,58 @@ int doIOForInterfaces() {
void initInterfaces() {
int i;
char * test;
+ ConfigParam * param;
- interface_timeout = strtol((getConf())[CONF_CONNECTION_TIMEOUT],&test,10);
- if(*test!='\0' || interface_timeout<=0) {
- ERROR("connection timeout \"%s\" is not a positive integer\n",(getConf())[CONF_CONNECTION_TIMEOUT]);
- exit(EXIT_FAILURE);
- }
+ param = getConfigParam(CONF_CONN_TIMEOUT);
- interface_max_connections = strtol((getConf())[CONF_MAX_CONNECTIONS],&test,10);
- if(*test!='\0' || interface_max_connections<=0) {
- ERROR("max connections \"%s\" is not a positive integer\n",(getConf())[CONF_MAX_CONNECTIONS]);
- exit(EXIT_FAILURE);
+ if(param) {
+ interface_timeout = strtol(param->value,&test,10);
+ if(*test!='\0' || interface_timeout<=0) {
+ ERROR("connection timeout \"%s\" is not a positive "
+ "integer, line %i\n", CONF_CONN_TIMEOUT,
+ param->line);
+ exit(EXIT_FAILURE);
+ }
}
- interface_max_command_list_size = strtoll((getConf())[CONF_MAX_COMMAND_LIST_SIZE],&test,10);
- if(*test!='\0' || interface_max_command_list_size<=0) {
- ERROR("max command list size \"%s\" is not a positive integer\n",(getConf())[CONF_MAX_COMMAND_LIST_SIZE]);
- exit(EXIT_FAILURE);
+ param = getConfigParam(CONF_MAX_CONN);
+
+ if(param) {
+ interface_max_connections = strtol(param->value, &test, 10);
+ if(*test!='\0' || interface_max_connections<=0) {
+ ERROR("max connections \"%s\" is not a positive integer"
+ ", line %i\n", param->value, param->line);
+ exit(EXIT_FAILURE);
+ }
}
- interface_max_output_buffer_size = strtoll((getConf())[CONF_MAX_OUTPUT_BUFFER_SIZE],&test,10);
- if(*test!='\0' || interface_max_output_buffer_size<=0) {
- ERROR("max output buffer size \"%s\" is not a positive integer\n",(getConf())[CONF_MAX_OUTPUT_BUFFER_SIZE]);
- exit(EXIT_FAILURE);
+ param = getConfigParam(CONF_MAX_COMMAND_LIST_SIZE);
+
+ if(param) {
+ interface_max_command_list_size = strtoll(param->value,
+ &test, 10);
+ if(*test!='\0' || interface_max_command_list_size<=0) {
+ ERROR("max command list size \"%s\" is not a positive "
+ "integer, line %i\n", param->value,
+ param->line);
+ exit(EXIT_FAILURE);
+ }
+ interface_max_command_list_size*=1024;
}
- interface_max_command_list_size*=1024;
- interface_max_output_buffer_size*=1024;
+ param = getConfigParam(CONF_MAX_OUTPUT_BUFFER_SIZE);
+
+ if(param) {
+ interface_max_output_buffer_size = strtoll(param->value, &test,
+ 10);
+ if(*test!='\0' || interface_max_output_buffer_size<=0) {
+ ERROR("max output buffer size \"%s\" is not a positive "
+ "integer, line %i\n", param->value,
+ param->line);
+ exit(EXIT_FAILURE);
+ }
+ interface_max_output_buffer_size*=1024;
+ }
interfaces = malloc(sizeof(Interface)*interface_max_connections);