rpm  5.4.4
rpmio/rpmurl.h
Go to the documentation of this file.
00001 #ifndef H_RPMURL
00002 #define H_RPMURL
00003 
00008 #include <assert.h>
00009 #include <rpmio.h>
00010 #include <rpmsw.h>
00011 
00015 typedef enum urltype_e {
00016     URL_IS_UNKNOWN      = 0,    
00017     URL_IS_DASH         = 1,    
00018     URL_IS_PATH         = 2,    
00019     URL_IS_FTP          = 3,    
00020     URL_IS_HTTP         = 4,    
00021     URL_IS_HTTPS        = 5,    
00022     URL_IS_HKP          = 6,    
00023     URL_IS_MONGO        = 7,    
00024 } urltype;
00025 
00026 #define URLMAGIC        0xd00b1ed0U
00027 #define URLSANE(u)      assert(u && u->magic == URLMAGIC)
00028 
00031 typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo_s * urlinfo;
00032 
00035 extern int (*urlNotify) (const urlinfo u, unsigned status)
00036         /*@*/;
00037 
00040 /*@unchecked@*/ /*@null@*/ /*@shared@*/
00041 extern void * urlNotifyArg;
00042 
00046 struct urlinfo_s {
00047     struct rpmioItem_s _item;   
00048 /*@owned@*/ /*@relnull@*/
00049     const char * url;           
00050 /*@owned@*/ /*@relnull@*/
00051     const char * scheme;        
00052 /*@owned@*/ /*@null@*/
00053     const char * user;          
00054 /*@owned@*/ /*@null@*/
00055     const char * password;      
00056 /*@owned@*/ /*@relnull@*/
00057     const char * host;          
00058 /*@owned@*/ /*@null@*/
00059     const char * portstr;       
00060 /*@owned@*/ /*@null@*/
00061     const char * query;         
00062 /*@owned@*/ /*@null@*/
00063     const char * fragment;      
00064 /*@owned@*/ /*@null@*/
00065     const char * proxyu;        
00066 /*@owned@*/ /*@null@*/
00067     const char * proxyh;        
00068     int proxyp;                 
00069     int port;                   
00070     urltype ut;                 
00071 /*@relnull@*/
00072     FD_t ctrl;                  
00073 /*@relnull@*/
00074     FD_t data;                  
00076 /*@relnull@*/
00077     void * capabilities;        
00078 /*@relnull@*/
00079     void * lockstore;           
00080 /*@relnull@*/
00081     void * sess;                
00083 /*@null@*/
00084     const char * location;      
00085 /*@null@*/
00086     const char * etag;          
00087 /*@null@*/
00088     int (*notify) (const urlinfo u, unsigned status);
00089 /*@null@*/ /*@shared@*/
00090     void * arg;
00091     struct fdNotify_s {
00092         unsigned status;
00093 /*@null@*/
00094         const char * hostname;
00095 /*@null@*/
00096         const char * address;
00097         int64_t progress;
00098         int64_t total;
00099     } info;
00100 /*@null@*/
00101     rpmop rop;                  
00102 /*@null@*/
00103     rpmop sop;                  
00104 /*@null@*/
00105     rpmop top;                  
00107     int bufAlloced;             
00108 /*@owned@*/
00109     char * buf;                 
00110     int openError;              
00111     int httpVersion;
00112     int allow;
00113 #define RPMURL_SERVER_HASRANGE          ( 1 << 0)
00114 #define RPMURL_SERVER_HASDAVCLASS1      ( 1 << 1)
00115 #define RPMURL_SERVER_HASDAVCLASS2      ( 1 << 2)
00116 #define RPMURL_SERVER_HASDAVEXEC        ( 1 << 3)
00117 
00118 #define RPMURL_SERVER_OPTIONSDONE       ( 1 << 8)
00119 
00120 #define RPMURL_SERVER_HASDAV    (RPMURL_SERVER_HASDAVCLASS1|RPMURL_SERVER_HASDAVCLASS2|RPMURL_SERVER_HASDAVEXEC)
00121     unsigned magic;
00122 #if defined(__LCLINT__)
00123 /*@refs@*/
00124     int nrefs;                  
00125 #endif
00126 };
00127 
00128 #ifdef __cplusplus
00129 extern "C" {
00130 #endif
00131 
00132 /*@unchecked@*/
00133 extern int _url_count;          
00135 /*@unchecked@*/
00136 /*@only@*/ /*@null@*/
00137 extern urlinfo * _url_cache;    
00139 /*@unchecked@*/
00140 extern int _url_iobuf_size;     
00141 #define RPMURL_IOBUF_SIZE       4096
00142 
00143 /*@unchecked@*/
00144 extern int _url_debug;          
00145 #define RPMURL_DEBUG_IO         0x40000000
00146 #define RPMURL_DEBUG_REFS       0x20000000
00147 
00153 /*@unused@*/ /*@null@*/
00154 urlinfo urlNew(const char * msg)
00155         /*@*/;
00156 
00158 /*@null@*/
00159 urlinfo XurlNew(const char * msg, const char * fn, unsigned ln)
00160         /*@globals fileSystem @*/
00161         /*@modifies fileSystem @*/;
00162 #define urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__)
00163 
00170 /*@unused@*/ /*@newref@*/
00171 urlinfo urlLink(/*@returned@*/ urlinfo u, const char * msg)
00172         /*@modifies u @*/;
00173 #define urlLink(_u, _msg)       \
00174         (urlinfo) rpmioLinkPoolItem((rpmioItem)(_u), _msg, __FILE__, __LINE__)
00175 
00182 /*@unused@*/ /*@null@*/
00183 urlinfo urlFree( /*@killref@*/ urlinfo u, const char * msg)
00184         /*@globals fileSystem, internalState @*/
00185         /*@modifies u, fileSystem, internalState @*/;
00186 #define urlFree(_u, _msg)       \
00187         ((urlinfo)rpmioFreePoolItem((rpmioItem)(_u), _msg, __FILE__, __LINE__))
00188 
00192 void urlFreeCache(void)
00193         /*@globals _url_cache, _url_count, fileSystem, internalState @*/
00194         /*@modifies _url_cache, _url_count, fileSystem, internalState @*/;
00195 
00201 urltype urlIsURL(const char * url)
00202         /*@*/;
00203 urltype urlType(void * _u)
00204         /*@*/;
00205 
00212 /*@-incondefs@*/
00213 urltype urlPath(const char * url, /*@out@*/ const char ** pathp)
00214         /*@modifies *pathp @*/;
00215 /*@=incondefs@*/
00216 
00223 int urlSplit(const char * url, /*@out@*/ urlinfo * uret)
00224         /*@globals h_errno, internalState @*/
00225         /*@modifies *uret, internalState @*/;
00226 
00233 int urlGetFile(const char * url, /*@null@*/ const char * dest)
00234         /*@globals h_errno, fileSystem, internalState @*/
00235         /*@modifies fileSystem, internalState @*/;
00236 
00237 #ifdef __cplusplus
00238 }
00239 #endif
00240 
00241 #endif  /* H_RPMURL */