X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=libs%2Fshttpd%2Fio_emb.c;h=762afe5a311ba16f8735951ef0c5b1b944c01269;hb=1dee4e3cd008a27789bbce05b0eb47b0eb5d121a;hp=42cd5c5e9be74cb611f781e6f3b13319396b5bae;hpb=d8ccfe2b3944adf07d35534459cdda19d15217c8;p=fms.git diff --git a/libs/shttpd/io_emb.c b/libs/shttpd/io_emb.c index 42cd5c5..762afe5 100644 --- a/libs/shttpd/io_emb.c +++ b/libs/shttpd/io_emb.c @@ -10,7 +10,6 @@ #include "defs.h" -#if defined(EMBEDDED) const char * shttpd_version(void) { @@ -29,6 +28,12 @@ call_user(struct conn *c, struct shttpd_arg *arg, shttpd_callback_t func) arg->in.len = io_data_len(&c->rem.io); arg->in.num_bytes = 0; + if (io_data_len(&c->rem.io) >= c->rem.io.size) + arg->flags |= SHTTPD_POST_BUFFER_FULL; + + if (c->rem.content_len > 0 && c->rem.io.total < c->rem.content_len) + arg->flags |= SHTTPD_MORE_POST_DATA; + func(arg); io_inc_head(&c->loc.io, arg->out.num_bytes); @@ -177,32 +182,6 @@ shttpd_register_uri(struct shttpd_ctx *ctx, } } -#if 0 -struct shttpd_ctx * -shttpd_init2(const char *config_file, char *names[], char *values[], size_t n) -{ - size_t i; - - for (i = 0; i < n; i++) - set_option(names[i], values[i]); - - return (init_ctx(config_file, 0, NULL)); -} -#endif - -void -shttpd_protect_uri(struct shttpd_ctx *ctx, const char *uri, const char *file) -{ - struct uri_auth *auth; - - if ((auth = malloc(sizeof(*auth))) != NULL) { - auth->uri = my_strdup(uri); - auth->file_name = my_strdup(file); - auth->uri_len = strlen(uri); - LL_ADD(&ctx->uri_auths, &auth->link); - } -} - int shttpd_get_var(const char *var, const char *buf, int buf_len, char *value, int value_len) @@ -211,27 +190,24 @@ shttpd_get_var(const char *var, const char *buf, int buf_len, size_t var_len; var_len = strlen(var); - e = buf + buf_len - var_len; + e = buf + buf_len; /* End of QUERY_STRING buffer */ /* buf is "var1=val1&var2=val2...". Find variable first */ - for (p = buf; p < e; p++) - if (!my_strncasecmp(var, p, var_len) && p[var_len] == '=') { + for (p = buf; p + var_len < e; p++) + if ((p == buf || p[-1] == '&') && + p[var_len] == '=' && + !my_strncasecmp(var, p, var_len)) { - /* Found. Shift to variable value */ - e = buf + buf_len; - p += var_len + 1; - - /* Find where the value ends */ + /* Point 'p' to var value, 's' to the end of value */ + p += var_len + 1; if ((s = memchr(p, '&', e - p)) == NULL) s = e; - /* Copy value into the buffer, decoding it */ - url_decode(p, s - p, value, value_len); - - return (1); + /* URL-decode value. Return result length */ + return (url_decode(p, s - p, value, value_len)); } - return (0); + return (-1); } static int @@ -297,5 +273,3 @@ const struct io_class io_embedded = { (int (*)(struct stream *, const void *, size_t)) do_embedded, close_embedded }; - -#endif /* EMBEDDED */