[Tilde-devel] new config api
Brought to you by:
tobi
From: Tobias <to...@to...> - 2002-08-14 10:02:56
|
This is my tought. tilde_config_data will stay the same. it will be seperated with the "root" nodes of the config file. struct tilde_config_data { tilde_hash *hosts; tilde_hash *dbmsconfig; tilde_hash *serverconfig; tilde_hash *mimeconfig; tilde_hash *collection; void *portsconfig; }; the new thing will come now :) when you lookup a value from one of those hashes you will be returned a tilde_config_value struct instead of a datapointer, and it will only be the first level nodes, not all levels at the same time, no more "docroot.paths" instead you have to lookup docroot first then extract paths from the config_value. the config_value struct definition looks like this: struct tilde_config_value { /* either TILDE_CONFIG_VALUE_PLAIN or TILDE_CONFIG_VALUE_LIST */ int type; /* all properties associated to this site. */ tilde_hash *properties; /* if type equals to TILDE_CONFIG_VALUE_LIST this value is set * to a sorted list with values */ tilde_config_value *child; /* this values are set if it is a plain value */ char *directive; tilde_binary *data; /* list pointers */ tilde_config_value *next; }; abstraction functions for this struct are: tilde_config_value *tilde_config_value_create (tilde_mem_zone *zone, int type, char *directive); void tilde_config_value_data_set (tilde_mem_zone *zone, tilde_config_value *value, tilde_binary *data); void tilde_config_value_list_add (tilde_mem_zone *zone, tilde_config_value *value, tilde_config_value *add); char *tilde_config_value_getprop (tilde_config_value *value, char *propname); void tilde_config_value_prop_add (tilde_config_value *value, char *propname, char *data); int tilde_config_value_type (tilde_config_value *value); int tilde_config_value_as_int (tilde_config_value *value); char *tilde_config_value_as_string (tilde_config_value *value); so a example for extracting paths.docroot from the localhost entry could be: tilde_config_data *data; tilde_config_value *value; tilde_hash *hash; char *foo; data = tilde_config_init(zone,"tilde.conf.xml"); hash = tilde_config_hostconfig_get(data,"localhost"); value = (tilde_config_value*) tilde_hash_lookup(hash,"paths"); value = tilde_config_value_list_lookup(value,"docroot"); foo = tilde_config_value_as_string(value); when looking at this I think maybe we want to keep tilde_config_data_get() and let it do all this? What do you think? |