Added XML file for configurations.
The XML file will be used to auto generate the configuratioin code
and the corresponding documentation in the future.
The perl script parses this XML format and outputs gen_config.{h,c} files
accordingly.
This commit is contained in:
306
src/core/gen_config.c
Normal file
306
src/core/gen_config.c
Normal file
@@ -0,0 +1,306 @@
|
||||
/* THIS FILE IS AUTOGENERATED - DO NOT CHANGE IT! */
|
||||
|
||||
void config_defaults(struct hub_config* config)
|
||||
{
|
||||
DEFAULT_INTEGER(server_port, 1511);
|
||||
DEFAULT_STRING (server_bind_addr, "any");
|
||||
DEFAULT_INTEGER(server_listen_backlog, 50);
|
||||
DEFAULT_STRING (server_alt_ports, "");
|
||||
DEFAULT_BOOLEAN(hub_enabled, 1);
|
||||
DEFAULT_BOOLEAN(show_banner, 1);
|
||||
DEFAULT_BOOLEAN(show_banner_sys_info, 1);
|
||||
DEFAULT_INTEGER(max_users, 500);
|
||||
DEFAULT_BOOLEAN(registered_users_only, 0);
|
||||
DEFAULT_BOOLEAN(obsolete_clients, 0);
|
||||
DEFAULT_BOOLEAN(chat_only, 0);
|
||||
DEFAULT_BOOLEAN(chat_is_privileged, 0);
|
||||
DEFAULT_STRING (hub_name, "uhub");
|
||||
DEFAULT_STRING (hub_description, "no description");
|
||||
DEFAULT_INTEGER(max_recv_buffer, 4096);
|
||||
DEFAULT_INTEGER(max_send_buffer, 131072);
|
||||
DEFAULT_INTEGER(max_send_buffer_soft, 98304);
|
||||
DEFAULT_BOOLEAN(low_bandwidth_mode, 0);
|
||||
DEFAULT_INTEGER(max_chat_history, 20);
|
||||
DEFAULT_INTEGER(max_logout_log, 20);
|
||||
DEFAULT_INTEGER(limit_max_hubs_user, 10);
|
||||
DEFAULT_INTEGER(limit_max_hubs_reg, 10);
|
||||
DEFAULT_INTEGER(limit_max_hubs_op, 10);
|
||||
DEFAULT_INTEGER(limit_max_hubs, 25);
|
||||
DEFAULT_INTEGER(limit_min_hubs_user, 10);
|
||||
DEFAULT_INTEGER(limit_min_hubs_reg, 10);
|
||||
DEFAULT_INTEGER(limit_min_hubs_op, 10);
|
||||
DEFAULT_INTEGER(limit_min_share, 0);
|
||||
DEFAULT_INTEGER(limit_max_share, 0);
|
||||
DEFAULT_INTEGER(limit_min_slots, 0);
|
||||
DEFAULT_INTEGER(limit_max_slots, 0);
|
||||
DEFAULT_INTEGER(flood_ctl_interval, 0);
|
||||
DEFAULT_INTEGER(flood_ctl_chat, 0);
|
||||
DEFAULT_INTEGER(flood_ctl_connect, 0);
|
||||
DEFAULT_INTEGER(flood_ctl_search, 0);
|
||||
DEFAULT_INTEGER(flood_ctl_update, 0);
|
||||
DEFAULT_INTEGER(flood_ctl_extras, 0);
|
||||
DEFAULT_BOOLEAN(tls_enable, 0);
|
||||
DEFAULT_BOOLEAN(tls_require, 0);
|
||||
DEFAULT_STRING (tls_certificate, "");
|
||||
DEFAULT_STRING (tls_private_key, "");
|
||||
DEFAULT_STRING (file_motd, "");
|
||||
DEFAULT_STRING (file_acl, "");
|
||||
DEFAULT_STRING (file_rules, "");
|
||||
DEFAULT_STRING (msg_hub_full, "Hub is full");
|
||||
DEFAULT_STRING (msg_hub_disabled, "Hub is disabled");
|
||||
DEFAULT_STRING (msg_hub_registered_users_only, "Hub is for registered users only");
|
||||
DEFAULT_STRING (msg_inf_error_nick_missing, "No nickname given");
|
||||
DEFAULT_STRING (msg_inf_error_nick_multiple, "Multiple nicknames given");
|
||||
DEFAULT_STRING (msg_inf_error_nick_invalid, "Nickname is invalid");
|
||||
DEFAULT_STRING (msg_inf_error_nick_long, "Nickname too long");
|
||||
DEFAULT_STRING (msg_inf_error_nick_short, "Nickname too short");
|
||||
DEFAULT_STRING (msg_inf_error_nick_spaces, "Nickname cannot start with spaces");
|
||||
DEFAULT_STRING (msg_inf_error_nick_bad_chars, "Nickname contains invalid characters");
|
||||
DEFAULT_STRING (msg_inf_error_nick_not_utf8, "Nickname is not valid UTF-8");
|
||||
DEFAULT_STRING (msg_inf_error_nick_taken, "Nickname is already in use");
|
||||
DEFAULT_STRING (msg_inf_error_nick_restricted, "Nickname cannot be used on this hub");
|
||||
DEFAULT_STRING (msg_inf_error_cid_invalid, "CID is not valid");
|
||||
DEFAULT_STRING (msg_inf_error_cid_missing, "CID is not specified");
|
||||
DEFAULT_STRING (msg_inf_error_cid_taken, "CID is taken");
|
||||
DEFAULT_STRING (msg_inf_error_pid_missing, "PID is not specified");
|
||||
DEFAULT_STRING (msg_inf_error_pid_invalid, "PID is invalid");
|
||||
DEFAULT_STRING (msg_ban_permanently, "Banned permanently");
|
||||
DEFAULT_STRING (msg_ban_temporarily, "Banned temporarily");
|
||||
DEFAULT_STRING (msg_auth_invalid_password, "Password is wrong");
|
||||
DEFAULT_STRING (msg_auth_user_not_found, "User not found in password database");
|
||||
DEFAULT_STRING (msg_error_no_memory, "No memory");
|
||||
DEFAULT_STRING (msg_user_share_size_low, "User is not sharing enough");
|
||||
DEFAULT_STRING (msg_user_share_size_high, "User is sharing too much");
|
||||
DEFAULT_STRING (msg_user_slots_low, "User have too few upload slots.");
|
||||
DEFAULT_STRING (msg_user_slots_high, "User have too many upload slots.");
|
||||
DEFAULT_STRING (msg_user_hub_limit_low, "User is on too few hubs.");
|
||||
DEFAULT_STRING (msg_user_hub_limit_high, "User is on too many hubs.");
|
||||
DEFAULT_STRING (msg_user_flood_chat, "Chat flood detected, messages are dropped.");
|
||||
DEFAULT_STRING (msg_user_flood_connect, "Connect flood detected, connection refused.");
|
||||
DEFAULT_STRING (msg_user_flood_search, "Search flood detected, search is stopped.");
|
||||
DEFAULT_STRING (msg_user_flood_update, "Update flood detected.");
|
||||
DEFAULT_STRING (msg_user_flood_extras, "Flood detected.");
|
||||
DEFAULT_STRING (msg_proto_no_common_hash, "No common hash algorithm.");
|
||||
DEFAULT_STRING (msg_proto_obsolete_adc0, "Client is using an obsolete ADC protocol version.");
|
||||
}
|
||||
|
||||
static int apply_config(struct hub_config* config, char* key, char* data, int line_count)
|
||||
{
|
||||
GET_INT (server_port);
|
||||
GET_STR (server_bind_addr);
|
||||
GET_INT (server_listen_backlog);
|
||||
GET_STR (server_alt_ports);
|
||||
GET_BOOL(hub_enabled);
|
||||
GET_BOOL(show_banner);
|
||||
GET_BOOL(show_banner_sys_info);
|
||||
GET_INT (max_users);
|
||||
GET_BOOL(registered_users_only);
|
||||
GET_BOOL(obsolete_clients);
|
||||
GET_BOOL(chat_only);
|
||||
GET_BOOL(chat_is_privileged);
|
||||
GET_STR (hub_name);
|
||||
GET_STR (hub_description);
|
||||
GET_INT (max_recv_buffer);
|
||||
GET_INT (max_send_buffer);
|
||||
GET_INT (max_send_buffer_soft);
|
||||
GET_BOOL(low_bandwidth_mode);
|
||||
GET_INT (max_chat_history);
|
||||
GET_INT (max_logout_log);
|
||||
GET_INT (limit_max_hubs_user);
|
||||
GET_INT (limit_max_hubs_reg);
|
||||
GET_INT (limit_max_hubs_op);
|
||||
GET_INT (limit_max_hubs);
|
||||
GET_INT (limit_min_hubs_user);
|
||||
GET_INT (limit_min_hubs_reg);
|
||||
GET_INT (limit_min_hubs_op);
|
||||
GET_INT (limit_min_share);
|
||||
GET_INT (limit_max_share);
|
||||
GET_INT (limit_min_slots);
|
||||
GET_INT (limit_max_slots);
|
||||
GET_INT (flood_ctl_interval);
|
||||
GET_INT (flood_ctl_chat);
|
||||
GET_INT (flood_ctl_connect);
|
||||
GET_INT (flood_ctl_search);
|
||||
GET_INT (flood_ctl_update);
|
||||
GET_INT (flood_ctl_extras);
|
||||
GET_BOOL(tls_enable);
|
||||
GET_BOOL(tls_require);
|
||||
GET_STR (tls_certificate);
|
||||
GET_STR (tls_private_key);
|
||||
GET_STR (file_motd);
|
||||
GET_STR (file_acl);
|
||||
GET_STR (file_rules);
|
||||
GET_STR (msg_hub_full);
|
||||
GET_STR (msg_hub_disabled);
|
||||
GET_STR (msg_hub_registered_users_only);
|
||||
GET_STR (msg_inf_error_nick_missing);
|
||||
GET_STR (msg_inf_error_nick_multiple);
|
||||
GET_STR (msg_inf_error_nick_invalid);
|
||||
GET_STR (msg_inf_error_nick_long);
|
||||
GET_STR (msg_inf_error_nick_short);
|
||||
GET_STR (msg_inf_error_nick_spaces);
|
||||
GET_STR (msg_inf_error_nick_bad_chars);
|
||||
GET_STR (msg_inf_error_nick_not_utf8);
|
||||
GET_STR (msg_inf_error_nick_taken);
|
||||
GET_STR (msg_inf_error_nick_restricted);
|
||||
GET_STR (msg_inf_error_cid_invalid);
|
||||
GET_STR (msg_inf_error_cid_missing);
|
||||
GET_STR (msg_inf_error_cid_taken);
|
||||
GET_STR (msg_inf_error_pid_missing);
|
||||
GET_STR (msg_inf_error_pid_invalid);
|
||||
GET_STR (msg_ban_permanently);
|
||||
GET_STR (msg_ban_temporarily);
|
||||
GET_STR (msg_auth_invalid_password);
|
||||
GET_STR (msg_auth_user_not_found);
|
||||
GET_STR (msg_error_no_memory);
|
||||
GET_STR (msg_user_share_size_low);
|
||||
GET_STR (msg_user_share_size_high);
|
||||
GET_STR (msg_user_slots_low);
|
||||
GET_STR (msg_user_slots_high);
|
||||
GET_STR (msg_user_hub_limit_low);
|
||||
GET_STR (msg_user_hub_limit_high);
|
||||
GET_STR (msg_user_flood_chat);
|
||||
GET_STR (msg_user_flood_connect);
|
||||
GET_STR (msg_user_flood_search);
|
||||
GET_STR (msg_user_flood_update);
|
||||
GET_STR (msg_user_flood_extras);
|
||||
GET_STR (msg_proto_no_common_hash);
|
||||
GET_STR (msg_proto_obsolete_adc0);
|
||||
/* Still here -- unknown directive */
|
||||
LOG_ERROR("Unknown configuration directive: '%s'", key);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void free_config(struct hub_config* config)
|
||||
{
|
||||
hub_free(config->server_bind_addr);
|
||||
hub_free(config->server_alt_ports);
|
||||
hub_free(config->hub_name);
|
||||
hub_free(config->hub_description);
|
||||
hub_free(config->tls_certificate);
|
||||
hub_free(config->tls_private_key);
|
||||
hub_free(config->file_motd);
|
||||
hub_free(config->file_acl);
|
||||
hub_free(config->file_rules);
|
||||
hub_free(config->msg_hub_full);
|
||||
hub_free(config->msg_hub_disabled);
|
||||
hub_free(config->msg_hub_registered_users_only);
|
||||
hub_free(config->msg_inf_error_nick_missing);
|
||||
hub_free(config->msg_inf_error_nick_multiple);
|
||||
hub_free(config->msg_inf_error_nick_invalid);
|
||||
hub_free(config->msg_inf_error_nick_long);
|
||||
hub_free(config->msg_inf_error_nick_short);
|
||||
hub_free(config->msg_inf_error_nick_spaces);
|
||||
hub_free(config->msg_inf_error_nick_bad_chars);
|
||||
hub_free(config->msg_inf_error_nick_not_utf8);
|
||||
hub_free(config->msg_inf_error_nick_taken);
|
||||
hub_free(config->msg_inf_error_nick_restricted);
|
||||
hub_free(config->msg_inf_error_cid_invalid);
|
||||
hub_free(config->msg_inf_error_cid_missing);
|
||||
hub_free(config->msg_inf_error_cid_taken);
|
||||
hub_free(config->msg_inf_error_pid_missing);
|
||||
hub_free(config->msg_inf_error_pid_invalid);
|
||||
hub_free(config->msg_ban_permanently);
|
||||
hub_free(config->msg_ban_temporarily);
|
||||
hub_free(config->msg_auth_invalid_password);
|
||||
hub_free(config->msg_auth_user_not_found);
|
||||
hub_free(config->msg_error_no_memory);
|
||||
hub_free(config->msg_user_share_size_low);
|
||||
hub_free(config->msg_user_share_size_high);
|
||||
hub_free(config->msg_user_slots_low);
|
||||
hub_free(config->msg_user_slots_high);
|
||||
hub_free(config->msg_user_hub_limit_low);
|
||||
hub_free(config->msg_user_hub_limit_high);
|
||||
hub_free(config->msg_user_flood_chat);
|
||||
hub_free(config->msg_user_flood_connect);
|
||||
hub_free(config->msg_user_flood_search);
|
||||
hub_free(config->msg_user_flood_update);
|
||||
hub_free(config->msg_user_flood_extras);
|
||||
hub_free(config->msg_proto_no_common_hash);
|
||||
hub_free(config->msg_proto_obsolete_adc0);
|
||||
}
|
||||
|
||||
void dump_config(struct hub_config* config, int ignore_defaults)
|
||||
{
|
||||
DUMP_INT (server_port, 1511);
|
||||
DUMP_STR(server_bind_addr, "any");
|
||||
DUMP_INT (server_listen_backlog, 50);
|
||||
DUMP_STR(server_alt_ports, "");
|
||||
DUMP_BOOL(hub_enabled, 1);
|
||||
DUMP_BOOL(show_banner, 1);
|
||||
DUMP_BOOL(show_banner_sys_info, 1);
|
||||
DUMP_INT (max_users, 500);
|
||||
DUMP_BOOL(registered_users_only, 0);
|
||||
DUMP_BOOL(obsolete_clients, 0);
|
||||
DUMP_BOOL(chat_only, 0);
|
||||
DUMP_BOOL(chat_is_privileged, 0);
|
||||
DUMP_STR(hub_name, "uhub");
|
||||
DUMP_STR(hub_description, "no description");
|
||||
DUMP_INT (max_recv_buffer, 4096);
|
||||
DUMP_INT (max_send_buffer, 131072);
|
||||
DUMP_INT (max_send_buffer_soft, 98304);
|
||||
DUMP_BOOL(low_bandwidth_mode, 0);
|
||||
DUMP_INT (max_chat_history, 20);
|
||||
DUMP_INT (max_logout_log, 20);
|
||||
DUMP_INT (limit_max_hubs_user, 10);
|
||||
DUMP_INT (limit_max_hubs_reg, 10);
|
||||
DUMP_INT (limit_max_hubs_op, 10);
|
||||
DUMP_INT (limit_max_hubs, 25);
|
||||
DUMP_INT (limit_min_hubs_user, 10);
|
||||
DUMP_INT (limit_min_hubs_reg, 10);
|
||||
DUMP_INT (limit_min_hubs_op, 10);
|
||||
DUMP_INT (limit_min_share, 0);
|
||||
DUMP_INT (limit_max_share, 0);
|
||||
DUMP_INT (limit_min_slots, 0);
|
||||
DUMP_INT (limit_max_slots, 0);
|
||||
DUMP_INT (flood_ctl_interval, 0);
|
||||
DUMP_INT (flood_ctl_chat, 0);
|
||||
DUMP_INT (flood_ctl_connect, 0);
|
||||
DUMP_INT (flood_ctl_search, 0);
|
||||
DUMP_INT (flood_ctl_update, 0);
|
||||
DUMP_INT (flood_ctl_extras, 0);
|
||||
DUMP_BOOL(tls_enable, 0);
|
||||
DUMP_BOOL(tls_require, 0);
|
||||
DUMP_STR(tls_certificate, "");
|
||||
DUMP_STR(tls_private_key, "");
|
||||
DUMP_STR(file_motd, "");
|
||||
DUMP_STR(file_acl, "");
|
||||
DUMP_STR(file_rules, "");
|
||||
DUMP_STR(msg_hub_full, "Hub is full");
|
||||
DUMP_STR(msg_hub_disabled, "Hub is disabled");
|
||||
DUMP_STR(msg_hub_registered_users_only, "Hub is for registered users only");
|
||||
DUMP_STR(msg_inf_error_nick_missing, "No nickname given");
|
||||
DUMP_STR(msg_inf_error_nick_multiple, "Multiple nicknames given");
|
||||
DUMP_STR(msg_inf_error_nick_invalid, "Nickname is invalid");
|
||||
DUMP_STR(msg_inf_error_nick_long, "Nickname too long");
|
||||
DUMP_STR(msg_inf_error_nick_short, "Nickname too short");
|
||||
DUMP_STR(msg_inf_error_nick_spaces, "Nickname cannot start with spaces");
|
||||
DUMP_STR(msg_inf_error_nick_bad_chars, "Nickname contains invalid characters");
|
||||
DUMP_STR(msg_inf_error_nick_not_utf8, "Nickname is not valid UTF-8");
|
||||
DUMP_STR(msg_inf_error_nick_taken, "Nickname is already in use");
|
||||
DUMP_STR(msg_inf_error_nick_restricted, "Nickname cannot be used on this hub");
|
||||
DUMP_STR(msg_inf_error_cid_invalid, "CID is not valid");
|
||||
DUMP_STR(msg_inf_error_cid_missing, "CID is not specified");
|
||||
DUMP_STR(msg_inf_error_cid_taken, "CID is taken");
|
||||
DUMP_STR(msg_inf_error_pid_missing, "PID is not specified");
|
||||
DUMP_STR(msg_inf_error_pid_invalid, "PID is invalid");
|
||||
DUMP_STR(msg_ban_permanently, "Banned permanently");
|
||||
DUMP_STR(msg_ban_temporarily, "Banned temporarily");
|
||||
DUMP_STR(msg_auth_invalid_password, "Password is wrong");
|
||||
DUMP_STR(msg_auth_user_not_found, "User not found in password database");
|
||||
DUMP_STR(msg_error_no_memory, "No memory");
|
||||
DUMP_STR(msg_user_share_size_low, "User is not sharing enough");
|
||||
DUMP_STR(msg_user_share_size_high, "User is sharing too much");
|
||||
DUMP_STR(msg_user_slots_low, "User have too few upload slots.");
|
||||
DUMP_STR(msg_user_slots_high, "User have too many upload slots.");
|
||||
DUMP_STR(msg_user_hub_limit_low, "User is on too few hubs.");
|
||||
DUMP_STR(msg_user_hub_limit_high, "User is on too many hubs.");
|
||||
DUMP_STR(msg_user_flood_chat, "Chat flood detected, messages are dropped.");
|
||||
DUMP_STR(msg_user_flood_connect, "Connect flood detected, connection refused.");
|
||||
DUMP_STR(msg_user_flood_search, "Search flood detected, search is stopped.");
|
||||
DUMP_STR(msg_user_flood_update, "Update flood detected.");
|
||||
DUMP_STR(msg_user_flood_extras, "Flood detected.");
|
||||
DUMP_STR(msg_proto_no_common_hash, "No common hash algorithm.");
|
||||
DUMP_STR(msg_proto_obsolete_adc0, "Client is using an obsolete ADC protocol version.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user