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 allow;
00079 #define RPMURL_SERVER_HASRANGE ( 1 << 0)
00080 #define RPMURL_SERVER_HASDAVCLASS1 ( 1 << 1)
00081 #define RPMURL_SERVER_HASDAVCLASS2 ( 1 << 2)
00082 #define RPMURL_SERVER_HASDAVEXEC ( 1 << 3)
00083
00084 #define RPMURL_SERVER_HASDAV (RPMURL_SERVER_HASDAVCLASS1|RPMURL_SERVER_HASDAVCLASS2|RPMURL_SERVER_HASDAVEXEC)
00085 int magic;
00086 };
00087
00088 #ifdef __cplusplus
00089 extern "C" {
00090 #endif
00091
00092
00093 extern int _url_count;
00095
00096
00097 extern urlinfo * _url_cache;
00099
00100 extern int _url_iobuf_size;
00101 #define RPMURL_IOBUF_SIZE 4096
00102
00103
00104 extern int _url_debug;
00105 #define RPMURL_DEBUG_IO 0x40000000
00106 #define RPMURL_DEBUG_REFS 0x20000000
00107
00108
00114 urlinfo urlNew(const char * msg) ;
00115
00117 urlinfo XurlNew(const char * msg, const char * file, unsigned line) ;
00118 #define urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__)
00119
00126 urlinfo urlLink(urlinfo u, const char * msg)
00127 ;
00128
00130 urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line)
00131 ;
00132 #define urlLink(_u, _msg) XurlLink(_u, _msg, __FILE__, __LINE__)
00133
00140 urlinfo urlFree( urlinfo u, const char * msg)
00141
00142 ;
00143
00145 urlinfo XurlFree( urlinfo u, const char * msg,
00146 const char * file, unsigned line)
00147
00148 ;
00149 #define urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__)
00150
00154 void urlFreeCache(void)
00155
00156 ;
00157
00163 urltype urlIsURL(const char * url)
00164 ;
00165
00172
00173 urltype urlPath(const char * url, const char ** pathp)
00174
00175 ;
00176
00177
00184 int urlSplit(const char * url, urlinfo * uret)
00185
00186 ;
00187
00194 int urlGetFile(const char * url, const char * dest)
00195
00196 ;
00197
00198 #ifdef __cplusplus
00199 }
00200 #endif
00201
00202 #endif