您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CONST_STR_LEN函数代码示例

51自学网 2021-06-01 20:03:57
  C++
这篇教程C++ CONST_STR_LEN函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CONST_STR_LEN函数的典型用法代码示例。如果您正苦于以下问题:C++ CONST_STR_LEN函数的具体用法?C++ CONST_STR_LEN怎么用?C++ CONST_STR_LEN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CONST_STR_LEN函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: auth_basic_free

static void auth_basic_free(liServer *srv, gpointer param) {	AuthBasicData *bdata = param;	AuthFile *afd = bdata->data;	UNUSED(srv);	g_string_free(bdata->realm, TRUE);	auth_file_free(afd);	g_slice_free(AuthBasicData, bdata);}/* auth option names */static const GString	aon_method = { CONST_STR_LEN("method"), 0 },	aon_realm = { CONST_STR_LEN("realm"), 0 },	aon_file = { CONST_STR_LEN("file"), 0 },	aon_ttl = { CONST_STR_LEN("ttl"), 0 };static liAction* auth_generic_create(liServer *srv, liWorker *wrk, liPlugin* p, liValue *val, const char *actname, AuthBasicBackend basic_action, gboolean has_realm) {	AuthFile *afd;	GString *method = NULL, *file = NULL;	liValue *realm = NULL;	gboolean have_ttl_parameter = FALSE;	gint ttl = 10;	val = li_value_get_single_argument(val);	if (NULL == (val = li_value_to_key_value_list(val))) {
开发者ID:9drops,项目名称:lighttpd2,代码行数:30,


示例2: mod_status_handle_server_status_html

//.........这里部分代码省略.........		const char *state = connection_get_short_state(c->state);		buffer_append_string_len(b, state, 1);		if (((j + 1) % 50) == 0) {			BUFFER_APPEND_STRING_CONST(b, "/n");		}	}	BUFFER_APPEND_STRING_CONST(b, "/n</pre><hr />/n<h2>Connections</h2>/n");	BUFFER_APPEND_STRING_CONST(b, "<table summary=/"status/" class=/"status/">/n");	BUFFER_APPEND_STRING_CONST(b, "<tr>");	mod_status_header_append_sort(b, p_d, "Client IP");	mod_status_header_append_sort(b, p_d, "Read");	mod_status_header_append_sort(b, p_d, "Written");	mod_status_header_append_sort(b, p_d, "State");	mod_status_header_append_sort(b, p_d, "Time");	mod_status_header_append_sort(b, p_d, "Host");	mod_status_header_append_sort(b, p_d, "URI");	mod_status_header_append_sort(b, p_d, "File");	BUFFER_APPEND_STRING_CONST(b, "</tr>/n");	for (j = 0; j < srv->conns->used; j++) {		connection *c = srv->conns->ptr[j];		BUFFER_APPEND_STRING_CONST(b, "<tr><td class=/"string/">");		buffer_append_string(b, inet_ntop_cache_get_ip(srv, &(c->dst_addr)));		BUFFER_APPEND_STRING_CONST(b, "</td><td class=/"int/">");		if (con->request.content_length) {			buffer_append_long(b, c->request_content_queue->bytes_in);			BUFFER_APPEND_STRING_CONST(b, "/");			buffer_append_long(b, c->request.content_length);		} else {			BUFFER_APPEND_STRING_CONST(b, "0/0");		}		BUFFER_APPEND_STRING_CONST(b, "</td><td class=/"int/">");		buffer_append_off_t(b, chunkqueue_written(c->write_queue));		BUFFER_APPEND_STRING_CONST(b, "/");		buffer_append_off_t(b, chunkqueue_length(c->write_queue));		BUFFER_APPEND_STRING_CONST(b, "</td><td class=/"string/">");		buffer_append_string(b, connection_get_state(c->state));		BUFFER_APPEND_STRING_CONST(b, "</td><td class=/"int/">");		buffer_append_long(b, srv->cur_ts - c->request_start);		BUFFER_APPEND_STRING_CONST(b, "</td><td class=/"string/">");		if (buffer_is_empty(c->server_name)) {			buffer_append_string_buffer(b, c->uri.authority);		}		else {			buffer_append_string_buffer(b, c->server_name);		}		BUFFER_APPEND_STRING_CONST(b, "</td><td class=/"string/">");		if (!buffer_is_empty(c->uri.path)) {			buffer_append_string_encoded(b, CONST_BUF_LEN(c->uri.path), ENCODING_HTML);		}		if (!buffer_is_empty(c->uri.query)) {			BUFFER_APPEND_STRING_CONST(b, "?");			buffer_append_string_encoded(b, CONST_BUF_LEN(c->uri.query), ENCODING_HTML);		}		if (!buffer_is_empty(c->request.orig_uri)) {			BUFFER_APPEND_STRING_CONST(b, " (");			buffer_append_string_encoded(b, CONST_BUF_LEN(c->request.orig_uri), ENCODING_HTML);			BUFFER_APPEND_STRING_CONST(b, ")");		}		BUFFER_APPEND_STRING_CONST(b, "</td><td class=/"string/">");		buffer_append_string_buffer(b, c->physical.path);		BUFFER_APPEND_STRING_CONST(b, "</td></tr>/n");	}	BUFFER_APPEND_STRING_CONST(b,		      "</table>/n");	BUFFER_APPEND_STRING_CONST(b,		      " </body>/n"		      "</html>/n"		      );	response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));	return 0;}
开发者ID:stanlyjohn2,项目名称:webq,代码行数:101,


示例3: main

//.........这里部分代码省略.........	/* set max-conns */	if (srv->srvconf.max_conns > srv->max_fds) {		/* we can't have more connections than max-fds */		srv->max_conns = srv->max_fds;	} else if (srv->srvconf.max_conns) {		/* otherwise respect the wishes of the user */		srv->max_conns = srv->srvconf.max_conns;	} else {		/* or use the default */		srv->max_conns = srv->max_fds;	}	if (HANDLER_GO_ON != plugins_call_init(srv)) {		log_error_write(srv, __FILE__, __LINE__, "s", "Initialization of plugins failed. Going down.");		plugins_free(srv);		network_close(srv);		server_free(srv);		return -1;	}#ifdef HAVE_FORK	/* network is up, let's deamonize ourself */	if (srv->srvconf.dont_daemonize == 0) daemonize();#endif	srv->gid = getgid();	srv->uid = getuid();	/* write pid file */	if (pid_fd != -1) {		buffer_copy_long(srv->tmp_buf, getpid());		buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN("/n"));		write(pid_fd, srv->tmp_buf->ptr, srv->tmp_buf->used - 1);		close(pid_fd);		pid_fd = -1;	}	/* Close stderr ASAP in the child process to make sure that nothing	 * is being written to that fd which may not be valid anymore. */	if (-1 == log_error_open(srv)) {		log_error_write(srv, __FILE__, __LINE__, "s", "Opening errorlog failed. Going down.");		plugins_free(srv);		network_close(srv);		server_free(srv);		return -1;	}	if (HANDLER_GO_ON != plugins_call_set_defaults(srv)) {		log_error_write(srv, __FILE__, __LINE__, "s", "Configuration of plugins failed. Going down.");		plugins_free(srv);		network_close(srv);		server_free(srv);		return -1;	}	/* dump unused config-keys */	for (i = 0; i < srv->config_context->used; i++) {		array *config = ((data_config *)srv->config_context->data[i])->value;		size_t j;		for (j = 0; config && j < config->used; j++) {
开发者ID:heavilessrose,项目名称:my-sync,代码行数:67,


示例4: switch

GString *li_value_to_string(liValue *val) {    GString *str;    switch (val->type) {    case LI_VALUE_NONE:        return NULL;    case LI_VALUE_BOOLEAN:        str = g_string_new(val->data.boolean ? "true" : "false");        break;    case LI_VALUE_NUMBER:        str = g_string_sized_new(0);        g_string_printf(str, "%" G_GINT64_FORMAT, val->data.number);        break;    case LI_VALUE_STRING:        str = g_string_new_len(CONST_STR_LEN("/""));        g_string_append_len(str, GSTR_LEN(val->data.string));        g_string_append_c(str, '"');        break;    case LI_VALUE_LIST:        str = g_string_new_len(CONST_STR_LEN("("));        if (val->data.list->len) {            GString *tmp = li_value_to_string(g_array_index(val->data.list, liValue*, 0));            g_string_append(str, tmp->str);            g_string_free(tmp, TRUE);            for (guint i = 1; i < val->data.list->len; i++) {                tmp = li_value_to_string(g_array_index(val->data.list, liValue*, i));                g_string_append_len(str, CONST_STR_LEN(", "));                g_string_append(str, tmp->str);                g_string_free(tmp, TRUE);            }        }        g_string_append_c(str, ')');        break;    case LI_VALUE_HASH:    {        GHashTableIter iter;        gpointer k, v;        GString *tmp;        guint i = 0;        str = g_string_new_len(CONST_STR_LEN("["));        g_hash_table_iter_init(&iter, val->data.hash);        while (g_hash_table_iter_next(&iter, &k, &v)) {            if (i)                g_string_append_len(str, CONST_STR_LEN(", "));            tmp = li_value_to_string((liValue*)v);            g_string_append_len(str, GSTR_LEN((GString*)k));            g_string_append_len(str, CONST_STR_LEN(" => "));            g_string_append_len(str, GSTR_LEN(tmp));            g_string_free(tmp, TRUE);            i++;        }        g_string_append_c(str, ']');        break;    }    case LI_VALUE_ACTION:        str = g_string_new_len(CONST_STR_LEN("<action>"));        break;    case LI_VALUE_CONDITION:        str = g_string_new_len(CONST_STR_LEN("<condition>"));        break;    default:        return NULL;    }
开发者ID:presbrey,项目名称:lighttpd2,代码行数:66,


示例5: ssi_expr_tokenizer

static int ssi_expr_tokenizer(server *srv, connection *con, handler_ctx *p,			      ssi_tokenizer_t *t, int *token_id, buffer *token) {	int tid = 0;	size_t i;	UNUSED(con);	for (tid = 0; tid == 0 && t->offset < t->size && t->input[t->offset] ; ) {		char c = t->input[t->offset];		data_string *ds;		switch (c) {		case '=':			tid = TK_EQ;			t->offset++;			t->line_pos++;			buffer_copy_string_len(token, CONST_STR_LEN("(=)"));			break;		case '>':			if (t->input[t->offset + 1] == '=') {				t->offset += 2;				t->line_pos += 2;				tid = TK_GE;				buffer_copy_string_len(token, CONST_STR_LEN("(>=)"));			} else {				t->offset += 1;				t->line_pos += 1;				tid = TK_GT;				buffer_copy_string_len(token, CONST_STR_LEN("(>)"));			}			break;		case '<':			if (t->input[t->offset + 1] == '=') {				t->offset += 2;				t->line_pos += 2;				tid = TK_LE;				buffer_copy_string_len(token, CONST_STR_LEN("(<=)"));			} else {				t->offset += 1;				t->line_pos += 1;				tid = TK_LT;				buffer_copy_string_len(token, CONST_STR_LEN("(<)"));			}			break;		case '!':			if (t->input[t->offset + 1] == '=') {				t->offset += 2;				t->line_pos += 2;				tid = TK_NE;				buffer_copy_string_len(token, CONST_STR_LEN("(!=)"));			} else {				t->offset += 1;				t->line_pos += 1;				tid = TK_NOT;				buffer_copy_string_len(token, CONST_STR_LEN("(!)"));			}			break;		case '&':			if (t->input[t->offset + 1] == '&') {				t->offset += 2;				t->line_pos += 2;				tid = TK_AND;				buffer_copy_string_len(token, CONST_STR_LEN("(&&)"));			} else {				log_error_write(srv, __FILE__, __LINE__, "sds",						"pos:", t->line_pos,						"missing second &");				return -1;			}			break;		case '|':			if (t->input[t->offset + 1] == '|') {				t->offset += 2;				t->line_pos += 2;				tid = TK_OR;				buffer_copy_string_len(token, CONST_STR_LEN("(||)"));//.........这里部分代码省略.........
开发者ID:gstrauss,项目名称:lighttpd1.4,代码行数:101,


示例6: mod_rrdtool_create_rrd

static int mod_rrdtool_create_rrd(server *srv, plugin_data *p, plugin_config *s) {	struct stat st;	int r;	/* check if DB already exists */	if (0 == stat(s->path_rrd->ptr, &st)) {		/* check if it is plain file */		if (!S_ISREG(st.st_mode)) {			log_error_write(srv, __FILE__, __LINE__, "sb",					"not a regular file:", s->path_rrd);			return HANDLER_ERROR;		}		/* still create DB if it's empty file */		if (st.st_size > 0) {			return HANDLER_GO_ON;		}	}	/* create a new one */	buffer_copy_string_len(p->cmd, CONST_STR_LEN("create "));	buffer_append_string_buffer(p->cmd, s->path_rrd);	buffer_append_string_len(p->cmd, CONST_STR_LEN(		" --step 60 "		"DS:InOctets:ABSOLUTE:600:U:U "		"DS:OutOctets:ABSOLUTE:600:U:U "		"DS:Requests:ABSOLUTE:600:U:U "		"RRA:AVERAGE:0.5:1:600 "		"RRA:AVERAGE:0.5:6:700 "		"RRA:AVERAGE:0.5:24:775 "		"RRA:AVERAGE:0.5:288:797 "		"RRA:MAX:0.5:1:600 "		"RRA:MAX:0.5:6:700 "		"RRA:MAX:0.5:24:775 "		"RRA:MAX:0.5:288:797 "		"RRA:MIN:0.5:1:600 "		"RRA:MIN:0.5:6:700 "		"RRA:MIN:0.5:24:775 "		"RRA:MIN:0.5:288:797/n"));	if (-1 == (safe_write(p->write_fd, p->cmd->ptr, p->cmd->used - 1))) {		log_error_write(srv, __FILE__, __LINE__, "ss",			"rrdtool-write: failed", strerror(errno));		return HANDLER_ERROR;	}	buffer_prepare_copy(p->resp, 4096);	if (-1 == (r = safe_read(p->read_fd, p->resp->ptr, p->resp->size))) {		log_error_write(srv, __FILE__, __LINE__, "ss",			"rrdtool-read: failed", strerror(errno));		return HANDLER_ERROR;	}	p->resp->used = r;	if (p->resp->ptr[0] != 'O' ||		p->resp->ptr[1] != 'K') {		log_error_write(srv, __FILE__, __LINE__, "sbb",			"rrdtool-response:", p->cmd, p->resp);		return HANDLER_ERROR;	}	return HANDLER_GO_ON;}
开发者ID:HitoriSensei,项目名称:lighttpd,代码行数:67,


示例7: mod_auth_patch_connection

static int mod_auth_patch_connection(server *srv, connection *con, mod_auth_plugin_data *p) {	size_t i, j;	mod_auth_plugin_config *s = p->config_storage[0];	PATCH(auth_backend);	PATCH(auth_plain_groupfile);	PATCH(auth_plain_userfile);	PATCH(auth_htdigest_userfile);	PATCH(auth_htpasswd_userfile);	PATCH(auth_require);	PATCH(auth_debug);	PATCH(auth_ldap_hostname);	PATCH(auth_ldap_basedn);	PATCH(auth_ldap_binddn);	PATCH(auth_ldap_bindpw);	PATCH(auth_ldap_filter);	PATCH(auth_ldap_cafile);	PATCH(auth_ldap_starttls);	PATCH(auth_ldap_allow_empty_pw);#ifdef USE_LDAP	p->anon_conf = s;	PATCH(ldap_filter_pre);	PATCH(ldap_filter_post);#endif	/* skip the first, the global context */	for (i = 1; i < srv->config_context->used; i++) {		data_config *dc = (data_config *)srv->config_context->data[i];		s = p->config_storage[i];		/* condition didn't match */		if (!config_check_cond(srv, con, dc)) continue;		/* merge config */		for (j = 0; j < dc->value->used; j++) {			data_unset *du = dc->value->data[j];			if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend"))) {				PATCH(auth_backend);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.plain.groupfile"))) {				PATCH(auth_plain_groupfile);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.plain.userfile"))) {				PATCH(auth_plain_userfile);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.htdigest.userfile"))) {				PATCH(auth_htdigest_userfile);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.htpasswd.userfile"))) {				PATCH(auth_htpasswd_userfile);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.require"))) {				PATCH(auth_require);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.debug"))) {				PATCH(auth_debug);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.hostname"))) {				PATCH(auth_ldap_hostname);#ifdef USE_LDAP				p->anon_conf = s;#endif			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.base-dn"))) {				PATCH(auth_ldap_basedn);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.filter"))) {				PATCH(auth_ldap_filter);#ifdef USE_LDAP				PATCH(ldap_filter_pre);				PATCH(ldap_filter_post);#endif			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.ca-file"))) {				PATCH(auth_ldap_cafile);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.starttls"))) {				PATCH(auth_ldap_starttls);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.bind-dn"))) {				PATCH(auth_ldap_binddn);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.bind-pw"))) {				PATCH(auth_ldap_bindpw);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("auth.backend.ldap.allow-empty-pw"))) {				PATCH(auth_ldap_allow_empty_pw);			}		}	}	return 0;}
开发者ID:Teino1978-Corp,项目名称:lighttpd1.4,代码行数:80,


示例8: ssi_env_add_request_headers

static int ssi_env_add_request_headers(server *srv, connection *con, plugin_data *p) {	size_t i;	for (i = 0; i < con->request.headers->used; i++) {		data_string *ds;		ds = (data_string *)con->request.headers->data[i];		if (ds->value->used && ds->key->used) {			size_t j;			buffer_reset(srv->tmp_buf);			/* don't forward the Authorization: Header */			if (0 == strcasecmp(ds->key->ptr, "AUTHORIZATION")) {				continue;			}			if (0 != strcasecmp(ds->key->ptr, "CONTENT-TYPE")) {				buffer_copy_string_len(srv->tmp_buf, CONST_STR_LEN("HTTP_"));				srv->tmp_buf->used--;			}			buffer_prepare_append(srv->tmp_buf, ds->key->used + 2);			for (j = 0; j < ds->key->used - 1; j++) {				char c = '_';				if (light_isalpha(ds->key->ptr[j])) {					/* upper-case */					c = ds->key->ptr[j] & ~32;				} else if (light_isdigit(ds->key->ptr[j])) {					/* copy */					c = ds->key->ptr[j];				}				srv->tmp_buf->ptr[srv->tmp_buf->used++] = c;			}			srv->tmp_buf->ptr[srv->tmp_buf->used] = '/0';			ssi_env_add(p->ssi_cgi_env, srv->tmp_buf->ptr, ds->value->ptr);		}	}	for (i = 0; i < con->environment->used; i++) {		data_string *ds;		ds = (data_string *)con->environment->data[i];		if (ds->value->used && ds->key->used) {			size_t j;			buffer_reset(srv->tmp_buf);			buffer_prepare_append(srv->tmp_buf, ds->key->used + 2);			for (j = 0; j < ds->key->used - 1; j++) {				char c = '_';				if (light_isalpha(ds->key->ptr[j])) {					/* upper-case */					c = ds->key->ptr[j] & ~32;				} else if (light_isdigit(ds->key->ptr[j])) {					/* copy */					c = ds->key->ptr[j];				}				srv->tmp_buf->ptr[srv->tmp_buf->used++] = c;			}			srv->tmp_buf->ptr[srv->tmp_buf->used] = '/0';			ssi_env_add(p->ssi_cgi_env, srv->tmp_buf->ptr, ds->value->ptr);		}	}	return 0;}
开发者ID:HitoriSensei,项目名称:lighttpd,代码行数:70,


示例9: mod_status_handle_server_status_text

static handler_t mod_status_handle_server_status_text(server *srv, connection *con, void *p_d) {	plugin_data *p = p_d;	buffer *b = buffer_init();	double avg;	time_t ts;	char buf[32];	unsigned int k;	unsigned int l;	/* output total number of requests */	buffer_append_string_len(b, CONST_STR_LEN("Total Accesses: "));	avg = p->abs_requests;	snprintf(buf, sizeof(buf) - 1, "%.0f", avg);	buffer_append_string(b, buf);	buffer_append_string_len(b, CONST_STR_LEN("/n"));	/* output total traffic out in kbytes */	buffer_append_string_len(b, CONST_STR_LEN("Total kBytes: "));	avg = p->abs_traffic_out / 1024;	snprintf(buf, sizeof(buf) - 1, "%.0f", avg);	buffer_append_string(b, buf);	buffer_append_string_len(b, CONST_STR_LEN("/n"));	/* output uptime */	buffer_append_string_len(b, CONST_STR_LEN("Uptime: "));	ts = srv->cur_ts - srv->startup_ts;	buffer_append_int(b, ts);	buffer_append_string_len(b, CONST_STR_LEN("/n"));	/* output busy servers */	buffer_append_string_len(b, CONST_STR_LEN("BusyServers: "));	buffer_append_int(b, srv->conns->used);	buffer_append_string_len(b, CONST_STR_LEN("/n"));	buffer_append_string_len(b, CONST_STR_LEN("IdleServers: "));	buffer_append_int(b, srv->conns->size - srv->conns->used);	buffer_append_string_len(b, CONST_STR_LEN("/n"));	/* output scoreboard */	buffer_append_string_len(b, CONST_STR_LEN("Scoreboard: "));	for (k = 0; k < srv->conns->used; k++) {		connection *c = srv->conns->ptr[k];		const char *state = connection_get_short_state(c->state);		buffer_append_string_len(b, state, 1);	}	for (l = 0; l < srv->conns->size - srv->conns->used; l++) {		buffer_append_string_len(b, CONST_STR_LEN("_"));	}	buffer_append_string_len(b, CONST_STR_LEN("/n"));	chunkqueue_append_buffer(con->write_queue, b);	buffer_free(b);	/* set text/plain output */	response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/plain"));	return 0;}
开发者ID:automatical,项目名称:lighttpd1.4,代码行数:58,


示例10: mod_auth_uri_handler

//.........这里部分代码省略.........			return HANDLER_FINISHED;		} else {			return HANDLER_GO_ON;		}	}	/* try to get Authorization-header */	if (NULL != (ds = (data_string *)array_get_element(con->request.headers, "Authorization")) && !buffer_is_empty(ds->value)) {		char *auth_realm;		http_authorization = ds->value->ptr;		/* parse auth-header */		if (NULL != (auth_realm = strchr(http_authorization, ' '))) {			int auth_type_len = auth_realm - http_authorization;			if ((auth_type_len == 5) &&			    (0 == strncasecmp(http_authorization, "Basic", auth_type_len))) {				auth_type = "Basic";				if (0 == strcmp(req_method->value->ptr, "basic")) {					auth_satisfied = http_auth_basic_check(srv, con, p, req, auth_realm+1);				}			} else if ((auth_type_len == 6) &&				   (0 == strncasecmp(http_authorization, "Digest", auth_type_len))) {				auth_type = "Digest";				if (0 == strcmp(req_method->value->ptr, "digest")) {					if (-1 == (auth_satisfied = http_auth_digest_check(srv, con, p, req, auth_realm+1))) {						con->http_status = 400;						con->mode = DIRECT;						/* a field was missing */						return HANDLER_FINISHED;					}				}			} else {				log_error_write(srv, __FILE__, __LINE__, "ss",						"unknown authentication type:",						http_authorization);			}		}	}	if (!auth_satisfied) {		data_string *method, *realm;		method = (data_string *)array_get_element(req, "method");		realm = (data_string *)array_get_element(req, "realm");		con->http_status = 401;		con->mode = DIRECT;		if (0 == strcmp(method->value->ptr, "basic")) {			buffer_copy_string_len(p->tmp_buf, CONST_STR_LEN("Basic realm=/""));			buffer_append_string_buffer(p->tmp_buf, realm->value);			buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("/""));			response_header_insert(srv, con, CONST_STR_LEN("WWW-Authenticate"), CONST_BUF_LEN(p->tmp_buf));		} else if (0 == strcmp(method->value->ptr, "digest")) {			char hh[33];			http_auth_digest_generate_nonce(srv, p, srv->tmp_buf, &hh);			buffer_copy_string_len(p->tmp_buf, CONST_STR_LEN("Digest realm=/""));			buffer_append_string_buffer(p->tmp_buf, realm->value);			buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("/", nonce=/""));			buffer_append_string(p->tmp_buf, hh);			buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("/", qop=/"auth/""));			response_header_insert(srv, con, CONST_STR_LEN("WWW-Authenticate"), CONST_BUF_LEN(p->tmp_buf));		} else {			/* evil */		}		return HANDLER_FINISHED;	} else {		/* the REMOTE_USER header */		if (NULL == (ds = (data_string *)array_get_element(con->environment, "REMOTE_USER"))) {			if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {				ds = data_string_init();			}			buffer_copy_string(ds->key, "REMOTE_USER");			array_insert_unique(con->environment, (data_unset *)ds);		}		buffer_copy_buffer(ds->value, p->auth_user);		/* AUTH_TYPE environment */		if (NULL == (ds = (data_string *)array_get_element(con->environment, "AUTH_TYPE"))) {			if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {				ds = data_string_init();			}			buffer_copy_string(ds->key, "AUTH_TYPE");			array_insert_unique(con->environment, (data_unset *)ds);		}		buffer_copy_string(ds->value, auth_type);	}	return HANDLER_GO_ON;}
开发者ID:Teino1978-Corp,项目名称:lighttpd1.4,代码行数:101,


示例11: network_init

//.........这里部分代码省略.........			return -1;		}		if (SSL_CTX_use_PrivateKey_file (s->ssl_ctx, s->ssl_pemfile->ptr, SSL_FILETYPE_PEM) < 0) {			log_error_write(srv, __FILE__, __LINE__, "ssb", "SSL:",					ERR_error_string(ERR_get_error(), NULL), s->ssl_pemfile);			return -1;		}		if (SSL_CTX_check_private_key(s->ssl_ctx) != 1) {			log_error_write(srv, __FILE__, __LINE__, "sssb", "SSL:",					"Private key does not match the certificate public key, reason:",					ERR_error_string(ERR_get_error(), NULL),					s->ssl_pemfile);			return -1;		}		SSL_CTX_set_default_read_ahead(s->ssl_ctx, 1);		SSL_CTX_set_mode(s->ssl_ctx, SSL_CTX_get_mode(s->ssl_ctx) | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);# ifndef OPENSSL_NO_TLSEXT		if (!SSL_CTX_set_tlsext_servername_callback(s->ssl_ctx, network_ssl_servername_callback) ||		    !SSL_CTX_set_tlsext_servername_arg(s->ssl_ctx, srv)) {			log_error_write(srv, __FILE__, __LINE__, "ss", "SSL:",					"failed to initialize TLS servername callback, openssl library does not support TLS servername extension");			return -1;		}# endif	}#endif	b = buffer_init();	buffer_copy_string_buffer(b, srv->srvconf.bindhost);	buffer_append_string_len(b, CONST_STR_LEN(":"));	buffer_append_long(b, srv->srvconf.port);	if (0 != network_server_init(srv, b, srv->config_storage[0])) {		return -1;	}	buffer_free(b);#ifdef USE_OPENSSL	srv->network_ssl_backend_write = network_write_chunkqueue_openssl;#endif	/* get a usefull default */	backend = network_backends[0].nb;	/* match name against known types */	if (!buffer_is_empty(srv->srvconf.network_backend)) {		for (i = 0; network_backends[i].name; i++) {			/**/			if (buffer_is_equal_string(srv->srvconf.network_backend, network_backends[i].name, strlen(network_backends[i].name))) {				backend = network_backends[i].nb;				break;			}		}		if (NULL == network_backends[i].name) {			/* we don't know it */			log_error_write(srv, __FILE__, __LINE__, "sb",					"server.network-backend has a unknown value:",					srv->srvconf.network_backend);			return -1;		}
开发者ID:h0tw1r3,项目名称:asuswrt-merlin,代码行数:67,


示例12: mod_evhost_uri_handler

static handler_t mod_evhost_uri_handler(server *srv, connection *con, void *p_d) {	plugin_data *p = p_d;	size_t i;	array *parsed_host;	register char *ptr;	int not_good = 0;	stat_cache_entry *sce = NULL;	/* not authority set */	if (con->uri.authority->used == 0) return HANDLER_GO_ON;	mod_evhost_patch_connection(srv, con, p);	/* missing even default(global) conf */	if (0 == p->conf.len) {		return HANDLER_GO_ON;	}	parsed_host = array_init();	mod_evhost_parse_host(con, parsed_host);	/* build document-root */	buffer_reset(p->tmp_buf);	for (i = 0; i < p->conf.len; i++) {		ptr = p->conf.path_pieces[i]->ptr;		if (*ptr == '%') {			data_string *ds;			if (*(ptr+1) == '%') {				/* %% */				buffer_append_string_len(p->tmp_buf,CONST_STR_LEN("%"));			} else if (*(ptr+1) == '_' ) {				/* %_ == full hostname */				char *colon = strchr(con->uri.authority->ptr, ':');				if(colon == NULL) {					buffer_append_string_buffer(p->tmp_buf, con->uri.authority); /* adds fqdn */				} else {					/* strip the port out of the authority-part of the URI scheme */					buffer_append_string_len(p->tmp_buf, con->uri.authority->ptr, colon - con->uri.authority->ptr); /* adds fqdn */				}			} else if (NULL != (ds = (data_string *)array_get_element(parsed_host,p->conf.path_pieces[i]->ptr))) {				if (ds->value->used) {					buffer_append_string_buffer(p->tmp_buf,ds->value);				}			} else {				/* unhandled %-sequence */			}		} else {			buffer_append_string_buffer(p->tmp_buf,p->conf.path_pieces[i]);		}	}	BUFFER_APPEND_SLASH(p->tmp_buf);	array_free(parsed_host);		if (HANDLER_ERROR == stat_cache_get_entry(srv, con, p->tmp_buf, &sce)) {		log_error_write(srv, __FILE__, __LINE__, "sb", strerror(errno), p->tmp_buf);		not_good = 1;	} else if(!S_ISDIR(sce->st.st_mode)) {		log_error_write(srv, __FILE__, __LINE__, "sb", "not a directory:", p->tmp_buf);		not_good = 1;	}	if (!not_good) {		buffer_copy_string_buffer(con->physical.doc_root, p->tmp_buf);	}	return HANDLER_GO_ON;}
开发者ID:Nymphetaminer,项目名称:dsl-n55u,代码行数:73,


示例13: auth_basic

static liHandlerResult auth_basic(liVRequest *vr, gpointer param, gpointer *context) {	liHttpHeader *hdr;	gboolean auth_ok = FALSE;	AuthBasicData *bdata = param;	gboolean debug = _OPTION(vr, bdata->p, 0).boolean;	UNUSED(context);	if (li_vrequest_is_handled(vr)) {		if (debug || CORE_OPTION(LI_CORE_OPTION_DEBUG_REQUEST_HANDLING).boolean) {			VR_DEBUG(vr, "skipping auth.basic as request is already handled with current status %i", vr->response.http_status);		}		return LI_HANDLER_GO_ON;	}	/* check for Authorization header */	hdr = li_http_header_lookup(vr->request.headers, CONST_STR_LEN("Authorization"));	if (!hdr || !g_str_has_prefix(LI_HEADER_VALUE(hdr), "Basic ")) {		if (debug) {			VR_DEBUG(vr, "requesting authorization from client for realm /"%s/"", bdata->realm->str);		}	} else {		gchar *decoded, *username = NULL, *password;		size_t len;		/* auth_info contains username:password encoded in base64 */		if (NULL != (decoded = (gchar*)g_base64_decode(LI_HEADER_VALUE(hdr) + sizeof("Basic ") - 1, &len))) {			/* bogus data? */			if (NULL != (password = strchr(decoded, ':'))) {				*password = '/0';				password++;				username = decoded;			} else {				g_free(decoded);			}		}		if (!username) {			if (debug) {				VR_DEBUG(vr, "couldn't parse authorization info from client for realm /"%s/"", bdata->realm->str);			}		} else {			GString user = li_const_gstring(username, password - username - 1);			GString pass = li_const_gstring(password, len - (password - username));			if (bdata->backend(vr, &user, &pass, bdata, debug)) {				auth_ok = TRUE;				li_environment_set(&vr->env, CONST_STR_LEN("REMOTE_USER"), username, password - username - 1);				li_environment_set(&vr->env, CONST_STR_LEN("AUTH_TYPE"), CONST_STR_LEN("Basic"));			} else {				if (debug) {					VR_DEBUG(vr, "wrong authorization info from client on realm /"%s/" (user: /"%s/")", bdata->realm->str, username);				}			}			g_free(decoded);		}	}	g_string_truncate(vr->wrk->tmp_str, 0);	g_string_append_len(vr->wrk->tmp_str, CONST_STR_LEN("Basic realm=/""));	g_string_append_len(vr->wrk->tmp_str, GSTR_LEN(bdata->realm));	g_string_append_c(vr->wrk->tmp_str, '"');	/* generate header always */	if (!auth_ok) {		li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("WWW-Authenticate"), GSTR_LEN(vr->wrk->tmp_str));		/* we already checked for handled */		if (!li_vrequest_handle_direct(vr))			return LI_HANDLER_ERROR;		vr->response.http_status = 401;		return LI_HANDLER_GO_ON;	} else {		/* lets hope browser just ignore the header if status is not 401		 * but this way it is easier to use a later "auth.deny;"		 */		li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("WWW-Authenticate"), GSTR_LEN(vr->wrk->tmp_str));	}	if (debug) {		VR_DEBUG(vr, "client authorization successful for realm /"%s/"", bdata->realm->str);	}	return LI_HANDLER_GO_ON;}
开发者ID:9drops,项目名称:lighttpd2,代码行数:86,


示例14: shutdown

subuser *checkrecv(ape_socket *co, acetables *g_ape){	unsigned int op;	http_state *http = co->parser.data;	subuser *user = NULL;	clientget cget;		if (http->host == NULL) {		shutdown(co->fd, 2);		return NULL;	}		if (gettransport(http->uri) == TRANSPORT_WEBSOCKET) {		char *origin = get_header_line(http->hlines, "Origin");		websocket_state *websocket;		if (origin == NULL) {			shutdown(co->fd, 2);			return NULL;		}				PACK_TCP(co->fd);		sendbin(co->fd, CONST_STR_LEN(WEBSOCKET_HARDCODED_HEADERS), 0, g_ape);		sendbin(co->fd, CONST_STR_LEN("WebSocket-Origin: "), 0, g_ape);		sendbin(co->fd, origin, strlen(origin), 0, g_ape);		sendbin(co->fd, CONST_STR_LEN("/r/nWebSocket-Location: ws://"), 0, g_ape);		sendbin(co->fd, http->host, strlen(http->host), 0, g_ape);		sendbin(co->fd, http->uri, strlen(http->uri), 0, g_ape);		sendbin(co->fd, CONST_STR_LEN("/r/n/r/n"), 0, g_ape);		FLUSH_TCP(co->fd);				co->parser = parser_init_stream(co);		websocket = co->parser.data;		websocket->http = http; /* keep http data */				return NULL;	}	if (http->data == NULL) {		sendbin(co->fd, HEADER_DEFAULT, HEADER_DEFAULT_LEN, 0, g_ape);		sendbin(co->fd, CONST_STR_LEN(CONTENT_NOTFOUND), 0, g_ape);				safe_shutdown(co->fd, g_ape);		return NULL;	}		cget.client = co;	cget.ip_get = co->ip_client;	cget.get = http->data;	cget.host = http->host;	cget.hlines = http->hlines;		op = checkcmd(&cget, gettransport(http->uri), &user, g_ape);	switch (op) {		case CONNECT_SHUTDOWN:			safe_shutdown(co->fd, g_ape);						break;		case CONNECT_KEEPALIVE:			break;	}		return user;}
开发者ID:Vinz3056,项目名称:APE_Server,代码行数:63,


示例15: process_ssi_stmt

//.........这里部分代码省略.........			}		}		if (p->if_is_false) break;		if (!var_val) {			log_error_write(srv, __FILE__, __LINE__, "sss",					"ssi: ",					l[1], "var is missing");			break;		}		switch(var) {		case SSI_ECHO_USER_NAME: {			struct passwd *pw;			b = chunkqueue_get_append_buffer(con->write_queue);#ifdef HAVE_PWD_H			if (NULL == (pw = getpwuid(sce->st.st_uid))) {				buffer_copy_long(b, sce->st.st_uid);			} else {				buffer_copy_string(b, pw->pw_name);			}#else			buffer_copy_long(b, sce->st.st_uid);#endif			break;		}		case SSI_ECHO_LAST_MODIFIED:	{			time_t t = sce->st.st_mtime;			b = chunkqueue_get_append_buffer(con->write_queue);			if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, localtime(&t))) {				buffer_copy_string_len(b, CONST_STR_LEN("(none)"));			} else {				buffer_copy_string(b, buf);			}			break;		}		case SSI_ECHO_DATE_LOCAL: {			time_t t = time(NULL);			b = chunkqueue_get_append_buffer(con->write_queue);			if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, localtime(&t))) {				buffer_copy_string_len(b, CONST_STR_LEN("(none)"));			} else {				buffer_copy_string(b, buf);			}			break;		}		case SSI_ECHO_DATE_GMT: {			time_t t = time(NULL);			b = chunkqueue_get_append_buffer(con->write_queue);			if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, gmtime(&t))) {				buffer_copy_string_len(b, CONST_STR_LEN("(none)"));			} else {				buffer_copy_string(b, buf);			}			break;		}		case SSI_ECHO_DOCUMENT_NAME: {			char *sl;			b = chunkqueue_get_append_buffer(con->write_queue);			if (NULL == (sl = strrchr(con->physical.path->ptr, '/'))) {
开发者ID:HitoriSensei,项目名称:lighttpd,代码行数:67,


示例16: proxy_create_env

static int proxy_create_env(server *srv, handler_ctx *hctx) {	size_t i;	connection *con   = hctx->remote_conn;	buffer *b;	/* build header */	b = chunkqueue_get_append_buffer(hctx->wb);	/* request line */	buffer_copy_string(b, get_http_method_name(con->request.http_method));	buffer_append_string_len(b, CONST_STR_LEN(" "));	buffer_append_string_buffer(b, con->request.uri);	buffer_append_string_len(b, CONST_STR_LEN(" HTTP/1.0/r/n"));	proxy_append_header(con, "X-Forwarded-For", (char *)inet_ntop_cache_get_ip(srv, &(con->dst_addr)));	/* http_host is NOT is just a pointer to a buffer	 * which is NULL if it is not set */	if (con->request.http_host &&	    !buffer_is_empty(con->request.http_host)) {		proxy_set_header(con, "X-Host", con->request.http_host->ptr);	}	proxy_set_header(con, "X-Forwarded-Proto", con->conf.is_ssl ? "https" : "http");	/* request header */	for (i = 0; i < con->request.headers->used; i++) {		data_string *ds;		ds = (data_string *)con->request.headers->data[i];		if (ds->value->used && ds->key->used) {			if (buffer_is_equal_string(ds->key, CONST_STR_LEN("Connection"))) continue;			if (buffer_is_equal_string(ds->key, CONST_STR_LEN("Proxy-Connection"))) continue;			buffer_append_string_buffer(b, ds->key);			buffer_append_string_len(b, CONST_STR_LEN(": "));			buffer_append_string_buffer(b, ds->value);			buffer_append_string_len(b, CONST_STR_LEN("/r/n"));		}	}	buffer_append_string_len(b, CONST_STR_LEN("/r/n"));	hctx->wb->bytes_in += b->used - 1;	/* body */	if (con->request.content_length) {		chunkqueue *req_cq = con->request_content_queue;		chunk *req_c;		off_t offset;		/* something to send ? */		for (offset = 0, req_c = req_cq->first; offset != req_cq->bytes_in; req_c = req_c->next) {			off_t weWant = req_cq->bytes_in - offset;			off_t weHave = 0;			/* we announce toWrite octects			 * now take all the request_content chunk that we need to fill this request			 * */			switch (req_c->type) {			case FILE_CHUNK:				weHave = req_c->file.length - req_c->offset;				if (weHave > weWant) weHave = weWant;				chunkqueue_append_file(hctx->wb, req_c->file.name, req_c->offset, weHave);				req_c->offset += weHave;				req_cq->bytes_out += weHave;				hctx->wb->bytes_in += weHave;				break;			case MEM_CHUNK:				/* append to the buffer */				weHave = req_c->mem->used - 1 - req_c->offset;				if (weHave > weWant) weHave = weWant;				b = chunkqueue_get_append_buffer(hctx->wb);				buffer_append_memory(b, req_c->mem->ptr + req_c->offset, weHave);				b->used++; /* add virtual /0 */				req_c->offset += weHave;				req_cq->bytes_out += weHave;				hctx->wb->bytes_in += weHave;				break;			default:				break;			}			offset += weHave;		}	}//.........这里部分代码省略.........
开发者ID:angad,项目名称:lighttpd-android,代码行数:101,


示例17: mod_ssi_handle_request

static int mod_ssi_handle_request(server *srv, connection *con, plugin_data *p) {	stream s;#ifdef  HAVE_PCRE_H	int i, n;#define N 10	int ovec[N * 3];#endif	stat_cache_entry *sce = NULL;	/* get a stream to the file */	array_reset(p->ssi_vars);	array_reset(p->ssi_cgi_env);	buffer_copy_string_len(p->timefmt, CONST_STR_LEN("%a, %d %b %Y %H:%M:%S %Z"));	p->sizefmt = 0;	build_ssi_cgi_vars(srv, con, p);	p->if_is_false = 0;	/* Reset the modified time of included files */	include_file_last_mtime = 0;	if (HANDLER_ERROR == stat_cache_get_entry(srv, con, con->physical.path, &sce)) {		log_error_write(srv, __FILE__, __LINE__,  "SB", "stat_cache_get_entry failed: ", con->physical.path);		return -1;	}	if (-1 == stream_open(&s, con->physical.path)) {		log_error_write(srv, __FILE__, __LINE__, "sb",				"stream-open: ", con->physical.path);		return -1;	}	/**	 * <!--#element attribute=value attribute=value ... -->	 *	 * config       DONE	 *   errmsg     -- missing	 *   sizefmt    DONE	 *   timefmt    DONE	 * echo         DONE	 *   var        DONE	 *   encoding   -- missing	 * exec         DONE	 *   cgi        -- never	 *   cmd        DONE	 * fsize        DONE	 *   file       DONE	 *   virtual    DONE	 * flastmod     DONE	 *   file       DONE	 *   virtual    DONE	 * include      DONE	 *   file       DONE	 *   virtual    DONE	 * printenv     DONE	 * set          DONE	 *   var        DONE	 *   value      DONE	 *	 * if           DONE	 * elif         DONE	 * else         DONE	 * endif        DONE	 *	 *	 * expressions	 * AND, OR      DONE	 * comp         DONE	 * ${...}       -- missing	 * $...         DONE	 * '...'        DONE	 * ( ... )      DONE	 *	 *	 *	 * ** all DONE **	 * DATE_GMT	 *   The current date in Greenwich Mean Time.	 * DATE_LOCAL	 *   The current date in the local time zone.	 * DOCUMENT_NAME	 *   The filename (excluding directories) of the document requested by the user.	 * DOCUMENT_URI	 *   The (%-decoded) URL path of the document requested by the user. Note that in the case of nested include files, this is not then URL for the current document.	 * LAST_MODIFIED	 *   The last modification date of the document requested by the user.	 * USER_NAME	 *   Contains the owner of the file which included it.	 *	 */#ifdef HAVE_PCRE_H	for (i = 0; (n = pcre_exec(p->ssi_regex, NULL, s.start, s.size, i, 0, ovec, N * 3)) > 0; i = ovec[1]) {		const char **l;		/* take everything from last offset to current match pos */		if (!p->if_is_false) chunkqueue_append_file(con->write_queue, con->physical.path, i, ovec[0] - i);//.........这里部分代码省略.........
开发者ID:HitoriSensei,项目名称:lighttpd,代码行数:101,


示例18: li_request_validate_header

gboolean li_request_validate_header(liConnection *con) {	liRequest *req = &con->mainvr->request;	liHttpHeader *hh;	GList *l;	if (con->info.is_ssl) {		g_string_append_len(req->uri.scheme, CONST_STR_LEN("https"));	} else {		g_string_append_len(req->uri.scheme, CONST_STR_LEN("http"));	}	switch (req->http_version) {	case LI_HTTP_VERSION_1_0:		if (!li_http_header_is(req->headers, CONST_STR_LEN("connection"), CONST_STR_LEN("keep-alive")))			con->info.keep_alive = FALSE;		break;	case LI_HTTP_VERSION_1_1:		if (li_http_header_is(req->headers, CONST_STR_LEN("connection"), CONST_STR_LEN("close")))			con->info.keep_alive = FALSE;		break;	case LI_HTTP_VERSION_UNSET:		bad_request(con, 505); /* Version not Supported */		return FALSE;	}	if (req->uri.raw->len == 0) {		bad_request(con, 400); /* bad request */		return FALSE;	}	/* get hostname */	l = li_http_header_find_first(req->headers, CONST_STR_LEN("host"));	if (NULL != l) {		if (NULL != li_http_header_find_next(l, CONST_STR_LEN("host"))) {			/* more than one "host" header */			bad_request(con, 400); /* bad request */			return FALSE;		}		hh = (liHttpHeader*) l->data;		g_string_append_len(req->uri.authority, LI_HEADER_VALUE_LEN(hh));		/* check header after we parsed the url, as it may override uri.authority */	}	/* Need hostname in HTTP/1.1 */	if (req->uri.authority->len == 0 && req->http_version == LI_HTTP_VERSION_1_1) {		bad_request(con, 400); /* bad request */		return FALSE;	}	/* may override hostname */	if (!request_parse_url(con->mainvr)) {		bad_request(con, 400); /* bad request */		return FALSE;	}	if (req->uri.host->len == 0 && req->uri.authority->len != 0) {		if (!li_parse_hostname(&req->uri)) {			bad_request(con, 400); /* bad request */			return FALSE;		}	}	/* remove trailing dots from hostname */	{		guint i = req->uri.host->len;		while (i > 0 && req->uri.host->str[i-1] == '.') i--;		g_string_truncate(req->uri.host, i);	}	/* content-length */	hh = li_http_header_lookup(req->headers, CONST_STR_LEN("content-length"));	if (hh) {		const gchar *val = LI_HEADER_VALUE(hh);		gint64 r;		char *err;		r = g_ascii_strtoll(val, &err, 10);		if (*err != '/0') {			_VR_DEBUG(con->srv, con->mainvr, "content-length is not a number: %s (Status: 400)", err);			bad_request(con, 400); /* bad request */			return FALSE;		}		/**			* negative content-length is not supported			* and is a bad request			*/		if (r < 0) {			bad_request(con, 400); /* bad request */			return FALSE;		}		/**			* check if we had a over- or underrun in the string conversion			*/		if (r == G_MININT64 || r == G_MAXINT64) {			if (errno == ERANGE) {				bad_request(con, 413); /* Request Entity Too Large */				return FALSE;//.........这里部分代码省略.........
开发者ID:lzw978,项目名称:lighttpd2,代码行数:101,


示例19: g_string_sized_new

//.........这里部分代码省略.........				break;			case AL_FORMAT_METHOD:				g_string_append_len(str, GSTR_LEN(req->http_method_str));				break;			case AL_FORMAT_RESPONSE_HEADER:				li_http_header_get_all(vr->wrk->tmp_str, resp->headers, GSTR_LEN(e->key));				if (vr->wrk->tmp_str->len)					al_append_escaped(str, vr->wrk->tmp_str);				else					g_string_append_c(str, '-');				break;			case AL_FORMAT_LOCAL_PORT:				switch (vr->coninfo->local_addr.addr->plain.sa_family) {				case AF_INET: li_string_append_int(str, ntohs(vr->coninfo->local_addr.addr->ipv4.sin_port)); break;				#ifdef HAVE_IPV6				case AF_INET6: li_string_append_int(str, ntohs(vr->coninfo->local_addr.addr->ipv6.sin6_port)); break;				#endif				default: g_string_append_c(str, '-'); break;				}				break;			case AL_FORMAT_QUERY_STRING:				if (req->uri.query->len)					al_append_escaped(str, req->uri.query);				else					g_string_append_c(str, '-');				break;			case AL_FORMAT_FIRST_LINE:				g_string_append_len(str, GSTR_LEN(req->http_method_str));				g_string_append_c(str, ' ');				al_append_escaped(str, req->uri.raw_orig_path);				g_string_append_c(str, ' ');				tmp_str = li_http_version_string(req->http_version, &len);				g_string_append_len(str, tmp_str, len);				break;			case AL_FORMAT_STATUS_CODE:				li_string_append_int(str, resp->http_status);				break;			case AL_FORMAT_TIME:				/* todo: implement format string */				tmp_gstr2 = li_worker_current_timestamp(vr->wrk, LI_LOCALTIME, ald->ts_ndx);				g_string_append_len(str, GSTR_LEN(tmp_gstr2));				break;			case AL_FORMAT_DURATION_SECONDS:				li_string_append_int(str, CUR_TS(vr->wrk) - vr->ts_started);				break;			case AL_FORMAT_AUTHED_USER:				tmp_gstr2 = li_environment_get(&vr->env, CONST_STR_LEN("REMOTE_USER"));				if (tmp_gstr2)					g_string_append_len(str, GSTR_LEN(tmp_gstr2));				else					g_string_append_c(str, '-');				break;			case AL_FORMAT_PATH:				g_string_append_len(str, GSTR_LEN(req->uri.path));				break;			case AL_FORMAT_SERVER_NAME:				if (CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_NAME).string)					g_string_append_len(str, GSTR_LEN(CORE_OPTIONPTR(LI_CORE_OPTION_SERVER_NAME).string));				else					g_string_append_len(str, GSTR_LEN(req->uri.host));				break;			case AL_FORMAT_HOSTNAME:				if (req->uri.host->len)					g_string_append_len(str, GSTR_LEN(req->uri.host));				else					g_string_append_c(str, '-');				break;			case AL_FORMAT_CONNECTION_STATUS: {					/* was request completed? */					liConnection *con = li_connection_from_vrequest(vr); /* try to get a connection object */					if (con && (con->in->is_closed && con->raw_out->is_closed && 0 == con->raw_out->length)) {						g_string_append_c(str, 'X');					} else {						g_string_append_c(str, vr->coninfo->keep_alive ? '+' : '-');					}				}				break;			case AL_FORMAT_BYTES_IN:				li_string_append_int(str, vr->coninfo->stats.bytes_in);				break;			case AL_FORMAT_BYTES_OUT:				li_string_append_int(str, vr->coninfo->stats.bytes_out);				break;			default:				/* not implemented:				{ 'C', FALSE, AL_FORMAT_COOKIE }				{ 't', FALSE, AL_FORMAT_TIME }, (partially implemented)				*/				g_string_append_c(str, '?');				break;			}		} else {			/* append normal string */			g_string_append_len(str, GSTR_LEN(e->key));		}	}	return str;}
开发者ID:soarpenguin,项目名称:lighttpd2,代码行数:101,


示例20: int

/* build NULL-terminated table of name + init-function */typedef struct {	const char* name;	int (*plugin_init)(plugin *p);} plugin_load_functions;static const plugin_load_functions load_functions[] = {#define PLUGIN_INIT(x) /	{ #x, &x ## _plugin_init },#include "plugin-static.h"	{ NULL, NULL }#undef PLUGIN_INIT};int plugins_load(server *srv) {	plugin *p;	size_t i, j;	for (i = 0; i < srv->srvconf.modules->used; i++) {		data_string *d = (data_string *)srv->srvconf.modules->data[i];		char *module = d->value->ptr;		for (j = 0; j < i; j++) {			if (buffer_is_equal(d->value, ((data_string *) srv->srvconf.modules->data[j])->value)) {				log_error_write(srv, __FILE__, __LINE__, "sbs",					"Cannot load plugin", d->value,					"more than once, please fix your config (lighttpd may not accept such configs in future releases)");				continue;			}		}		for (j = 0; load_functions[j].name; ++j) {			if (0 == strcmp(load_functions[j].name, module)) {				p = plugin_init();				if ((*load_functions[j].plugin_init)(p)) {					log_error_write(srv, __FILE__, __LINE__, "ss", module, "plugin init failed" );					plugin_free(p);					return -1;				}				plugins_register(srv, p);				break;			}		}		if (!load_functions[j].name) {			log_error_write(srv, __FILE__, __LINE__, "ss", module, " plugin not found" );			return -1;		}	}	return 0;}#else /* defined(LIGHTTPD_STATIC) */int plugins_load(server *srv) {	plugin *p;	int (*init)(plugin *pl);	size_t i, j;	for (i = 0; i < srv->srvconf.modules->used; i++) {		data_string *d = (data_string *)srv->srvconf.modules->data[i];		char *module = d->value->ptr;		for (j = 0; j < i; j++) {			if (buffer_is_equal(d->value, ((data_string *) srv->srvconf.modules->data[j])->value)) {				log_error_write(srv, __FILE__, __LINE__, "sbs",					"Cannot load plugin", d->value,					"more than once, please fix your config (lighttpd may not accept such configs in future releases)");				continue;			}		}		buffer_copy_buffer(srv->tmp_buf, srv->srvconf.modules_dir);		buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN("/"));		buffer_append_string(srv->tmp_buf, module);#if defined(__WIN32) || defined(__CYGWIN__)		buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN(".dll"));#else		buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN(".so"));#endif		p = plugin_init();#ifdef __WIN32		if (NULL == (p->lib = LoadLibrary(srv->tmp_buf->ptr))) {			LPVOID lpMsgBuf;			FormatMessage(				FORMAT_MESSAGE_ALLOCATE_BUFFER |					FORMAT_MESSAGE_FROM_SYSTEM,				NULL,				GetLastError(),				MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),				(LPTSTR) &lpMsgBuf,				0, NULL);			log_error_write(srv, __FILE__, __LINE__, "ssb", "LoadLibrary() failed",				lpMsgBuf, srv->tmp_buf);			plugin_free(p);//.........这里部分代码省略.........
开发者ID:ikayzo,项目名称:lighttpd1.4,代码行数:101,


示例21: http_response_parse_range

static int http_response_parse_range(server *srv, connection *con, plugin_data *p) {	int multipart = 0;	char *boundary = "fkj49sn38dcn3";	data_string *ds;	stat_cache_entry *sce = NULL;	buffer *content_type = NULL;	buffer *range = NULL;	http_req_range *ranges, *r;	if (NULL != (ds = (data_string *)array_get_element(con->request.headers, CONST_STR_LEN("Range")))) {		range = ds->value;	} else {		/* we don't have a Range header */		return -1;	}	if (HANDLER_ERROR == stat_cache_get_entry(srv, con, con->physical.path, &sce)) {		SEGFAULT("stat_cache_get_entry(%s) returned %d", SAFE_BUF_STR(con->physical.path), HANDLER_ERROR);	}	con->response.content_length = 0;	if (NULL != (ds = (data_string *)array_get_element(con->response.headers, CONST_STR_LEN("Content-Type")))) {		content_type = ds->value;	}	/* start the range-header parser	 * bytes=<num>  */	ranges = p->ranges;	http_request_range_reset(ranges);	switch (http_request_range_parse(range, ranges)) {	case PARSE_ERROR:		return -1; /* no range valid Range Header */	case PARSE_SUCCESS:		break;	default:		TRACE("%s", "foobar");		return -1;	}	if (ranges->next) {		multipart = 1;	}	/* patch the '-1' */	for (r = ranges; r; r = r->next) {		if (r->start == -1) {			/* -<end>			 *			 * the last <end> bytes  */			r->start = sce->st.st_size - r->end;			r->end = sce->st.st_size - 1;		}		if (r->end == -1) {			/* <start>-			 * all but the first <start> bytes */			r->end = sce->st.st_size - 1;		}		if (r->end > sce->st.st_size - 1) {			/* RFC 2616 - 14.35.1			 *			 * if last-byte-pos not present or > size-of-file			 * take the size-of-file			 *			 *  */			r->end = sce->st.st_size - 1;		}		if (r->start > sce->st.st_size - 1) {			/* RFC 2616 - 14.35.1			 *			 * if first-byte-pos > file-size, 416			 */			con->http_status = 416;			return -1;		}		if (r->start > r->end) {			/* RFC 2616 - 14.35.1			 *			 * if last-byte-pos is present, it has to be >= first-byte-pos			 *			 * invalid ranges have to be handle as no Range specified			 *  */			return -1;		}	}	if (r) {		/* we ran into an range violation */		return -1;	}	if (multipart) {//.........这里部分代码省略.........
开发者ID:Fumon,项目名称:lighttpd-Basic-auth-hack,代码行数:101,


示例22: cache_parse_lua

int cache_parse_lua(server *srv, connection *con, plugin_data *p, buffer *fn) {	lua_State *L;	readme rm;	int ret = -1;	buffer *b = buffer_init();	int header_tbl = 0;	rm.done = 0;	stream_open(&rm.st, fn);	/* push the lua file to the interpreter and see what happends */	L = luaL_newstate();	luaL_openlibs(L);	/* register functions */	lua_register(L, "md5", f_crypto_md5);	lua_register(L, "file_mtime", f_file_mtime);	lua_register(L, "file_isreg", f_file_isreg);	lua_register(L, "file_isdir", f_file_isreg);	lua_register(L, "dir_files", f_dir_files);#ifdef HAVE_MEMCACHE_H	lua_pushliteral(L, "memcache_get_long");	lua_pushlightuserdata(L, p->conf.mc);	lua_pushcclosure(L, f_memcache_get_long, 1);	lua_settable(L, LUA_GLOBALSINDEX);	lua_pushliteral(L, "memcache_get_string");	lua_pushlightuserdata(L, p->conf.mc);	lua_pushcclosure(L, f_memcache_get_string, 1);	lua_settable(L, LUA_GLOBALSINDEX);	lua_pushliteral(L, "memcache_exists");	lua_pushlightuserdata(L, p->conf.mc);	lua_pushcclosure(L, f_memcache_exists, 1);	lua_settable(L, LUA_GLOBALSINDEX);#endif	/* register CGI environment */	lua_pushliteral(L, "request");	lua_newtable(L);	lua_settable(L, LUA_GLOBALSINDEX);	lua_pushliteral(L, "request");	header_tbl = lua_gettop(L);	lua_gettable(L, LUA_GLOBALSINDEX);	c_to_lua_push(L, header_tbl, CONST_STR_LEN("REQUEST_URI"), CONST_BUF_LEN(con->request.orig_uri));	c_to_lua_push(L, header_tbl, CONST_STR_LEN("SCRIPT_NAME"), CONST_BUF_LEN(con->uri.path));	c_to_lua_push(L, header_tbl, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(con->physical.path));	c_to_lua_push(L, header_tbl, CONST_STR_LEN("DOCUMENT_ROOT"), CONST_BUF_LEN(con->physical.doc_root));	if (!buffer_is_empty(con->request.pathinfo)) {		c_to_lua_push(L, header_tbl, CONST_STR_LEN("PATH_INFO"), CONST_BUF_LEN(con->request.pathinfo));	}	c_to_lua_push(L, header_tbl, CONST_STR_LEN("CWD"), CONST_BUF_LEN(p->basedir));	c_to_lua_push(L, header_tbl, CONST_STR_LEN("BASEURL"), CONST_BUF_LEN(p->baseurl));	/* register GET parameter */	lua_pushliteral(L, "get");	lua_newtable(L);	lua_settable(L, LUA_GLOBALSINDEX);	lua_pushliteral(L, "get");	header_tbl = lua_gettop(L);	lua_gettable(L, LUA_GLOBALSINDEX);	buffer_copy_string_buffer(b, con->uri.query);	cache_export_get_params(L, header_tbl, b);	buffer_reset(b);	/* 2 default constants */	lua_pushliteral(L, "CACHE_HIT");	lua_pushnumber(L, 0);	lua_settable(L, LUA_GLOBALSINDEX);	lua_pushliteral(L, "CACHE_MISS");	lua_pushnumber(L, 1);	lua_settable(L, LUA_GLOBALSINDEX);	/* load lua program */	if (lua_load(L, load_file, &rm, fn->ptr) || lua_pcall(L,0,1,0)) {		log_error_write(srv, __FILE__, __LINE__, "s",				lua_tostring(L,-1));		goto error;	}	/* get return value */	ret = (int)lua_tonumber(L, -1);	lua_pop(L, 1);	/* fetch the data from lua */	lua_to_c_get_string(L, "trigger_handler", p->trigger_handler);	if (0 == lua_to_c_get_string(L, "output_contenttype", b)) {		response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_BUF_LEN(b));	}	if (ret == 0) {		/* up to now it is a cache-hit, check if all files exist *///.........这里部分代码省略.........
开发者ID:hnwfs,项目名称:lighttpd-plus,代码行数:101,


示例23: mod_dirlisting_patch_connection

static int mod_dirlisting_patch_connection(server *srv, connection *con, plugin_data *p) {	size_t i, j;	plugin_config *s = p->config_storage[0];	PATCH(dir_listing);	PATCH(external_css);	PATCH(hide_dot_files);	PATCH(encoding);	PATCH(show_readme);	PATCH(hide_readme_file);	PATCH(show_header);	PATCH(hide_header_file);	PATCH(excludes);	PATCH(set_footer);	PATCH(encode_readme);	PATCH(encode_header);	PATCH(auto_layout);	/* skip the first, the global context */	for (i = 1; i < srv->config_context->used; i++) {		data_config *dc = (data_config *)srv->config_context->data[i];		s = p->config_storage[i];		/* condition didn't match */		if (!config_check_cond(srv, con, dc)) continue;		/* merge config */		for (j = 0; j < dc->value->used; j++) {			data_unset *du = dc->value->data[j];			if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_ACTIVATE)) ||			    buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_DIR_LISTING))) {				PATCH(dir_listing);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_HIDE_DOTFILES))) {				PATCH(hide_dot_files);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_EXTERNAL_CSS))) {				PATCH(external_css);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_ENCODING))) {				PATCH(encoding);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_SHOW_README))) {				PATCH(show_readme);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_HIDE_README_FILE))) {				PATCH(hide_readme_file);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_SHOW_HEADER))) {				PATCH(show_header);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_HIDE_HEADER_FILE))) {				PATCH(hide_header_file);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_SET_FOOTER))) {				PATCH(set_footer);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_EXCLUDE))) {				PATCH(excludes);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_ENCODE_README))) {				PATCH(encode_readme);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_ENCODE_HEADER))) {				PATCH(encode_header);			} else if (buffer_is_equal_string(du->key, CONST_STR_LEN(CONFIG_AUTO_LAYOUT))) {				PATCH(auto_layout);			}		}	}	return 0;}
开发者ID:cloud-control,项目名称:brownout-lb-lighttpd,代码行数:63,


