rpm  5.2.1
rpmdav.h
Go to the documentation of this file.
1 #ifndef RPMDAV_H
2 #define RPMDAV_H
3 
8 #include <argv.h>
9 
12 /*@unchecked@*/
13 extern int rpmioHttpReadTimeoutSecs;
14 /*@unchecked@*/
16 /*@unchecked@*/ /*@null@*/
17 extern const char * rpmioHttpAccept;
18 /*@unchecked@*/ /*@null@*/
19 extern const char * rpmioHttpUserAgent;
20 
21 #if defined(_RPMDAV_INTERNAL)
22 struct __dirstream {
23  int fd; /* File descriptor. */
24  char * data; /* Directory block. */
25  size_t allocation; /* Space allocated for the block. */
26  size_t size; /* Total valid data in the block. */
27  size_t offset; /* Current offset into the block. */
28  off_t filepos; /* Position of next entry to read. */
29 #if defined(WITH_PTHREADS)
30  pthread_mutex_t lock; /* Mutex lock for this structure. */
31 #endif
32 };
33 #endif
34 
35 #if !defined(DT_DIR) || defined(__APPLE__)
36 # define DT_UNKNOWN 0
37 # define DT_FIFO 1
38 # define DT_CHR 2
39 # define DT_DIR 4
40 # define DT_BLK 6
41 # define DT_REG 8
42 # define DT_LNK 10
43 # define DT_SOCK 12
44 # define DT_WHT 14
45 typedef struct __dirstream * AVDIR;
46 typedef struct __dirstream * DAVDIR;
47 #else
48 # if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
49 typedef struct __dirstream * AVDIR;
50 typedef struct __dirstream * DAVDIR;
51 #else /* __FreeBSD__ */
52 typedef DIR * AVDIR;
53 typedef DIR * DAVDIR;
54 #endif /* __FreeBSD__ */
55 #endif
56 
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 #if defined(_RPMAV_INTERNAL)
63 
65 typedef struct avContext_s * avContext;
66 
69 /*@unchecked@*/
70 extern int avmagicdir;
71 #define ISAVMAGIC(_dir) (!memcmp((_dir), &avmagicdir, sizeof(avmagicdir)))
72 
75 struct avContext_s {
76 /*@relnull@*/ /*@dependent@*/
77  void ** resrock;
78  const char *uri;
79 /*@refcounted@*/
80  urlinfo u;
81  int ac;
82  int nalloced;
83  ARGV_t av;
84 /*@relnull@*/ /*@shared@*/
85  struct stat *st;
86  rpmuint16_t * modes; /* XXX sizeof(mode_t) != sizeof(rpmmode_t) */
87  size_t * sizes;
88  time_t * mtimes;
89 };
90 
93 /*@null@*/
94 void * avContextDestroy(/*@only@*/ /*@null@*/ avContext ctx)
95  /*@globals internalState @*/
96  /*@modifies ctx, internalState @*/;
97 
100 /*@null@*/
101 void * avContextCreate(const char *uri, /*@null@*/ struct stat *st)
102  /*@globals internalState @*/
103  /*@modifies *st, internalState @*/;
104 
107 int avContextAdd(avContext ctx, const char * path,
108  mode_t mode, size_t size, time_t mtime)
109  /*@globals internalState @*/
110  /*@modifies ctx, internalState @*/;
111 
117 int avClosedir(/*@only@*/ DIR * dir)
118  /*@globals fileSystem @*/
119  /*@modifies dir, fileSystem @*/;
120 
126 /*@dependent@*/ /*@null@*/
127 struct dirent * avReaddir(DIR * dir)
128  /*@globals fileSystem @*/
129  /*@modifies fileSystem @*/;
130 
138 /*@null@*/
139 DIR * avOpendir(const char * path,
140  /*@null@*/ const char ** av, /*@null@*/ rpmuint16_t * modes)
141  /*@globals fileSystem, internalState @*/
142  /*@modifies fileSystem, internalState @*/;
143 #endif
144 
150 int davDisconnect(void * _u)
151  /*@globals internalState @*/
152  /*@modifies _u, internalState @*/;
153 
159 int davFree(urlinfo u)
160  /*@globals internalState @*/
161  /*@modifies u, internalState @*/;
162 
166 void davDestroy(void)
167  /*@globals internalState @*/
168  /*@modifies internalState @*/;
169 
177 int davReq(FD_t ctrl, const char * httpCmd, /*@null@*/ const char * httpArg)
178  /*@globals fileSystem, internalState @*/
179  /*@modifies ctrl, fileSystem, internalState @*/;
180 
188 /*@-exportlocal@*/
189 int davResp(urlinfo u, FD_t ctrl, /*@out@*/ /*@null@*/ char *const * str)
190  /*@globals fileSystem, internalState @*/
191  /*@modifies ctrl, *str, fileSystem, internalState @*/;
192 /*@=exportlocal@*/
193 
202 /*@null@*/
203 FD_t davOpen(const char * url, /*@unused@*/ int flags,
204  /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
205  /*@globals internalState @*/
206  /*@modifies *uret, internalState @*/;
207 
208 /*@null@*/
209 FD_t httpOpen(const char * url, /*@unused@*/ int flags,
210  /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
211  /*@globals internalState @*/
212  /*@modifies *uret, internalState @*/;
213 
216 ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
217  /*@globals errno, fileSystem, internalState @*/
218  /*@modifies buf, errno, fileSystem, internalState @*/;
219 
222 ssize_t davWrite(void * cookie, const char * buf, size_t count)
223  /*@globals fileSystem, internalState @*/
224  /*@modifies fileSystem, internalState @*/;
225 
228 int davSeek(void * cookie, _libio_pos_t pos, int whence)
229  /*@globals fileSystem, internalState @*/
230  /*@modifies fileSystem, internalState @*/;
231 
234 int davClose(void * cookie)
235  /*@globals fileSystem, internalState @*/
236  /*@modifies cookie, fileSystem, internalState @*/;
237 
240 int davMkdir(const char * path, mode_t mode)
241  /*@globals fileSystem, internalState @*/
242  /*@modifies fileSystem, internalState @*/;
243 
246 int davRmdir(const char * path)
247  /*@globals fileSystem, internalState @*/
248  /*@modifies fileSystem, internalState @*/;
249 
252 int davRename(const char * oldpath, const char * newpath)
253  /*@globals fileSystem, internalState @*/
254  /*@modifies fileSystem, internalState @*/;
255 
258 int davUnlink(const char * path)
259  /*@globals fileSystem, internalState @*/
260  /*@modifies fileSystem, internalState @*/;
261 
267 int davClosedir(/*@only@*/ DIR * dir)
268  /*@globals fileSystem @*/
269  /*@modifies dir, fileSystem @*/;
270 
276 /*@dependent@*/ /*@null@*/
277 struct dirent * davReaddir(DIR * dir)
278  /*@globals fileSystem @*/
279  /*@modifies fileSystem @*/;
280 
286 /*@null@*/
287 DIR * davOpendir(const char * path)
288  /*@globals errno, fileSystem, internalState @*/
289  /*@modifies errno, fileSystem, internalState @*/;
290 
294 int davStat(const char * path, /*@out@*/ struct stat * st)
295  /*@globals errno, fileSystem, internalState @*/
296  /*@modifies *st, errno, fileSystem, internalState @*/;
297 
301 int davLstat(const char * path, /*@out@*/ struct stat * st)
302  /*@globals errno, fileSystem, internalState @*/
303  /*@modifies *st, errno, fileSystem, internalState @*/;
304 
308 char * davRealpath(const char * path, /*@out@*/ /*@null@*/ char * resolved_path)
309  /*@modifies *resolved_path @*/;
310 
311 #ifdef __cplusplus
312 }
313 #endif
314 
315 #endif /* RPMDAV_H */