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
00053 FD_t ctrl;
00054
00055 FD_t data;
00057 #ifdef REFERENCE
00058 typedef enum {
00059 ne_conn_namelookup,
00060 ne_conn_connecting,
00061 ne_conn_connected,
00062 ne_conn_secure
00063 } ne_conn_status;
00064 #endif
00065
00066 int bufAlloced;
00067
00068 char * buf;
00069 int openError;
00070 int httpVersion;
00071 int allow;
00072 #define RPMURL_SERVER_HASRANGE ( 1 << 0)
00073 #define RPMURL_SERVER_HASDAVCLASS1 ( 1 << 1)
00074 #define RPMURL_SERVER_HASDAVCLASS2 ( 1 << 2)
00075 #define RPMURL_SERVER_HASDAVEXEC ( 1 << 3)
00076
00077 #define RPMURL_SERVER_HASDAV (RPMURL_SERVER_HASDAVCLASS1|RPMURL_SERVER_HASDAVCLASS2|RPMURL_SERVER_HASDAVEXEC)
00078 int magic;
00079 };
00080
00081 #ifdef __cplusplus
00082 extern "C" {
00083 #endif
00084
00085
00086 extern int _url_count;
00088
00089
00090 extern urlinfo * _url_cache;
00092
00093 extern int _url_iobuf_size;
00094 #define RPMURL_IOBUF_SIZE 4096
00095
00096
00097 extern int _url_debug;
00098 #define RPMURL_DEBUG_IO 0x40000000
00099 #define RPMURL_DEBUG_REFS 0x20000000
00100
00101
00107 urlinfo urlNew(const char * msg) ;
00108
00110 urlinfo XurlNew(const char * msg, const char * file, unsigned line) ;
00111 #define urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__)
00112
00119 urlinfo urlLink(urlinfo u, const char * msg)
00120 ;
00121
00123 urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line)
00124 ;
00125 #define urlLink(_u, _msg) XurlLink(_u, _msg, __FILE__, __LINE__)
00126
00133 urlinfo urlFree( urlinfo u, const char * msg)
00134
00135 ;
00136
00138 urlinfo XurlFree( urlinfo u, const char * msg,
00139 const char * file, unsigned line)
00140
00141 ;
00142 #define urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__)
00143
00147 void urlFreeCache(void)
00148
00149 ;
00150
00156 urltype urlIsURL(const char * url)
00157 ;
00158
00165
00166 urltype urlPath(const char * url, const char ** pathp)
00167
00168 ;
00169
00170
00177 int urlSplit(const char * url, urlinfo * uret)
00178
00179 ;
00180
00187 int urlGetFile(const char * url, const char * dest)
00188
00189 ;
00190
00191 #ifdef __cplusplus
00192 }
00193 #endif
00194
00195 #endif