rpm  5.2.1
rpmio/rpmdav.h
Go to the documentation of this file.
00001 #ifndef RPMDAV_H
00002 #define RPMDAV_H
00003 
00008 #include <argv.h>
00009 
00012 /*@unchecked@*/
00013 extern int rpmioHttpReadTimeoutSecs;
00014 /*@unchecked@*/
00015 extern int rpmioHttpConnectTimeoutSecs;
00016 /*@unchecked@*/ /*@null@*/
00017 extern const char * rpmioHttpAccept;
00018 /*@unchecked@*/ /*@null@*/
00019 extern const char * rpmioHttpUserAgent;
00020 
00021 #if defined(_RPMDAV_INTERNAL)
00022 struct __dirstream {
00023     int fd;                     /* File descriptor.  */
00024     char * data;                /* Directory block.  */
00025     size_t allocation;          /* Space allocated for the block.  */
00026     size_t size;                /* Total valid data in the block.  */
00027     size_t offset;              /* Current offset into the block.  */
00028     off_t filepos;              /* Position of next entry to read.  */
00029 #if defined(WITH_PTHREADS)
00030     pthread_mutex_t lock;       /* Mutex lock for this structure.  */
00031 #endif
00032 };
00033 #endif
00034 
00035 #if !defined(DT_DIR) || defined(__APPLE__)
00036 # define DT_UNKNOWN     0
00037 # define DT_FIFO        1
00038 # define DT_CHR         2
00039 # define DT_DIR         4
00040 # define DT_BLK         6
00041 # define DT_REG         8
00042 # define DT_LNK         10
00043 # define DT_SOCK        12
00044 # define DT_WHT         14
00045 typedef struct __dirstream *    AVDIR;
00046 typedef struct __dirstream *    DAVDIR;
00047 #else
00048 # if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
00049 typedef struct __dirstream *    AVDIR;
00050 typedef struct __dirstream *    DAVDIR;
00051 #else   /* __FreeBSD__ */
00052 typedef DIR *                   AVDIR;
00053 typedef DIR *                   DAVDIR;
00054 #endif  /* __FreeBSD__ */
00055 #endif
00056 
00057 
00058 #ifdef __cplusplus
00059 extern "C" {
00060 #endif
00061 
00062 #if defined(_RPMAV_INTERNAL)
00063 
00065 typedef struct avContext_s * avContext;
00066 
00069 /*@unchecked@*/
00070 extern int avmagicdir;
00071 #define ISAVMAGIC(_dir) (!memcmp((_dir), &avmagicdir, sizeof(avmagicdir)))
00072 
00075 struct avContext_s {
00076 /*@relnull@*/ /*@dependent@*/
00077     void ** resrock;
00078     const char *uri;
00079 /*@refcounted@*/
00080     urlinfo u;
00081     int ac;
00082     int nalloced;
00083     ARGV_t av;
00084 /*@relnull@*/ /*@shared@*/
00085     struct stat *st;
00086     rpmuint16_t * modes;        /* XXX sizeof(mode_t) != sizeof(rpmmode_t) */
00087     size_t * sizes;
00088     time_t * mtimes;
00089 };
00090 
00093 /*@null@*/
00094 void * avContextDestroy(/*@only@*/ /*@null@*/ avContext ctx)
00095         /*@globals internalState @*/
00096         /*@modifies ctx, internalState @*/;
00097 
00100 /*@null@*/
00101 void * avContextCreate(const char *uri, /*@null@*/ struct stat *st)
00102         /*@globals internalState @*/
00103         /*@modifies *st, internalState @*/;
00104 
00107 int avContextAdd(avContext ctx, const char * path,
00108                 mode_t mode, size_t size, time_t mtime)
00109         /*@globals internalState @*/
00110         /*@modifies ctx, internalState @*/;
00111 
00117 int avClosedir(/*@only@*/ DIR * dir)
00118         /*@globals fileSystem @*/
00119         /*@modifies dir, fileSystem @*/;
00120 
00126 /*@dependent@*/ /*@null@*/
00127 struct dirent * avReaddir(DIR * dir)
00128         /*@globals fileSystem @*/
00129         /*@modifies fileSystem @*/;
00130 
00138 /*@null@*/
00139 DIR * avOpendir(const char * path,
00140                 /*@null@*/ const char ** av, /*@null@*/ rpmuint16_t * modes)
00141         /*@globals fileSystem, internalState @*/
00142         /*@modifies fileSystem, internalState @*/;
00143 #endif
00144 
00150 int davDisconnect(void * _u)
00151         /*@globals internalState @*/
00152         /*@modifies _u, internalState @*/;
00153 
00159 int davFree(urlinfo u)
00160         /*@globals internalState @*/
00161         /*@modifies u, internalState @*/;
00162 
00166 void davDestroy(void)
00167         /*@globals internalState @*/
00168         /*@modifies internalState @*/;
00169 
00177 int davReq(FD_t ctrl, const char * httpCmd, /*@null@*/ const char * httpArg)
00178         /*@globals fileSystem, internalState @*/
00179         /*@modifies ctrl, fileSystem, internalState @*/;
00180 
00188 /*@-exportlocal@*/
00189 int davResp(urlinfo u, FD_t ctrl, /*@out@*/ /*@null@*/ char *const * str)
00190         /*@globals fileSystem, internalState @*/
00191         /*@modifies ctrl, *str, fileSystem, internalState @*/;
00192 /*@=exportlocal@*/
00193 
00202 /*@null@*/
00203 FD_t davOpen(const char * url, /*@unused@*/ int flags,
00204                 /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
00205         /*@globals internalState @*/
00206         /*@modifies *uret, internalState @*/;
00207 
00208 /*@null@*/
00209 FD_t httpOpen(const char * url, /*@unused@*/ int flags,
00210                 /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
00211         /*@globals internalState @*/
00212         /*@modifies *uret, internalState @*/;
00213 
00216 ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
00217         /*@globals errno, fileSystem, internalState @*/
00218         /*@modifies buf, errno, fileSystem, internalState @*/;
00219 
00222 ssize_t davWrite(void * cookie, const char * buf, size_t count)
00223         /*@globals fileSystem, internalState @*/
00224         /*@modifies fileSystem, internalState @*/;
00225 
00228 int davSeek(void * cookie, _libio_pos_t pos, int whence)
00229         /*@globals fileSystem, internalState @*/
00230         /*@modifies fileSystem, internalState @*/;
00231 
00234 int davClose(void * cookie)
00235         /*@globals fileSystem, internalState @*/
00236         /*@modifies cookie, fileSystem, internalState @*/;
00237 
00240 int davMkdir(const char * path, mode_t mode)
00241         /*@globals fileSystem, internalState @*/
00242         /*@modifies fileSystem, internalState @*/;
00243 
00246 int davRmdir(const char * path)
00247         /*@globals fileSystem, internalState @*/
00248         /*@modifies fileSystem, internalState @*/;
00249 
00252 int davRename(const char * oldpath, const char * newpath)
00253         /*@globals fileSystem, internalState @*/
00254         /*@modifies fileSystem, internalState @*/;
00255 
00258 int davUnlink(const char * path)
00259         /*@globals fileSystem, internalState @*/
00260         /*@modifies fileSystem, internalState @*/;
00261 
00267 int davClosedir(/*@only@*/ DIR * dir)
00268         /*@globals fileSystem @*/
00269         /*@modifies dir, fileSystem @*/;
00270 
00276 /*@dependent@*/ /*@null@*/
00277 struct dirent * davReaddir(DIR * dir)
00278         /*@globals fileSystem @*/
00279         /*@modifies fileSystem @*/;
00280 
00286 /*@null@*/
00287 DIR * davOpendir(const char * path)
00288         /*@globals errno, fileSystem, internalState @*/
00289         /*@modifies errno, fileSystem, internalState @*/;
00290 
00294 int davStat(const char * path, /*@out@*/ struct stat * st)
00295         /*@globals errno, fileSystem, internalState @*/
00296         /*@modifies *st, errno, fileSystem, internalState @*/;
00297 
00301 int davLstat(const char * path, /*@out@*/ struct stat * st)
00302         /*@globals errno, fileSystem, internalState @*/
00303         /*@modifies *st, errno, fileSystem, internalState @*/;
00304 
00308 char * davRealpath(const char * path, /*@out@*/ /*@null@*/ char * resolved_path)
00309         /*@modifies *resolved_path @*/;
00310 
00311 #ifdef __cplusplus
00312 }
00313 #endif
00314 
00315 #endif /* RPMDAV_H */