/******************************************************************************
 * public メソッド
 *****************************************************************************/
UploaderConfig *CGIConfigReader::read(apr_pool_t *pool,
                                           const char *conf_file_path)
{
    UploaderConfig *config;

    APR_PCALLOC(config, UploaderConfig *, pool, sizeof(UploaderConfig));
    new(config) UploaderConfig(pool);

    std::auto_ptr<ConfigReader::config_map>
        cmap(ConfigReader::read(pool, conf_file_path));
    for (ConfigReader::config_map::const_iterator i = cmap.get()->begin();
         i != cmap.get()->end(); i++) {
        SET_STR_PARAM(BASE_URL,             base_url);
        SET_STR_PARAM(DATA_DIRECTORY,       data_dir_path);
        SET_STR_PARAM(FILE_DIRECTORY,       file_dir_path);
        SET_STR_PARAM(THUMB_DIRECTORY,      thumb_dir_path);
        SET_STR_PARAM(TEMP_DIRECTORY,       temp_dir_path);
        SET_INT64_PARAM(TOTAL_FILE_SIZE,    total_file_size_limit);
        SET_INT_PARAM(TOTAL_FILE_NUMBER,    total_file_number_limit);
        SET_INT64_PARAM(FILE_SIZE_LIMIT,    file_size_limit);
        SET_INT_PARAM(PER_PAGE_ITEM_NUMBER, per_page_item_number);

        SET_TMPL_PARAM(INDEX_VIEW_TEMPLATE,     INDEX_VIEW);
        SET_TMPL_PARAM(PROGRESS_VIEW_TEMPLATE,  PROGRESS_VIEW);
        SET_TMPL_PARAM(DOWNLOAD_VIEW_TEMPLATE,  DOWNLOAD_VIEW);
        SET_TMPL_PARAM(THUMBNAIL_VIEW_TEMPLATE, THUMBNAIL_VIEW);
        SET_TMPL_PARAM(ADMIN_VIEW_TEMPLATE,     ADMIN_VIEW);
        SET_TMPL_PARAM(ERROR_VIEW_TEMPLATE,     ERROR_VIEW);
    }

    config->init();

    return config;
}
Exemple #2
0
static int uploader_post_config_server(apr_pool_t *p, server_rec *s)
{
    UploaderConfig **configs;
    UploaderConfig *config;

    configs = (UploaderConfig **)AVOID_ALIGN_WARN uploader_config_array->elts;

    for (int i = 0; i < uploader_config_array->nelts; i++) {
        config = configs[i];

        try {
            config->init();
            config->is_debug_mode = get_apache_debug_mode();

            apr_pool_cleanup_register(p, config, uploader_finalize_dir_config,
                                      apr_pool_cleanup_null);
        } catch(const char *message) {
            logger.error(__FILE__, __LINE__, s,
                         "(%s) %s: %s", "UploaderConfig::init", message,
                         get_last_error_message(p));

            return HTTP_INTERNAL_SERVER_ERROR;
        }
    }

    return OK;
}