这篇教程C++ CONST_BUF_LEN函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CONST_BUF_LEN函数的典型用法代码示例。如果您正苦于以下问题:C++ CONST_BUF_LEN函数的具体用法?C++ CONST_BUF_LEN怎么用?C++ CONST_BUF_LEN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CONST_BUF_LEN函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: magnet_env_nextstatic int magnet_env_next(lua_State *L) { server *srv = magnet_get_server(L); connection *con = magnet_get_connection(L); const int pos = lua_tointeger(L, lua_upvalueindex(1)); buffer *dest; /* ignore previous key: use upvalue for current pos */ lua_settop(L, 0); if (NULL == magnet_env[pos].name) return 0; /* end of list */ /* Update our positional upval to reflect our new current position */ lua_pushinteger(L, pos + 1); lua_replace(L, lua_upvalueindex(1)); /* key to return */ lua_pushstring(L, magnet_env[pos].name); /* get value */ dest = magnet_env_get_buffer_by_id(srv, con, magnet_env[pos].type); if (!buffer_is_empty(dest)) { lua_pushlstring(L, CONST_BUF_LEN(dest)); } else { lua_pushnil(L); } /* return 2 items on the stack (key, value) */ return 2;}
开发者ID:jonahglover,项目名称:lighttpd1.4,代码行数:29,
示例2: http_chunk_append_to_tempfilestatic int http_chunk_append_to_tempfile(server *srv, connection *con, const char * mem, size_t len) { chunkqueue * const cq = con->write_queue; if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) { /*http_chunk_append_len(srv, con, len);*/ buffer *b = srv->tmp_chunk_len; buffer_string_set_length(b, 0); buffer_append_uint_hex(b, len); buffer_append_string_len(b, CONST_STR_LEN("/r/n")); if (0 != chunkqueue_append_mem_to_tempfile(srv, cq, CONST_BUF_LEN(b))) { return -1; } } if (0 != chunkqueue_append_mem_to_tempfile(srv, cq, mem, len)) { return -1; } if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) { if (0 != chunkqueue_append_mem_to_tempfile(srv, cq, CONST_STR_LEN("/r/n"))) { return -1; } } return 0;}
开发者ID:HiWong,项目名称:lighttpd1.4,代码行数:28,
示例3: magnet_env_getstatic int magnet_env_get(lua_State *L) { server *srv; connection *con; const char *key = luaL_checkstring(L, 2); buffer *dest = NULL; lua_pushstring(L, "lighty.srv"); lua_gettable(L, LUA_REGISTRYINDEX); srv = lua_touserdata(L, -1); lua_pop(L, 1); lua_pushstring(L, "lighty.con"); lua_gettable(L, LUA_REGISTRYINDEX); con = lua_touserdata(L, -1); lua_pop(L, 1); dest = magnet_env_get_buffer(srv, con, key); if (!buffer_is_empty(dest)) { lua_pushlstring(L, CONST_BUF_LEN(dest)); } else { lua_pushnil(L); } return 1;}
开发者ID:kraj,项目名称:lighttpd-1.x,代码行数:27,
示例4: magnet_array_next/* Define a function that will iterate over an array* (in upval 1) using current position (upval 2) */static int magnet_array_next(lua_State *L) { data_unset *du; data_string *ds; data_integer *di; size_t pos = lua_tointeger(L, lua_upvalueindex(1)); array *a = lua_touserdata(L, lua_upvalueindex(2)); lua_settop(L, 0); if (pos >= a->used) return 0; if (NULL != (du = a->data[pos])) { lua_pushlstring(L, CONST_BUF_LEN(du->key)); switch (du->type) { case TYPE_STRING: ds = (data_string *)du; if (!buffer_is_empty(ds->value)) { lua_pushlstring(L, CONST_BUF_LEN(ds->value)); } else { lua_pushnil(L); } break; case TYPE_COUNT: case TYPE_INTEGER: di = (data_integer *)du; lua_pushinteger(L, di->value); break; default: lua_pushnil(L); break; } /* Update our positional upval to reflect our new current position */ pos++; lua_pushinteger(L, pos); lua_replace(L, lua_upvalueindex(1)); /* Returning 2 items on the stack (key, value) */ return 2; } return 0;}
开发者ID:jonahglover,项目名称:lighttpd1.4,代码行数:43,
示例5: http_list_directory_footerstatic 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,
示例6: log_writestatic void log_write(server *srv, buffer *b) { switch(srv->errorlog_mode) { case ERRORLOG_PIPE: case ERRORLOG_FILE: case ERRORLOG_FD: buffer_append_string_len(b, CONST_STR_LEN("/n")); write_all(srv->errorlog_fd, CONST_BUF_LEN(b)); break; case ERRORLOG_SYSLOG: syslog(LOG_ERR, "%s", b->ptr); break; }}
开发者ID:glensc,项目名称:lighttpd,代码行数:13,
示例7: magnet_cgi_getstatic int magnet_cgi_get(lua_State *L) { connection *con = magnet_get_connection(L); data_string *ds; /* __index: param 1 is the (empty) table the value was not found in */ const char *key = luaL_checkstring(L, 2); ds = (data_string *)array_get_element(con->environment, key); if (NULL != ds && !buffer_is_empty(ds->value)) lua_pushlstring(L, CONST_BUF_LEN(ds->value)); else lua_pushnil(L); return 1;}
开发者ID:jonahglover,项目名称:lighttpd1.4,代码行数:15,
示例8: magnet_reqhdr_getstatic int magnet_reqhdr_get(lua_State *L) { connection *con = magnet_get_connection(L); data_string *ds; /* __index: param 1 is the (empty) table the value was not found in */ const char *key = luaL_checkstring(L, 2); if (NULL != (ds = (data_string *)array_get_element(con->request.headers, key))) { if (!buffer_is_empty(ds->value)) { lua_pushlstring(L, CONST_BUF_LEN(ds->value)); } else { lua_pushnil(L); } } else { lua_pushnil(L); } return 1;}
开发者ID:jonahglover,项目名称:lighttpd1.4,代码行数:18,
示例9: magnet_env_getstatic int magnet_env_get(lua_State *L) { server *srv = magnet_get_server(L); connection *con = magnet_get_connection(L); /* __index: param 1 is the (empty) table the value was not found in */ const char *key = luaL_checkstring(L, 2); buffer *dest = NULL; dest = magnet_env_get_buffer(srv, con, key); if (!buffer_is_empty(dest)) { lua_pushlstring(L, CONST_BUF_LEN(dest)); } else { lua_pushnil(L); } return 1;}
开发者ID:jonahglover,项目名称:lighttpd1.4,代码行数:18,
示例10: magnet_cgi_getstatic int magnet_cgi_get(lua_State *L) { connection *con; data_string *ds; const char *key = luaL_checkstring(L, 2); lua_pushstring(L, "lighty.con"); lua_gettable(L, LUA_REGISTRYINDEX); con = lua_touserdata(L, -1); lua_pop(L, 1); if (NULL != (ds = (data_string *)array_get_element(con->environment, key)) && ds->value->used) lua_pushlstring(L, CONST_BUF_LEN(ds->value)); else lua_pushnil(L); return 1;}
开发者ID:presidentbeef,项目名称:sqwee,代码行数:18,
示例11: smbc_wrapper_response_401void smbc_wrapper_response_401(server *srv, connection *con){ data_string *ds = (data_string *)array_get_element(con->request.headers, "user-Agent"); //- Browser response if( ds && (strstr( ds->value->ptr, "Mozilla" )||strstr( ds->value->ptr, "Opera" )) ){ if(con->mode == SMB_BASIC||con->mode == DIRECT){ Cdbg(DBE, "con->mode == SMB_BASIC -> return 401"); con->http_status = 401; return; } } Cdbg(DBE, "smbc_wrapper_response_401 -> return 401"); char str[50]; UNUSED(srv); buffer* tmp_buf = buffer_init(); if(con->mode == SMB_BASIC){ //sprintf(str, "Basic realm=/"%s/"", "smbdav"); if(con->smb_info&&con->smb_info->server->used) sprintf(str, "Basic realm=/"smb://%s/"", con->smb_info->server->ptr); else sprintf(str, "Basic realm=/"%s/"", "webdav"); } else if(con->mode == SMB_NTLM) sprintf(str, "NTLM"); else sprintf(str, "Basic realm=/"%s/"", "webdav"); buffer_copy_string(tmp_buf, str); response_header_insert(srv, con, CONST_STR_LEN("WWW-Authenticate"), CONST_BUF_LEN(tmp_buf)); con->http_status = 401; buffer_free(tmp_buf);}
开发者ID:heartshare,项目名称:asuswrt-merlin,代码行数:40,
示例12: magnet_reqhdr_getstatic int magnet_reqhdr_get(lua_State *L) { connection *con; data_string *ds; const char *key = luaL_checkstring(L, 2); lua_pushstring(L, "lighty.con"); lua_gettable(L, LUA_REGISTRYINDEX); con = lua_touserdata(L, -1); lua_pop(L, 1); if (NULL != (ds = (data_string *)array_get_element(con->request.headers, key))) { if (!buffer_is_empty(ds->value)) { lua_pushlstring(L, CONST_BUF_LEN(ds->value)); } else { lua_pushnil(L); } } else { lua_pushnil(L); } return 1;}
开发者ID:kraj,项目名称:lighttpd-1.x,代码行数:22,
示例13: magnet_env_nextstatic int magnet_env_next(lua_State *L) { server *srv; connection *con; int pos = lua_tointeger(L, lua_upvalueindex(1)); buffer *dest; lua_pushstring(L, "lighty.srv"); lua_gettable(L, LUA_REGISTRYINDEX); srv = lua_touserdata(L, -1); lua_pop(L, 1); lua_pushstring(L, "lighty.con"); lua_gettable(L, LUA_REGISTRYINDEX); con = lua_touserdata(L, -1); lua_pop(L, 1); lua_settop(L, 0); if (NULL == magnet_env[pos].name) return 0; /* end of list */ lua_pushstring(L, magnet_env[pos].name); dest = magnet_env_get_buffer_by_id(srv, con, magnet_env[pos].type); if (!buffer_is_empty(dest)) { lua_pushlstring(L, CONST_BUF_LEN(dest)); } else { lua_pushnil(L); } /* Update our positional upval to reflect our new current position */ pos++; lua_pushinteger(L, pos); lua_replace(L, lua_upvalueindex(1)); /* Returning 2 items on the stack (key, value) */ return 2;}
开发者ID:kraj,项目名称:lighttpd-1.x,代码行数:38,
示例14: smbc_wrapper_response_realm_401void smbc_wrapper_response_realm_401(server *srv, connection *con){/* if(con->mode == SMB_BASIC){ if(con->smb_info&&con->smb_info->server->used){ Cdbg(DBE, "sssssssss"); con->http_status = 401; } return; } */ char str[50]; UNUSED(srv); buffer* tmp_buf = buffer_init(); if(con->mode == SMB_BASIC){ //sprintf(str, "Basic realm=/"%s/"", "smbdav"); if(con->smb_info&&con->smb_info->server->used) sprintf(str, "Basic realm=/"smb://%s/"", con->smb_info->server->ptr); else sprintf(str, "Basic realm=/"%s/"", "webdav"); } else if(con->mode == SMB_NTLM) sprintf(str, "NTLM"); else sprintf(str, "Basic realm=/"%s/"", "webdav"); buffer_copy_string(tmp_buf, str); response_header_insert(srv, con, CONST_STR_LEN("WWW-Authenticate"), CONST_BUF_LEN(tmp_buf)); con->http_status = 401; buffer_free(tmp_buf);}
开发者ID:heartshare,项目名称:asuswrt-merlin,代码行数:37,
示例15: magnet_statstatic int magnet_stat(lua_State *L) { buffer *sb = magnet_checkbuffer(L, 1); server *srv = magnet_get_server(L); connection *con = magnet_get_connection(L); stat_cache_entry *sce = NULL; handler_t res; res = stat_cache_get_entry(srv, con, sb, &sce); buffer_free(sb); if (HANDLER_GO_ON != res) { lua_pushnil(L); return 1; } lua_newtable(L); // return value lua_pushboolean(L, S_ISREG(sce->st.st_mode)); lua_setfield(L, -2, "is_file"); lua_pushboolean(L, S_ISDIR(sce->st.st_mode)); lua_setfield(L, -2, "is_dir"); lua_pushboolean(L, S_ISCHR(sce->st.st_mode)); lua_setfield(L, -2, "is_char"); lua_pushboolean(L, S_ISBLK(sce->st.st_mode)); lua_setfield(L, -2, "is_block"); lua_pushboolean(L, S_ISSOCK(sce->st.st_mode)); lua_setfield(L, -2, "is_socket"); lua_pushboolean(L, S_ISLNK(sce->st.st_mode)); lua_setfield(L, -2, "is_link"); lua_pushboolean(L, S_ISFIFO(sce->st.st_mode)); lua_setfield(L, -2, "is_fifo"); lua_pushinteger(L, sce->st.st_mtime); lua_setfield(L, -2, "st_mtime"); lua_pushinteger(L, sce->st.st_ctime); lua_setfield(L, -2, "st_ctime"); lua_pushinteger(L, sce->st.st_atime); lua_setfield(L, -2, "st_atime"); lua_pushinteger(L, sce->st.st_uid); lua_setfield(L, -2, "st_uid"); lua_pushinteger(L, sce->st.st_gid); lua_setfield(L, -2, "st_gid"); lua_pushinteger(L, sce->st.st_size); lua_setfield(L, -2, "st_size"); lua_pushinteger(L, sce->st.st_ino); lua_setfield(L, -2, "st_ino"); if (!buffer_string_is_empty(sce->etag)) { /* we have to mutate the etag */ buffer *b = buffer_init(); etag_mutate(b, sce->etag); lua_pushlstring(L, CONST_BUF_LEN(b)); buffer_free(b); } else { lua_pushnil(L); } lua_setfield(L, -2, "etag"); if (!buffer_string_is_empty(sce->content_type)) { lua_pushlstring(L, CONST_BUF_LEN(sce->content_type)); } else { lua_pushnil(L); } lua_setfield(L, -2, "content-type"); return 1;}
开发者ID:jonahglover,项目名称:lighttpd1.4,代码行数:80,
示例16: log_buffer_append_printf/* lowercase: append space, uppercase: don't */static void log_buffer_append_printf(buffer *out, const char *fmt, va_list ap) { for(; *fmt; fmt++) { int d; char *s; buffer *b; off_t o; switch(*fmt) { case 's': /* string */ s = va_arg(ap, char *); buffer_append_string_c_escaped(out, s, (NULL != s) ? strlen(s) : 0); buffer_append_string_len(out, CONST_STR_LEN(" ")); break; case 'b': /* buffer */ b = va_arg(ap, buffer *); buffer_append_string_c_escaped(out, CONST_BUF_LEN(b)); buffer_append_string_len(out, CONST_STR_LEN(" ")); break; case 'd': /* int */ d = va_arg(ap, int); buffer_append_int(out, d); buffer_append_string_len(out, CONST_STR_LEN(" ")); break; case 'o': /* off_t */ o = va_arg(ap, off_t); buffer_append_int(out, o); buffer_append_string_len(out, CONST_STR_LEN(" ")); break; case 'x': /* int (hex) */ d = va_arg(ap, int); buffer_append_string_len(out, CONST_STR_LEN("0x")); buffer_append_uint_hex(out, d); buffer_append_string_len(out, CONST_STR_LEN(" ")); break; case 'S': /* string */ s = va_arg(ap, char *); buffer_append_string_c_escaped(out, s, (NULL != s) ? strlen(s) : 0); break; case 'B': /* buffer */ b = va_arg(ap, buffer *); buffer_append_string_c_escaped(out, CONST_BUF_LEN(b)); break; case 'D': /* int */ d = va_arg(ap, int); buffer_append_int(out, d); break; case 'O': /* off_t */ o = va_arg(ap, off_t); buffer_append_int(out, o); break; case 'X': /* int (hex) */ d = va_arg(ap, int); buffer_append_string_len(out, CONST_STR_LEN("0x")); buffer_append_uint_hex(out, d); break; case '(': case ')': case '<': case '>': case ',': case ' ': buffer_append_string_len(out, fmt, 1); break; } }}
开发者ID:glensc,项目名称:lighttpd,代码行数:67,
示例17: mod_redirect_uri_handlerstatic handler_t mod_redirect_uri_handler(server *srv, connection *con, void *p_data) {#ifdef HAVE_PCRE_H plugin_data *p = p_data; size_t i; /* * REWRITE URL * * e.g. redirect /base/ to /index.php?section=base * */ mod_redirect_patch_connection(srv, con, p); buffer_copy_string_buffer(p->match_buf, con->request.uri); for (i = 0; i < p->conf.redirect->used; i++) { pcre *match; pcre_extra *extra; const char *pattern; size_t pattern_len; int n; pcre_keyvalue *kv = p->conf.redirect->kv[i];# define N 10 int ovec[N * 3]; match = kv->key; extra = kv->key_extra; pattern = kv->value->ptr; pattern_len = kv->value->used - 1; if ((n = pcre_exec(match, extra, p->match_buf->ptr, p->match_buf->used - 1, 0, 0, ovec, 3 * N)) < 0) { if (n != PCRE_ERROR_NOMATCH) { log_error_write(srv, __FILE__, __LINE__, "sd", "execution error while matching: ", n); return HANDLER_ERROR; } } else { const char **list; size_t start, end; size_t k; /* it matched */ pcre_get_substring_list(p->match_buf->ptr, ovec, n, &list); /* search for $[0-9] */ buffer_reset(p->location); start = 0; end = pattern_len; for (k = 0; k < pattern_len; k++) { if ((pattern[k] == '$' || pattern[k] == '%') && isdigit((unsigned char)pattern[k + 1])) { /* got one */ size_t num = pattern[k + 1] - '0'; end = k; buffer_append_string_len(p->location, pattern + start, end - start); if (pattern[k] == '$') { /* n is always > 0 */ if (num < (size_t)n) { buffer_append_string(p->location, list[num]); } } else { config_append_cond_match_buffer(con, p->conf.context, p->location, num); } k++; start = k + 1; } } buffer_append_string_len(p->location, pattern + start, pattern_len - start); pcre_free(list); response_header_insert(srv, con, CONST_STR_LEN("Location"), CONST_BUF_LEN(p->location)); con->http_status = 301; con->file_finished = 1; return HANDLER_FINISHED; } }#undef N#else UNUSED(srv); UNUSED(con); UNUSED(p_data);#endif return HANDLER_GO_ON;}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:97,
示例18: cgi_demux_responsestatic int cgi_demux_response(server *srv, connection *con, plugin_data *p) { cgi_session *sess = con->plugin_ctx[p->id]; switch(srv->network_backend_read(srv, con, sess->sock, sess->rb)) { case NETWORK_STATUS_CONNECTION_CLOSE: fdevent_event_del(srv->ev, sess->sock); /* connection closed. close the read chunkqueue. */ sess->rb->is_closed = 1; case NETWORK_STATUS_SUCCESS: /* we got content */ break; case NETWORK_STATUS_WAIT_FOR_EVENT: return 0; default: /* oops */ ERROR("%s", "oops, read-pipe-read failed and I don't know why"); return -1; } /* looks like we got some content * * split off the header from the incoming stream */ if (con->file_started == 0) { size_t i; int have_content_length = 0; http_response_reset(p->resp); /* the response header is not fully received yet, * * extract the http-response header from the rb-cq */ switch (http_response_parse_cq(sess->rb, p->resp)) { case PARSE_UNSET: case PARSE_ERROR: /* parsing failed */ TRACE("%s", "response parser failed"); con->http_status = 502; /* Bad Gateway */ return -1; case PARSE_NEED_MORE: if (sess->rb->is_closed) { /* backend died before sending a header */ con->http_status = 502; /* Bad Gateway */ return -1; } return 0; case PARSE_SUCCESS: con->http_status = p->resp->status; chunkqueue_remove_finished_chunks(sess->rb); /* copy the http-headers */ for (i = 0; i < p->resp->headers->used; i++) { const char *ign[] = { "Status", "Connection", NULL }; size_t j; data_string *ds; data_string *header = (data_string *)p->resp->headers->data[i]; /* some headers are ignored by default */ for (j = 0; ign[j]; j++) { if (0 == strcasecmp(ign[j], header->key->ptr)) break; } if (ign[j]) continue; if (0 == buffer_caseless_compare(CONST_BUF_LEN(header->key), CONST_STR_LEN("Location"))) { /* CGI/1.1 rev 03 - 7.2.1.2 */ if (con->http_status == 0) con->http_status = 302; } else if (0 == buffer_caseless_compare(CONST_BUF_LEN(header->key), CONST_STR_LEN("Content-Length"))) { have_content_length = 1; } if (NULL == (ds = (data_string *)array_get_unused_element(con->response.headers, TYPE_STRING))) { ds = data_response_init(); } buffer_copy_string_buffer(ds->key, header->key); buffer_copy_string_buffer(ds->value, header->value); array_insert_unique(con->response.headers, (data_unset *)ds); } con->file_started = 1; /* if Status: ... is not set, 200 is our default status-code */ if (con->http_status == 0) con->http_status = 200; sess->state = CGI_STATE_READ_RESPONSE_CONTENT; if (con->request.http_version == HTTP_VERSION_1_1 && !have_content_length) { con->response.transfer_encoding = HTTP_TRANSFER_ENCODING_CHUNKED; } break; } }//.........这里部分代码省略.........
开发者ID:Fumon,项目名称:lighttpd-Basic-auth-hack,代码行数:101,
示例19: cgi_create_envstatic int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *cgi_handler) { pid_t pid;#ifdef HAVE_IPV6 char b2[INET6_ADDRSTRLEN + 1];#endif int to_cgi_fds[2]; int from_cgi_fds[2]; struct stat st;#ifndef __WIN32 if (cgi_handler->used > 1) { /* stat the exec file */ if (-1 == (stat(cgi_handler->ptr, &st))) { log_error_write(srv, __FILE__, __LINE__, "sbss", "stat for cgi-handler", cgi_handler, "failed:", strerror(errno)); return -1; } } if (pipe(to_cgi_fds)) { log_error_write(srv, __FILE__, __LINE__, "ss", "pipe failed:", strerror(errno)); return -1; } if (pipe(from_cgi_fds)) { log_error_write(srv, __FILE__, __LINE__, "ss", "pipe failed:", strerror(errno)); return -1; } /* fork, execve */ switch (pid = fork()) { case 0: { /* child */ char **args; int argc; int i = 0; char buf[32]; size_t n; char_array env; char *c; const char *s; server_socket *srv_sock = con->srv_socket; /* move stdout to from_cgi_fd[1] */ close(STDOUT_FILENO); dup2(from_cgi_fds[1], STDOUT_FILENO); close(from_cgi_fds[1]); /* not needed */ close(from_cgi_fds[0]); /* move the stdin to to_cgi_fd[0] */ close(STDIN_FILENO); dup2(to_cgi_fds[0], STDIN_FILENO); close(to_cgi_fds[0]); /* not needed */ close(to_cgi_fds[1]); /* HACK: * this is not nice, but it works * * we feed the stderr of the CGI to our errorlog, if possible */ if (srv->errorlog_mode == ERRORLOG_FILE) { close(STDERR_FILENO); dup2(srv->errorlog_fd, STDERR_FILENO); } /* create environment */ env.ptr = NULL; env.size = 0; env.used = 0; cgi_env_add(&env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_STR_LEN(PACKAGE_NAME"/"PACKAGE_VERSION)); if (!buffer_is_empty(con->server_name)) { cgi_env_add(&env, CONST_STR_LEN("SERVER_NAME"), CONST_BUF_LEN(con->server_name)); } else {#ifdef HAVE_IPV6 s = inet_ntop(srv_sock->addr.plain.sa_family, srv_sock->addr.plain.sa_family == AF_INET6 ? (const void *) &(srv_sock->addr.ipv6.sin6_addr) : (const void *) &(srv_sock->addr.ipv4.sin_addr), b2, sizeof(b2)-1);#else s = inet_ntoa(srv_sock->addr.ipv4.sin_addr);#endif cgi_env_add(&env, CONST_STR_LEN("SERVER_NAME"), s, strlen(s)); } cgi_env_add(&env, CONST_STR_LEN("GATEWAY_INTERFACE"), CONST_STR_LEN("CGI/1.1")); s = get_http_version_name(con->request.http_version); cgi_env_add(&env, CONST_STR_LEN("SERVER_PROTOCOL"), s, strlen(s)); ltostr(buf,#ifdef HAVE_IPV6//.........这里部分代码省略.........
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:101,
示例20: handle_fragmentstatic void handle_fragment(server *srv, connection *con, void *plugindata){ int err; plugin_data *p = plugindata; off_t range_start, range_end; if (copy_bits_session_id_or_set_error(srv, con)) return; err = get_range(srv, con, con->range_offset, &range_start, &range_end); if (range_start > p->state.abs_off || range_end < p->state.abs_off) { //BITS requests must be contiguious - a Transient error may have occured DEBUGLOG("sooo", "The fragment range is greater than abs_off", range_start, p->state.abs_off, range_end); con->http_status = 416; err = -EINVAL; goto done; } if (((con->range_offset + range_start) < p->state.abs_off) && (range_end > p->state.abs_off)){ DEBUGLOG("sooo", "Fragment Overlaps Abs_off:", con->range_offset + range_start, p->state.abs_off, range_end); //Discard bytes we already have: //discard_bytes(srv, con->request_content_queue, p->state.abs_off - (con->range_offset + range_start)+1); //DEBUGLOG("sos", "Discarded", p->state.abs_off -(range_start + con->range_offset), "bytes"); //con->range_offset = p->state.abs_off - range_start; //DEBUGLOG("so", "Setting range offset - ", con->range_offset); p->state.abs_off = con->range_offset + range_start; DEBUGLOG("so", "Re-adjust abs_off", p->state.abs_off); } /* *PREVIOUS IMPLEMENTATION OF 416 - Discards already written data* if ( range_end < p->state.abs_off ) { DEBUGLOG("soo", "The requests range has already been dealt with", range_start, range_end); //Set the range_offset to be the content_length, to return with a healthy 200 http_status con->range_offset = con->request.content_length; goto done; }*/ DEBUGLOG("so", "Range Offset", con->range_offset); DEBUGLOG("soo","Handling Fragment (start/end)", range_start, range_end); if (err) goto done; while (1) { if (chunkqueue_avail(con->request_content_queue) > range_end - range_start + 1 - con->range_offset) { LOG("sdo", "More data than we want!", chunkqueue_avail(con->request_content_queue), range_end - range_start + 1 - con->range_offset); err = -EINVAL; goto done; } err = process_data(srv, con, p, con->physical.path, con->request_content_queue, range_start); if (err) goto done; if (con->range_offset >= range_end - range_start + 1 || chunkqueue_avail(con->request_content_queue) == 0){ DEBUGLOG("sd", "Leaving for more data", chunkqueue_avail(con->request_content_queue)); break; } }done: /* if (con->range_offset == range_end - range_start + 1) { buffer_reset(p->tmpbuf); if (err) buffer_append_off_t(p->tmpbuf, range_start); else buffer_append_off_t(p->tmpbuf, range_end + 1); DEBUGLOG("sdb", "BITS-Received-Content-Range header length", p->tmpbuf->used, p->tmpbuf); response_header_insert(srv, con, CONST_STR_LEN("BITS-Received-Content-Range"), CONST_BUF_LEN(p->tmpbuf)); } */ DEBUGLOG("so", "Abs_off", p->state.abs_off); if (!err) { DEBUGLOG("s", "Resetting HTTP Status"); con->http_status = 0; return; } if (con->http_status != 416 && con->http_status != 400) con->http_status = 400; if (con->http_status = 416) { buffer_reset(p->tmpbuf); buffer_append_off_t(p->tmpbuf, p->state.abs_off); response_header_insert(srv, con, CONST_STR_LEN("BITS-Received-Content-Range"),//.........这里部分代码省略.........
开发者ID:2xyo,项目名称:transfervm,代码行数:101,
示例21: cgi_create_env//.........这里部分代码省略......... env.ptr = NULL; env.size = 0; env.used = 0; cgi_env_add(&env, CONST_STR_LEN("SERVER_SOFTWARE"), CONST_STR_LEN(PACKAGE_NAME"/"PACKAGE_VERSION)); s = sock_addr_to_p(srv, &srv_sock->addr); cgi_env_add(&env, CONST_STR_LEN("SERVER_ADDR"), s, strlen(s)); /* !!! careful: s maybe reused for SERVER_NAME !!! */ if (!buffer_is_empty(con->server_name)) { size_t len = con->server_name->used - 1; char *colon = strchr(con->server_name->ptr, ':'); if (colon) len = colon - con->server_name->ptr; cgi_env_add(&env, CONST_STR_LEN("SERVER_NAME"), con->server_name->ptr, len); } else { /* use SERVER_ADDR */ cgi_env_add(&env, CONST_STR_LEN("SERVER_NAME"), s, strlen(s)); } cgi_env_add(&env, CONST_STR_LEN("GATEWAY_INTERFACE"), CONST_STR_LEN("CGI/1.1")); s = get_http_version_name(con->request.http_version); cgi_env_add(&env, CONST_STR_LEN("SERVER_PROTOCOL"), s, strlen(s)); LI_ltostr(buf, sock_addr_get_port(&srv_sock->addr)); cgi_env_add(&env, CONST_STR_LEN("SERVER_PORT"), buf, strlen(buf)); s = get_http_method_name(con->request.http_method); cgi_env_add(&env, CONST_STR_LEN("REQUEST_METHOD"), s, strlen(s)); if (!buffer_is_empty(con->request.pathinfo)) { cgi_env_add(&env, CONST_STR_LEN("PATH_INFO"), CONST_BUF_LEN(con->request.pathinfo)); } cgi_env_add(&env, CONST_STR_LEN("REDIRECT_STATUS"), CONST_STR_LEN("200")); if (!buffer_is_empty(con->uri.query)) { cgi_env_add(&env, CONST_STR_LEN("QUERY_STRING"), CONST_BUF_LEN(con->uri.query)); } else { /* set a empty QUERY_STRING */ cgi_env_add(&env, CONST_STR_LEN("QUERY_STRING"), CONST_STR_LEN("")); } if (!buffer_is_empty(con->request.orig_uri)) { cgi_env_add(&env, CONST_STR_LEN("REQUEST_URI"), CONST_BUF_LEN(con->request.orig_uri)); } s = sock_addr_to_p(srv, &con->dst_addr); cgi_env_add(&env, CONST_STR_LEN("REMOTE_ADDR"), s, strlen(s)); LI_ltostr(buf, sock_addr_get_port(&con->dst_addr)); cgi_env_add(&env, CONST_STR_LEN("REMOTE_PORT"), buf, strlen(buf)); if (!buffer_is_empty(con->authed_user)) { cgi_env_add(&env, CONST_STR_LEN("REMOTE_USER"), CONST_BUF_LEN(con->authed_user)); }#ifdef USE_OPENSSL if (srv_sock->is_ssl) { cgi_env_add(&env, CONST_STR_LEN("HTTPS"), CONST_STR_LEN("on")); }#endif /* request.content_length < SSIZE_MAX, see request.c */ if (con->request.content_length > 0) { LI_ltostr(buf, con->request.content_length);
开发者ID:Fumon,项目名称:lighttpd-Basic-auth-hack,代码行数:67,
示例22: http_response_write_headerint http_response_write_header(server *srv, connection *con) { buffer *b; size_t i; int have_date = 0; int have_server = 0; b = chunkqueue_get_prepend_buffer(con->write_queue); if (con->request.http_version == HTTP_VERSION_1_1) { buffer_copy_string_len(b, CONST_STR_LEN("HTTP/1.1 ")); } else { buffer_copy_string_len(b, CONST_STR_LEN("HTTP/1.0 ")); } buffer_append_long(b, con->http_status); buffer_append_string_len(b, CONST_STR_LEN(" ")); buffer_append_string(b, get_http_status_name(con->http_status)); /* disable keep-alive if requested */ if (con->request_count > con->conf.max_keep_alive_requests || 0 == con->conf.max_keep_alive_idle) { con->keep_alive = 0; } else { con->keep_alive_idle = con->conf.max_keep_alive_idle; } if (con->request.http_version != HTTP_VERSION_1_1 || con->keep_alive == 0) { if (con->keep_alive) { response_header_overwrite(srv, con, CONST_STR_LEN("Connection"), CONST_STR_LEN("keep-alive")); } else { response_header_overwrite(srv, con, CONST_STR_LEN("Connection"), CONST_STR_LEN("close")); } } if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) { response_header_overwrite(srv, con, CONST_STR_LEN("Transfer-Encoding"), CONST_STR_LEN("chunked")); } /* add all headers */ for (i = 0; i < con->response.headers->used; i++) { data_string *ds; ds = (data_string *)con->response.headers->data[i]; if (ds->value->used && ds->key->used && 0 != strncasecmp(ds->key->ptr, CONST_STR_LEN("X-LIGHTTPD-")) && 0 != strncasecmp(ds->key->ptr, CONST_STR_LEN("X-Sendfile"))) { if (0 == strcasecmp(ds->key->ptr, "Date")) have_date = 1; if (0 == strcasecmp(ds->key->ptr, "Server")) have_server = 1; if (0 == strcasecmp(ds->key->ptr, "Content-Encoding") && 304 == con->http_status) continue; buffer_append_string_len(b, CONST_STR_LEN("/r/n")); buffer_append_string_buffer(b, ds->key); buffer_append_string_len(b, CONST_STR_LEN(": "));#if 0 /** * the value might contain newlines, encode them with at least one white-space */ buffer_append_string_encoded(b, CONST_BUF_LEN(ds->value), ENCODING_HTTP_HEADER);#else buffer_append_string_buffer(b, ds->value);#endif } } if (!have_date) { /* HTTP/1.1 requires a Date: header */ buffer_append_string_len(b, CONST_STR_LEN("/r/nDate: ")); /* cache the generated timestamp */ if (srv->cur_ts != srv->last_generated_date_ts) { buffer_prepare_copy(srv->ts_date_str, 255); strftime(srv->ts_date_str->ptr, srv->ts_date_str->size - 1, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&(srv->cur_ts))); srv->ts_date_str->used = strlen(srv->ts_date_str->ptr) + 1; srv->last_generated_date_ts = srv->cur_ts; } buffer_append_string_buffer(b, srv->ts_date_str); } if (!have_server) { if (buffer_is_empty(con->conf.server_tag)) { buffer_append_string_len(b, CONST_STR_LEN("/r/nServer: " PACKAGE_DESC)); } else if (con->conf.server_tag->used > 1) { buffer_append_string_len(b, CONST_STR_LEN("/r/nServer: ")); buffer_append_string_encoded(b, CONST_BUF_LEN(con->conf.server_tag), ENCODING_HTTP_HEADER); } } //- Jerry add 20110923#if EMBEDDED_EANBLE char * ddns_host_n = nvram_get_ddns_host_name(); if(ddns_host_n){ buffer_append_string_len(b, CONST_STR_LEN("/r/nDDNS: ")); buffer_append_string(b, ddns_host_n); }else#endif//.........这里部分代码省略.........
开发者ID:heartshare,项目名称:asuswrt-merlin,代码行数:101,
示例23: mod_status_handle_server_status_html//.........这里部分代码省略......... BUFFER_APPEND_STRING_CONST(b, "r = read, R = read-POST, W = write, h = handle-request/n"); BUFFER_APPEND_STRING_CONST(b, "q = request-start, Q = request-end/n"); BUFFER_APPEND_STRING_CONST(b, "s = response-start, S = response-end/n"); BUFFER_APPEND_STRING_CONST(b, "<b>"); buffer_append_long(b, srv->conns->used); BUFFER_APPEND_STRING_CONST(b, " connections</b>/n"); for (j = 0; j < srv->conns->used; j++) { connection *c = srv->conns->ptr[j]; 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); } 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:miettal,项目名称:armadillo420_standard,代码行数:101,
注:本文中的CONST_BUF_LEN函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CONST_INT_P函数代码示例 C++ CONSTLIT函数代码示例 |