このページを編集する際は,編集に関する方針に従ってください.
概要
* parse the configuration file, do inclusions and command line replacements
引数
* @param file the file to parse (NULL to use the default) * @param cmd_line the command line arguments * @param is_restart 0 if it is the initial configuration processing, 1 if it is a restart * @return 1 on error, 0 on success
実装
int configurate(char *file, xht cmd_line, int is_restart) { char def[] = CONFIG_DIR"/jabber.xml"; char *realfile = (char *)def; char *import_spool = NULL; xmlnode incl; char *c;
/* if no file name is specified, fall back to the default file */ if(file != NULL) realfile = file;
/* read and parse file */ greymatter__ = xmlnode_file(realfile);
/* was the there a read/parse error? */ if(greymatter__ == NULL) { fprintf(stderr, "Configuration parsing using %s failed: %s\n",realfile,xmlnode_file_borked(realfile)); return 1; }
/* parse -i foo.xml,bar.xml */ if((realfile = xhash_get(cmd_line,"i")) != NULL) { while(realfile != NULL) { c = strchr(realfile,','); if(c != NULL) { *c = '\0'; c++; } if((incl = xmlnode_file(realfile)) == NULL) { fprintf(stderr, "Configuration parsing included file %s failed: %s\n",realfile,xmlnode_file_borked(realfile)); return 1; }else{ xmlnode_insert_tag_node(greymatter__,incl); xmlnode_free(incl); } realfile = c; } }
/* adding a spool importer if requested (-I command-line option) */ import_spool = xhash_get(cmd_line, "I"); if (import_spool != NULL) { xmlnode service = NULL; xmlnode importspool = NULL;
service = xmlnode_insert_tag_ns(greymatter__, "service", NULL, NS_JABBERD_CONFIGFILE); xmlnode_put_attrib_ns(service, "id", NULL, NULL, "spoolimporter.localhost"); importspool = xmlnode_insert_tag_ns(service, "importspool", NULL, NS_JABBERD_CONFIGFILE); xmlnode_insert_cdata(importspool, import_spool, -1); }
/* check greymatter for additional includes */ do_include(0,greymatter__); cmdline_replace(greymatter__, cmd_line);
/* if it is the initial configuration, we have to write the PID */ if (!is_restart) show_pid(greymatter__);
_set_configured_debug(greymatter__);
/* set locale mappings */ if (!is_restart) { xht namespaces = NULL; xmlnode_list_item locale = NULL;
namespaces = xhash_new(1); xhash_put(namespaces, "", NS_JABBERD_CONFIGFILE); locale = xmlnode_get_tags(greymatter__, "global/locales/locale", namespaces); xhash_free(namespaces); namespaces = NULL;
for (; locale != NULL; locale = locale->next) { messages_set_mapping(xmlnode_get_attrib_ns(locale->node, "lang", NULL), xmlnode_get_attrib_ns(locale->node, "locale", NULL)); } }
return 0; }
呼出元
#related: relatedプラグインは廃止されました。