static ret_t test_configuration_file (void) { ret_t ret; ret = cherokee_server_read_config_file (srv, config_file); PRINT_MSG ("Test on %s: %s\n", config_file, (ret == ret_ok)? "OK": "Failed"); return ret; }
static ret_t test_configuration_file (void) { ret_t ret; const char *config; config = (config_file) ? config_file : DEFAULT_CONFIG_FILE; ret = cherokee_server_read_config_file (srv, config); PRINT_MSG ("Test on %s: %s\n", config, (ret == ret_ok)? "OK": "Failed"); return ret; }
static ret_t common_server_initialization (cherokee_server_t *srv) { ret_t ret; struct sigaction act; /* Signals it handles */ memset(&act, 0, sizeof(act)); /* SIGPIPE */ act.sa_handler = SIG_IGN; sigaction (SIGPIPE, &act, NULL); /* Signal Handler */ act.sa_sigaction = signals_handler; act.sa_flags = SA_SIGINFO; sigaction (SIGHUP, &act, NULL); sigaction (SIGUSR2, &act, NULL); sigaction (SIGSEGV, &act, NULL); sigaction (SIGTERM, &act, NULL); sigaction (SIGINT, &act, NULL); sigaction (SIGCHLD, &act, NULL); #ifdef SIGBUS sigaction (SIGBUS, &act, NULL); #endif if (document_root != NULL) { cherokee_buffer_t tmp = CHEROKEE_BUF_INIT; cherokee_buffer_t droot = CHEROKEE_BUF_INIT; /* Sanity check */ if (port > 0xFFFF) { PRINT_ERROR ("Port %d is out of limits\n", port); return ret_error; } /* Build the configuration string */ cherokee_buffer_add (&droot, document_root, strlen(document_root)); cherokee_path_arg_eval (&droot); cherokee_buffer_add_va (&tmp, "server!bind!1!port = %d\n" "vserver!1!document_root = %s\n" BASIC_CONFIG, port, droot.buf); /* Apply it */ ret = cherokee_server_read_config_string (srv, &tmp); cherokee_buffer_mrproper (&tmp); cherokee_buffer_mrproper (&droot); if (ret != ret_ok) { PRINT_MSG ("Couldn't start serving directory %s\n", document_root); return ret_error; } } else { const char *config; /* Check parameter inconsistencies */ if (port_set) { PRINT_MSG ("The -p parameter can only be used in conjunction with -r."); return ret_error; } /* Read the configuration file */ config = (config_file) ? config_file : DEFAULT_CONFIG_FILE; ret = cherokee_server_read_config_file (srv, config); if (ret != ret_ok) { PRINT_MSG ("Couldn't read the config file: %s\n", config); return ret_error; } } if (daemon_mode) cherokee_server_daemonize (srv); ret = cherokee_server_initialize (srv); if (ret != ret_ok) return ret_error; cherokee_server_unlock_threads (srv); return ret_ok; }