Jabberd14-1.6.0/jabberd/config.c/cmdline_replace

Last-modified: 2007-03-17 (土) 22:20:44

このページを編集する際は,編集に関する方針に従ってください.

概要

  • Jabberd14-1.6.0/jabberd/config.cにて定義
  • jabberd:cmdline/ タグの置き換え
    jabberdの引数として渡された要素で設定ファイルの内容を置き換える。
    * replace <jabberd:cmdline/> elements in the configuration file with strings given at the command line

引数

* @param x the parsed configuration file
* @param cmd_line a hash of given command line options

実装

再帰的にタグを検索して見付かったら処理する。みんな同じアルゴリズム。
ほとんど同じ処理なのにdo_includeとは雰囲気が違う。違うひとが書いたのかな?
4873113008にあるコードと似ている。

static void cmdline_replace(xmlnode x, xht cmd_line) {
    char *flag;
    char *replace_text;
    xmlnode cur=xmlnode_get_firstchild(x);
    for(;cur!=NULL;cur=xmlnode_get_nextsibling(cur))
    {
	 if(cur->type!=NTYPE_TAG)continue;
  • 処理しないタグ。再帰的に処理するタグがないかチェック
	 if(j_strcmp(xmlnode_get_localname(cur),"cmdline")!=0 ||
           j_strcmp(xmlnode_get_namespace(cur), NS_JABBERD_CONFIGFILE_REPLACE) != 0)
	 {
	     cmdline_replace(cur, cmd_line);
	     continue;
	 }
	 flag=xmlnode_get_attrib_ns(cur,"flag", NULL);
	 replace_text=xhash_get(cmd_line,flag);
	 if(replace_text==NULL) replace_text=xmlnode_get_data(cur);
	 xmlnode_hide(xmlnode_get_firstchild(x));
	 xmlnode_insert_cdata(x,replace_text,-1);
	 break;
    }
}

呼出元

#related: relatedプラグインは廃止されました。