Miniupnpd: update from 1.8 (20140422) to 1.9 (20141209)
[tomato.git] / release / src / router / udpxy / rparse.h
blob6b136bf013a72a4afa22885aec78827fe64a103c
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
56 * @param tail buffer for tail (whatever is beyond options)
57 * @param tlen length of tail buffer
59 * @return 0 if success: cmd and opt get get populated
60 * non-zero if an error ocurred
62 int
63 parse_param( const char* s, size_t slen,
64 char* cmd, size_t clen,
65 char* opt, size_t optlen,
66 char* tail, size_t tlen);
69 /* parse options of upd-relay command into IP address
70 * and port
72 * @param opt options string
73 * @param optlen options string size (including zero-terminating byte)
74 * @param addr destination for address string
75 * @param addrlen length of address string buffer
76 * @param port port to populate
78 * @return 0 if success: inaddr and port get populated
79 * non-zero if error
81 int
82 parse_udprelay( const char* opt, size_t optlen,
83 char* addr, size_t addrlen,
84 uint16_t* port );
87 #ifdef __cplusplus
88 } /* extern "C" */
89 #endif
91 #endif
93 /* __EOF__ */