LI_EXPORT int mod_staticfile_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("staticfile"); p->init = mod_staticfile_init; p->handle_start_backend = mod_staticfile_subrequest; p->handle_send_request_content = mod_staticfile_dev_null; p->set_defaults = mod_staticfile_set_defaults; p->cleanup = mod_staticfile_free; p->data = NULL; return 0; }
int mod_evasive_plugin_init(plugin * p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("evasive"); p->init = mod_evasive_init; p->set_defaults = mod_evasive_set_defaults; p->handle_uri_clean = mod_evasive_uri_handler; p->cleanup = mod_evasive_free; p->data = NULL; return 0; }
int mod_access_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("access"); p->init = mod_access_init; p->set_defaults = mod_access_set_defaults; p->handle_uri_clean = mod_access_uri_handler; p->handle_subrequest_start = mod_access_uri_handler; p->cleanup = mod_access_free; p->data = NULL; return 0; }
int mod_magnet_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("magnet"); p->init = mod_magnet_init; p->handle_uri_clean = mod_magnet_uri_handler; p->handle_physical = mod_magnet_physical; p->set_defaults = mod_magnet_set_defaults; p->cleanup = mod_magnet_free; p->data = NULL; return 0; }
int mod_rrdtool_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("rrd"); p->init = mod_rrd_init; p->cleanup = mod_rrd_free; p->set_defaults= mod_rrd_set_defaults; p->handle_trigger = mod_rrd_trigger; p->handle_request_done = mod_rrd_account; p->data = NULL; return 0; }
int mod_setenv_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("setenv"); p->init = mod_setenv_init; p->handle_uri_clean = mod_setenv_uri_handler; p->set_defaults = mod_setenv_set_defaults; p->cleanup = mod_setenv_free; p->connection_reset = mod_setenv_reset; p->data = NULL; return 0; }
int mod_cml_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("cache"); p->init = mod_cml_init; p->cleanup = mod_cml_free; p->set_defaults = mod_cml_set_defaults; p->handle_subrequest_start = mod_cml_is_handled; p->handle_physical = mod_cml_power_magnet; p->data = NULL; return 0; }
int aicloud_mod_aidisk_access_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("smbdav_access"); p->init = mod_aidisk_access_init; p->set_defaults = mod_aidisk_access_set_defaults; //p->handle_uri_clean = mod_aidisk_access_uri_handler; p->handle_physical = mod_aidisk_access_physical_handler; //p->handle_subrequest_start = mod_aidisk_access_uri_handler; p->cleanup = mod_aidisk_access_free; p->data = NULL; return 0; }
int mod_uploadprogress_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("uploadprogress"); p->init = mod_uploadprogress_init; p->handle_uri_clean = mod_uploadprogress_uri_handler; p->handle_request_done = mod_uploadprogress_request_done; p->handle_connection_close = mod_uploadprogress_request_done; p->set_defaults = mod_uploadprogress_set_defaults; p->cleanup = mod_uploadprogress_free; p->data = NULL; return 0; }
int mod_accesslog_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("accesslog"); p->init = mod_accesslog_init; p->set_defaults= log_access_open; p->cleanup = mod_accesslog_free; p->handle_request_done = log_access_write; p->handle_sighup = log_access_cycle; p->data = NULL; return 0; }
int mod_extforward_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("extforward"); p->init = mod_extforward_init; p->handle_uri_raw = mod_extforward_uri_handler; p->handle_request_done = mod_extforward_restore; p->connection_reset = mod_extforward_restore; p->set_defaults = mod_extforward_set_defaults; p->cleanup = mod_extforward_free; p->data = NULL; return 0; }
static int mod_authn_gssapi_create_krb5_ccache(server *srv, connection *con, plugin_data *p, krb5_context kcontext, krb5_principal princ, krb5_ccache *ccache) { buffer * const kccname = buffer_init_string("FILE:/tmp/krb5cc_gssapi_XXXXXX"); char * const ccname = kccname->ptr + sizeof("FILE:")-1; const size_t ccnamelen = buffer_string_length(kccname)-(sizeof("FILE:")-1); /*(future: might consider using server.upload-dirs instead of /tmp)*/ /* coverity[secure_temp : FALSE] */ int fd = mkstemp(ccname); if (fd < 0) { log_error_write(srv, __FILE__, __LINE__, "ss", "mkstemp():", strerror(errno)); buffer_free(kccname); return -1; } close(fd); do { krb5_error_code problem; problem = krb5_cc_resolve(kcontext, kccname->ptr, ccache); if (problem) { mod_authn_gssapi_log_krb5_error(srv, __FILE__, __LINE__, "krb5_cc_resolve", NULL, kcontext, problem); break; } problem = krb5_cc_initialize(kcontext, *ccache, princ); if (problem) { mod_authn_gssapi_log_krb5_error(srv, __FILE__, __LINE__, "krb5_cc_initialize", kccname->ptr, kcontext, problem); break; } con->plugin_ctx[p->id] = kccname; array_set_key_value(con->environment, CONST_STR_LEN("KRB5CCNAME"), ccname, ccnamelen); array_set_key_value(con->request.headers, CONST_STR_LEN("X-Forwarded-Keytab"), ccname, ccnamelen); return 0; } while (0); if (*ccache) { krb5_cc_destroy(kcontext, *ccache); *ccache = NULL; } unlink(ccname); buffer_free(kccname); return -1; }
int mod_cgi_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("cgi"); p->connection_reset = cgi_connection_close_callback; p->handle_subrequest_start = cgi_is_handled; p->handle_subrequest = mod_cgi_handle_subrequest; p->handle_trigger = cgi_trigger; p->init = mod_cgi_init; p->cleanup = mod_cgi_free; p->set_defaults = mod_fastcgi_set_defaults; p->data = NULL; return 0; }
int mod_bitsvhd_plugin_init(plugin *p) { bits_sessions_init(); p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("bitsvhd"); p->init = mod_bitsvhd_init; p->handle_physical = mod_bitsvhd_physicalpath_handler; p->set_defaults = mod_bitsvhd_set_defaults; p->cleanup = mod_bitsvhd_free; p->data = NULL; return 0; }
int mod_trigger_b4_dl_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("trigger_b4_dl"); p->init = mod_trigger_b4_dl_init; p->handle_uri_clean = mod_trigger_b4_dl_uri_handler; p->set_defaults = mod_trigger_b4_dl_set_defaults; #if defined(HAVE_GDBM_H) p->handle_trigger = mod_trigger_b4_dl_handle_trigger; #endif p->cleanup = mod_trigger_b4_dl_free; p->data = NULL; return 0; }
int mod_status_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("status"); p->init = mod_status_init; p->cleanup = mod_status_free; p->set_defaults= mod_status_set_defaults; p->handle_uri_clean = mod_status_handler; p->handle_trigger = mod_status_trigger; p->handle_request_done = mod_status_account; p->data = NULL; return 0; }
int mod_proxy_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("proxy"); p->init = mod_proxy_init; p->cleanup = mod_proxy_free; p->set_defaults = mod_proxy_set_defaults; p->connection_reset = mod_proxy_connection_close_callback; /* end of req-resp cycle */ p->handle_connection_close = mod_proxy_connection_close_callback; /* end of client connection */ p->handle_uri_clean = mod_proxy_check_extension; p->handle_subrequest = mod_proxy_handle_subrequest; p->handle_trigger = mod_proxy_trigger; p->data = NULL; return 0; }
int mod_rewrite_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("rewrite"); p->init = mod_rewrite_init; /* it has to stay _raw as we are matching on uri + querystring */ p->handle_uri_raw = mod_rewrite_uri_handler; p->set_defaults = mod_rewrite_set_defaults; p->cleanup = mod_rewrite_free; p->connection_reset = mod_rewrite_con_reset; p->data = NULL; return 0; }
LI_EXPORT int mod_proxy_backend_http_plugin_init(plugin *p) { data_string *ds; p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("mod_proxy_backend_http"); p->init = mod_proxy_backend_http_init; p->cleanup = mod_proxy_backend_http_free; p->data = NULL; ds = data_string_init(); buffer_copy_string_len(ds->value, CONST_STR_LEN(CORE_PLUGIN)); array_insert_unique(p->required_plugins, (data_unset *)ds); return 0; }
LI_EXPORT int mod_cgi_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("cgi"); p->connection_reset = cgi_connection_close_callback; p->handle_start_backend = mod_cgi_start_backend; p->handle_send_request_content = mod_cgi_send_request_content; p->handle_read_response_content = mod_cgi_read_response_content; p->handle_trigger = cgi_trigger; p->init = mod_cgi_init; p->cleanup = mod_cgi_free; p->set_defaults = mod_cgi_set_defaults; p->data = NULL; return 0; }
/* * 插件的对外借口。通过dlsym调用。 */ void anti_stealpic_plugin_init(plugin *p) { if(NULL == p) { return; } struct plugin_data *p_d = malloc(sizeof(*p_d)); if(NULL == p_d) { return; } p_d -> index = indexs; p -> name = buffer_init_string("anti steal pictures mod"); p -> version = SWIFTD_VERSION; return; }
LI_EXPORT int mod_magnet_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string(PLUGIN_NAME); p->init = mod_magnet_init; p->set_defaults = mod_magnet_set_defaults; p->cleanup = mod_magnet_free; p->handle_uri_clean = mod_magnet_uri_handler; /* match against the uri */ p->handle_physical = mod_magnet_physical; /* match against the filename */ p->handle_response_header = mod_magnet_handle_response_header; #if 0 p->handle_filter_response_content = mod_magnet_handle_filter_response_content; #endif p->data = NULL; return 0; }
static int config_parse(server *srv, config_t *context, tokenizer_t *t) { void *pParser; int token_id; buffer *token, *lasttoken; int ret; pParser = configparserAlloc( malloc ); lasttoken = buffer_init(); token = buffer_init(); while((1 == (ret = config_tokenizer(srv, t, &token_id, token))) && context->ok) { buffer_copy_string_buffer(lasttoken, token); configparser(pParser, token_id, token, context); token = buffer_init(); } buffer_free(token); if (ret != -1 && context->ok) { /* add an EOL at EOF, better than say sorry */ configparser(pParser, TK_EOL, buffer_init_string("(EOL)"), context); if (context->ok) { configparser(pParser, 0, NULL, context); } } configparserFree(pParser, free); if (ret == -1) { log_error_write(srv, __FILE__, __LINE__, "sb", "configfile parser failed:", lasttoken); } else if (context->ok == 0) { log_error_write(srv, __FILE__, __LINE__, "sbsdsdsb", "source:", t->source, "line:", t->line, "pos:", t->line_pos, "parser failed somehow near here:", lasttoken); ret = -1; } buffer_free(lasttoken); return ret == -1 ? -1 : 0; }
int add_password(const char *passwd) { password *pwd; for (pwd = g_pwd_head.next; pwd != NULL; pwd = pwd->next) { if (0 == strcmp(passwd, pwd->b->ptr)) { return 0; } } pwd = (password *) malloc(sizeof(*pwd)); if (pwd == NULL) { return -1; } pwd->b = buffer_init_string(passwd); pwd->next = NULL; g_pwd_tail->next = pwd; g_pwd_tail = pwd; return 0; }
/* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( yyParser *yypParser, /* The parser */ int yyruleno /* Number of the rule by which to reduce */ ){ int yygoto; /* The next state */ int yyact; /* The next action */ YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ configparserARG_FETCH; yymsp = &yypParser->yystack[yypParser->yyidx]; #ifndef NDEBUG if( yyTraceFILE && yyruleno>=0 && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){ fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, yyRuleName[yyruleno]); } #endif /* NDEBUG */ switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ case 0: /* No destructor defined for metalines */ break; case 1: /* No destructor defined for metalines */ /* No destructor defined for metaline */ break; case 2: break; case 3: /* No destructor defined for varline */ break; case 4: /* No destructor defined for global */ break; case 5: #line 115 "./configparser.y" { yymsp[-1].minor.yy78 = NULL; } #line 822 "configparser.c" yy_destructor(1,&yymsp[0].minor); break; case 6: /* No destructor defined for include */ break; case 7: /* No destructor defined for include_shell */ break; case 8: yy_destructor(1,&yymsp[0].minor); break; case 9: #line 144 "./configparser.y" { if (ctx->ok) { buffer_copy_string_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43); if (strncmp(yymsp[-2].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) { fprintf(stderr, "Setting env variable is not supported in conditional %d %s: %s\n", ctx->current->context_ndx, ctx->current->key->ptr, yymsp[-2].minor.yy43->ptr); ctx->ok = 0; } else if (NULL == array_get_element(ctx->current->value, yymsp[0].minor.yy41->key->ptr)) { array_insert_unique(ctx->current->value, yymsp[0].minor.yy41); yymsp[0].minor.yy41 = NULL; } else { fprintf(stderr, "Duplicate config variable in conditional %d %s: %s\n", ctx->current->context_ndx, ctx->current->key->ptr, yymsp[0].minor.yy41->key->ptr); ctx->ok = 0; yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); yymsp[0].minor.yy41 = NULL; } } buffer_free(yymsp[-2].minor.yy43); yymsp[-2].minor.yy43 = NULL; } #line 859 "configparser.c" yy_destructor(2,&yymsp[-1].minor); break; case 10: #line 168 "./configparser.y" { array *vars = ctx->current->value; data_unset *du; if (strncmp(yymsp[-2].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) { fprintf(stderr, "Appending env variable is not supported in conditional %d %s: %s\n", ctx->current->context_ndx, ctx->current->key->ptr, yymsp[-2].minor.yy43->ptr); ctx->ok = 0; } else if (NULL != (du = array_get_element(vars, yymsp[-2].minor.yy43->ptr))) { /* exists in current block */ du = configparser_merge_data(du, yymsp[0].minor.yy41); if (NULL == du) { ctx->ok = 0; } else { buffer_copy_string_buffer(du->key, yymsp[-2].minor.yy43); array_replace(vars, du); } yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); } else if (NULL != (du = configparser_get_variable(ctx, yymsp[-2].minor.yy43))) { du = configparser_merge_data(du, yymsp[0].minor.yy41); if (NULL == du) { ctx->ok = 0; du->free(du); } else { buffer_copy_string_buffer(du->key, yymsp[-2].minor.yy43); array_insert_unique(ctx->current->value, du); } yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); } else { buffer_copy_string_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43); array_insert_unique(ctx->current->value, yymsp[0].minor.yy41); } buffer_free(yymsp[-2].minor.yy43); yymsp[-2].minor.yy43 = NULL; yymsp[0].minor.yy41 = NULL; } #line 903 "configparser.c" yy_destructor(3,&yymsp[-1].minor); break; case 11: #line 208 "./configparser.y" { if (strchr(yymsp[0].minor.yy0->ptr, '.') == NULL) { yygotominor.yy43 = buffer_init_string("var."); buffer_append_string_buffer(yygotominor.yy43, yymsp[0].minor.yy0); buffer_free(yymsp[0].minor.yy0); yymsp[0].minor.yy0 = NULL; } else { yygotominor.yy43 = yymsp[0].minor.yy0; yymsp[0].minor.yy0 = NULL; } } #line 919 "configparser.c" break; case 12: #line 220 "./configparser.y" { yygotominor.yy41 = configparser_merge_data(yymsp[-2].minor.yy41, yymsp[0].minor.yy41); if (NULL == yygotominor.yy41) { ctx->ok = 0; } yymsp[-2].minor.yy41 = NULL; yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); yymsp[0].minor.yy41 = NULL; } #line 932 "configparser.c" yy_destructor(5,&yymsp[-1].minor); break; case 13: #line 230 "./configparser.y" { yygotominor.yy41 = yymsp[0].minor.yy41; yymsp[0].minor.yy41 = NULL; } #line 941 "configparser.c" break; case 14: #line 235 "./configparser.y" { yygotominor.yy41 = NULL; if (strncmp(yymsp[0].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) { char *env; if (NULL != (env = getenv(yymsp[0].minor.yy43->ptr + 4))) { data_string *ds; ds = data_string_init(); buffer_append_string(ds->value, env); yygotominor.yy41 = (data_unset *)ds; } else { fprintf(stderr, "Undefined env variable: %s\n", yymsp[0].minor.yy43->ptr + 4); ctx->ok = 0; } } else if (NULL == (yygotominor.yy41 = configparser_get_variable(ctx, yymsp[0].minor.yy43))) { fprintf(stderr, "Undefined config variable: %s\n", yymsp[0].minor.yy43->ptr); ctx->ok = 0; } if (!yygotominor.yy41) { /* make a dummy so it won't crash */ yygotominor.yy41 = (data_unset *)data_string_init(); } buffer_free(yymsp[0].minor.yy43); yymsp[0].minor.yy43 = NULL; } #line 971 "configparser.c" break; case 15: #line 262 "./configparser.y" { yygotominor.yy41 = (data_unset *)data_string_init(); buffer_copy_string_buffer(((data_string *)(yygotominor.yy41))->value, yymsp[0].minor.yy0); buffer_free(yymsp[0].minor.yy0); yymsp[0].minor.yy0 = NULL; } #line 981 "configparser.c" break; case 16: #line 269 "./configparser.y" { yygotominor.yy41 = (data_unset *)data_integer_init(); ((data_integer *)(yygotominor.yy41))->value = strtol(yymsp[0].minor.yy0->ptr, NULL, 10); buffer_free(yymsp[0].minor.yy0); yymsp[0].minor.yy0 = NULL; } #line 991 "configparser.c" break; case 17: #line 275 "./configparser.y" { yygotominor.yy41 = (data_unset *)data_array_init(); array_free(((data_array *)(yygotominor.yy41))->value); ((data_array *)(yygotominor.yy41))->value = yymsp[0].minor.yy40; yymsp[0].minor.yy40 = NULL; } #line 1001 "configparser.c" break; case 18: #line 281 "./configparser.y" { yygotominor.yy40 = array_init(); } #line 1008 "configparser.c" yy_destructor(8,&yymsp[-1].minor); yy_destructor(9,&yymsp[0].minor); break; case 19: #line 284 "./configparser.y" { yygotominor.yy40 = yymsp[-1].minor.yy40; yymsp[-1].minor.yy40 = NULL; } #line 1018 "configparser.c" yy_destructor(8,&yymsp[-2].minor); yy_destructor(9,&yymsp[0].minor); break; case 20: #line 289 "./configparser.y" { if (buffer_is_empty(yymsp[0].minor.yy41->key) || NULL == array_get_element(yymsp[-2].minor.yy40, yymsp[0].minor.yy41->key->ptr)) { array_insert_unique(yymsp[-2].minor.yy40, yymsp[0].minor.yy41); yymsp[0].minor.yy41 = NULL; } else { fprintf(stderr, "Duplicate array-key: %s\n", yymsp[0].minor.yy41->key->ptr); ctx->ok = 0; yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); yymsp[0].minor.yy41 = NULL; } yygotominor.yy40 = yymsp[-2].minor.yy40; yymsp[-2].minor.yy40 = NULL; } #line 1040 "configparser.c" yy_destructor(10,&yymsp[-1].minor); break; case 21: #line 306 "./configparser.y" { yygotominor.yy40 = yymsp[-1].minor.yy40; yymsp[-1].minor.yy40 = NULL; } #line 1049 "configparser.c" yy_destructor(10,&yymsp[0].minor); break; case 22: #line 311 "./configparser.y" { yygotominor.yy40 = array_init(); array_insert_unique(yygotominor.yy40, yymsp[0].minor.yy41); yymsp[0].minor.yy41 = NULL; } #line 1059 "configparser.c" break; case 23: #line 317 "./configparser.y" { yygotominor.yy41 = yymsp[0].minor.yy41; yymsp[0].minor.yy41 = NULL; } #line 1067 "configparser.c" break; case 24: #line 321 "./configparser.y" { buffer_copy_string_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43); buffer_free(yymsp[-2].minor.yy43); yymsp[-2].minor.yy43 = NULL; yygotominor.yy41 = yymsp[0].minor.yy41; yymsp[0].minor.yy41 = NULL; } #line 1079 "configparser.c" yy_destructor(11,&yymsp[-1].minor); break; case 25: yy_destructor(1,&yymsp[0].minor); break; case 26: break; case 27: #line 333 "./configparser.y" { data_config *dc; dc = (data_config *)array_get_element(ctx->srv->config_context, "global"); assert(dc); configparser_push(ctx, dc, 0); } #line 1095 "configparser.c" yy_destructor(12,&yymsp[0].minor); break; case 28: #line 340 "./configparser.y" { data_config *cur; cur = ctx->current; configparser_pop(ctx); assert(cur && ctx->current); yygotominor.yy78 = cur; } #line 1110 "configparser.c" /* No destructor defined for globalstart */ yy_destructor(13,&yymsp[-2].minor); /* No destructor defined for metalines */ yy_destructor(14,&yymsp[0].minor); break; case 29: #line 351 "./configparser.y" { assert(yymsp[-3].minor.yy78->context_ndx < yymsp[0].minor.yy78->context_ndx); yymsp[0].minor.yy78->prev = yymsp[-3].minor.yy78; yymsp[-3].minor.yy78->next = yymsp[0].minor.yy78; yygotominor.yy78 = yymsp[0].minor.yy78; yymsp[-3].minor.yy78 = NULL; yymsp[0].minor.yy78 = NULL; } #line 1126 "configparser.c" /* No destructor defined for eols */ yy_destructor(15,&yymsp[-1].minor); break; case 30: #line 360 "./configparser.y" { yygotominor.yy78 = yymsp[0].minor.yy78; yymsp[0].minor.yy78 = NULL; } #line 1136 "configparser.c" break; case 31: #line 365 "./configparser.y" { data_config *cur; cur = ctx->current; configparser_pop(ctx); assert(cur && ctx->current); yygotominor.yy78 = cur; } #line 1150 "configparser.c" /* No destructor defined for context */ yy_destructor(13,&yymsp[-2].minor); /* No destructor defined for metalines */ yy_destructor(14,&yymsp[0].minor); break; case 32: #line 376 "./configparser.y" { data_config *dc; buffer *b, *rvalue, *op; if (ctx->ok && yymsp[0].minor.yy41->type != TYPE_STRING) { fprintf(stderr, "rvalue must be string"); ctx->ok = 0; } switch(yymsp[-1].minor.yy27) { case CONFIG_COND_NE: op = buffer_init_string("!="); break; case CONFIG_COND_EQ: op = buffer_init_string("=="); break; case CONFIG_COND_NOMATCH: op = buffer_init_string("!~"); break; case CONFIG_COND_MATCH: op = buffer_init_string("=~"); break; default: assert(0); return; } b = buffer_init(); buffer_copy_string_buffer(b, ctx->current->key); buffer_append_string(b, "/"); buffer_append_string_buffer(b, yymsp[-5].minor.yy0); buffer_append_string_buffer(b, yymsp[-3].minor.yy43); buffer_append_string_buffer(b, op); rvalue = ((data_string*)yymsp[0].minor.yy41)->value; buffer_append_string_buffer(b, rvalue); if (NULL != (dc = (data_config *)array_get_element(ctx->all_configs, b->ptr))) { configparser_push(ctx, dc, 0); } else { struct { comp_key_t comp; char *comp_key; size_t len; } comps[] = { { COMP_SERVER_SOCKET, CONST_STR_LEN("SERVER[\"socket\"]" ) }, { COMP_HTTP_URL, CONST_STR_LEN("HTTP[\"url\"]" ) }, { COMP_HTTP_HOST, CONST_STR_LEN("HTTP[\"host\"]" ) }, { COMP_HTTP_REFERER, CONST_STR_LEN("HTTP[\"referer\"]" ) }, { COMP_HTTP_USER_AGENT, CONST_STR_LEN("HTTP[\"useragent\"]" ) }, { COMP_HTTP_USER_AGENT, CONST_STR_LEN("HTTP[\"user-agent\"]" ) }, { COMP_HTTP_COOKIE, CONST_STR_LEN("HTTP[\"cookie\"]" ) }, { COMP_HTTP_REMOTE_IP, CONST_STR_LEN("HTTP[\"remoteip\"]" ) }, { COMP_HTTP_REMOTE_IP, CONST_STR_LEN("HTTP[\"remote-ip\"]" ) }, { COMP_HTTP_QUERY_STRING, CONST_STR_LEN("HTTP[\"querystring\"]") }, { COMP_HTTP_QUERY_STRING, CONST_STR_LEN("HTTP[\"query-string\"]") }, { COMP_HTTP_REQUEST_METHOD, CONST_STR_LEN("HTTP[\"request-method\"]") }, { COMP_HTTP_SCHEME, CONST_STR_LEN("HTTP[\"scheme\"]" ) }, { COMP_UNSET, NULL, 0 }, }; size_t i; dc = data_config_init(); buffer_copy_string_buffer(dc->key, b); buffer_copy_string_buffer(dc->op, op); buffer_copy_string_buffer(dc->comp_key, yymsp[-5].minor.yy0); buffer_append_string_len(dc->comp_key, CONST_STR_LEN("[\"")); buffer_append_string_buffer(dc->comp_key, yymsp[-3].minor.yy43); buffer_append_string_len(dc->comp_key, CONST_STR_LEN("\"]")); dc->cond = yymsp[-1].minor.yy27; for (i = 0; comps[i].comp_key; i ++) { if (buffer_is_equal_string( dc->comp_key, comps[i].comp_key, comps[i].len)) { dc->comp = comps[i].comp; break; } } if (COMP_UNSET == dc->comp) { fprintf(stderr, "error comp_key %s", dc->comp_key->ptr); ctx->ok = 0; } switch(yymsp[-1].minor.yy27) { case CONFIG_COND_NE: case CONFIG_COND_EQ: dc->string = buffer_init_buffer(rvalue); break; case CONFIG_COND_NOMATCH: case CONFIG_COND_MATCH: { #ifdef HAVE_PCRE_H const char *errptr; int erroff; if (NULL == (dc->regex = pcre_compile(rvalue->ptr, 0, &errptr, &erroff, NULL))) { dc->string = buffer_init_string(errptr); dc->cond = CONFIG_COND_UNSET; fprintf(stderr, "parsing regex failed: %s -> %s at offset %d\n", rvalue->ptr, errptr, erroff); ctx->ok = 0; } else if (NULL == (dc->regex_study = pcre_study(dc->regex, 0, &errptr)) && errptr != NULL) { fprintf(stderr, "studying regex failed: %s -> %s\n", rvalue->ptr, errptr); ctx->ok = 0; } else { dc->string = buffer_init_buffer(rvalue); } #else fprintf(stderr, "can't handle '$%s[%s] =~ ...' as you compiled without pcre support. \n" "(perhaps just a missing pcre-devel package ?) \n", yymsp[-5].minor.yy0->ptr, yymsp[-3].minor.yy43->ptr); ctx->ok = 0; #endif break; } default: fprintf(stderr, "unknown condition for $%s[%s]\n", yymsp[-5].minor.yy0->ptr, yymsp[-3].minor.yy43->ptr); ctx->ok = 0; break; } configparser_push(ctx, dc, 1); } buffer_free(b); buffer_free(op); buffer_free(yymsp[-5].minor.yy0); yymsp[-5].minor.yy0 = NULL; buffer_free(yymsp[-3].minor.yy43); yymsp[-3].minor.yy43 = NULL; yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); yymsp[0].minor.yy41 = NULL; } #line 1298 "configparser.c" yy_destructor(16,&yymsp[-6].minor); yy_destructor(18,&yymsp[-4].minor); yy_destructor(19,&yymsp[-2].minor); break; case 33: #line 516 "./configparser.y" { yygotominor.yy27 = CONFIG_COND_EQ; } #line 1308 "configparser.c" yy_destructor(20,&yymsp[0].minor); break; case 34: #line 519 "./configparser.y" { yygotominor.yy27 = CONFIG_COND_MATCH; } #line 1316 "configparser.c" yy_destructor(21,&yymsp[0].minor); break; case 35: #line 522 "./configparser.y" { yygotominor.yy27 = CONFIG_COND_NE; } #line 1324 "configparser.c" yy_destructor(22,&yymsp[0].minor); break; case 36: #line 525 "./configparser.y" { yygotominor.yy27 = CONFIG_COND_NOMATCH; } #line 1332 "configparser.c" yy_destructor(23,&yymsp[0].minor); break; case 37: #line 529 "./configparser.y" { yygotominor.yy43 = NULL; if (ctx->ok) { if (yymsp[0].minor.yy41->type == TYPE_STRING) { yygotominor.yy43 = buffer_init_buffer(((data_string*)yymsp[0].minor.yy41)->value); } else if (yymsp[0].minor.yy41->type == TYPE_INTEGER) { yygotominor.yy43 = buffer_init(); buffer_copy_long(yygotominor.yy43, ((data_integer *)yymsp[0].minor.yy41)->value); } else { fprintf(stderr, "operand must be string"); ctx->ok = 0; } } yymsp[0].minor.yy41->free(yymsp[0].minor.yy41); yymsp[0].minor.yy41 = NULL; } #line 1353 "configparser.c" break; case 38: #line 546 "./configparser.y" { if (ctx->ok) { if (0 != config_parse_file(ctx->srv, ctx, yymsp[0].minor.yy43->ptr)) { ctx->ok = 0; } buffer_free(yymsp[0].minor.yy43); yymsp[0].minor.yy43 = NULL; } } #line 1366 "configparser.c" yy_destructor(24,&yymsp[-1].minor); break; case 39: #line 556 "./configparser.y" { if (ctx->ok) { if (0 != config_parse_cmd(ctx->srv, ctx, yymsp[0].minor.yy43->ptr)) { ctx->ok = 0; } buffer_free(yymsp[0].minor.yy43); yymsp[0].minor.yy43 = NULL; } } #line 1380 "configparser.c" yy_destructor(25,&yymsp[-1].minor); break; }; yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yypParser->yyidx -= yysize; yyact = yy_find_reduce_action(yypParser,yygoto); if( yyact < YYNSTATE ){ yy_shift(yypParser,yyact,yygoto,&yygotominor); }else if( yyact == YYNSTATE + YYNRULE + 1 ){ yy_accept(yypParser); } }
static server *server_init(void) { int i; FILE *frandom = NULL; server *srv = calloc(1, sizeof(*srv)); assert(srv); #define CLEAN(x) \ srv->x = buffer_init(); CLEAN(response_header); CLEAN(parse_full_path); CLEAN(ts_debug_str); CLEAN(ts_date_str); CLEAN(errorlog_buf); CLEAN(response_range); CLEAN(tmp_buf); srv->empty_string = buffer_init_string(""); CLEAN(cond_check_buf); CLEAN(srvconf.errorlog_file); CLEAN(srvconf.breakagelog_file); CLEAN(srvconf.groupname); CLEAN(srvconf.username); CLEAN(srvconf.changeroot); CLEAN(srvconf.bindhost); CLEAN(srvconf.event_handler); CLEAN(srvconf.pid_file); CLEAN(tmp_chunk_len); #undef CLEAN #define CLEAN(x) \ srv->x = array_init(); CLEAN(config_context); CLEAN(config_touched); CLEAN(status); #undef CLEAN for (i = 0; i < FILE_CACHE_MAX; i++) { srv->mtime_cache[i].mtime = (time_t)-1; srv->mtime_cache[i].str = buffer_init(); } if ((NULL != (frandom = fopen("/dev/urandom", "rb")) || NULL != (frandom = fopen("/dev/random", "rb"))) && 1 == fread(srv->entropy, sizeof(srv->entropy), 1, frandom)) { unsigned int e; memcpy(&e, srv->entropy, sizeof(e) < sizeof(srv->entropy) ? sizeof(e) : sizeof(srv->entropy)); srand(e); srv->is_real_entropy = 1; } else { unsigned int j; srand(time(NULL) ^ getpid()); srv->is_real_entropy = 0; for (j = 0; j < sizeof(srv->entropy); j++) srv->entropy[j] = rand(); } if (frandom) fclose(frandom); srv->cur_ts = time(NULL); srv->startup_ts = srv->cur_ts; srv->conns = calloc(1, sizeof(*srv->conns)); assert(srv->conns); srv->joblist = calloc(1, sizeof(*srv->joblist)); assert(srv->joblist); srv->fdwaitqueue = calloc(1, sizeof(*srv->fdwaitqueue)); assert(srv->fdwaitqueue); srv->srvconf.modules = array_init(); srv->srvconf.modules_dir = buffer_init_string(LIBRARY_DIR); srv->srvconf.network_backend = buffer_init(); srv->srvconf.upload_tempdirs = array_init(); srv->srvconf.reject_expect_100_with_417 = 1; /* use syslog */ srv->errorlog_fd = STDERR_FILENO; srv->errorlog_mode = ERRORLOG_FD; srv->split_vals = array_init(); return srv; }
/** * walk through the content array * * content = { "<pre>", { file = "/content" } , "</pre>" } * * header["Content-Type"] = "text/html" * * return 200 */ static int magnet_attach_content(server *srv, connection *con, plugin_data *p, lua_State *L) { UNUSED(p); /** * get the environment of the function */ force_assert(lua_isfunction(L, -1)); lua_getfenv(L, -1); /* -1 is the function */ lua_getfield(L, -1, "lighty"); /* lighty.* from the env */ force_assert(lua_istable(L, -1)); lua_getfield(L, -1, "content"); /* lighty.content */ if (lua_istable(L, -1)) { int i; /* header is found, and is a table */ for (i = 1; ; i++) { lua_rawgeti(L, -1, i); /* -1 is the value and should be the value ... aka a table */ if (lua_isstring(L, -1)) { size_t s_len = 0; const char *s = lua_tolstring(L, -1, &s_len); chunkqueue_append_mem(con->write_queue, s, s_len); } else if (lua_istable(L, -1)) { lua_getfield(L, -1, "filename"); lua_getfield(L, -2, "length"); lua_getfield(L, -3, "offset"); if (lua_isstring(L, -3)) { /* filename has to be a string */ buffer *fn; stat_cache_entry *sce; const char *fn_str; handler_t res; fn_str = lua_tostring(L, -3); fn = buffer_init_string(fn_str); res = stat_cache_get_entry(srv, con, fn, &sce); if (HANDLER_GO_ON == res) { off_t off = 0; off_t len = 0; if (lua_isnumber(L, -1)) { off = lua_tonumber(L, -1); } if (lua_isnumber(L, -2)) { len = lua_tonumber(L, -2); } else { len = sce->st.st_size; } if (off < 0) { buffer_free(fn); return luaL_error(L, "offset for '%s' is negative", fn_str); } if (len < off) { buffer_free(fn); return luaL_error(L, "offset > length for '%s'", fn_str); } chunkqueue_append_file(con->write_queue, fn, off, len - off); } buffer_free(fn); } else { lua_pop(L, 3 + 2); /* correct the stack */ return luaL_error(L, "content[%d] is a table and requires the field \"filename\"", i); } lua_pop(L, 3); } else if (lua_isnil(L, -1)) { /* oops, end of list */ lua_pop(L, 1); break; } else { lua_pop(L, 4); return luaL_error(L, "content[%d] is neither a string nor a table: ", i); } lua_pop(L, 1); /* pop the content[...] table */ } } else { return luaL_error(L, "lighty.content has to be a table"); } lua_pop(L, 1); /* pop the header-table */ lua_pop(L, 1); /* pop the lighty-table */ lua_pop(L, 1); /* php the function env */ return 0; }
static int magnet_stat(lua_State *L) { const char *s = luaL_checkstring(L, 1); server *srv; connection *con; buffer *sb; stat_cache_entry *sce = NULL; handler_t res; lua_pushstring(L, "lighty.srv"); lua_gettable(L, LUA_REGISTRYINDEX); srv = lua_touserdata(L, -1); lua_pop(L, 1); lua_pushstring(L, "lighty.con"); lua_gettable(L, LUA_REGISTRYINDEX); con = lua_touserdata(L, -1); lua_pop(L, 1); sb = buffer_init_string(s); res = stat_cache_get_entry(srv, con, sb, &sce); buffer_free(sb); if (HANDLER_GO_ON != res) { lua_pushnil(L); return 1; } lua_newtable(L); lua_pushboolean(L, S_ISREG(sce->st.st_mode)); lua_setfield(L, -2, "is_file"); lua_pushboolean(L, S_ISDIR(sce->st.st_mode)); lua_setfield(L, -2, "is_dir"); lua_pushboolean(L, S_ISCHR(sce->st.st_mode)); lua_setfield(L, -2, "is_char"); lua_pushboolean(L, S_ISBLK(sce->st.st_mode)); lua_setfield(L, -2, "is_block"); lua_pushboolean(L, S_ISSOCK(sce->st.st_mode)); lua_setfield(L, -2, "is_socket"); lua_pushboolean(L, S_ISLNK(sce->st.st_mode)); lua_setfield(L, -2, "is_link"); lua_pushboolean(L, S_ISFIFO(sce->st.st_mode)); lua_setfield(L, -2, "is_fifo"); lua_pushinteger(L, sce->st.st_mtime); lua_setfield(L, -2, "st_mtime"); lua_pushinteger(L, sce->st.st_ctime); lua_setfield(L, -2, "st_ctime"); lua_pushinteger(L, sce->st.st_atime); lua_setfield(L, -2, "st_atime"); lua_pushinteger(L, sce->st.st_uid); lua_setfield(L, -2, "st_uid"); lua_pushinteger(L, sce->st.st_gid); lua_setfield(L, -2, "st_gid"); lua_pushinteger(L, sce->st.st_size); lua_setfield(L, -2, "st_size"); lua_pushinteger(L, sce->st.st_ino); lua_setfield(L, -2, "st_ino"); if (!buffer_string_is_empty(sce->etag)) { /* we have to mutate the etag */ buffer *b = buffer_init(); etag_mutate(b, sce->etag); lua_pushlstring(L, CONST_BUF_LEN(b)); buffer_free(b); } else { lua_pushnil(L); } lua_setfield(L, -2, "etag"); if (!buffer_string_is_empty(sce->content_type)) { lua_pushlstring(L, CONST_BUF_LEN(sce->content_type)); } else { lua_pushnil(L); } lua_setfield(L, -2, "content-type"); return 1; }
int mod_mysql_vhost_plugin_init(plugin *p) { p->version = LIGHTTPD_VERSION_ID; p->name = buffer_init_string("mysql_vhost"); return 0; }
static server *server_init(void) { int i; server *srv = calloc(1, sizeof(*srv)); assert(srv); #define CLEAN(x) \ srv->x = buffer_init(); CLEAN(response_header); CLEAN(parse_full_path); CLEAN(ts_debug_str); CLEAN(ts_date_str); CLEAN(errorlog_buf); CLEAN(response_range); CLEAN(tmp_buf); srv->empty_string = buffer_init_string(""); CLEAN(cond_check_buf); CLEAN(srvconf.errorlog_file); CLEAN(srvconf.groupname); CLEAN(srvconf.username); CLEAN(srvconf.changeroot); CLEAN(srvconf.bindhost); CLEAN(srvconf.event_handler); CLEAN(srvconf.pid_file); CLEAN(tmp_chunk_len); #undef CLEAN #define CLEAN(x) \ srv->x = array_init(); CLEAN(config_context); CLEAN(config_touched); CLEAN(status); #undef CLEAN for (i = 0; i < FILE_CACHE_MAX; i++) { srv->mtime_cache[i].mtime = (time_t)-1; srv->mtime_cache[i].str = buffer_init(); } srv->cur_ts = time(NULL); srv->startup_ts = srv->cur_ts; srv->conns = calloc(1, sizeof(*srv->conns)); assert(srv->conns); srv->joblist = calloc(1, sizeof(*srv->joblist)); assert(srv->joblist); srv->fdwaitqueue = calloc(1, sizeof(*srv->fdwaitqueue)); assert(srv->fdwaitqueue); srv->srvconf.modules = array_init(); srv->srvconf.modules_dir = buffer_init_string(LIBRARY_DIR); srv->srvconf.network_backend = buffer_init(); srv->srvconf.upload_tempdirs = array_init(); /* use syslog */ srv->errorlog_fd = -1; srv->errorlog_mode = ERRORLOG_STDERR; srv->split_vals = array_init(); return srv; }