a53c256508c2d4bab5797d3de72ce694fddd730c
2 * uhttpd - Tiny single-threaded httpd - Utility header
4 * Copyright (C) 2010-2012 Jo-Philipp Wich <xm@subsignal.org>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #ifndef _UHTTPD_UTILS_
41 #define min(x, y) (((x) < (y)) ? (x) : (y))
42 #define max(x, y) (((x) > (y)) ? (x) : (y))
44 #define array_size(x) \
45 (sizeof(x) / sizeof(x[0]))
47 #define fd_cloexec(fd) \
48 fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC)
51 static inline void clearenv(void)
53 extern char **environ
;
59 #define __printf(a, b) __attribute__((format(printf, a, b)))
61 #define __printf(a, b)
64 int uh_urldecode(char *buf
, int blen
, const char *src
, int slen
);
65 int uh_urlencode(char *buf
, int blen
, const char *src
, int slen
);
66 int uh_b64decode(char *buf
, int blen
, const void *src
, int slen
);
67 bool uh_path_match(const char *prefix
, const char *url
);
68 char *uh_split_header(char *str
);
69 bool uh_addr_rfc1918(struct uh_addr
*addr
);