X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuhttpd.git;a=blobdiff_plain;f=utils.h;h=c583f453798fb46915dfcefd2d6573c59b74bc3d;hp=07db0cfec2b029942f7ae1c6183e57b6d75f88f8;hb=d09bf11d572207b79286cdb5e6253278ebec147c;hpb=46cf4c79368daa556ed6936999ab05408f61da00 diff --git a/utils.h b/utils.h index 07db0cf..c583f45 100644 --- a/utils.h +++ b/utils.h @@ -1,19 +1,20 @@ /* - * uhttpd - Tiny single-threaded httpd - Utility header + * uhttpd - Tiny single-threaded httpd * - * Copyright (C) 2010-2012 Jo-Philipp Wich + * Copyright (C) 2010-2013 Jo-Philipp Wich + * Copyright (C) 2013 Felix Fietkau * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _UHTTPD_UTILS_ @@ -27,8 +28,19 @@ #include #include #include +#include +#include #include +struct uh_addr { + uint8_t family; + uint16_t port; + union { + struct in_addr in; + struct in6_addr in6; + }; +}; + #define min(x, y) (((x) < (y)) ? (x) : (y)) #define max(x, y) (((x) > (y)) ? (x) : (y)) @@ -42,8 +54,11 @@ static inline void clearenv(void) { extern char **environ; - environ = NULL; + *environ = NULL; } + +time_t timegm (struct tm *tm); + #endif #ifdef __GNUC__ @@ -54,7 +69,9 @@ static inline void clearenv(void) int uh_urldecode(char *buf, int blen, const char *src, int slen); int uh_urlencode(char *buf, int blen, const char *src, int slen); -int uh_b64decode(char *buf, int blen, const unsigned char *src, int slen); +int uh_b64decode(char *buf, int blen, const void *src, int slen); bool uh_path_match(const char *prefix, const char *url); +char *uh_split_header(char *str); +bool uh_addr_rfc1918(struct uh_addr *addr); #endif