Go to the source code of this file.
Data Structures | |
| struct | ast_comment |
| struct | ast_variable |
Functions | |
| ast_config * | ast_load (char *configfile) |
| Load a config file. More... | |
| void | ast_destroy (struct ast_config *config) |
| Removes a config. More... | |
| char * | ast_category_browse (struct ast_config *config, char *prev) |
| Goes through categories. More... | |
| ast_variable * | ast_variable_browse (struct ast_config *config, char *category) |
| Goes through variables. More... | |
| char * | ast_variable_retrieve (struct ast_config *config, char *category, char *value) |
| Gets a variable. More... | |
| int | ast_true (char *val) |
| Make sure something is true. More... | |
| int | ast_false (char *val) |
| Make sure something is false. More... | |
| int | ast_category_exist (struct ast_config *config, char *category_name) |
| Check for category duplicates. More... | |
| ast_variable * | ast_variable_append_modify (struct ast_config *cfg, char *category, char *variable, char *newvalue, int newcat, int newvar, int move) |
| int | ast_category_delete (struct ast_config *cfg, char *category) |
| int | ast_variable_delete (struct ast_config *cfg, char *category, char *variable, char *value) |
| int | ast_save (char *filename, struct ast_config *cfg, char *generator) |
|
||||||||||||
|
Goes through categories.
Definition at line 936 of file config.c. References ast_category::name, ast_category::next, and ast_config::root.
00937 {
00938 struct ast_category *cat;
00939 if (!prev) {
00940 if (config->root)
00941 return config->root->name;
00942 else
00943 return NULL;
00944 }
00945 cat = config->root;
00946 while(cat) {
00947 if (cat->name == prev) {
00948 if (cat->next)
00949 return cat->next->name;
00950 else
00951 return NULL;
00952 }
00953 cat = cat->next;
00954 }
00955 cat = config->root;
00956 while(cat) {
00957 if (!strcasecmp(cat->name, prev)) {
00958 if (cat->next)
00959 return cat->next->name;
00960 else
00961 return NULL;
00962 }
00963 cat = cat->next;
00964 }
00965 return NULL;
00966 }
|
|
||||||||||||
|
|
|
||||||||||||
|
Check for category duplicates.
Definition at line 399 of file config.c. References ast_category::name, ast_category::next, and ast_config::root.
00400 {
00401 struct ast_category *category = NULL;
00402
00403 category = config->root;
00404
00405 while(category) {
00406 if (!strcasecmp(category->name,category_name))
00407 return 1;
00408 category = category->next;
00409 }
00410
00411 return 0;
00412 }
|
|
|
Removes a config.
Definition at line 67 of file config.c. References free, ast_variable::name, ast_category::next, ast_variable::next, ast_variable::precomments, ast_category::root, ast_config::root, ast_variable::sameline, and ast_variable::value. Referenced by ast_enum_init(), ast_load_resource(), ast_rtp_reload(), init_manager(), load_modules(), and read_ast_cust_config().
00068 {
00069 struct ast_category *cat, *catn;
00070 struct ast_variable *v, *vn;
00071
00072 if (!ast)
00073 return;
00074
00075 cat = ast->root;
00076 while(cat) {
00077 v = cat->root;
00078 while(v) {
00079 vn = v;
00080 free(v->name);
00081 free(v->value);
00082 #ifdef PRESERVE_COMMENTS
00083 free_comments(v->precomments);
00084 free_comments(v->sameline);
00085 #endif
00086 v = v->next;
00087 free(vn);
00088 }
00089 catn = cat;
00090 #ifdef PRESERVE_COMMENTS
00091 free_comments(cat->precomments);
00092 free_comments(cat->sameline);
00093 #endif
00094 cat = cat->next;
00095 free(catn);
00096 }
00097 #ifdef PRESERVE_COMMENTS
00098 free_comments(ast->trailingcomments);
00099 #endif
00100 free(ast);
00101 }
|
|
|
Make sure something is false. Determine falseness of a boolean value. This function checks to see whether a string passed to it is an indication of a negatirve value. It checks to see if the string is "no", "false", "n", "f", and "0". Returns 0 if the value of s is a NULL pointer, 0 on "truth", and -1 on falsehood. Definition at line 118 of file config.c. References s.
00119 {
00120 if (!s)
00121 return 0;
00122 /* Determine if this is a false value */
00123 if (!strcasecmp(s, "no") ||
00124 !strcasecmp(s, "false") ||
00125 !strcasecmp(s, "n") ||
00126 !strcasecmp(s, "f") ||
00127 !strcasecmp(s, "0") ||
00128 !strcasecmp(s, "off"))
00129 return -1;
00130 return 0;
00131 }
|
|
|
Load a config file.
Definition at line 918 of file config.c. Referenced by ast_enum_init(), ast_load_resource(), ast_rtp_reload(), init_manager(), load_modules(), and read_ast_cust_config().
00919 {
00920 struct ast_category *tmpc=NULL;
00921 struct ast_variable *last = NULL;
00922
00923
00924 #ifdef PRESERVE_COMMENTS
00925 struct ast_comment_struct acs = { NULL, NULL };
00926 #endif
00927
00928
00929 return __ast_load(configfile, NULL, &tmpc, &last, 0
00930 #ifdef PRESERVE_COMMENTS
00931 ,&acs
00932 #endif
00933 );
00934 }
|
|
||||||||||||||||
|
|
|
|
Make sure something is true. Determine affermativeness of a boolean value. This function checks to see whether a string passed to it is an indication of an affirmitave value. It checks to see if the string is "yes", "true", "y", "t", and "1". Returns 0 if the value of s is a NULL pointer, 0 on "truth", and -1 on falsehood. Definition at line 103 of file config.c. References s. Referenced by ast_load_resource(), ast_rtp_reload(), init_manager(), and load_modules().
00104 {
00105 if (!s)
00106 return 0;
00107 /* Determine if this is a true value */
00108 if (!strcasecmp(s, "yes") ||
00109 !strcasecmp(s, "true") ||
00110 !strcasecmp(s, "y") ||
00111 !strcasecmp(s, "t") ||
00112 !strcasecmp(s, "1") ||
00113 !strcasecmp(s, "on"))
00114 return -1;
00115 return 0;
00116 }
|
|
||||||||||||||||||||||||||||||||
|
|
|
||||||||||||
|
Goes through variables. Somewhat similar in intent as the ast_category_browse. The category MUST be an actual pointer to an actual category (such as one obtained by using ast_category_browse()). List variables of config file Returns ast_variable list on success, or NULL on failure Definition at line 133 of file config.c. References ast_category::name, ast_category::next, and ast_category::root. Referenced by ast_enum_init(), ast_variable_retrieve(), load_modules(), and read_ast_cust_config().
00134 {
00135 struct ast_category *cat;
00136 cat = config->root;
00137 while(cat) {
00138 if (cat->name == category)
00139 return cat->root;
00140 cat = cat->next;
00141 }
00142 cat = config->root;
00143 while(cat) {
00144 if (!strcasecmp(cat->name, category))
00145 return cat->root;
00146 cat = cat->next;
00147 }
00148 return NULL;
00149 }
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||
|
Gets a variable.
Definition at line 151 of file config.c. References ast_variable_browse(), ast_variable::name, ast_category::next, ast_variable::next, ast_category::root, ast_config::root, and ast_variable::value. Referenced by ast_load_resource(), ast_rtp_reload(), init_manager(), and load_modules().
00152 {
00153 struct ast_variable *v;
00154 if (category) {
00155 v = ast_variable_browse(config, category);
00156 while (v) {
00157 if (value == v->name)
00158 return v->value;
00159 v=v->next;
00160 }
00161 v = ast_variable_browse(config, category);
00162 while (v) {
00163 if (!strcasecmp(value, v->name))
00164 return v->value;
00165 v=v->next;
00166 }
00167 } else {
00168 struct ast_category *cat;
00169 cat = config->root;
00170 while(cat) {
00171 v = cat->root;
00172 while (v) {
00173 if (!strcasecmp(value, v->name))
00174 return v->value;
00175 v=v->next;
00176 }
00177 cat = cat->next;
00178 }
00179 }
00180 return NULL;
00181 }
|
1.2.15