• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/uhttpd/utils.h

  1 /*
  2  * uhttpd - Tiny single-threaded httpd
  3  *
  4  *   Copyright (C) 2010-2013 Jo-Philipp Wich <xm@subsignal.org>
  5  *   Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
  6  *
  7  * Permission to use, copy, modify, and/or distribute this software for any
  8  * purpose with or without fee is hereby granted, provided that the above
  9  * copyright notice and this permission notice appear in all copies.
 10  *
 11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 18  */
 19 
 20 #ifndef _UHTTPD_UTILS_
 21 
 22 #include <sys/stat.h>
 23 
 24 #include <stdarg.h>
 25 #include <fcntl.h>
 26 #include <pwd.h>
 27 #include <stdio.h>
 28 #include <string.h>
 29 #include <errno.h>
 30 #include <stdlib.h>
 31 #include <alloca.h>
 32 #include <time.h>
 33 #include <unistd.h>
 34 
 35 struct uh_addr {
 36         uint8_t family;
 37         uint16_t port;
 38         union {
 39                 struct in_addr in;
 40                 struct in6_addr in6;
 41         };
 42 };
 43 
 44 #define min(x, y) (((x) < (y)) ? (x) : (y))
 45 #define max(x, y) (((x) > (y)) ? (x) : (y))
 46 
 47 #define array_size(x) \
 48         (sizeof(x) / sizeof(x[0]))
 49 
 50 #define fd_cloexec(fd) \
 51         fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC)
 52 
 53 #ifdef __APPLE__
 54 static inline void clearenv(void)
 55 {
 56         extern char **environ;
 57         *environ = NULL;
 58 }
 59 
 60 time_t timegm (struct tm *tm);
 61 
 62 #endif
 63 
 64 #ifdef __GNUC__
 65 #define __printf(a, b) __attribute__((format(printf, a, b)))
 66 #else
 67 #define __printf(a, b)
 68 #endif
 69 
 70 int uh_urldecode(char *buf, int blen, const char *src, int slen);
 71 int uh_urlencode(char *buf, int blen, const char *src, int slen);
 72 int uh_b64decode(char *buf, int blen, const void *src, int slen);
 73 bool uh_path_match(const char *prefix, const char *url);
 74 char *uh_split_header(char *str);
 75 bool uh_addr_rfc1918(struct uh_addr *addr);
 76 char *uh_htmlescape(const char *src);
 77 
 78 #endif
 79 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt