1 |
/* wptHttp.h - Generic HTTP code |
2 |
* Copyright (C) 2004, 2005 Timo Schulz |
3 |
* |
4 |
* This file is part of WinPT. |
5 |
* |
6 |
* WinPT is free software; you can redistribute it and/or |
7 |
* modify it under the terms of the GNU General Public License |
8 |
* as published by the Free Software Foundation; either version 2 |
9 |
* of the License, or (at your option) any later version. |
10 |
* |
11 |
* WinPT is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
* General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
*/ |
20 |
|
21 |
#ifndef WPT_HTTP_H |
22 |
#define WPT_HTTP_H |
23 |
|
24 |
#ifdef __cplusplus |
25 |
extern "C" { |
26 |
#endif |
27 |
|
28 |
enum http_types_t { |
29 |
HTTP_NONE = 0, |
30 |
HTTP_GET, |
31 |
HTTP_POST, |
32 |
}; |
33 |
|
34 |
enum http_statcode_t { |
35 |
HTTP_STAT_NONE = 0, |
36 |
HTTP_STAT_200 = 200, /* OK */ |
37 |
HTTP_STAT_301 = 301, /* Moved Permanently */ |
38 |
HTTP_STAT_302 = 302, /* Moved Temporarily */ |
39 |
HTTP_STAT_400 = 400, /* Bad Request */ |
40 |
HTTP_STAT_403 = 403, /* Forbidden */ |
41 |
HTTP_STAT_404 = 404, /* Not Found */ |
42 |
HTTP_STAT_405 = 405, /* Method Not Allowed */ |
43 |
}; |
44 |
|
45 |
|
46 |
struct http_head_s { |
47 |
struct http_head_s * next; |
48 |
int flags; |
49 |
char d[1]; |
50 |
}; |
51 |
typedef struct http_head_s * http_head_t; |
52 |
|
53 |
struct http_hd_s { |
54 |
int fd; |
55 |
http_head_t head; |
56 |
}; |
57 |
typedef struct http_hd_s * http_hd_t; |
58 |
|
59 |
struct http_req_s { |
60 |
int type; |
61 |
http_head_t head; |
62 |
char * url; |
63 |
}; |
64 |
typedef struct http_req_s * http_req_t; |
65 |
|
66 |
int http_send_request (const char * host, int port, const char* url, |
67 |
http_hd_t * r_hd); |
68 |
int http_send_request2 (const char * url, http_hd_t * r_hd); |
69 |
int http_parse_response (http_hd_t hd, int * statcode); |
70 |
int http_parse_data (http_hd_t hd, FILE * out); |
71 |
int http_hd_new (http_hd_t * hd); |
72 |
void http_hd_free (http_hd_t hd); |
73 |
int http_req_new (http_req_t * ctx); |
74 |
void http_req_free (http_req_t ctx); |
75 |
int http_parse_request (http_hd_t hd, http_req_t * r_req); |
76 |
|
77 |
#ifdef __cplusplus |
78 |
} |
79 |
#endif |
80 |
|
81 |
#endif /* WPT_HTTP_H */ |