本文整理汇总了C++中buffer_copy_buffer函数的典型用法代码示例。如果您正苦于以下问题:C++ buffer_copy_buffer函数的具体用法?C++ buffer_copy_buffer怎么用?C++ buffer_copy_buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了buffer_copy_buffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: cache_call_lua
static int cache_call_lua(server *srv, connection *con, plugin_data *p, buffer *cml_file) {
buffer *b;
char *c;
/* cleanup basedir */
b = p->baseurl;
buffer_copy_buffer(b, con->uri.path);
for (c = b->ptr + buffer_string_length(b); c > b->ptr && *c != '/'; c--);
if (*c == '/') {
buffer_string_set_length(b, c - b->ptr + 1);
}
b = p->basedir;
buffer_copy_buffer(b, con->physical.path);
for (c = b->ptr + buffer_string_length(b); c > b->ptr && *c != '/'; c--);
if (*c == '/') {
buffer_string_set_length(b, c - b->ptr + 1);
}
/* prepare variables
* - cookie-based
* - get-param-based
*/
return cache_parse_lua(srv, con, p, cml_file);
}
开发者ID:AndreLouisCaron,项目名称:lighttpd,代码行数:28,代码来源:mod_cml.c
示例2: mod_vhostdb_found
static handler_t mod_vhostdb_found (connection *con, vhostdb_entry *ve)
{
/* fix virtual server and docroot */
buffer_copy_buffer(con->server_name, ve->server_name);
buffer_copy_buffer(con->physical.doc_root, ve->document_root);
return HANDLER_GO_ON;
}
开发者ID:ikayzo,项目名称:lighttpd1.4,代码行数:7,代码来源:mod_vhostdb.c
示例3: data_string_init
static data_unset *data_string_copy(const data_unset *s) {
data_string *src = (data_string *)s;
data_string *ds = data_string_init();
buffer_copy_buffer(ds->key, src->key);
buffer_copy_buffer(ds->value, src->value);
ds->is_index_key = src->is_index_key;
return (data_unset *)ds;
}
开发者ID:carriercomm,项目名称:lighttpd_ported,代码行数:9,代码来源:data_string.c
示例4: data_fastcgi_init
static data_unset *data_fastcgi_copy(const data_unset *s) {
data_fastcgi *src = (data_fastcgi *)s;
data_fastcgi *ds = data_fastcgi_init();
buffer_copy_buffer(ds->key, src->key);
buffer_copy_buffer(ds->host, src->host);
ds->is_index_key = src->is_index_key;
return (data_unset *)ds;
}
开发者ID:carriercomm,项目名称:lighttpd_ported,代码行数:9,代码来源:data_fastcgi.c
示例5: run_buffer_path_simplify
static void run_buffer_path_simplify(buffer *psrc, buffer *pdest, const char *in, size_t in_len, const char *out, size_t out_len) {
buffer_copy_string_len(psrc, in, in_len);
buffer_path_simplify(pdest, psrc);
if (!buffer_is_equal_string(pdest, out, out_len)) {
fprintf(stderr,
"%s.%d: buffer_path_simplify('%s') failed: expected '%s', got '%s'\n",
__FILE__,
__LINE__,
in,
out,
pdest->ptr ? pdest->ptr : "");
fflush(stderr);
abort();
} else {
if (psrc != pdest) buffer_copy_buffer(psrc, pdest);
buffer_path_simplify(pdest, psrc);
if (!buffer_is_equal_string(pdest, out, out_len)) {
fprintf(stderr,
"%s.%d: buffer_path_simplify('%s') failed - not idempotent: expected '%s', got '%s'\n",
__FILE__,
__LINE__,
in,
out,
pdest->ptr ? pdest->ptr : "");
fflush(stderr);
abort();
}
}
}
开发者ID:gstrauss,项目名称:lighttpd1.4,代码行数:32,代码来源:test_buffer.c
示例6: log_buffer_prepare
static int log_buffer_prepare(buffer *b, server *srv, const char *filename, unsigned int line) {
switch(srv->errorlog_mode) {
case ERRORLOG_PIPE:
case ERRORLOG_FILE:
case ERRORLOG_FD:
if (-1 == srv->errorlog_fd) return -1;
/* cache the generated timestamp */
if (srv->cur_ts != srv->last_generated_debug_ts) {
buffer_string_prepare_copy(srv->ts_debug_str, 255);
buffer_append_strftime(srv->ts_debug_str, "%Y-%m-%d %H:%M:%S", localtime(&(srv->cur_ts)));
srv->last_generated_debug_ts = srv->cur_ts;
}
buffer_copy_buffer(b, srv->ts_debug_str);
buffer_append_string_len(b, CONST_STR_LEN(": ("));
break;
case ERRORLOG_SYSLOG:
/* syslog is generating its own timestamps */
buffer_copy_string_len(b, CONST_STR_LEN("("));
break;
}
buffer_append_string(b, filename);
buffer_append_string_len(b, CONST_STR_LEN("."));
buffer_append_int(b, line);
buffer_append_string_len(b, CONST_STR_LEN(") "));
return 0;
}
开发者ID:glensc,项目名称:lighttpd,代码行数:30,代码来源:log.c
示例7: excludes_buffer_append
static int excludes_buffer_append(excludes_buffer *exb, buffer *string) {
size_t i;
const char *errptr;
int erroff;
if (!string) return -1;
if (exb->used == exb->size) {
exb->size += 4;
exb->ptr = realloc(exb->ptr, exb->size * sizeof(*exb->ptr));
for(i = exb->used; i < exb->size; i++) {
exb->ptr[i] = calloc(1, sizeof(**exb->ptr));
}
}
if (NULL == (exb->ptr[exb->used]->regex = pcre_compile(string->ptr, 0,
&errptr, &erroff, NULL))) {
return -1;
}
exb->ptr[exb->used]->string = buffer_init();
buffer_copy_buffer(exb->ptr[exb->used]->string, string);
exb->used++;
return 0;
}
开发者ID:gstrauss,项目名称:lighttpd1.4,代码行数:30,代码来源:mod_dirlisting.c
示例8: connection_map_insert
static int connection_map_insert(connection_map *cm, connection *con, buffer *con_id) {
connection_map_entry *cme;
size_t i;
if (cm->size == 0) {
cm->size = 16;
cm->ptr = malloc(cm->size * sizeof(*(cm->ptr)));
for (i = 0; i < cm->size; i++) {
cm->ptr[i] = NULL;
}
} else if (cm->used == cm->size) {
cm->size += 16;
cm->ptr = realloc(cm->ptr, cm->size * sizeof(*(cm->ptr)));
for (i = cm->used; i < cm->size; i++) {
cm->ptr[i] = NULL;
}
}
if (cm->ptr[cm->used]) {
/* is already alloced, just reuse it */
cme = cm->ptr[cm->used];
} else {
cme = malloc(sizeof(*cme));
}
cme->con_id = buffer_init();
buffer_copy_buffer(cme->con_id, con_id);
cme->con = con;
cm->ptr[cm->used++] = cme;
return 0;
}
开发者ID:jonahglover,项目名称:lighttpd1.4,代码行数:32,代码来源:mod_uploadprogress.c
示例9: mod_simple_vhost_docroot
static handler_t mod_simple_vhost_docroot(server *srv, connection *con, void *p_data) {
plugin_data *p = p_data;
/*
* cache the last successfull translation from hostname (authority) to docroot
* - this saves us a stat() call
*
*/
mod_simple_vhost_patch_connection(srv, con, p);
/* build_doc_root() requires a server_root; skip module if simple-vhost.server-root is not set
* or set to an empty string (especially don't cache any results!)
*/
if (buffer_string_is_empty(p->conf.server_root)) return HANDLER_GO_ON;
if (!buffer_string_is_empty(p->conf.docroot_cache_key) &&
!buffer_string_is_empty(con->uri.authority) &&
buffer_is_equal(p->conf.docroot_cache_key, con->uri.authority)) {
/* cache hit */
buffer_copy_buffer(con->server_name, p->conf.docroot_cache_servername);
buffer_copy_buffer(con->physical.doc_root, p->conf.docroot_cache_value);
} else {
/* build document-root */
if (buffer_string_is_empty(con->uri.authority) ||
build_doc_root(srv, con, p, p->doc_root, con->uri.authority)) {
/* not found, fallback the default-host */
if (0 == build_doc_root(srv, con, p,
p->doc_root,
p->conf.default_host)) {
/* default host worked */
buffer_copy_buffer(con->server_name, p->conf.default_host);
buffer_copy_buffer(con->physical.doc_root, p->doc_root);
/* do not cache default host */
}
return HANDLER_GO_ON;
}
/* found host */
buffer_copy_buffer(con->server_name, con->uri.authority);
buffer_copy_buffer(con->physical.doc_root, p->doc_root);
/* copy to cache */
buffer_copy_buffer(p->conf.docroot_cache_key, con->uri.authority);
buffer_copy_buffer(p->conf.docroot_cache_value, p->doc_root);
buffer_copy_buffer(p->conf.docroot_cache_servername, con->server_name);
}
return HANDLER_GO_ON;
}
开发者ID:automatical,项目名称:lighttpd1.4,代码行数:50,代码来源:mod_simple_vhost.c
示例10: data_array_init
static data_unset *data_array_copy(const data_unset *s) {
data_array *src = (data_array *)s;
data_array *ds = data_array_init();
buffer_copy_buffer(ds->key, src->key);
array_free(ds->value);
ds->value = array_init_array(src->value);
ds->is_index_key = src->is_index_key;
return (data_unset *)ds;
}
开发者ID:Shield-Firewall,项目名称:lighttpd1.4,代码行数:10,代码来源:data_array.c
示例11: 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
示例12: 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_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 (!buffer_string_is_empty(p->conf.set_footer)) {
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:cenbzh,项目名称:lighttpd1.4,代码行数:49,代码来源:mod_dirlisting.c
示例13: 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 (!buffer_is_empty(ds_dst->value)) {
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,代码行数:15,代码来源:data_string.c
示例14: chunkqueue_append_file
void chunkqueue_append_file(chunkqueue *cq, buffer *fn, off_t offset, off_t len) {
chunk *c;
if (0 == len) return;
c = chunkqueue_get_unused_chunk(cq);
c->type = FILE_CHUNK;
buffer_copy_buffer(c->file.name, fn);
c->file.start = offset;
c->file.length = len;
c->offset = 0;
chunkqueue_append_chunk(cq, c);
}
开发者ID:Shield-Firewall,项目名称:lighttpd1.4,代码行数:16,代码来源:chunk.c
示例15: build_doc_root
static int build_doc_root(server *srv, connection *con, plugin_data *p, buffer *out, buffer *host) {
stat_cache_entry *sce = NULL;
force_assert(!buffer_string_is_empty(p->conf.server_root));
buffer_string_prepare_copy(out, 127);
buffer_copy_buffer(out, p->conf.server_root);
if (!buffer_string_is_empty(host)) {
/* 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 (buffer_string_length(p->conf.document_root) > 1 && p->conf.document_root->ptr[0] == '/') {
buffer_append_string_len(out, p->conf.document_root->ptr + 1, buffer_string_length(p->conf.document_root) - 1);
} else {
buffer_append_string_buffer(out, p->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:automatical,项目名称:lighttpd1.4,代码行数:42,代码来源:mod_simple_vhost.c
示例16: 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
示例17: time
lua_State *script_cache_get_script(server *srv, connection *con, script_cache *cache, buffer *name) {
size_t i;
script *sc = NULL;
stat_cache_entry *sce;
for (i = 0; i < cache->used; i++) {
sc = cache->ptr[i];
if (buffer_is_equal(name, sc->name)) {
sc->last_used = time(NULL);
/* oops, the script failed last time */
if (lua_gettop(sc->L) == 0) break;
force_assert(lua_gettop(sc->L) == 1);
if (HANDLER_ERROR == stat_cache_get_entry(srv, con, sc->name, &sce)) {
lua_pop(sc->L, 1); /* pop the old function */
break;
}
if (!buffer_is_equal(sce->etag, sc->etag)) {
/* the etag is outdated, reload the function */
lua_pop(sc->L, 1);
break;
}
force_assert(lua_isfunction(sc->L, -1));
return sc->L;
}
sc = NULL;
}
/* if the script was script already loaded but either got changed or
* failed to load last time */
if (sc == NULL) {
sc = script_init();
if (cache->size == 0) {
cache->size = 16;
cache->ptr = malloc(cache->size * sizeof(*(cache->ptr)));
} else if (cache->used == cache->size) {
cache->size += 16;
cache->ptr = realloc(cache->ptr, cache->size * sizeof(*(cache->ptr)));
}
cache->ptr[cache->used++] = sc;
buffer_copy_buffer(sc->name, name);
sc->L = luaL_newstate();
luaL_openlibs(sc->L);
}
sc->last_used = time(NULL);
if (0 != luaL_loadfile(sc->L, name->ptr)) {
/* oops, an error, return it */
return sc->L;
}
if (HANDLER_GO_ON == stat_cache_get_entry(srv, con, sc->name, &sce)) {
buffer_copy_buffer(sc->etag, sce->etag);
}
force_assert(lua_isfunction(sc->L, -1));
return sc->L;
}
开发者ID:AndreLouisCaron,项目名称:lighttpd,代码行数:71,代码来源:mod_magnet_cache.c
示例18: stat_cache_get_entry
handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_cache_entry **ret_sce) {
#ifdef HAVE_FAM_H
fam_dir_entry *fam_dir = NULL;
int dir_ndx = -1;
splay_tree *dir_node = NULL;
#endif
stat_cache_entry *sce = NULL;
stat_cache *sc;
struct stat st;
size_t k;
int fd;
struct stat lst;
#ifdef DEBUG_STAT_CACHE
size_t i;
#endif
int file_ndx;
splay_tree *file_node = NULL;
*ret_sce = NULL;
/*
* check if the directory for this file has changed
*/
sc = srv->stat_cache;
buffer_copy_buffer(sc->hash_key, name);
buffer_append_int(sc->hash_key, con->conf.follow_symlink);
file_ndx = hashme(sc->hash_key);
sc->files = splaytree_splay(sc->files, file_ndx);
#ifdef DEBUG_STAT_CACHE
for (i = 0; i < ctrl.used; i++) {
if (ctrl.ptr[i] == file_ndx) break;
}
#endif
if (sc->files && (sc->files->key == file_ndx)) {
#ifdef DEBUG_STAT_CACHE
/* it was in the cache */
force_assert(i < ctrl.used);
#endif
/* we have seen this file already and
* don't stat() it again in the same second */
file_node = sc->files;
sce = file_node->data;
/* check if the name is the same, we might have a collision */
if (buffer_is_equal(name, sce->name)) {
if (srv->srvconf.stat_cache_engine == STAT_CACHE_ENGINE_SIMPLE) {
if (sce->stat_ts == srv->cur_ts) {
*ret_sce = sce;
return HANDLER_GO_ON;
}
}
} else {
/* oops, a collision,
*
* file_node is used by the FAM check below to see if we know this file
* and if we can save a stat().
*
* BUT, the sce is not reset here as the entry into the cache is ok, we
* it is just not pointing to our requested file.
*
* */
file_node = NULL;
}
} else {
#ifdef DEBUG_STAT_CACHE
if (i != ctrl.used) {
log_error_write(srv, __FILE__, __LINE__, "xSB",
file_ndx, "was already inserted but not found in cache, ", name);
}
force_assert(i == ctrl.used);
#endif
}
#ifdef HAVE_FAM_H
/* dir-check */
if (srv->srvconf.stat_cache_engine == STAT_CACHE_ENGINE_FAM) {
if (0 != buffer_copy_dirname(sc->dir_name, name)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
"no '/' found in filename:", name);
return HANDLER_ERROR;
}
buffer_copy_buffer(sc->hash_key, sc->dir_name);
buffer_append_int(sc->hash_key, con->conf.follow_symlink);
dir_ndx = hashme(sc->hash_key);
sc->dirs = splaytree_splay(sc->dirs, dir_ndx);
//.........这里部分代码省略.........
开发者ID:automatical,项目名称:lighttpd1.4,代码行数:101,代码来源:stat_cache.c
示例19: mod_redirect_uri_handler
static 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_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 = buffer_string_length(kv->value);
if ((n = pcre_exec(match, extra, CONST_BUF_LEN(p->match_buf), 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;
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;
for (k = 0; k + 1 < pattern_len; k++) {
if (pattern[k] == '$' || pattern[k] == '%') {
/* got one */
size_t num = pattern[k + 1] - '0';
buffer_append_string_len(p->location, pattern + start, k - start);
if (!isdigit((unsigned char)pattern[k + 1])) {
/* enable escape: "%%" => "%", "%a" => "%a", "$$" => "$" */
buffer_append_string_len(p->location, pattern+k, pattern[k] == pattern[k+1] ? 1 : 2);
} else if (pattern[k] == '$') {
/* n is always > 0 */
if (num < (size_t)n) {
buffer_append_string(p->location, list[num]);
}
} else if (p->conf.context == NULL) {
/* we have no context, we are global */
log_error_write(srv, __FILE__, __LINE__, "sb",
"used a rewrite containing a %[0-9]+ in the global scope, ignored:",
kv->value);
} 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 = p->conf.redirect_code > 99 && p->conf.redirect_code < 1000 ? p->conf.redirect_code : 301;
con->mode = DIRECT;
con->file_finished = 1;
return HANDLER_FINISHED;
}
}
#undef N
#else
UNUSED(srv);
UNUSED(con);
UNUSED(p_data);
#endif
//.........这里部分代码省略.........
开发者ID:lilohuang,项目名称:lighttpd1.4,代码行数:101,代码来源:mod_redirect.c
示例20: network_server_init
static int network_server_init(server *srv, buffer *host_token, specific_config *s) {
int val;
socklen_t addr_len;
server_socket *srv_socket;
unsigned int port = 0;
const char *host;
buffer *b;
int err;
#ifdef __WIN32
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
return -1;
}
#endif
err = -1;
srv_socket = calloc(1, sizeof(*srv_socket));
force_assert(NULL != srv_socket);
srv_socket->addr.plain.sa_family = AF_INET; /* default */
srv_socket->fd = -1;
srv_socket->fde_ndx = -1;
srv_socket->srv_token = buffer_init();
buffer_copy_buffer(srv_socket->srv_token, host_token);
b = buffer_init();
buffer_copy_buffer(b, host_token);
host = b->ptr;
if (host[0] == '/') {
/* host is a unix-domain-socket */
#ifdef HAVE_SYS_UN_H
srv_socket->addr.plain.sa_family = AF_UNIX;
#else
log_error_write(srv, __FILE__, __LINE__, "s",
"ERROR: Unix Domain sockets are not supported.");
goto error_free_socket;
#endif
} else {
/* ipv4:port
* [ipv6]:port
*/
size_t len = buffer_string_length(b);
char *sp = NULL;
if (0 == len) {
log_error_write(srv, __FILE__, __LINE__, "s", "value of $SERVER[\"socket\"] must not be empty");
goto error_free_socket;
}
if ((b->ptr[0] == '[' && b->ptr[len-1] == ']') || NULL == (sp = strrchr(b->ptr, ':'))) {
/* use server.port if set in config, or else default from config_set_defaults() */
port = srv->srvconf.port;
sp = b->ptr + len; /* point to '\0' at end of string so end of IPv6 address can be found below */
} else {
/* found ip:port separator at *sp; port doesn't end in ']', so *sp hopefully doesn't split an IPv6 address */
*sp = '\0';
port = strtol(sp+1, NULL, 10);
}
/* check for [ and ] */
if (b->ptr[0] == '[' && *(sp-1) == ']') {
*(sp-1) = '\0';
host++;
s->use_ipv6 = 1;
}
if (port == 0 || port > 65535) {
log_error_write(srv, __FILE__, __LINE__, "sd", "port not set or out of range:", port);
goto error_free_socket;
}
}
if (*host == '\0') host = NULL;
#ifdef HAVE_IPV6
if (s->use_ipv6) {
srv_socket->addr.plain.sa_family = AF_INET6;
}
#endif
switch(srv_socket->addr.plain.sa_family) {
#ifdef HAVE_IPV6
case AF_INET6:
memset(&srv_socket->addr, 0, sizeof(struct sockaddr_in6));
srv_socket->addr.ipv6.sin6_family = AF_INET6;
if (host == NULL) {
srv_socket->addr.ipv6.sin6_addr = in6addr_any;
log_error_write(srv, __FILE__, __LINE__, "s", "warning: please use server.use-ipv6 only for hostnames, not without server.bind / empty address; your config will break if the kernel default for IPV6_V6ONLY changes");
} else {
struct addrinfo hints, *res;
//.........这里部分代码省略.........
开发者ID:Master-Lee,项目名称:lighttpd1.4,代码行数:101,代码来源:network.c
注:本文中的buffer_copy_buffer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论