本文整理汇总了C++中buffer_append_string_buffer函数的典型用法代码示例。如果您正苦于以下问题:C++ buffer_append_string_buffer函数的具体用法?C++ buffer_append_string_buffer怎么用?C++ buffer_append_string_buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了buffer_append_string_buffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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 = buffer_init();
/* 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 (!buffer_string_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->uri.scheme->ptr);
/* request header */
for (i = 0; i < con->request.headers->used; i++) {
data_string *ds;
ds = (data_string *)con->request.headers->data[i];
if (!buffer_is_empty(ds->value) && !buffer_is_empty(ds->key)) {
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 += buffer_string_length(b);
chunkqueue_append_buffer(hctx->wb, b);
buffer_free(b);
/* body */
if (con->request.content_length) {
chunkqueue *req_cq = con->request_content_queue;
chunkqueue_steal(hctx->wb, req_cq, req_cq->bytes_in);
}
return 0;
}
开发者ID:automatical,项目名称:lighttpd1.4,代码行数:58,代码来源:mod_proxy.c
示例2: http_list_directory_footer
static void http_list_directory_footer(server *srv, connection *con, plugin_data *p, buffer *out) {
UNUSED(srv);
buffer_append_string_len(out, CONST_STR_LEN(
"</tbody>\n"
"</table>\n"
"</div>\n"
));
if (!buffer_string_is_empty(p->conf.show_readme)) {
/* if we have a README file, display it in <pre class="readme"></pre> */
buffer *rb = p->conf.show_readme;
if (rb->ptr[0] != '/') {
buffer_copy_buffer(p->tmp_buf, con->physical.path);
buffer_append_path_len(p->tmp_buf, CONST_BUF_LEN(p->conf.show_readme));
rb = p->tmp_buf;
}
http_list_directory_include_file(out, con->conf.follow_symlink, rb, "readme", p->conf.encode_readme);
}
if(p->conf.auto_layout) {
buffer_append_string_len(out, CONST_STR_LEN(
"<div class=\"foot\">"
));
if (!buffer_string_is_empty(p->conf.set_footer)) {
buffer_append_string_buffer(out, p->conf.set_footer);
} else {
buffer_append_string_buffer(out, con->conf.server_tag);
}
buffer_append_string_len(out, CONST_STR_LEN(
"</div>\n"
));
if (!buffer_string_is_empty(p->conf.external_js)) {
buffer_append_string_len(out, CONST_STR_LEN("<script type=\"text/javascript\" src=\""));
buffer_append_string_buffer(out, p->conf.external_js);
buffer_append_string_len(out, CONST_STR_LEN("\"></script>\n"));
} else if (buffer_is_empty(p->conf.external_js)) {
http_dirlist_append_js_table_resort(out, con);
}
buffer_append_string_len(out, CONST_STR_LEN(
"</body>\n"
"</html>\n"
));
}
}
开发者ID:gstrauss,项目名称:lighttpd1.4,代码行数:52,代码来源:mod_dirlisting.c
示例3: http_list_directory_footer
static void http_list_directory_footer(server *srv, connection *con, plugin_data *p, buffer *out) {
UNUSED(srv);
buffer_append_string_len(out, CONST_STR_LEN(
"</tbody>\n"
"</table>\n"
"</div>\n"
));
if (p->conf.show_readme) {
stream s;
/* if we have a README file, display it in <pre class="readme"></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("README.txt"));
if (-1 != stream_open(&s, p->tmp_buf)) {
if (p->conf.encode_readme) {
buffer_append_string_len(out, CONST_STR_LEN("<pre class=\"readme\">"));
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);
}
if(p->conf.auto_layout) {
buffer_append_string_len(out, CONST_STR_LEN(
"<div class=\"foot\">"
));
if (p->conf.set_footer->used > 1) {
buffer_append_string_buffer(out, p->conf.set_footer);
} else if (buffer_is_empty(con->conf.server_tag)) {
buffer_append_string_len(out, CONST_STR_LEN(PACKAGE_DESC));
} else {
buffer_append_string_buffer(out, con->conf.server_tag);
}
buffer_append_string_len(out, CONST_STR_LEN(
"</div>\n"
"</body>\n"
"</html>\n"
));
}
}
开发者ID:cloud-control,项目名称:brownout-lb-lighttpd,代码行数:49,代码来源:mod_dirlisting.c
示例4: mod_status_handle_server_statistics
static handler_t mod_status_handle_server_statistics(server *srv, connection *con, void *p_d) {
plugin_data *p = p_d;
buffer *b = p->module_list;
size_t i;
array *st = srv->status;
if (0 == st->used) {
/* we have nothing to send */
con->http_status = 204;
con->file_finished = 1;
return HANDLER_FINISHED;
}
b = chunkqueue_get_append_buffer(con->write_queue);
for (i = 0; i < st->used; i++) {
size_t ndx = st->sorted[i];
buffer_append_string_buffer(b, st->data[ndx]->key);
buffer_append_string(b, ": ");
buffer_append_long(b, ((data_integer *)(st->data[ndx]))->value);
buffer_append_string(b, "\n");
}
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/plain"));
con->http_status = 200;
con->file_finished = 1;
return HANDLER_FINISHED;
}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:32,代码来源:mod_status.c
示例5: mod_status_handle_server_statistics
static handler_t mod_status_handle_server_statistics(server *srv, connection *con, void *p_d) {
buffer *b;
size_t i;
array *st = srv->status;
UNUSED(p_d);
if (0 == st->used) {
/* we have nothing to send */
con->http_status = 204;
con->file_finished = 1;
return HANDLER_FINISHED;
}
b = buffer_init();
for (i = 0; i < st->used; i++) {
size_t ndx = st->sorted[i];
buffer_append_string_buffer(b, st->data[ndx]->key);
buffer_append_string_len(b, CONST_STR_LEN(": "));
buffer_append_int(b, ((data_integer *)(st->data[ndx]))->value);
buffer_append_string_len(b, CONST_STR_LEN("\n"));
}
chunkqueue_append_buffer(con->write_queue, b);
buffer_free(b);
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/plain"));
con->http_status = 200;
con->file_finished = 1;
return HANDLER_FINISHED;
}
开发者ID:automatical,项目名称:lighttpd1.4,代码行数:34,代码来源:mod_status.c
示例6: build_doc_root
static int build_doc_root(server *srv, connection *con, plugin_data *p, buffer *out, buffer *host) {
stat_cache_entry *sce = NULL;
buffer_prepare_copy(out, 128);
if (p->conf.server_root->used) {
buffer_copy_string_buffer(out, p->conf.server_root);
if (host->used) {
/* a hostname has to start with a alpha-numerical character
* and must not contain a slash "/"
*/
char *dp;
BUFFER_APPEND_SLASH(out);
if (NULL == (dp = strchr(host->ptr, ':'))) {
buffer_append_string_buffer(out, host);
} else {
buffer_append_string_len(out, host->ptr, dp - host->ptr);
}
}
BUFFER_APPEND_SLASH(out);
if (p->conf.document_root->used > 2 && p->conf.document_root->ptr[0] == '/') {
buffer_append_string_len(out, p->conf.document_root->ptr + 1, p->conf.document_root->used - 2);
} else {
buffer_append_string_buffer(out, p->conf.document_root);
BUFFER_APPEND_SLASH(out);
}
} else {
buffer_copy_string_buffer(out, con->conf.document_root);
BUFFER_APPEND_SLASH(out);
}
if (HANDLER_ERROR == stat_cache_get_entry(srv, con, out, &sce)) {
if (p->conf.debug) {
log_error_write(srv, __FILE__, __LINE__, "sb",
strerror(errno), out);
}
return -1;
} else if (!S_ISDIR(sce->st.st_mode)) {
return -1;
}
return 0;
}
开发者ID:UIKit0,项目名称:ylem,代码行数:47,代码来源:mod_simple_vhost.c
示例7: data_response_insert_dup
static int data_response_insert_dup(data_unset *dst, data_unset *src) {
data_string *ds_dst = (data_string *)dst;
data_string *ds_src = (data_string *)src;
if (!buffer_is_empty(ds_dst->value)) {
buffer_append_string_len(ds_dst->value, CONST_STR_LEN("\r\n"));
buffer_append_string_buffer(ds_dst->value, ds_dst->key);
buffer_append_string_len(ds_dst->value, CONST_STR_LEN(": "));
buffer_append_string_buffer(ds_dst->value, ds_src->value);
} else {
buffer_copy_buffer(ds_dst->value, ds_src->value);
}
src->free(src);
return 0;
}
开发者ID:carriercomm,项目名称:lighttpd_ported,代码行数:17,代码来源:data_string.c
示例8: buffer_append_long
/* op1 is to be eat/return by this function if success, op1->key is not cared
op2 is left untouch, unreferenced
*/
data_unset *configparser_merge_data(data_unset *op1, const data_unset *op2) {
/* type mismatch */
if (op1->type != op2->type) {
if (op1->type == TYPE_STRING && op2->type == TYPE_INTEGER) {
data_string *ds = (data_string *)op1;
buffer_append_long(ds->value, ((data_integer*)op2)->value);
return op1;
} else if (op1->type == TYPE_INTEGER && op2->type == TYPE_STRING) {
data_string *ds = data_string_init();
buffer_append_long(ds->value, ((data_integer*)op1)->value);
buffer_append_string_buffer(ds->value, ((data_string*)op2)->value);
op1->free(op1);
return (data_unset *)ds;
} else {
fprintf(stderr, "data type mismatch, cannot be merge\n");
return NULL;
}
}
switch (op1->type) {
case TYPE_STRING:
buffer_append_string_buffer(((data_string *)op1)->value, ((data_string *)op2)->value);
break;
case TYPE_INTEGER:
((data_integer *)op1)->value += ((data_integer *)op2)->value;
break;
case TYPE_ARRAY: {
array *dst = ((data_array *)op1)->value;
array *src = ((data_array *)op2)->value;
data_unset *du;
size_t i;
for (i = 0; i < src->used; i ++) {
du = (data_unset *)src->data[i];
if (du) {
array_insert_unique(dst, du->copy(du));
}
}
break;
default:
assert(0);
break;
}
}
return op1;
}
开发者ID:UIKit0,项目名称:ylem,代码行数:49,代码来源:configparser.c
示例9: http_list_directory_footer
static void http_list_directory_footer(server *srv, connection *con, plugin_data *p, buffer *out) {
UNUSED(srv);
buffer_append_string_len(out, CONST_STR_LEN(
"</tbody>\n"
"</table>\n"
"</div>\n"
));
if (p->conf.show_readme) {
/* if we have a README file, display it in <pre class="readme"></pre> */
buffer_copy_buffer(p->tmp_buf, con->physical.path);
buffer_append_slash(p->tmp_buf);
buffer_append_string_len(p->tmp_buf, CONST_STR_LEN("README.txt"));
http_list_directory_include_file(out, p->tmp_buf, "readme", p->conf.encode_readme);
}
if(p->conf.auto_layout) {
buffer_append_string_len(out, CONST_STR_LEN(
"<div class=\"foot\">"
));
if (!buffer_string_is_empty(p->conf.set_footer)) {
buffer_append_string_buffer(out, p->conf.set_footer);
} else {
buffer_append_string_buffer(out, con->conf.server_tag);
}
buffer_append_string_len(out, CONST_STR_LEN(
"</div>\n"
"</body>\n"
"</html>\n"
));
}
}
开发者ID:HiWong,项目名称:lighttpd1.4,代码行数:37,代码来源:mod_dirlisting.c
示例10: data_string_insert_dup
static int data_string_insert_dup(data_unset *dst, data_unset *src) {
data_string *ds_dst = (data_string *)dst;
data_string *ds_src = (data_string *)src;
if (ds_dst->value->used) {
buffer_append_string_len(ds_dst->value, CONST_STR_LEN(", "));
buffer_append_string_buffer(ds_dst->value, ds_src->value);
} else {
buffer_copy_string_buffer(ds_dst->value, ds_src->value);
}
src->free(src);
return 0;
}
开发者ID:Fumon,项目名称:lighttpd-Basic-auth-hack,代码行数:15,代码来源:data_string.c
示例11: http_response_finish_header
int http_response_finish_header(server *srv, connection *con)
{
if (NULL == srv || NULL == con || NULL == con -> write_queue)
{
return -1;
}
/*
* 这个header有安全问题。通产默认不添加。
*/
//http_response_insert_header(srv, con, CONST_STR_LEN("Server"), CONST_STR_LEN("Swiftd/0.1 written by hcy"));
buffer *b = chunkqueue_get_prepend_buffer(con -> write_queue);
if (NULL == b)
{
log_error_write(srv, __FILE__, __LINE__, "s", "chunkqueue_get_prepend_buffer failed.");
return -1;
}
buffer_reset(b);
/*
* Status-Line:
* HTTP-Version SP Status-Code SP Reason-Phrase CRLF
*/
buffer_copy_string_len(b, CONST_STR_LEN("HTTP/1.1"));
buffer_append_string_len(b, CONST_STR_LEN(" ")); //SP
buffer_append_long(b, con -> http_status);
buffer_append_string_len(b, CONST_STR_LEN(" ")); //SP
buffer_append_string(b, get_http_status_name(con -> http_status));
buffer_append_string_len(b, CONST_STR_LEN(CRLF)); //CRLF = '\r\n' defined in base.h
if(con -> keep_alive)
{
http_response_insert_header(srv, con, CONST_STR_LEN("Connection")
, CONST_STR_LEN("keep-alive"));
}
else
{
http_response_insert_header(srv, con, CONST_STR_LEN("Connection")
, CONST_STR_LEN("close"));
}
/*
* Headers:
* Key:Value CRLF
*/
size_t i;
data_string *ds;
for (i = 0; i < con -> response.headers -> used; ++i)
{
ds = (data_string *)con -> response.headers -> data[i];
if (NULL == ds)
{
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(CRLF));
}
/*
* header 和 message body之间的CRLF。
*/
buffer_append_string_len(b, CONST_STR_LEN(CRLF));
/*
* 最后一个'\0'不能发送出去!!
*/
-- b -> used;
log_error_write(srv, __FILE__, __LINE__, "sb", "Response Headers:", b);
array_reset(con -> response.headers);
return 0;
}
开发者ID:kernelhcy,项目名称:swiftd,代码行数:78,代码来源:response.c
示例12: cgi_demux_response
static int cgi_demux_response(server *srv, handler_ctx *hctx) {
plugin_data *p = hctx->plugin_data;
connection *con = hctx->remote_conn;
while(1) {
int n;
buffer_prepare_copy(hctx->response, 1024);
if (-1 == (n = read(hctx->fd, hctx->response->ptr, hctx->response->size - 1))) {
if (errno == EAGAIN || errno == EINTR) {
/* would block, wait for signal */
return FDEVENT_HANDLED_NOT_FINISHED;
}
/* error */
log_error_write(srv, __FILE__, __LINE__, "sdd", strerror(errno), con->fd, hctx->fd);
return FDEVENT_HANDLED_ERROR;
}
if (n == 0) {
/* read finished */
con->file_finished = 1;
/* send final chunk */
http_chunk_append_mem(srv, con, NULL, 0);
joblist_append(srv, con);
return FDEVENT_HANDLED_FINISHED;
}
hctx->response->ptr[n] = '\0';
hctx->response->used = n+1;
/* split header from body */
if (con->file_started == 0) {
char *c;
int in_header = 0;
int header_end = 0;
int cp, eol = EOL_UNSET;
size_t used = 0;
buffer_append_string_buffer(hctx->response_header, hctx->response);
/* nph (non-parsed headers) */
if (0 == strncmp(hctx->response_header->ptr, "HTTP/1.", 7)) in_header = 1;
/* search for the \r\n\r\n or \n\n in the string */
for (c = hctx->response_header->ptr, cp = 0, used = hctx->response_header->used - 1; used; c++, cp++, used--) {
if (*c == ':') in_header = 1;
else if (*c == '\n') {
if (in_header == 0) {
/* got a response without a response header */
c = NULL;
header_end = 1;
break;
}
if (eol == EOL_UNSET) eol = EOL_N;
if (*(c+1) == '\n') {
header_end = 1;
break;
}
} else if (used > 1 && *c == '\r' && *(c+1) == '\n') {
if (in_header == 0) {
/* got a response without a response header */
c = NULL;
header_end = 1;
break;
}
if (eol == EOL_UNSET) eol = EOL_RN;
if (used > 3 &&
*(c+2) == '\r' &&
*(c+3) == '\n') {
header_end = 1;
break;
}
/* skip the \n */
c++;
cp++;
used--;
}
}
if (header_end) {
if (c == NULL) {
/* no header, but a body */
if (con->request.http_version == HTTP_VERSION_1_1) {
con->response.transfer_encoding = HTTP_TRANSFER_ENCODING_CHUNKED;
}
http_chunk_append_mem(srv, con, hctx->response_header->ptr, hctx->response_header->used);
//.........这里部分代码省略.........
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:101,代码来源:mod_cgi.c
示例13: config_set_defaults
int config_set_defaults(server *srv) {
size_t i;
specific_config *s = srv->config_storage[0];
struct stat st1, st2;
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" },
{ FDEVENT_HANDLER_FREEBSD_KQUEUE, "kqueue" },
#endif
{ FDEVENT_HANDLER_UNSET, NULL }
};
if (buffer_is_empty(s->document_root)) {
log_error_write(srv, __FILE__, __LINE__, "s",
"a default document-root has to be set");
return -1;
}
if (buffer_is_empty(srv->srvconf.changeroot)) {
if (-1 == stat(s->document_root->ptr, &st1)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"base-docroot doesn't exist:",
s->document_root);
return -1;
}
} else {
buffer_copy_string_buffer(srv->tmp_buf, srv->srvconf.changeroot);
buffer_append_string_buffer(srv->tmp_buf, s->document_root);
if (-1 == stat(srv->tmp_buf->ptr, &st1)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"base-docroot doesn't exist:",
srv->tmp_buf);
return -1;
}
}
buffer_copy_string_buffer(srv->tmp_buf, s->document_root);
buffer_to_lower(srv->tmp_buf);
if (0 == stat(srv->tmp_buf->ptr, &st1)) {
int is_lower = 0;
is_lower = buffer_is_equal(srv->tmp_buf, s->document_root);
/* lower-case existed, check upper-case */
buffer_copy_string_buffer(srv->tmp_buf, s->document_root);
buffer_to_upper(srv->tmp_buf);
/* we have to handle the special case that upper and lower-casing results in the same filename
* as in server.document-root = "/" or "/12345/" */
if (is_lower && buffer_is_equal(srv->tmp_buf, s->document_root)) {
/* lower-casing and upper-casing didn't result in
* an other filename, no need to stat(),
* just assume it is case-sensitive. */
s->force_lowercase_filenames = 0;
} else if (0 == stat(srv->tmp_buf->ptr, &st2)) {
/* upper case exists too, doesn't the FS handle this ? */
/* upper and lower have the same inode -> case-insensitve FS */
if (st1.st_ino == st2.st_ino) {
/* upper and lower have the same inode -> case-insensitve FS */
s->force_lowercase_filenames = 1;
}
}
//.........这里部分代码省略.........
开发者ID:presidentbeef,项目名称:sqwee,代码行数:101,代码来源:configfile.c
示例14: log_error_write
/**
* 输出日志.
* 日志的格式:
* 2009-11-25 22:31:25: (filename.line) information
*
* 参数fmt的说明如下:
* 's':字符串 'b':buffer 'd':int 'o':off_t 'x':int的十六进制
* 上面的几个参数,在输出相应的值后都追加一个空格' '。
* 如果参数为大写,则不追加空格。
*
*/
int log_error_write(server * srv, const char *filename, unsigned int line,
const char *fmt, ...)
{
pthread_mutex_lock(&srv -> log_lock);
va_list ap;
switch (srv->errorlog_mode)
{
case ERRORLOG_FILE:
case ERRORLOG_STDERR:
/*
* 日志文件和标准错误输出要设定日志的时间。
*/
if (srv->cur_ts != srv->last_generated_debug_ts)
{
buffer_prepare_copy(srv->ts_debug_str, 1024);
strftime(srv->ts_debug_str->ptr, srv->ts_debug_str->size - 1,
"%Y-%m-%d %H:%M:%S", localtime(&(srv->cur_ts)));
srv->ts_debug_str->used = strlen(srv->ts_debug_str->ptr) + 1;
srv->last_generated_debug_ts = srv->cur_ts;
}
buffer_copy_string_buffer(srv->errorlog_buf, srv->ts_debug_str);
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(": ("));
break;
case ERRORLOG_SYSLOG:
/*
* syslog自己产生时间
*/
buffer_copy_string_len(srv->errorlog_buf, CONST_STR_LEN("("));
break;
}
buffer_append_string(srv->errorlog_buf, filename);
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("."));
buffer_append_long(srv->errorlog_buf, line);
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(") "));
//根据字符串fmt来遍历可变参数。
for (va_start(ap, fmt); *fmt; fmt++)
{
int d;
char *s;
buffer *b;
off_t o;
switch (*fmt)
{
case 's': /* string */
s = va_arg(ap, char *);
buffer_append_string(srv->errorlog_buf, s);
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" "));
break;
case 'b': /* buffer */
b = va_arg(ap, buffer *);
buffer_append_string_buffer(srv->errorlog_buf, b);
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" "));
break;
case 'd': /* int */
d = va_arg(ap, int);
buffer_append_long(srv->errorlog_buf, d);
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" "));
break;
case 'o': /* off_t */
o = va_arg(ap, off_t);
buffer_append_off_t(srv->errorlog_buf, o);
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" "));
break;
case 'x': /* int (hex) */
d = va_arg(ap, int);
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN("0x"));
buffer_append_long_hex(srv->errorlog_buf, d);
buffer_append_string_len(srv->errorlog_buf, CONST_STR_LEN(" "));
break;
case 'S': /* string */
s = va_arg(ap, char *);
buffer_append_string(srv->errorlog_buf, s);
break;
case 'B': /* buffer */
b = va_arg(ap, buffer *);
buffer_append_string_buffer(srv->errorlog_buf, b);
break;
case 'D': /* int */
d = va_arg(ap, int);
buffer_append_long(srv->errorlog_buf, d);
break;
case 'O': /* off_t */
o = va_arg(ap, off_t);
//.........这里部分代码省略.........
开发者ID:kernelhcy,项目名称:swiftd,代码行数:101,代码来源:log.c
示例15: cgi_demux_response
static int cgi_demux_response(server *srv, handler_ctx *hctx) {
plugin_data *p = hctx->plugin_data;
connection *con = hctx->remote_conn;
while(1) {
int n;
int toread;
#if defined(__WIN32)
buffer_prepare_copy(hctx->response, 4 * 1024);
#else
if (ioctl(con->fd, FIONREAD, &toread) || toread == 0 || toread <= 4*1024) {
buffer_prepare_copy(hctx->response, 4 * 1024);
} else {
if (toread > MAX_READ_LIMIT) toread = MAX_READ_LIMIT;
buffer_prepare_copy(hctx->response, toread + 1);
}
#endif
if (-1 == (n = read(hctx->fd, hctx->response->ptr, hctx->response->size - 1))) {
if (errno == EAGAIN || errno == EINTR) {
/* would block, wait for signal */
return FDEVENT_HANDLED_NOT_FINISHED;
}
/* error */
log_error_write(srv, __FILE__, __LINE__, "sdd", strerror(errno), con->fd, hctx->fd);
return FDEVENT_HANDLED_ERROR;
}
if (n == 0) {
/* read finished */
con->file_finished = 1;
/* send final chunk */
http_chunk_append_mem(srv, con, NULL, 0);
joblist_append(srv, con);
return FDEVENT_HANDLED_FINISHED;
}
hctx->response->ptr[n] = '\0';
hctx->response->used = n+1;
/* split header from body */
if (con->file_started == 0) {
int is_header = 0;
int is_header_end = 0;
size_t last_eol = 0;
size_t i;
buffer_append_string_buffer(hctx->response_header, hctx->response);
/**
* we have to handle a few cases:
*
* nph:
*
* HTTP/1.0 200 Ok\n
* Header: Value\n
* \n
*
* CGI:
* Header: Value\n
* Status: 200\n
* \n
*
* and different mixes of \n and \r\n combinations
*
* Some users also forget about CGI and just send a response and hope
* we handle it. No headers, no header-content seperator
*
*/
/* nph (non-parsed headers) */
if (0 == strncmp(hctx->response_header->ptr, "HTTP/1.", 7)) is_header = 1;
for (i = 0; !is_header_end && i < hctx->response_header->used - 1; i++) {
char c = hctx->response_header->ptr[i];
switch (c) {
case ':':
/* we found a colon
*
* looks like we have a normal header
*/
is_header = 1;
break;
case '\n':
/* EOL */
if (is_header == 0) {
/* we got a EOL but we don't seem to got a HTTP header */
is_header_end = 1;
break;
}
/**
//.........这里部分代码省略.........
开发者ID:routelastresort,项目名称:lighttpd-for-juise,代码行数:101,代码来源:mod_cgi.c
示例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,代码来源:mod_proxy.c
示例17: 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:miettal,项目名称:armadillo420_standard,代码行数:92,代码来源:mod_status.c
示例18: 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,代码来源:mod_rrdtool.c
示例19: mod_status_handle_server_status_html
//.........这里部分代码省略.........
" rows[j-1] = table.rows[j];\n"
" sort_column = lnk.parentNode.cellIndex;\n"
" rows.sort(sortfn);\n");
BUFFER_APPEND_STRING_CONST(b,
" if (prev_span != null) prev_span.innerHTML = '';\n"
" if (span.getAttribute('sortdir')=='down') {\n"
" span.innerHTML = '↑';\n"
" span.setAttribute('sortdir','up');\n"
" rows.reverse();\n"
" } else {\n"
" span.innerHTML = '↓';\n"
" span.setAttribute('sortdir','down');\n"
" }\n"
" for (i=0;i<rows.length;i++)\n"
" table.tBodies[0].appendChild(rows[i]);\n"
" prev_span = span;\n"
"}\n"
"// -->\n"
"</script>\n");
}
BUFFER_APPEND_STRING_CONST(b,
" </head>\n"
" <body>\n");
/* connection listing */
BUFFER_APPEND_STRING_CONST(b, "<h1>Server-Status</h1>");
BUFFER_APPEND_STRING_CONST(b, "<table summary=\"status\" class=\"status\">");
BUFFER_APPEND_STRING_CONST(b, "<tr><td>Hostname</td><td class=\"string\">");
buffer_append_string_buffer(b, con->uri.authority);
BUFFER_APPEND_STRING_CONST(b, " (");
buffer_append_string_buffer(b, con->server_name);
BUFFER_APPEND_STRING_CONST(b, ")</td></tr>\n");
BUFFER_APPEND_STRING_CONST(b, "<tr><td>Uptime</td><td class=\"string\">");
ts = srv->cur_ts - srv->startup_ts;
days = ts / (60 * 60 * 24);
ts %= (60 * 60 * 24);
hours = ts / (60 * 60);
ts %= (60 * 60);
mins = ts / (60);
ts %= (60);
seconds = ts;
if (days) {
buffer_append_long(b, days);
BUFFER_APPEND_STRING_CONST(b, " days ");
}
if (hours) {
buffer_append_long(b, hours);
BUFFER_APPEND_STRING_CONST(b, " hours ");
}
if (mins) {
buffer_append_long(b, mins);
BUFFER_APPEND_STRING_CONST(b, " min ");
}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:67,代码来源:mod_status.c
示例20: http_response_write_header
-
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:18148|2023-10-27
-
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9634|2022-11-06
-
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8161|2022-11-06
-
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8538|2022-11-06
-
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8440|2022-11-06
-
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9360|2022-11-06
-
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8410|2022-11-06
-
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7848|2022-11-06
-
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8395|2022-11-06
-
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7387|2022-11-06
|
请发表评论