[15591] | 1 | /* |
---|
| 2 | * http_trans.h -- This file contains definitions for http transport functions |
---|
| 3 | * Created: Christopher Blizzard <blizzard@appliedtheory.com>, 5-Aug-1998 |
---|
| 4 | * |
---|
| 5 | * Copyright (C) 1998 Free Software Foundation |
---|
| 6 | * |
---|
| 7 | * This library is free software; you can redistribute it and/or |
---|
| 8 | * modify it under the terms of the GNU Library General Public |
---|
| 9 | * License as published by the Free Software Foundation; either |
---|
| 10 | * version 2 of the License, or (at your option) any later version. |
---|
| 11 | * |
---|
| 12 | * This library 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 GNU |
---|
| 15 | * Library General Public License for more details. |
---|
| 16 | * |
---|
| 17 | * You should have received a copy of the GNU Library General Public |
---|
| 18 | * License along with this library; if not, write to the Free |
---|
| 19 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #ifndef HTTP_TRANS_H |
---|
| 23 | #define HTTP_TRANS_H |
---|
| 24 | |
---|
| 25 | #include <sys/types.h> |
---|
| 26 | #include <sys/socket.h> |
---|
| 27 | #include <netinet/in.h> |
---|
| 28 | #include <netdb.h> |
---|
| 29 | |
---|
| 30 | typedef enum http_trans_err_type_tag { |
---|
| 31 | http_trans_err_type_host = 0, |
---|
| 32 | http_trans_err_type_errno |
---|
| 33 | } http_trans_err_type; |
---|
| 34 | |
---|
| 35 | typedef struct http_trans_conn_tag { |
---|
| 36 | struct hostent *hostinfo; |
---|
| 37 | struct sockaddr_in saddr; |
---|
| 38 | char *host; |
---|
| 39 | char *proxy_host; |
---|
| 40 | int sock; |
---|
| 41 | short port; |
---|
| 42 | short proxy_port; |
---|
| 43 | http_trans_err_type error_type; |
---|
| 44 | int error; |
---|
| 45 | int sync; /* sync or async? */ |
---|
| 46 | char *io_buf; /* buffer */ |
---|
| 47 | int io_buf_len; /* how big is it? */ |
---|
| 48 | int io_buf_alloc; /* how much is used */ |
---|
| 49 | int io_buf_io_done; /* how much have we already moved? */ |
---|
| 50 | int io_buf_io_left; /* how much data do we have left? */ |
---|
| 51 | int io_buf_chunksize; /* how big should the chunks be that get |
---|
| 52 | read in and out be? */ |
---|
| 53 | int last_read; /* the size of the last read */ |
---|
| 54 | int chunk_len; /* length of a chunk. */ |
---|
| 55 | char *errstr; /* a hint as to an error */ |
---|
| 56 | } http_trans_conn; |
---|
| 57 | |
---|
| 58 | http_trans_conn * |
---|
| 59 | http_trans_conn_new(void); |
---|
| 60 | |
---|
| 61 | void |
---|
| 62 | http_trans_conn_destroy(http_trans_conn *a_conn); |
---|
| 63 | |
---|
| 64 | void |
---|
| 65 | http_trans_buf_reset(http_trans_conn *a_conn); |
---|
| 66 | |
---|
| 67 | void |
---|
| 68 | http_trans_buf_clip(http_trans_conn *a_conn, char *a_clip_to); |
---|
| 69 | |
---|
| 70 | int |
---|
| 71 | http_trans_connect(http_trans_conn *a_conn); |
---|
| 72 | |
---|
| 73 | const char * |
---|
| 74 | http_trans_get_host_error(int a_herror); |
---|
| 75 | |
---|
| 76 | int |
---|
| 77 | http_trans_append_data_to_buf(http_trans_conn *a_conn, |
---|
| 78 | char *a_data, |
---|
| 79 | int a_data_len); |
---|
| 80 | |
---|
| 81 | int |
---|
| 82 | http_trans_read_into_buf(http_trans_conn *a_conn); |
---|
| 83 | |
---|
| 84 | int |
---|
| 85 | http_trans_write_buf(http_trans_conn *a_conn); |
---|
| 86 | |
---|
| 87 | char * |
---|
| 88 | http_trans_buf_has_patt(char *a_buf, int a_len, |
---|
| 89 | char *a_pat, int a_patlen); |
---|
| 90 | |
---|
| 91 | #endif /* HTTP_TRANS_H */ |
---|