Logo Search packages:      
Sourcecode: rapple version File versions  Download package

static void config_end ( void *  data,
const char *  el 
) [static]

Handles end of element event. Passed to XML_SetElementHandler.

Parameters:
data 
el 

Definition at line 210 of file confp.c.

References config_copy_buf(), config_missing_file_error(), rpl_str_list_node::node, rpl_fs_file_exists(), rpl_list_prepend(), rpl_log_set_level(), rpl_me_free(), rpl_str_concat(), and rpl_str_list_create_node().

Referenced by rpl_cfg_parse().

                                       {
    int     log_int;
    rpl_str_list_node *lnp;
      rpl_str_t abs_dg_dir = NULL, log_dir = NULL, log_fp = NULL;

    /* capture value data */
    if(log_flag && (strcmp(el,"logfile") == 0))
      {
        config_copy_buf(&cfg_log_file);
            log_dir = strdup(cfg_log_file);
            if((log_fp = strrchr(log_dir, '/')) != NULL)
            {
                  *log_fp = '\0';
                  if(rpl_fs_file_exists(log_dir) < 0)
                        config_missing_file_error("log dir does not exist", log_dir);
                  *log_fp = '/'; /* ensures release of full chunk */
            }
            rpl_me_free(log_dir);
      }

    if(strcmp(el,"srcdir") == 0)
      {
        config_copy_buf(&cfg_srcdir);
            if(rpl_fs_file_exists(cfg_srcdir) < 0)
                  config_missing_file_error("srcdir does not exist", cfg_srcdir);
      }

    if(strcmp(el,"webdir") == 0)
      {
        config_copy_buf(&cfg_webdir);
            if(rpl_fs_file_exists(cfg_webdir) < 0)
                  config_missing_file_error("webdir does not exist", cfg_webdir);
      }

    if(log_flag && (strcmp(el,"loglevel") == 0)) {
        log_int = atoi((rpl_c_str_t)cfg_str_buf);
        /* if outside permissible range then pick a sensible default */
        if((log_int < 1) || (log_int > 5)) {
            cfg_RPL_LOG_LEVEL = "3";
        } else {
            config_copy_buf(&cfg_RPL_LOG_LEVEL);
        }
        rpl_log_set_level(atoi((rpl_c_str_t)cfg_RPL_LOG_LEVEL));
    }

    if(ds_flag && (strcmp(el,"basedir") == 0))
      {
        config_copy_buf(&cfg_ds_basedir);
            if(rpl_fs_file_exists(cfg_ds_basedir) < 0)
                  config_missing_file_error("datastore does not exist", cfg_ds_basedir);
      }

    if(tidy_flag && (strcmp(el,"config") == 0))
        config_copy_buf(&cfg_tidy_conf);

    if(tpl_flag && (strcmp(el,"domain") == 0))
        config_copy_buf(&cfg_trf_tpl_domain);

    if(tpl_flag && (strcmp(el,"tplXSLT") == 0))
      {
        config_copy_buf(&cfg_trf_tpl_xslt);
            if(rpl_fs_file_exists(cfg_trf_tpl_xslt) < 0)
                  config_missing_file_error("XSLT does not exist", cfg_trf_tpl_xslt);
      }

    if(tpl_flag && (strcmp(el,"catalog") == 0))
        config_copy_buf(&cfg_trf_catalog);

      if(lc_flag && (strcmp(el, "xslt") == 0))
            config_copy_buf(&cfg_linkchecker_xslt);
      if(lc_flag && (strcmp(el, "htmlReport") == 0))
            config_copy_buf(&cfg_linkchecker_html_report);
      if(lc_flag && (strcmp(el, "xmlReport") == 0))
            config_copy_buf(&cfg_linkchecker_xml_report);

    if(dg_flag && (strcmp(el, "dir") == 0)) {
            abs_dg_dir = rpl_str_concat(cfg_srcdir, "/", cfg_dg_dir, RPL_STR_EOC);
            if(rpl_fs_file_exists(abs_dg_dir) < 0)
                  config_missing_file_error("digest dir does not exist", abs_dg_dir);
            rpl_me_free(abs_dg_dir);
        config_copy_buf(&cfg_dg_dir);
        lnp = rpl_str_list_create_node(cfg_dg_dir);
        rpl_list_prepend(&cfg_dg_dir_names, &lnp->node, lnp);
    }

    if(db_flag && (strcmp(el,"dbname") == 0))
      {
            if(cfg_str_buf == NULL) 
                  cfg_str_buf =  RPL_DB_NAME;
        config_copy_buf(&cfg_db_name);
      }
    if(db_flag && (strcmp(el,"host") == 0))
      {
            if(cfg_str_buf == NULL) 
                  cfg_str_buf =  RPL_DB_HOST;
        config_copy_buf(&cfg_db_host);
      }
    if(db_flag && (strcmp(el,"port") == 0))
      {
            if(cfg_str_buf == NULL) 
                  cfg_str_buf =  RPL_DB_PORT;
        config_copy_buf(&cfg_db_port);
      }
    if(db_flag && (strcmp(el,"username") == 0))
      {
            if(cfg_str_buf == NULL) 
                  cfg_str_buf =  RPL_DB_USER;
        config_copy_buf(&cfg_db_user);
      }
    if(db_flag && (strcmp(el,"password") == 0))
      {
            if(cfg_str_buf == NULL) 
                  cfg_str_buf =  RPL_DB_PWD;
        config_copy_buf(&cfg_db_pwd);
      }

    /* remove container flag out of scope */
    if(strcmp(el, "logger") == 0)
        log_flag = 0;
    if(strcmp(el, "datastore") == 0)
        ds_flag = 0;
    if(strcmp(el, "tidy") == 0)
        tidy_flag = 0;
    if(strcmp(el, "template") == 0)
        tpl_flag = 0;
      if(strcmp(el, "linkchecker") == 0)
            lc_flag = 0;
    if((strcmp(el, "digest") == 0))
        dg_flag = 0;
    if((strcmp(el, "database") == 0))
        db_flag = 0;
}


Generated by  Doxygen 1.6.0   Back to index