示例24: http_list_directory_header

static void http_list_directory_header(server *srv, connection *con, plugin_data *p, buffer *out) {	UNUSED(srv);	if (p->conf.auto_layout) {		buffer_append_string_len(out, CONST_STR_LEN(			"<!DOCTYPE html PUBLIC /"-//W3C//DTD XHTML 1.1//EN/" /"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd/">/n"			"<html xmlns=/"http://www.w3.org/1999/xhtml/" xml:lang=/"en/">/n"			"<head>/n"			"<title>Index of "		));		buffer_append_string_encoded(out, CONST_BUF_LEN(con->uri.path), ENCODING_MINIMAL_XML);		buffer_append_string_len(out, CONST_STR_LEN("</title>/n"));		if (p->conf.external_css->used > 1) {			buffer_append_string_len(out, CONST_STR_LEN("<link rel=/"stylesheet/" type=/"text/css/" href=/""));			buffer_append_string_buffer(out, p->conf.external_css);			buffer_append_string_len(out, CONST_STR_LEN("/" />/n"));		} else {			buffer_append_string_len(out, CONST_STR_LEN(				"<style type=/"text/css/">/n"				"a, a:active {text-decoration: none; color: blue;}/n"				"a:visited {color: #48468F;}/n"				"a:hover, a:focus {text-decoration: underline; color: red;}/n"				"body {background-color: #F5F5F5;}/n"				"h2 {margin-bottom: 12px;}/n"				"table {margin-left: 12px;}/n"				"th, td {"				" font: 90% monospace;"				" text-align: left;"				"}/n"				"th {"				" font-weight: bold;"				" padding-right: 14px;"				" padding-bottom: 3px;"				"}/n"				"td {padding-right: 14px;}/n"				"td.s, th.s {text-align: right;}/n"				"div.list {"				" background-color: white;"				" border-top: 1px solid #646464;"				" border-bottom: 1px solid #646464;"				" padding-top: 10px;"				" padding-bottom: 14px;"				"}/n"				"div.foot {"				" font: 90% monospace;"				" color: #787878;"				" padding-top: 4px;"				"}/n"				"</style>/n"			));		}		buffer_append_string_len(out, CONST_STR_LEN("</head>/n<body>/n"));	}	/* HEADER.txt */	if (p->conf.show_header) {		stream s;		/* if we have a HEADER file, display it in <pre class="header"></pre> */		buffer_copy_string_buffer(p->tmp_buf, con->physical.path);		BUFFER_APPEND_SLASH(p->tmp_buf);		buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("HEADER.txt"));		if (-1 != stream_open(&s, p->tmp_buf)) {			if (p->conf.encode_header) {				buffer_append_string_len(out, CONST_STR_LEN("<pre class=/"header/">"));				buffer_append_string_encoded(out, s.start, s.size, ENCODING_MINIMAL_XML);				buffer_append_string_len(out, CONST_STR_LEN("</pre>"));			} else {				buffer_append_string_len(out, s.start, s.size);			}		}		stream_close(&s);	}	buffer_append_string_len(out, CONST_STR_LEN("<h2>Index of "));	buffer_append_string_encoded(out, CONST_BUF_LEN(con->uri.path), ENCODING_MINIMAL_XML);	buffer_append_string_len(out, CONST_STR_LEN(		"</h2>/n"		"<div class=/"list/">/n"		"<table summary=/"Directory Listing/" cellpadding=/"0/" cellspacing=/"0/">/n"		"<thead>"		"<tr>"			"<th class=/"n/">Name</th>"			"<th class=/"m/">Last Modified</th>"			"<th class=/"s/">Size</th>"			"<th class=/"t/">Type</th>"		"</tr>"		"</thead>/n"		"<tbody>/n"		"<tr>"			"<td class=/"n/"><a href=/"..//">Parent Directory</a>/</td>"			"<td class=/"m/">&nbsp;</td>"			"<td class=/"s/">- &nbsp;</td>"			"<td class=/"t/">Directory</td>"		"</tr>/n"	));}
开发者ID:cloud-control,项目名称:brownout-lb-lighttpd,代码行数:100,


示例25: mod_status_handle_server_config

static handler_t mod_status_handle_server_config(server *srv, connection *con, void *p_d) {	plugin_data *p = p_d;	buffer *b, *m = p->module_list;	size_t i;	struct ev_map { fdevent_handler_t et; const char *name; } event_handlers[] =	{		/* - poll is most reliable		 * - select works everywhere		 * - linux-* are experimental		 */#ifdef USE_POLL		{ FDEVENT_HANDLER_POLL,           "poll" },#endif#ifdef USE_SELECT		{ FDEVENT_HANDLER_SELECT,         "select" },#endif#ifdef USE_LINUX_EPOLL		{ FDEVENT_HANDLER_LINUX_SYSEPOLL, "linux-sysepoll" },#endif#ifdef USE_LINUX_SIGIO		{ FDEVENT_HANDLER_LINUX_RTSIG,    "linux-rtsig" },#endif#ifdef USE_SOLARIS_DEVPOLL		{ FDEVENT_HANDLER_SOLARIS_DEVPOLL,"solaris-devpoll" },#endif#ifdef USE_FREEBSD_KQUEUE		{ FDEVENT_HANDLER_FREEBSD_KQUEUE, "freebsd-kqueue" },#endif		{ FDEVENT_HANDLER_UNSET,          NULL }	};	b = chunkqueue_get_append_buffer(con->write_queue);	BUFFER_COPY_STRING_CONST(b,			   "<?xml version=/"1.0/" encoding=/"iso-8859-1/"?>/n"			   "<!DOCTYPE html PUBLIC /"-//W3C//DTD XHTML 1.0 Transitional//EN/"/n"			   "         /"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd/">/n"			   "<html xmlns=/"http://www.w3.org/1999/xhtml/" xml:lang=/"en/" lang=/"en/">/n"			   " <head>/n"			   "  <title>Status</title>/n"			   " </head>/n"			   " <body>/n"			   "  <h1>" PACKAGE_NAME " " PACKAGE_VERSION "</h1>/n"			   "  <table summary=/"status/" border=/"1/">/n");	mod_status_header_append(b, "Server-Features");#ifdef HAVE_PCRE_H	mod_status_row_append(b, "RegEx Conditionals", "enabled");#else	mod_status_row_append(b, "RegEx Conditionals", "disabled - pcre missing");#endif	mod_status_header_append(b, "Network Engine");	for (i = 0; event_handlers[i].name; i++) {		if (event_handlers[i].et == srv->event_handler) {			mod_status_row_append(b, "fd-Event-Handler", event_handlers[i].name);			break;		}	}	mod_status_header_append(b, "Config-File-Settings");	for (i = 0; i < srv->plugins.used; i++) {		plugin **ps = srv->plugins.ptr;		plugin *pl = ps[i];		if (i == 0) {			buffer_copy_string_buffer(m, pl->name);		} else {			BUFFER_APPEND_STRING_CONST(m, "<br />");			buffer_append_string_buffer(m, pl->name);		}	}	mod_status_row_append(b, "Loaded Modules", m->ptr);	BUFFER_APPEND_STRING_CONST(b, "  </table>/n");	BUFFER_APPEND_STRING_CONST(b,		      " </body>/n"		      "</html>/n"		      );	response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html"));	con->http_status = 200;	con->file_finished = 1;	return HANDLER_FINISHED;}
开发者ID:stanlyjohn2,项目名称:webq,代码行数:92,


示例26: http_list_directory

//.........这里部分代码省略.........		 *       so this should actually not be a buffer-overflow-risk		 */		if (i > (size_t)name_max) continue;		memcpy(path_file, dent->d_name, i + 1);		if (stat(path, &st) != 0)			continue;		list = &files;		if (S_ISDIR(st.st_mode))			list = &dirs;		if (list->used == list->size) {			list->size += DIRLIST_BLOB_SIZE;			list->ent   = (dirls_entry_t**) realloc(list->ent, sizeof(dirls_entry_t*) * list->size);			assert(list->ent);		}		tmp = (dirls_entry_t*) malloc(sizeof(dirls_entry_t) + 1 + i);		tmp->mtime = st.st_mtime;		tmp->size  = st.st_size;		tmp->namelen = i;		memcpy(DIRLIST_ENT_NAME(tmp), dent->d_name, i + 1);		list->ent[list->used++] = tmp;	}	closedir(dp);	if (dirs.used) http_dirls_sort(dirs.ent, dirs.used);	if (files.used) http_dirls_sort(files.ent, files.used);	out = chunkqueue_get_append_buffer(con->write_queue);	buffer_copy_string_len(out, CONST_STR_LEN("<?xml version=/"1.0/" encoding=/""));	if (buffer_is_empty(p->conf.encoding)) {		buffer_append_string_len(out, CONST_STR_LEN("iso-8859-1"));	} else {		buffer_append_string_buffer(out, p->conf.encoding);	}	buffer_append_string_len(out, CONST_STR_LEN("/"?>/n"));	http_list_directory_header(srv, con, p, out);	/* directories */	for (i = 0; i < dirs.used; i++) {		tmp = dirs.ent[i];#ifdef HAVE_LOCALTIME_R		localtime_r(&(tmp->mtime), &tm);		strftime(datebuf, sizeof(datebuf), "%Y-%b-%d %H:%M:%S", &tm);#else		strftime(datebuf, sizeof(datebuf), "%Y-%b-%d %H:%M:%S", localtime(&(tmp->mtime)));#endif		buffer_append_string_len(out, CONST_STR_LEN("<tr><td class=/"n/"><a href=/""));		buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_REL_URI_PART);		buffer_append_string_len(out, CONST_STR_LEN("//">"));		buffer_append_string_encoded(out, DIRLIST_ENT_NAME(tmp), tmp->namelen, ENCODING_MINIMAL_XML);		buffer_append_string_len(out, CONST_STR_LEN("</a>/</td><td class=/"m/">"));		buffer_append_string_len(out, datebuf, sizeof(datebuf) - 1);		buffer_append_string_len(out, CONST_STR_LEN("</td><td class=/"s/">- &nbsp;</td><td class=/"t/">Directory</td></tr>/n"));		free(tmp);	}	/* files */	for (i = 0; i < files.used; i++) {
开发者ID:cloud-control,项目名称:brownout-lb-lighttpd,代码行数:67,


示例27: mod_gnutls_con_new

static gboolean mod_gnutls_con_new(liConnection *con, int fd) {	liEventLoop *loop = &con->wrk->loop;	liServer *srv = con->srv;	mod_context *ctx = con->srv_sock->data;	mod_connection_ctx *conctx;	gnutls_session_t session;	int r;	if (GNUTLS_E_SUCCESS > (r = gnutls_init(&session, GNUTLS_SERVER))) {		ERROR(srv, "gnutls_init (%s): %s",			gnutls_strerror_name(r), gnutls_strerror(r));		return FALSE;	}	mod_gnutls_context_acquire(ctx);	if (GNUTLS_E_SUCCESS > (r = gnutls_priority_set(session, ctx->server_priority))) {		ERROR(srv, "gnutls_priority_set (%s): %s",			gnutls_strerror_name(r), gnutls_strerror(r));		goto fail;	}	if (GNUTLS_E_SUCCESS > (r = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, ctx->server_cert))) {		ERROR(srv, "gnutls_credentials_set (%s): %s",			gnutls_strerror_name(r), gnutls_strerror(r));		goto fail;	}	if (NULL != ctx->session_db) {		gnutls_db_set_ptr(session, ctx->session_db);		gnutls_db_set_remove_function(session, session_db_remove_cb);		gnutls_db_set_retrieve_function(session, session_db_retrieve_cb);		gnutls_db_set_store_function(session, session_db_store_cb);	}#ifdef HAVE_SESSION_TICKET	if (GNUTLS_E_SUCCESS > (r = gnutls_session_ticket_enable_server(session, &ctx->ticket_key))) {		ERROR(srv, "gnutls_session_ticket_enable_server (%s): %s",			gnutls_strerror_name(r), gnutls_strerror(r));		goto fail;	}#endif#ifdef GNUTLS_ALPN_MAND	{		static const gnutls_datum_t proto_http1 = { (unsigned char*) CONST_STR_LEN("http/1.1") };		gnutls_alpn_set_protocols(session, &proto_http1, 1, 0);	}#endif	conctx = g_slice_new0(mod_connection_ctx);	conctx->session = session;	conctx->sock_stream = li_iostream_new(con->wrk, fd, tcp_io_cb, conctx);	conctx->client_hello_stream = li_ssl_client_hello_stream(&con->wrk->loop, gnutls_client_hello_cb, conctx);#ifdef USE_SNI	li_job_init(&conctx->sni_job, sni_job_cb);	conctx->sni_jobref = li_job_ref(&con->wrk->loop.jobqueue, &conctx->sni_job);#endif	li_stream_connect(&conctx->sock_stream->stream_in, conctx->client_hello_stream);	conctx->tls_filter = li_gnutls_filter_new(srv, con->wrk, &filter_callbacks, conctx, conctx->session,		conctx->client_hello_stream, &conctx->sock_stream->stream_out);	conctx->con = con;	conctx->ctx = ctx;	con->con_sock.data = conctx;	con->con_sock.callbacks = &gnutls_tcp_cbs;	con->con_sock.raw_out = li_stream_plug_new(loop);	con->con_sock.raw_in = li_stream_plug_new(loop);	con->info.is_ssl = TRUE;	return TRUE;fail:	gnutls_deinit(session);	mod_gnutls_context_release(ctx);	return FALSE;}
开发者ID:lighttpd,项目名称:lighttpd2,代码行数:81,


示例28: http_response_parse_range

//.........这里部分代码省略.........					s = err + 1;					end = le;					start = la;				} else {					/* error */					error = 1;				}			} else {				/* error */				error = 1;			}		}		if (!error) {			if (start < 0) start = 0;			/* RFC 2616 - 14.35.1 */			if (end > sce->st.st_size - 1) end = sce->st.st_size - 1;			if (start > sce->st.st_size - 1) {				error = 1;				con->http_status = 416;			}		}		if (!error) {			if (multipart) {				/* write boundary-header */				buffer *b;				b = chunkqueue_get_append_buffer(con->write_queue);				buffer_copy_string_len(b, CONST_STR_LEN("/r/n--"));				buffer_append_string(b, boundary);				/* write Content-Range */				buffer_append_string_len(b, CONST_STR_LEN("/r/nContent-Range: bytes "));				buffer_append_off_t(b, start);				buffer_append_string_len(b, CONST_STR_LEN("-"));				buffer_append_off_t(b, end);				buffer_append_string_len(b, CONST_STR_LEN("/"));				buffer_append_off_t(b, sce->st.st_size);				buffer_append_string_len(b, CONST_STR_LEN("/r/nContent-Type: "));				buffer_append_string_buffer(b, content_type);				/* write END-OF-HEADER */				buffer_append_string_len(b, CONST_STR_LEN("/r/n/r/n"));				con->response.content_length += b->used - 1;			}			chunkqueue_append_file(con->write_queue, con->physical.path, start, end - start + 1);			con->response.content_length += end - start + 1;		}	}	/* something went wrong */	if (error) return -1;	if (multipart) {		/* add boundary end */		buffer *b;		b = chunkqueue_get_append_buffer(con->write_queue);		buffer_copy_string_len(b, "/r/n--", 4);		buffer_append_string(b, boundary);		buffer_append_string_len(b, "--/r/n", 4);		con->response.content_length += b->used - 1;		/* set header-fields */		buffer_copy_string_len(p->range_buf, CONST_STR_LEN("multipart/byteranges; boundary="));		buffer_append_string(p->range_buf, boundary);		/* overwrite content-type */		response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_BUF_LEN(p->range_buf));	} else {		/* add Content-Range-header */		buffer_copy_string_len(p->range_buf, CONST_STR_LEN("bytes "));		buffer_append_off_t(p->range_buf, start);		buffer_append_string_len(p->range_buf, CONST_STR_LEN("-"));		buffer_append_off_t(p->range_buf, end);		buffer_append_string_len(p->range_buf, CONST_STR_LEN("/"));		buffer_append_off_t(p->range_buf, sce->st.st_size);		response_header_insert(srv, con, CONST_STR_LEN("Content-Range"), CONST_BUF_LEN(p->range_buf));	}	/* ok, the file is set-up */	return 0;}
开发者ID:hnwfs,项目名称:lighttpd-plus,代码行数:101,



注:本文中的CONST_STR_LEN函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CONS_Printf函数代码示例
C++ CONST_S函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。