Merge branch 'VLAN-MultiSSID' into Teaman-ND
[tomato.git] / release / src / router / udpxy / rparse.h
blob49743195dd9086b59e9a09aa40066bee7dd39e03
1 /* @(#) header for parsing functions for udpxy
3 * Copyright 2008-2011 Pavel V. Cherenkov (pcherenkov@gmail.com)
5 * This file is part of udpxy.
7 * udpxy is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * udpxy is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with udpxy. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef RPARSE_H_121420071651_
22 #define RPARSE_H_121420071651_
24 #include <sys/types.h>
25 #include <sys/socket.h>
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
31 /* parse and copy parameters of HTTP GET request into
32 * request buffer
34 * @param src buffer with raw source data
35 * @param srclen length of raw data
36 * @param request destination buffer for the request
37 * @param rqlen length of request buffer on entry
38 * length of request on exit
40 * @return 0 if success: request buffer gets populated,
41 * non-zero if error
43 int
44 get_request( const char* src, size_t srclen,
45 char* request, size_t* rqlen );
48 /* parse (GET) request into command and parameters (options)
49 * c-strings
51 * @param s source c-string
52 * @param cmd buffer for the parsed command c-string
53 * @param clen length of command buffer
54 * @param opt buffer for the parsed options c-string
55 * @param optlen length of options buffer
57 * @return 0 if success: cmd and opt get get populated
58 * non-zero if an error ocurred
60 int
61 parse_param( const char* s, size_t slen,
62 char* cmd, size_t clen,
63 char* opt, size_t optlen );
66 /* parse options of upd-relay command into IP address
67 * and port
69 * @param opt options string
70 * @param optlen options string size (including zero-terminating byte)
71 * @param addr destination for address string
72 * @param addrlen length of address string buffer
73 * @param port port to populate
75 * @return 0 if success: inaddr and port get populated
76 * non-zero if error
78 int
79 parse_udprelay( const char* opt, size_t optlen,
80 char* addr, size_t addrlen,
81 uint16_t* port );
84 #ifdef __cplusplus
85 } /* extern "C" */
86 #endif
88 #endif
90 /* __EOF__ */