rpm  5.4.15
rpmdir.h
Go to the documentation of this file.
1 #ifndef H_RPMDIR
2 #define H_RPMDIR
3 
8 #include <sys/types.h>
9 #include <dirent.h>
10 
11 #if !defined(DT_DIR) || defined(__APPLE__)
12 # define DT_UNKNOWN 0
13 # define DT_FIFO 1
14 # define DT_CHR 2
15 # define DT_DIR 4
16 # define DT_BLK 6
17 # define DT_REG 8
18 # define DT_LNK 10
19 # define DT_SOCK 12
20 # define DT_WHT 14
21 typedef struct __dirstream * AVDIR;
22 typedef struct __dirstream * DAVDIR;
23 #else
24 # if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
25 typedef struct __dirstream * AVDIR;
26 typedef struct __dirstream * DAVDIR;
27 #else /* __FreeBSD__ */
28 typedef DIR * AVDIR;
29 typedef DIR * DAVDIR;
30 #endif /* __FreeBSD__ */
31 #endif
32 
33 /*@unchecked@*/
34 extern int _av_debug;
35 
38 /*@unchecked@*/
39 extern int avmagicdir;
40 #define ISAVMAGIC(_dir) (!memcmp((_dir), &avmagicdir, sizeof(avmagicdir)))
41 
42 #if defined(_RPMDIR_INTERNAL)
43 #include <argv.h>
44 
45 struct __dirstream {
46  int fd; /* File descriptor. */
47  char * data; /* Directory block. */
48  size_t allocation; /* Space allocated for the block. */
49  size_t size; /* Total valid data in the block. */
50  size_t offset; /* Current offset into the block. */
51  off_t filepos; /* Position of next entry to read. */
52 #if defined(WITH_PTHREADS)
53  pthread_mutex_t lock; /* Mutex lock for this structure. */
54 #endif
55 };
56 
59 typedef /*@abstrct@*/ /*@refcounted@*/ struct rpmavx_s * rpmavx;
60 
63 struct rpmavx_s {
64  struct rpmioItem_s _item;
65 /*@relnull@*/ /*@dependent@*/
66  void ** resrock;
67  const char *uri;
68 /*@refcounted@*/
69  urlinfo u;
70  int ac;
71  int nalloced;
72  ARGV_t av;
73 /*@relnull@*/ /*@shared@*/
74  struct stat *st;
75  rpmuint16_t * modes; /* XXX sizeof(mode_t) != sizeof(rpmmode_t) */
76  size_t * sizes;
77  time_t * mtimes;
78 #if defined(__LCLINT__)
79 /*@refs@*/
80  int nrefs;
81 #endif
82 };
83 #endif /* _RPMDIR_INTERNAL */
84 
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88 
89 #if defined(_RPMDIR_INTERNAL)
90 
95 /*@unused@*/ /*@null@*/
96 rpmavx rpmavxUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmavx avx)
97  /*@modifies avx @*/;
98 #define rpmavxUnlink(_avx) \
99  ((rpmavx)rpmioUnlinkPoolItem((rpmioItem)(_avx), __FUNCTION__, __FILE__, __LINE__))
100 
106 /*@unused@*/ /*@newref@*/ /*@null@*/
107 rpmavx rpmavxLink (/*@null@*/ rpmavx avx)
108  /*@modifies avx @*/;
109 #define rpmavxLink(_avx) \
110  ((rpmavx)rpmioLinkPoolItem((rpmioItem)(_avx), __FUNCTION__, __FILE__, __LINE__))
111 
117 /*@null@*/
118 rpmavx rpmavxFree(/*@killref@*/ /*@null@*/rpmavx avx)
119  /*@globals internalState @*/
120  /*@modifies avx, internalState @*/;
121 #define rpmavxFree(_avx) \
122  ((rpmavx)rpmioFreePoolItem((rpmioItem)(_avx), __FUNCTION__, __FILE__, __LINE__))
123 
126 /*@null@*/
127 void * rpmavxNew(const char *uri, /*@null@*/ struct stat *st)
128  /*@globals internalState @*/
129  /*@modifies *st, internalState @*/;
130 
133 int rpmavxAdd(rpmavx avx, const char * path,
134  mode_t mode, size_t size, time_t mtime)
135  /*@globals internalState @*/
136  /*@modifies avx, internalState @*/;
137 
143 int avClosedir(/*@only@*/ DIR * dir)
144  /*@globals fileSystem @*/
145  /*@modifies dir, fileSystem @*/;
146 
154 /*@null@*/
155 DIR * avOpendir(const char * path,
156  /*@null@*/ const char ** av, /*@null@*/ rpmuint16_t * modes)
157  /*@globals fileSystem, internalState @*/
158  /*@modifies fileSystem, internalState @*/;
159 
165 /*@dependent@*/ /*@null@*/
166 struct dirent * avReaddir(DIR * dir)
167  /*@globals fileSystem @*/
168  /*@modifies fileSystem @*/;
169 #endif /* _RPMDIR_INTERNAL */
170 
174 int Closedir(/*@only@*/ DIR * dir)
175  /*@globals errno, fileSystem @*/
176  /*@modifies *dir, errno, fileSystem @*/;
177 
181 /*@null@*/
182 DIR * Opendir(const char * path)
183  /*@globals errno, h_errno, fileSystem, internalState @*/
184  /*@modifies errno, fileSystem, internalState @*/;
185 
189 /*@dependent@*/ /*@null@*/
190 struct dirent * Readdir(DIR * dir)
191  /*@globals errno, fileSystem @*/
192  /*@modifies *dir, errno, fileSystem @*/;
193 
197 void Rewinddir(DIR * dir)
198  /*@modifies dir @*/;
199 
203 int Scandir(const char * path, struct dirent *** nl,
204  int (*filter) (const struct dirent *),
205  int (*compar) (const void *, const void *))
206  /*@modifies *nl @*/;
207 int Alphasort(const void * a, const void * b)
208  /*@*/;
209 int Versionsort(const void * a, const void * b)
210  /*@*/;
211 
215 void Seekdir(DIR * dir, off_t offset)
216  /*@modifies dir @*/;
217 
221 off_t Telldir(DIR * dir)
222  /*@globals errno @*/
223  /*@modifies dir, errno @*/;
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 
229 #endif /* H_RPMDIR */
const bson * b
Definition: bson.h:280
int Scandir(const char *path, struct dirent ***nl, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *))
scandir(3) clone.
Definition: rpmdir.c:454
struct __dirstream * DAVDIR
Definition: rpmdir.h:22
int rpmavxAdd(rpmavx avx, const char *path, mode_t mode, size_t size, time_t mtime)
Definition: rpmdir.c:89
struct dirent * Readdir(DIR *dir)
readdir(3) clone.
Definition: rpmdir.c:432
URL control structure.
Definition: rpmurl.h:52
unsigned short rpmuint16_t
Definition: rpmiotypes.h:27
int Closedir(DIR *dir)
closedir(3) clone.
Definition: rpmdir.c:385
void Rewinddir(DIR *dir)
rewinddir(3) clone.
Definition: rpmdir.c:443
DIR * Opendir(const char *path)
opendir(3) clone.
Definition: rpmdir.c:396
void * rpmavxNew(const char *uri, struct stat *st)
Definition: rpmdir.c:64
#define pthread_mutex_t
Definition: yarn.c:68
off_t Telldir(DIR *dir)
telldir(3) clone.
Definition: rpmdir.c:521
int avClosedir(DIR *dir)
Definition: rpmdir.c:118
const char * mode
Definition: mongo.h:440
const char const bson * data
Definition: mongo.h:463
int Alphasort(const void *a, const void *b)
Definition: rpmdir.c:488
int avmagicdir
Definition: rpmdav.c:2218
int Versionsort(const void *a, const void *b)
Definition: rpmdir.c:499
struct dirent * avReaddir(DIR *dir)
Definition: rpmdir.c:219
#define dirent
Definition: system.h:245
struct __dirstream * AVDIR
Definition: rpmdir.h:21
DIR * avOpendir(const char *path, const char **av, rpmuint16_t *modes)
Definition: rpmdir.c:135
int _av_debug
Definition: rpmio.c:185
const char const char size_t size
Definition: bson.h:895
void Seekdir(DIR *dir, off_t offset)
seekdir(3) clone.
Definition: rpmdir.c:510
ARGstr_t * ARGV_t
Definition: argv.h:12
modes
Definition: rpmqv.c:136