00001 #ifndef H_RPMURL
00002 #define H_RPMURL
00003
00008 #include <assert.h>
00009
00013 typedef enum urltype_e {
00014 URL_IS_UNKNOWN = 0,
00015 URL_IS_DASH = 1,
00016 URL_IS_PATH = 2,
00017 URL_IS_FTP = 3,
00018 URL_IS_HTTP = 4,
00019 URL_IS_HTTPS = 5,
00020 URL_IS_HKP = 6
00021 } urltype;
00022
00023 #define URLMAGIC 0xd00b1ed0
00024 #define URLSANE(u) assert(u && u->magic == URLMAGIC)
00025
00026 typedef struct urlinfo_s * urlinfo;
00027
00031 struct urlinfo_s {
00032 int nrefs;
00033
00034 const char * url;
00035
00036 const char * scheme;
00037
00038 const char * user;
00039
00040 const char * password;
00041
00042 const char * host;
00043
00044 const char * portstr;
00045
00046 const char * proxyu;
00047
00048 const char * proxyh;
00049 int proxyp;
00050 int port;
00051 int urltype;
00052 FD_t ctrl;
00053 FD_t data;
00055
00056 void * capabilities;
00057
00058 void * lockstore;
00059
00060 void * sess;
00061 off_t current;
00062 off_t total;
00063 int connstatus;
00064 #ifdef REFERENCE
00065 typedef enum {
00066 ne_conn_namelookup,
00067 ne_conn_connecting,
00068 ne_conn_connected,
00069 ne_conn_secure
00070 } ne_conn_status;
00071 #endif
00072
00073 int bufAlloced;
00074
00075 char * buf;
00076 int openError;
00077 int httpVersion;
00078 int httpHasRange;
00079 int magic;
00080 };
00081
00082 #ifdef __cplusplus
00083 extern "C" {
00084 #endif
00085
00086
00087 extern int _url_count;
00089
00090
00091 extern urlinfo * _url_cache;
00093
00094 extern int _url_iobuf_size;
00095 #define RPMURL_IOBUF_SIZE 4096
00096
00097
00098 extern int _url_debug;
00099 #define RPMURL_DEBUG_IO 0x40000000
00100 #define RPMURL_DEBUG_REFS 0x20000000
00101
00102
00108 urlinfo urlNew(const char * msg) ;
00109
00111 urlinfo XurlNew(const char * msg, const char * file, unsigned line) ;
00112 #define urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__)
00113
00120 urlinfo urlLink(urlinfo u, const char * msg)
00121 ;
00122
00124 urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line)
00125 ;
00126 #define urlLink(_u, _msg) XurlLink(_u, _msg, __FILE__, __LINE__)
00127
00134 urlinfo urlFree( urlinfo u, const char * msg)
00135
00136 ;
00137
00139 urlinfo XurlFree( urlinfo u, const char * msg,
00140 const char * file, unsigned line)
00141
00142 ;
00143 #define urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__)
00144
00148 void urlFreeCache(void)
00149
00150 ;
00151
00157 urltype urlIsURL(const char * url)
00158 ;
00159
00166
00167 urltype urlPath(const char * url, const char ** pathp)
00168
00169 ;
00170
00171
00178 int urlSplit(const char * url, urlinfo * uret)
00179
00180 ;
00181
00188 int urlGetFile(const char * url, const char * dest)
00189
00190 ;
00191
00192 #ifdef __cplusplus
00193 }
00194 #endif
00195
00196 #endif