2 * uhttpd - Tiny single-threaded httpd - Utility header
4 * Copyright (C) 2010 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_
27 #define min(x, y) (((x) < (y)) ? (x) : (y))
28 #define max(x, y) (((x) > (y)) ? (x) : (y))
30 #define array_size(x) \
31 (sizeof(x) / sizeof(x[0]))
33 #define foreach_header(i, h) \
34 for( i = 0; (i + 1) < (sizeof(h) / sizeof(h[0])) && h[i]; i += 2 )
36 #define fd_cloexec(fd) \
37 fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC)
49 const char * sa_straddr(void *sa
);
50 const char * sa_strport(void *sa
);
51 int sa_port(void *sa
);
53 char *strfind(char *haystack
, int hslen
, const char *needle
, int ndlen
);
55 int select_intr(int n
, fd_set
*r
, fd_set
*w
, fd_set
*e
, struct timeval
*t
);
57 int uh_tcp_send(struct client
*cl
, const char *buf
, int len
);
58 int uh_tcp_peek(struct client
*cl
, char *buf
, int len
);
59 int uh_tcp_recv(struct client
*cl
, char *buf
, int len
);
62 struct client
*cl
, int code
, const char *summary
,
66 #define uh_http_response(cl, code, message) \
67 uh_http_sendhf(cl, code, message, message)
69 int uh_http_sendc(struct client
*cl
, const char *data
, int len
);
72 struct client
*cl
, struct http_request
*req
,
77 struct client
*cl
, struct http_request
*req
,
78 const char *buf
, int len
82 int uh_urldecode(char *buf
, int blen
, const char *src
, int slen
);
83 int uh_urlencode(char *buf
, int blen
, const char *src
, int slen
);
84 int uh_b64decode(char *buf
, int blen
, const unsigned char *src
, int slen
);
87 struct auth_realm
* uh_auth_add(char *path
, char *user
, char *pass
);
90 struct client
*cl
, struct http_request
*req
, struct path_info
*pi
94 struct path_info
* uh_path_lookup(struct client
*cl
, const char *url
);
96 struct listener
* uh_listener_add(int sock
, struct config
*conf
);
97 struct listener
* uh_listener_lookup(int sock
);
99 struct client
* uh_client_add(int sock
, struct listener
*serv
);
100 struct client
* uh_client_lookup(int sock
);
101 void uh_client_remove(int sock
);
This page took 0.04927 seconds and 5 git commands to generate.