ret_t cherokee_handler_custom_error_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props) { ret_t ret; int val; cherokee_list_t *i; cherokee_config_node_t *subconf; cherokee_handler_custom_error_props_t *props; UNUSED(srv); if (*_props == NULL) { CHEROKEE_NEW_STRUCT (n, handler_custom_error_props); cherokee_handler_props_init_base (HANDLER_PROPS(n), MODULE_PROPS_FREE(props_free)); n->error_code = http_unset; *_props = MODULE_PROPS(n); } props = PROP_CUSTOM_ERROR(*_props); cherokee_config_node_foreach (i, conf) { subconf = CONFIG_NODE(i); if (equal_buf_str (&subconf->key, "error")) { ret = cherokee_atoi (subconf->val.buf, &val); if (ret != ret_ok) return ret; props->error_code = val; } }
ret_t cherokee_handler_streaming_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props) { ret_t ret; cherokee_list_t *i; cherokee_handler_streaming_props_t *props; if (*_props == NULL) { CHEROKEE_NEW_STRUCT (n, handler_streaming_props); cherokee_handler_props_init_base (HANDLER_PROPS(n), MODULE_PROPS_FREE(cherokee_handler_streaming_props_free)); n->props_file = NULL; n->auto_rate = true; n->auto_rate_factor = 0.1; n->auto_rate_boost = 5; *_props = MODULE_PROPS(n); } props = PROP_STREAMING(*_props); /* Parse 'streaming' parameters */ cherokee_config_node_foreach (i, conf) { cherokee_config_node_t *subconf = CONFIG_NODE(i); if (equal_buf_str (&subconf->key, "rate")) { ret = cherokee_atob (subconf->val.buf, &props->auto_rate); if (ret != ret_ok) return ret_error; } else if (equal_buf_str (&subconf->key, "rate_factor")) { props->auto_rate_factor = strtof (subconf->val.buf, NULL); } else if (equal_buf_str (&subconf->key, "rate_boost")) { ret = cherokee_atoi (subconf->val.buf, &props->auto_rate_boost); if (ret != ret_ok) return ret_error; } }
ret_t cherokee_validator_ldap_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props) { ret_t ret; cherokee_list_t *i; cherokee_validator_ldap_props_t *props; UNUSED(srv); if (*_props == NULL) { CHEROKEE_NEW_STRUCT (n, validator_ldap_props); cherokee_validator_props_init_base (VALIDATOR_PROPS(n), MODULE_PROPS_FREE(props_free)); n->port = LDAP_DEFAULT_PORT; n->tls = false; cherokee_buffer_init (&n->server); cherokee_buffer_init (&n->binddn); cherokee_buffer_init (&n->bindpw); cherokee_buffer_init (&n->basedn); cherokee_buffer_init (&n->filter); cherokee_buffer_init (&n->ca_file); *_props = MODULE_PROPS(n); } props = PROP_LDAP(*_props); cherokee_config_node_foreach (i, conf) { cherokee_config_node_t *subconf = CONFIG_NODE(i); if (equal_buf_str (&subconf->key, "server")) { cherokee_buffer_add_buffer (&props->server, &subconf->val); } else if (equal_buf_str (&subconf->key, "port")) { ret = cherokee_atoi (subconf->val.buf, &props->port); if (ret != ret_ok) return ret_error; } else if (equal_buf_str (&subconf->key, "bind_dn")) { cherokee_buffer_add_buffer (&props->binddn, &subconf->val); } else if (equal_buf_str (&subconf->key, "bind_pw")) { cherokee_buffer_add_buffer (&props->bindpw, &subconf->val); } else if (equal_buf_str (&subconf->key, "base_dn")) { cherokee_buffer_add_buffer (&props->basedn, &subconf->val); } else if (equal_buf_str (&subconf->key, "filter")) { cherokee_buffer_add_buffer (&props->filter, &subconf->val); } else if (equal_buf_str (&subconf->key, "tls")) { ret = cherokee_atob (subconf->val.buf, &props->tls); if (ret != ret_ok) return ret_error; } else if (equal_buf_str (&subconf->key, "ca_file")) { cherokee_buffer_add_buffer (&props->ca_file, &subconf->val); } else if (equal_buf_str (&subconf->key, "methods") || equal_buf_str (&subconf->key, "realm") || equal_buf_str (&subconf->key, "users")) { /* Handled in validator.c */ } else { LOG_WARNING (CHEROKEE_ERROR_VALIDATOR_LDAP_KEY, subconf->key.buf); } }
ret_t cherokee_logger_writer_configure (cherokee_logger_writer_t *writer, cherokee_config_node_t *config) { ret_t ret; cherokee_buffer_t *tmp = NULL; /* Check the type */ ret = config_read_type (config, &writer->type); if (ret != ret_ok) { return ret; } /* Extra properties */ switch (writer->type) { case cherokee_logger_writer_file: ret = cherokee_config_node_read (config, "filename", &tmp); if (ret != ret_ok) { LOG_ERROR (CHEROKEE_ERROR_LOGGER_WRITER_READ, "file"); return ret_error; } cherokee_buffer_add_buffer (&writer->filename, tmp); break; case cherokee_logger_writer_pipe: ret = cherokee_config_node_read (config, "command", &tmp); if (ret != ret_ok) { LOG_ERROR (CHEROKEE_ERROR_LOGGER_WRITER_READ, "exec"); return ret_error; } cherokee_buffer_add_buffer (&writer->command, tmp); break; default: break; } /* Reside the internal buffer if needed */ ret = cherokee_config_node_read (config, "bufsize", &tmp); if (ret == ret_ok) { int buf_len; ret = cherokee_atoi (tmp->buf, &buf_len); if (ret != ret_ok) { return ret_error; } if (buf_len < LOGGER_MIN_BUFSIZE) buf_len = LOGGER_MIN_BUFSIZE; else if (buf_len > LOGGER_MAX_BUFSIZE) buf_len = LOGGER_MAX_BUFSIZE; cherokee_buffer_mrproper (&writer->buffer); cherokee_buffer_init (&writer->buffer); ret = cherokee_buffer_ensure_size (&writer->buffer, buf_len); if (ret != ret_ok) { LOG_ERROR (CHEROKEE_ERROR_LOGGER_WRITER_ALLOC, writer->max_bufsize); return ret_nomem; } writer->max_bufsize = (size_t)buf_len; } return ret_ok; }
static void process_parameters (int argc, char **argv) { ret_t ret; int c; cherokee_boolean_t error = false; struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'V'}, {"debug", no_argument, NULL, 'x'}, {"unsecure", no_argument, NULL, 'u'}, {"internal-tcp", no_argument, NULL, 't'}, {"disable-iocache", no_argument, NULL, 'i'}, {"bind", optional_argument, NULL, 'b'}, {"appdir", required_argument, NULL, 'd'}, {"port", required_argument, NULL, 'p'}, {"target", required_argument, NULL, 'C'}, {"threads", required_argument, NULL, 'T'}, {NULL, 0, NULL, 0} }; while ((c = getopt_long(argc, argv, "hVxutib::d:p:C:T:", long_options, NULL)) != -1) { switch(c) { case 'b': free (bind_to); if (optarg) { bind_to = strdup(optarg); } else if (argv[optind] && argv[optind][0] != '-') { bind_to = strdup(argv[optind]); optind++; } else { bind_to = NULL; } break; case 'p': ret = cherokee_atoi (optarg, &port); if (ret != ret_ok) { error = true; } break; case 'T': ret = cherokee_atoi (optarg, &thread_num); if (ret != ret_ok) { error = true; } break; case 'd': free (document_root); document_root = strdup(optarg); break; case 'C': free (config_file); config_file = strdup(optarg); break; case 'x': debug = 1; iocache = 0; break; case 'u': unsecure = 1; break; case 'i': iocache = 0; break; case 't': scgi_port = 0; break; case 'V': printf (APP_NAME " " PACKAGE_VERSION "\n" APP_COPY_NOTICE); exit(0); case 'h': case '?': default: error = true; } if (error) { print_help(); exit (1); } } /* Check for trailing parameters */ for (c = optind; c < argc; c++) { if ((argv[c] != NULL) && (strlen(argv[c]) > 0)) { print_help(); exit (1); } } }