アットウィキロゴ

vsftpd_1.2.1_parseconf.c_vsf_parseconf_load_file

vsf_parseconf_load_file


source

parseconf.c

line

151 - 210

概要


void vsf_parseconf_load_file(const char* p_filename, int errs_fatal)

  • PURPOSE
* Parse the given file as a vsftpd config file. If the file cannot be
* opened for whatever reason, a fatal error is raised. If the file contains
* any syntax errors, a fatal error is raised.
* If the call returns (no fatal error raised), then the config file was
* parsed and the global config settings will have been updated.
vsftpdコンフィグファイルとして与えられたファイルを分析してください。 いかなる理由でもファイルを開くことができないなら、致命的な誤りは高くしています。 
ファイルが何か構文エラーを含んでいるなら、致命的な誤りは高くしています。
呼び出しが(上げられなかったどんな致命的な誤りも)を返すなら、コンフィグファイルを分析しました、そして、グローバルなコンフィグ設定をアップデートしてしまうでしょう。

  • PARAMETERS
* p_filename     - the name of the config file to parse
                   分析するコンフィグファイルの名前

* errs_fatal     - errors will cause the calling process to exit if not 0
                   誤りは出る呼び出しプロセスか0を引き起こすでしょう。

  • NOTES
* If p_filename is NULL, then the last filename passed to this function is
* used to reload the configuration details.
p_ファイル名がNULLであるなら、この機能に通過された最後のファイル名は、構成の詳細を再び積むのに使用されます。

処理の流れ


    1. コンフィグファイルが存在するか確認

  • 存在しない場合
p_filename = s_p_saved_filename;
   162   }
   163   else
   164   {
   165     if (s_p_saved_filename)
   166     {
   167       vsf_sysutil_free((char*)s_p_saved_filename);
   168     }
   169     s_p_saved_filename = vsf_sysutil_strdup(p_filename);
   170   }
   171   if (!p_filename)
   172   {
   173     bug("null filename in vsf_parseconf_load_file");
   174   }
   175   if (!s_strings_copied)
   176   {
   177     s_strings_copied = 1;
   178     /* A minor hack to make sure all strings are malloc()'ed so we can free
   179      * them at some later date. Specifically handles strings embedded in the
   180      * binary.
   181      */
   182     copy_string_settings();
   183   }

    1. コンフィグファイルの読み込み

   184   retval = str_fileread(&config_file_str, p_filename, VSFTP_CONF_FILE_MAX);
   185   if (vsf_sysutil_retval_is_error(retval))
   186   {
   187     if (errs_fatal)
   188     {
   189       die2("cannot open config file:", p_filename);
   190     }
   191     else
   192     {
   193       return;
   194     }
   195   }
   196   while (str_getline(&config_file_str, &config_setting_str, &str_pos))
   197   {
   198     if (str_isempty(&config_setting_str) ||
   199         str_get_char_at(&config_setting_str, 0) == '#')
   200     {
   201       continue;
   202     }
   203     /* Split into name=value pair */
   204     str_split_char(&config_setting_str, &config_value_str, '=');
   205     handle_config_setting(&config_setting_str, &config_value_str, errs_fatal);
   206   }
   207   str_free(&config_file_str);
   208   str_free(&config_setting_str);
   209   str_free(&config_value_str);
   210 }


./defs.h:#define VSFTP_CONF_FILE_MAX 100000

function


   151 void
   152 vsf_parseconf_load_file(const char* p_filename, int errs_fatal)
   153 {
   154   struct mystr config_file_str = INIT_MYSTR;
   155   struct mystr config_setting_str = INIT_MYSTR;
   156   struct mystr config_value_str = INIT_MYSTR;
   157   unsigned int str_pos = 0;
   158   int retval;
   159   if (!p_filename)
   160   {
   161     p_filename = s_p_saved_filename;
   162   }
   163   else
   164   {
   165     if (s_p_saved_filename)
   166     {
   167       vsf_sysutil_free((char*)s_p_saved_filename);
   168     }
   169     s_p_saved_filename = vsf_sysutil_strdup(p_filename);
   170   }
   171   if (!p_filename)
   172   {
   173     bug("null filename in vsf_parseconf_load_file");
   174   }
   175   if (!s_strings_copied)
   176   {
   177     s_strings_copied = 1;
   178     /* A minor hack to make sure all strings are malloc()'ed so we can free
   179      * them at some later date. Specifically handles strings embedded in the
   180      * binary.
   181      */
   182     copy_string_settings();
   183   }
   184   retval = str_fileread(&config_file_str, p_filename, VSFTP_CONF_FILE_MAX);
   185   if (vsf_sysutil_retval_is_error(retval))
   186   {
   187     if (errs_fatal)
   188     {
   189       die2("cannot open config file:", p_filename);
   190     }
   191     else
   192     {
   193       return;
   194     }
   195   }
   196   while (str_getline(&config_file_str, &config_setting_str, &str_pos))
   197   {
   198     if (str_isempty(&config_setting_str) ||
   199         str_get_char_at(&config_setting_str, 0) == '#')
   200     {
   201       continue;
   202     }
   203     /* Split into name=value pair */
   204     str_split_char(&config_setting_str, &config_value_str, '=');
   205     handle_config_setting(&config_setting_str, &config_value_str, errs_fatal);
   206   }
   207   str_free(&config_file_str);
   208   str_free(&config_setting_str);
   209   str_free(&config_value_str);
   210 }
最終更新:2009年02月09日 21:07
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。