Config.c (2009B)
1 #include <EGong/Util/Config.h> 2 #include <EGong/Util/Log.h> 3 #include <EGong/Util/Misc.h> 4 #include <stdlib.h> 5 6 struct EGong_config EGong_global_configuration; 7 8 struct EGong_config_file_entry EGong_configuration_file_interface[EGONG_CONFIG_FILE_ENTRYCOUNT]={ 9 [EGONG_CONFIG_FILE_LOG_COLOR]={ 10 .type=EGONG_CONFIG_TYPE_BOOL, 11 .name="STDIO-Farben", 12 .data_offset=offsetof(struct EGong_config,log.color) 13 }, 14 [EGONG_CONFIG_FILE_LOG_LEVEL]={ 15 .type=EGONG_CONFIG_TYPE_UINT, 16 .name="Log-Level", 17 .data_offset=offsetof(struct EGong_config,log.level) 18 }, 19 [EGONG_CONFIG_FILE_LOG_DEST]={ 20 .type=EGONG_CONFIG_TYPE_BITMASK, 21 .name="Logdestinationsbitmaske", 22 .data_offset=offsetof(struct EGong_config,log.destinations) 23 }, 24 [EGONG_CONFIG_FILE_PACKET_COOKIE]={ 25 .type=EGONG_CONFIG_TYPE_STRING, 26 .name="Cookie", 27 .data_offset=offsetof(struct EGong_config,packet.cookie) 28 }, 29 [EGONG_CONFIG_FILE_PACKET_LEN]={ 30 .type=EGONG_CONFIG_TYPE_STRING, 31 .name="Packet-Maximallänge", 32 .data_offset=offsetof(struct EGong_config,log.level) 33 }, 34 [EGONG_CONFIG_FILE_SERVER_BINDIP]={ 35 .type=EGONG_CONFIG_TYPE_STRING, 36 .name="Bind-IP", 37 .data_offset=offsetof(struct EGong_config,server.bind_ip) 38 }, 39 [EGONG_CONFIG_FILE_SERVER_PORT]={ 40 .type=EGONG_CONFIG_TYPE_STRING, 41 .name="Port", 42 .data_offset=offsetof(struct EGong_config,server.port) 43 } 44 }; 45 void EGong_config_set_defaults(struct EGong_config *conf){ 46 conf->log.color=0; 47 conf->log.level=LOG_LEVEL_DEBUG; 48 conf->log.destinations=LOG_DEST_STDIO; 49 50 conf->server.port=4242; 51 STRING_EX_STATIC(conf->server.bind_ip, "0.0.0.0"); 52 53 conf->packet.packet_maxlen=1000; 54 STRING_EX_STATIC(conf->packet.cookie, "Derpaherp"); 55 56 conf->gui.destinations=EGONG_CONFIG_GUI_DEST_NOTIFY; 57 } 58 59 int EGong_config_write(struct EGong_config *conf, int file){ 60 unsigned int i; 61 for(i=0;i<CSIZEOF(EGong_configuration_file_interface); i++){ 62 63 } 64 return 0; 65 } 66 67 void EGong_config_init(struct EGong_config *conf){ 68 if(conf==NULL) 69 conf=&EGong_global_configuration; 70 EGong_config_set_defaults(conf); 71 }