/[winpt]/trunk/Include/wptHTTP.h
ViewVC logotype

Annotation of /trunk/Include/wptHTTP.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations)
Mon Jan 31 11:02:21 2005 UTC (20 years, 1 month ago) by twoaday
File MIME type: text/plain
File size: 2534 byte(s)
WinPT initial checkin.


1 twoaday 2 /* wptInet.cpp - New INET code
2     * Copyright (C) 2004 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_INET_H
22     #define WPT_INET_H
23    
24     #ifdef __cplusplus
25     extern "C" {
26     #endif
27    
28     #define s_close(fd) closesocket (fd)
29    
30     enum http_types_t
31     {
32     HTTP_NONE = 0,
33     HTTP_GET,
34     HTTP_POST,
35     };
36    
37     enum http_statcode_t
38     {
39     HTTP_STAT_NONE = 0,
40     HTTP_STAT_200 = 200, /* OK */
41     HTTP_STAT_301 = 301, /* Moved Permanently */
42     HTTP_STAT_302 = 302, /* Moved Temporarily */
43     HTTP_STAT_400 = 400, /* Bad Request */
44     HTTP_STAT_403 = 403, /* Forbidden */
45     HTTP_STAT_404 = 404, /* Not Found */
46     HTTP_STAT_405 = 405, /* Method Not Allowed */
47     };
48    
49     enum http_err_t
50     {
51     HTTP_ERR_SUCCESS = 0,
52     HTTP_ERR_CONNECT,
53     HTTP_ERR_INVADDR,
54     HTTP_ERR_SOCK,
55     HTTP_ERR_IO,
56     HTTP_ERR_PROTO,
57     HTTP_ERR_STAT,
58     };
59    
60     struct http_head_s
61     {
62     struct http_head_s * next;
63     int flags;
64     char d[1];
65     };
66     typedef struct http_head_s * http_head_t;
67    
68     struct http_hd_s
69     {
70     int fd;
71     http_head_t head;
72     };
73     typedef struct http_hd_s * http_hd_t;
74    
75     struct http_req_s
76     {
77     int type;
78     http_head_t head;
79     char * url;
80     };
81     typedef struct http_req_s * http_req_t;
82    
83     int http_send_request (const char * host, int port, const char* url,
84     http_hd_t * r_hd);
85     int http_send_request2 (const char * url, http_hd_t * r_hd);
86     int http_parse_response (http_hd_t hd, int * statcode);
87     int http_parse_data (http_hd_t hd, FILE * out);
88     const char * http_strerror (int rc);
89     int http_hd_new (http_hd_t * hd);
90     void http_hd_free (http_hd_t hd);
91     int http_req_new (http_req_t * ctx);
92     void http_req_free (http_req_t ctx);
93     int http_parse_request (http_hd_t hd, http_req_t * r_req);
94    
95     #ifdef __cplusplus
96     }
97     #endif
98    
99     #endif /* WPT_INET_H */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26