int main(int argc, const char * const *argv) { apr_pool_t *pool; UploaderConfig *config; int status; apr_app_initialize(&argc, &argv, NULL); apr_pool_create(&pool, NULL); config = NULL; status = 0; try { config = UploaderConfigReader::read(pool, CONF_FILE_NAME); config->child_init(); // ベンチマーク用 bench_count = atoi(getenv("UPLOADER_BENCH")); if (bench_count == 0) { bench_count++; } STRACE_MARKER(); for (apr_size_t i = 0; i < bench_count; i++) { TemporaryPool temp_pool(pool); CGIResponse::Handle handle(temp_pool.get()); status = uploader_command_handler<CGIResponse> (&handle, config, arg); } STRACE_MARKER(); config->finalize(); apr_pool_destroy(pool); apr_terminate(); return status; } catch(const char *message) { std::cout << "Fatal Error: " << message << std::endl; if (config != NULL) { config->finalize(); } apr_pool_destroy(pool); apr_terminate(); return EXIT_FAILURE; } }
static apr_status_t uploader_finalize_dir_config(void *data) { UploaderConfig *config; config = AS_UCONFIG(data); config->finalize(); return APR_SUCCESS; }
int main(int argc, const char * const *argv) { apr_pool_t *pool; const char *arg; UploaderConfig *config; int status; apr_size_t bench_count; apr_app_initialize(&argc, &argv, NULL); apr_pool_create(&pool, NULL); config = NULL; status = 0; try { arg = getenv("PATH_INFO"); if (arg == NULL) { std::cout << "Location: http://"; std::cout << CGIResponse::get_env(pool, "SERVER_NAME"); if ((strcmp(CGIResponse::get_env(pool, "SERVER_PORT"), "80") != 0)) { std::cout << ":" << CGIResponse::get_env(pool, "SERVER_PORT"); } std::cout << CGIResponse::get_env(pool, "SCRIPT_NAME") << "/\r\n\r\n"; return EXIT_SUCCESS; } config = CGIConfigReader::read(pool, CONF_FILE_NAME); config->child_init(); // ベンチマーク用 bench_count = atoi(getenv("UPLOADER_BENCH")); if (bench_count == 0) { bench_count++; } STRACE_MARKER(); for (apr_size_t i = 0; i < bench_count; i++) { TemporaryPool temp_pool(pool); CGIResponse::Handle handle(temp_pool.get()); status = uploader_command_handler<CGIResponse> (&handle, config, arg); } STRACE_MARKER(); config->finalize(); apr_pool_destroy(pool); apr_terminate(); return status; } catch(const char *message) { // できれば Internal Server Error にしたいけど,問い合わせが多 // くなりそうなので... std::cout << "Content-type: text/html; charset=UTF-8\r\n\r\n"; std::cout << "Fatal Error: " << message << std::endl; if (config != NULL) { config->finalize(); } apr_pool_destroy(pool); apr_terminate(); return EXIT_FAILURE; } }