1 | #ifndef H_RPMIO |
---|
2 | #define H_RPMIO |
---|
3 | |
---|
4 | /** \ingroup rpmio |
---|
5 | * \file rpmio/rpmio.h |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #include <sys/types.h> |
---|
10 | #include <sys/stat.h> |
---|
11 | #include <dirent.h> |
---|
12 | /*@-noparams@*/ |
---|
13 | #include <glob.h> |
---|
14 | /*@=noparams@*/ |
---|
15 | #include <stdio.h> |
---|
16 | #include <stdlib.h> |
---|
17 | #include <unistd.h> |
---|
18 | |
---|
19 | /** |
---|
20 | */ |
---|
21 | typedef /*@abstract@*/ struct pgpDig_s * pgpDig; |
---|
22 | |
---|
23 | /** |
---|
24 | */ |
---|
25 | typedef /*@abstract@*/ struct pgpDigParams_s * pgpDigParams; |
---|
26 | |
---|
27 | /** \ingroup rpmio |
---|
28 | * Hide libio API lossage. |
---|
29 | * The libio interface changed after glibc-2.1.3 to pass the seek offset |
---|
30 | * argument as a pointer rather than as an off_t. The snarl below defines |
---|
31 | * typedefs to isolate the lossage. |
---|
32 | */ |
---|
33 | /*@{*/ |
---|
34 | #if !defined(__LCLINT__) && defined(__GLIBC__) && \ |
---|
35 | (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) |
---|
36 | #define USE_COOKIE_SEEK_POINTER 1 |
---|
37 | typedef _IO_off64_t _libio_off_t; |
---|
38 | typedef _libio_off_t * _libio_pos_t; |
---|
39 | #else |
---|
40 | typedef off_t _libio_off_t; |
---|
41 | typedef off_t _libio_pos_t; |
---|
42 | #endif |
---|
43 | /*@}*/ |
---|
44 | |
---|
45 | /** \ingroup rpmio |
---|
46 | */ |
---|
47 | typedef /*@abstract@*/ /*@refcounted@*/ struct _FD_s * FD_t; |
---|
48 | |
---|
49 | /** \ingroup rpmio |
---|
50 | */ |
---|
51 | typedef /*@observer@*/ struct FDIO_s * FDIO_t; |
---|
52 | |
---|
53 | #ifdef __cplusplus |
---|
54 | extern "C" { |
---|
55 | #endif |
---|
56 | |
---|
57 | /** \ingroup rpmio |
---|
58 | * \name RPMIO Vectors. |
---|
59 | */ |
---|
60 | /*@{*/ |
---|
61 | |
---|
62 | /** |
---|
63 | */ |
---|
64 | typedef ssize_t (*fdio_read_function_t) (void *cookie, char *buf, size_t nbytes) |
---|
65 | /*@globals errno, fileSystem @*/ |
---|
66 | /*@modifies *cookie, errno, fileSystem @*/ |
---|
67 | /*@requires maxSet(buf) >= (nbytes - 1) @*/ |
---|
68 | /*@ensures maxRead(buf) == result @*/ ; |
---|
69 | |
---|
70 | /** |
---|
71 | */ |
---|
72 | typedef ssize_t (*fdio_write_function_t) (void *cookie, const char *buf, size_t nbytes) |
---|
73 | /*@globals errno, fileSystem @*/ |
---|
74 | /*@modifies *cookie, errno, fileSystem @*/; |
---|
75 | |
---|
76 | /** |
---|
77 | */ |
---|
78 | typedef int (*fdio_seek_function_t) (void *cookie, _libio_pos_t pos, int whence) |
---|
79 | /*@globals errno, fileSystem @*/ |
---|
80 | /*@modifies *cookie, errno, fileSystem @*/; |
---|
81 | |
---|
82 | /** |
---|
83 | */ |
---|
84 | typedef int (*fdio_close_function_t) (void *cookie) |
---|
85 | /*@globals errno, fileSystem, systemState @*/ |
---|
86 | /*@modifies *cookie, errno, fileSystem, systemState @*/; |
---|
87 | |
---|
88 | |
---|
89 | /** |
---|
90 | */ |
---|
91 | typedef /*@only@*/ /*@null@*/ FD_t (*fdio_ref_function_t) ( /*@only@*/ void * cookie, |
---|
92 | const char * msg, const char * file, unsigned line) |
---|
93 | /*@globals fileSystem @*/ |
---|
94 | /*@modifies fileSystem @*/; |
---|
95 | |
---|
96 | /** |
---|
97 | */ |
---|
98 | typedef /*@only@*/ /*@null@*/ FD_t (*fdio_deref_function_t) ( /*@only@*/ FD_t fd, |
---|
99 | const char * msg, const char * file, unsigned line) |
---|
100 | /*@globals fileSystem @*/ |
---|
101 | /*@modifies fd, fileSystem @*/; |
---|
102 | |
---|
103 | |
---|
104 | /** |
---|
105 | */ |
---|
106 | typedef /*@only@*/ /*@null@*/ FD_t (*fdio_new_function_t) (const char * msg, |
---|
107 | const char * file, unsigned line) |
---|
108 | /*@globals fileSystem @*/ |
---|
109 | /*@modifies fileSystem @*/; |
---|
110 | |
---|
111 | |
---|
112 | /** |
---|
113 | */ |
---|
114 | typedef int (*fdio_fileno_function_t) (void * cookie) |
---|
115 | /*@globals fileSystem @*/ |
---|
116 | /*@modifies *cookie, fileSystem @*/; |
---|
117 | |
---|
118 | |
---|
119 | /** |
---|
120 | */ |
---|
121 | typedef FD_t (*fdio_open_function_t) (const char * path, int flags, mode_t mode) |
---|
122 | /*@globals errno, fileSystem @*/ |
---|
123 | /*@modifies errno, fileSystem @*/; |
---|
124 | |
---|
125 | /** |
---|
126 | */ |
---|
127 | typedef FD_t (*fdio_fopen_function_t) (const char * path, const char * fmode) |
---|
128 | /*@globals fileSystem @*/ |
---|
129 | /*@modifies fileSystem @*/; |
---|
130 | |
---|
131 | /** |
---|
132 | */ |
---|
133 | typedef void * (*fdio_ffileno_function_t) (FD_t fd) |
---|
134 | /*@globals fileSystem @*/ |
---|
135 | /*@modifies fileSystem @*/; |
---|
136 | |
---|
137 | /** |
---|
138 | */ |
---|
139 | typedef int (*fdio_fflush_function_t) (FD_t fd) |
---|
140 | /*@globals fileSystem @*/ |
---|
141 | /*@modifies fileSystem @*/; |
---|
142 | /*@}*/ |
---|
143 | |
---|
144 | |
---|
145 | /** \ingroup rpmrpc |
---|
146 | * \name RPMRPC Vectors. |
---|
147 | */ |
---|
148 | /*@{*/ |
---|
149 | |
---|
150 | /** |
---|
151 | */ |
---|
152 | typedef int (*fdio_mkdir_function_t) (const char * path, mode_t mode) |
---|
153 | /*@globals errno, fileSystem @*/ |
---|
154 | /*@modifies errno, fileSystem @*/; |
---|
155 | |
---|
156 | /** |
---|
157 | */ |
---|
158 | typedef int (*fdio_chdir_function_t) (const char * path) |
---|
159 | /*@globals errno, fileSystem @*/ |
---|
160 | /*@modifies errno, fileSystem @*/; |
---|
161 | |
---|
162 | /** |
---|
163 | */ |
---|
164 | typedef int (*fdio_rmdir_function_t) (const char * path) |
---|
165 | /*@globals errno, fileSystem @*/ |
---|
166 | /*@modifies errno, fileSystem @*/; |
---|
167 | |
---|
168 | /** |
---|
169 | */ |
---|
170 | typedef int (*fdio_rename_function_t) (const char * oldpath, const char * newpath) |
---|
171 | /*@globals errno, fileSystem @*/ |
---|
172 | /*@modifies errno, fileSystem @*/; |
---|
173 | |
---|
174 | /** |
---|
175 | */ |
---|
176 | typedef int (*fdio_unlink_function_t) (const char * path) |
---|
177 | /*@globals errno, fileSystem @*/ |
---|
178 | /*@modifies errno, fileSystem @*/; |
---|
179 | /*@-typeuse@*/ |
---|
180 | |
---|
181 | /** |
---|
182 | */ |
---|
183 | typedef int (*fdio_stat_function_t) (const char * path, /*@out@*/ struct stat * st) |
---|
184 | /*@globals errno, fileSystem @*/ |
---|
185 | /*@modifies *st, errno, fileSystem @*/; |
---|
186 | |
---|
187 | /** |
---|
188 | */ |
---|
189 | typedef int (*fdio_lstat_function_t) (const char * path, /*@out@*/ struct stat * st) |
---|
190 | /*@globals errno, fileSystem @*/ |
---|
191 | /*@modifies *st, errno, fileSystem @*/; |
---|
192 | |
---|
193 | /** |
---|
194 | */ |
---|
195 | typedef int (*fdio_access_function_t) (const char * path, int amode) |
---|
196 | /*@globals errno, fileSystem @*/ |
---|
197 | /*@modifies errno, fileSystem @*/; |
---|
198 | /*@=typeuse@*/ |
---|
199 | /*@}*/ |
---|
200 | |
---|
201 | |
---|
202 | /** \ingroup rpmio |
---|
203 | */ |
---|
204 | struct FDIO_s { |
---|
205 | fdio_read_function_t read; |
---|
206 | fdio_write_function_t write; |
---|
207 | fdio_seek_function_t seek; |
---|
208 | fdio_close_function_t close; |
---|
209 | |
---|
210 | fdio_ref_function_t _fdref; |
---|
211 | fdio_deref_function_t _fdderef; |
---|
212 | fdio_new_function_t _fdnew; |
---|
213 | fdio_fileno_function_t _fileno; |
---|
214 | |
---|
215 | fdio_open_function_t _open; |
---|
216 | fdio_fopen_function_t _fopen; |
---|
217 | fdio_ffileno_function_t _ffileno; |
---|
218 | fdio_fflush_function_t _fflush; |
---|
219 | |
---|
220 | fdio_mkdir_function_t _mkdir; |
---|
221 | fdio_chdir_function_t _chdir; |
---|
222 | fdio_rmdir_function_t _rmdir; |
---|
223 | fdio_rename_function_t _rename; |
---|
224 | fdio_unlink_function_t _unlink; |
---|
225 | }; |
---|
226 | |
---|
227 | |
---|
228 | /** \ingroup rpmio |
---|
229 | * \name RPMIO Interface. |
---|
230 | */ |
---|
231 | /*@{*/ |
---|
232 | |
---|
233 | /** |
---|
234 | * strerror(3) clone. |
---|
235 | */ |
---|
236 | /*@observer@*/ const char * Fstrerror(/*@null@*/ FD_t fd) |
---|
237 | /*@*/; |
---|
238 | |
---|
239 | /** |
---|
240 | * fread(3) clone. |
---|
241 | */ |
---|
242 | /*@-incondefs@*/ |
---|
243 | size_t Fread(/*@out@*/ void * buf, size_t size, size_t nmemb, FD_t fd) |
---|
244 | /*@globals fileSystem @*/ |
---|
245 | /*@modifies fd, *buf, fileSystem @*/ |
---|
246 | /*@requires maxSet(buf) >= (nmemb - 1) @*/ |
---|
247 | /*@ensures maxRead(buf) == result @*/; |
---|
248 | /*@=incondefs@*/ |
---|
249 | |
---|
250 | /** |
---|
251 | * fwrite(3) clone. |
---|
252 | */ |
---|
253 | /*@-incondefs@*/ |
---|
254 | size_t Fwrite(const void * buf, size_t size, size_t nmemb, FD_t fd) |
---|
255 | /*@globals fileSystem @*/ |
---|
256 | /*@modifies fd, fileSystem @*/ |
---|
257 | /*@requires maxRead(buf) >= nmemb @*/; |
---|
258 | /*@=incondefs@*/ |
---|
259 | |
---|
260 | /** |
---|
261 | * fseek(3) clone. |
---|
262 | */ |
---|
263 | int Fseek(FD_t fd, _libio_off_t offset, int whence) |
---|
264 | /*@globals fileSystem @*/ |
---|
265 | /*@modifies fileSystem @*/; |
---|
266 | |
---|
267 | /** |
---|
268 | * fclose(3) clone. |
---|
269 | */ |
---|
270 | int Fclose( /*@killref@*/ FD_t fd) |
---|
271 | /*@globals fileSystem, internalState @*/ |
---|
272 | /*@modifies fd, fileSystem, internalState @*/; |
---|
273 | |
---|
274 | /** |
---|
275 | */ |
---|
276 | /*@null@*/ FD_t Fdopen(FD_t ofd, const char * fmode) |
---|
277 | /*@globals fileSystem @*/ |
---|
278 | /*@modifies ofd, fileSystem @*/; |
---|
279 | |
---|
280 | /** |
---|
281 | * fopen(3) clone. |
---|
282 | */ |
---|
283 | /*@null@*/ FD_t Fopen(/*@null@*/ const char * path, |
---|
284 | /*@null@*/ const char * fmode) |
---|
285 | /*@globals fileSystem, internalState @*/ |
---|
286 | /*@modifies fileSystem, internalState @*/; |
---|
287 | |
---|
288 | |
---|
289 | /** |
---|
290 | * fflush(3) clone. |
---|
291 | */ |
---|
292 | int Fflush(/*@null@*/ FD_t fd) |
---|
293 | /*@globals fileSystem @*/ |
---|
294 | /*@modifies fd, fileSystem @*/; |
---|
295 | |
---|
296 | /** |
---|
297 | * ferror(3) clone. |
---|
298 | */ |
---|
299 | int Ferror(/*@null@*/ FD_t fd) |
---|
300 | /*@*/; |
---|
301 | |
---|
302 | /** |
---|
303 | * fileno(3) clone. |
---|
304 | */ |
---|
305 | int Fileno(FD_t fd) |
---|
306 | /*@globals fileSystem @*/ |
---|
307 | /*@modifies fileSystem@*/; |
---|
308 | |
---|
309 | /** |
---|
310 | * fcntl(2) clone. |
---|
311 | */ |
---|
312 | /*@unused@*/ |
---|
313 | int Fcntl(FD_t fd, int op, void *lip) |
---|
314 | /*@globals errno, fileSystem @*/ |
---|
315 | /*@modifies fd, *lip, errno, fileSystem @*/; |
---|
316 | |
---|
317 | /*@}*/ |
---|
318 | |
---|
319 | /** \ingroup rpmrpc |
---|
320 | * \name RPMRPC Interface. |
---|
321 | */ |
---|
322 | /*@{*/ |
---|
323 | |
---|
324 | /** |
---|
325 | * mkdir(2) clone. |
---|
326 | */ |
---|
327 | int Mkdir(const char * path, mode_t mode) |
---|
328 | /*@globals errno, fileSystem, internalState @*/ |
---|
329 | /*@modifies errno, fileSystem, internalState @*/; |
---|
330 | |
---|
331 | /** |
---|
332 | * chdir(2) clone. |
---|
333 | */ |
---|
334 | int Chdir(const char * path) |
---|
335 | /*@globals errno, fileSystem, internalState @*/ |
---|
336 | /*@modifies errno, fileSystem, internalState @*/; |
---|
337 | |
---|
338 | /** |
---|
339 | * rmdir(2) clone. |
---|
340 | */ |
---|
341 | int Rmdir(const char * path) |
---|
342 | /*@globals errno, fileSystem, internalState @*/ |
---|
343 | /*@modifies errno, fileSystem, internalState @*/; |
---|
344 | |
---|
345 | /** |
---|
346 | * rename(2) clone. |
---|
347 | */ |
---|
348 | int Rename(const char * oldpath, const char * newpath) |
---|
349 | /*@globals errno, fileSystem, internalState @*/ |
---|
350 | /*@modifies errno, fileSystem, internalState @*/; |
---|
351 | |
---|
352 | /** |
---|
353 | * link(2) clone. |
---|
354 | */ |
---|
355 | int Link(const char * oldpath, const char * newpath) |
---|
356 | /*@globals errno, fileSystem, internalState @*/ |
---|
357 | /*@modifies errno, fileSystem, internalState @*/; |
---|
358 | |
---|
359 | /** |
---|
360 | * unlink(2) clone. |
---|
361 | */ |
---|
362 | int Unlink(const char * path) |
---|
363 | /*@globals errno, fileSystem, internalState @*/ |
---|
364 | /*@modifies errno, fileSystem, internalState @*/; |
---|
365 | |
---|
366 | /** |
---|
367 | * readlink(2) clone. |
---|
368 | */ |
---|
369 | /*@-incondefs@*/ |
---|
370 | int Readlink(const char * path, /*@out@*/ char * buf, size_t bufsiz) |
---|
371 | /*@globals errno, fileSystem, internalState @*/ |
---|
372 | /*@modifies *buf, errno, fileSystem, internalState @*/ |
---|
373 | /*@requires maxSet(buf) >= (bufsiz - 1) @*/ |
---|
374 | /*@ensures maxRead(buf) <= bufsiz @*/; |
---|
375 | /*@=incondefs@*/ |
---|
376 | |
---|
377 | /** |
---|
378 | * stat(2) clone. |
---|
379 | */ |
---|
380 | int Stat(const char * path, /*@out@*/ struct stat * st) |
---|
381 | /*@globals errno, fileSystem, internalState @*/ |
---|
382 | /*@modifies *st, errno, fileSystem, internalState @*/; |
---|
383 | |
---|
384 | /** |
---|
385 | * lstat(2) clone. |
---|
386 | */ |
---|
387 | int Lstat(const char * path, /*@out@*/ struct stat * st) |
---|
388 | /*@globals errno, fileSystem, internalState @*/ |
---|
389 | /*@modifies *st, errno, fileSystem, internalState @*/; |
---|
390 | |
---|
391 | /** |
---|
392 | * access(2) clone. |
---|
393 | */ |
---|
394 | int Access(const char * path, int amode) |
---|
395 | /*@globals errno, fileSystem @*/ |
---|
396 | /*@modifies errno, fileSystem @*/; |
---|
397 | |
---|
398 | |
---|
399 | /** |
---|
400 | * glob(3) clone. |
---|
401 | */ |
---|
402 | int Glob(const char * pattern, int flags, |
---|
403 | int errfunc(const char * epath, int eerrno), |
---|
404 | /*@out@*/ glob_t * pglob) |
---|
405 | /*@globals fileSystem @*/ |
---|
406 | /*@modifies *pglob, fileSystem @*/; |
---|
407 | |
---|
408 | /** |
---|
409 | * globfree(3) clone. |
---|
410 | */ |
---|
411 | void Globfree( /*@only@*/ glob_t * pglob) |
---|
412 | /*@globals fileSystem @*/ |
---|
413 | /*@modifies *pglob, fileSystem @*/; |
---|
414 | |
---|
415 | |
---|
416 | /** |
---|
417 | * opendir(3) clone. |
---|
418 | */ |
---|
419 | /*@null@*/ |
---|
420 | DIR * Opendir(const char * path) |
---|
421 | /*@globals errno, fileSystem, internalState @*/ |
---|
422 | /*@modifies errno, fileSystem, internalState @*/; |
---|
423 | |
---|
424 | /** |
---|
425 | * readdir(3) clone. |
---|
426 | */ |
---|
427 | /*@dependent@*/ /*@null@*/ |
---|
428 | struct dirent * Readdir(DIR * dir) |
---|
429 | /*@globals errno, fileSystem @*/ |
---|
430 | /*@modifies *dir, errno, fileSystem @*/; |
---|
431 | |
---|
432 | /** |
---|
433 | * closedir(3) clone. |
---|
434 | */ |
---|
435 | int Closedir(/*@only@*/ DIR * dir) |
---|
436 | /*@globals errno, fileSystem @*/ |
---|
437 | /*@modifies *dir, errno, fileSystem @*/; |
---|
438 | |
---|
439 | /*@}*/ |
---|
440 | |
---|
441 | |
---|
442 | /** \ingroup rpmio |
---|
443 | * \name RPMIO Utilities. |
---|
444 | */ |
---|
445 | /*@{*/ |
---|
446 | |
---|
447 | /** |
---|
448 | */ |
---|
449 | off_t fdSize(FD_t fd) |
---|
450 | /*@globals fileSystem @*/ |
---|
451 | /*@modifies fd, fileSystem@*/; |
---|
452 | |
---|
453 | /** |
---|
454 | */ |
---|
455 | /*@null@*/ FD_t fdDup(int fdno) |
---|
456 | /*@globals fileSystem, internalState @*/ |
---|
457 | /*@modifies fileSystem, internalState @*/; |
---|
458 | |
---|
459 | #ifdef UNUSED |
---|
460 | /*@null@*/ FILE *fdFdopen( /*@only@*/ void * cookie, const char * mode); |
---|
461 | #endif |
---|
462 | |
---|
463 | /* XXX Legacy interfaces needed by gnorpm, rpmfind et al */ |
---|
464 | |
---|
465 | /*@-exportlocal@*/ |
---|
466 | /** |
---|
467 | */ |
---|
468 | #ifndef H_RPMIO_INTERNAL /* XXX avoid gcc warning */ |
---|
469 | /*@unused@*/ int fdFileno(void * cookie) |
---|
470 | /*@*/; |
---|
471 | #define fdFileno(_fd) fdio->_fileno(_fd) |
---|
472 | #endif |
---|
473 | |
---|
474 | /** |
---|
475 | */ |
---|
476 | /*@null@*/ FD_t fdOpen(const char *path, int flags, mode_t mode) |
---|
477 | /*@globals errno, fileSystem, internalState @*/ |
---|
478 | /*@modifies errno, fileSystem, internalState @*/; |
---|
479 | #define fdOpen(_path, _flags, _mode) fdio->_open((_path), (_flags), (_mode)) |
---|
480 | |
---|
481 | /** |
---|
482 | */ |
---|
483 | /*@-incondefs@*/ |
---|
484 | ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count) |
---|
485 | /*@globals errno, fileSystem @*/ |
---|
486 | /*@modifies *cookie, *buf, errno, fileSystem @*/ |
---|
487 | /*@requires maxSet(buf) >= (count - 1) @*/ |
---|
488 | /*@ensures maxRead(buf) == result @*/ ; |
---|
489 | #define fdRead(_fd, _buf, _count) fdio->read((_fd), (_buf), (_count)) |
---|
490 | /*@=incondefs@*/ |
---|
491 | |
---|
492 | /** |
---|
493 | */ |
---|
494 | ssize_t fdWrite(void * cookie, const char * buf, size_t count) |
---|
495 | /*@globals errno, fileSystem @*/ |
---|
496 | /*@modifies *cookie, errno, fileSystem @*/; |
---|
497 | #define fdWrite(_fd, _buf, _count) fdio->write((_fd), (_buf), (_count)) |
---|
498 | |
---|
499 | /** |
---|
500 | */ |
---|
501 | int fdClose( /*@only@*/ void * cookie) |
---|
502 | /*@globals errno, fileSystem, systemState, internalState @*/ |
---|
503 | /*@modifies *cookie, errno, fileSystem, systemState, internalState @*/; |
---|
504 | #define fdCLose(_fd) fdio->close(_fd) |
---|
505 | |
---|
506 | /** |
---|
507 | */ |
---|
508 | /*@unused@*/ |
---|
509 | /*@only@*/ /*@null@*/ |
---|
510 | FD_t fdLink (/*@only@*/ void * cookie, const char * msg) |
---|
511 | /*@globals fileSystem @*/ |
---|
512 | /*@modifies *cookie, fileSystem @*/; |
---|
513 | #define fdLink(_fd, _msg) fdio->_fdref(_fd, _msg, __FILE__, __LINE__) |
---|
514 | |
---|
515 | /** |
---|
516 | */ |
---|
517 | /*@unused@*/ |
---|
518 | /*@only@*/ /*@null@*/ |
---|
519 | FD_t fdFree(/*@only@*/ FD_t fd, const char * msg) |
---|
520 | /*@globals fileSystem @*/ |
---|
521 | /*@modifies fd, fileSystem @*/; |
---|
522 | #define fdFree(_fd, _msg) fdio->_fdderef(_fd, _msg, __FILE__, __LINE__) |
---|
523 | |
---|
524 | /** |
---|
525 | */ |
---|
526 | /*@unused@*/ |
---|
527 | /*@only@*/ /*@null@*/ |
---|
528 | FD_t fdNew (const char * msg) |
---|
529 | /*@globals fileSystem @*/ |
---|
530 | /*@modifies fileSystem @*/; |
---|
531 | #define fdNew(_msg) fdio->_fdnew(_msg, __FILE__, __LINE__) |
---|
532 | |
---|
533 | /** |
---|
534 | */ |
---|
535 | int fdWritable(FD_t fd, int secs) |
---|
536 | /*@globals errno, fileSystem @*/ |
---|
537 | /*@modifies fd, errno, fileSystem @*/; |
---|
538 | |
---|
539 | /** |
---|
540 | */ |
---|
541 | int fdReadable(FD_t fd, int secs) |
---|
542 | /*@globals errno @*/ |
---|
543 | /*@modifies fd, errno @*/; |
---|
544 | /*@=exportlocal@*/ |
---|
545 | |
---|
546 | /** |
---|
547 | * Insure that directories in path exist, creating as needed. |
---|
548 | * @param path diretory path |
---|
549 | * @param mode directory mode (if created) |
---|
550 | * @param uid directory uid (if created), or -1 to skip |
---|
551 | * @param gid directory uid (if created), or -1 to skip |
---|
552 | * @return 0 on success, errno (or -1) on error |
---|
553 | */ |
---|
554 | int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid) |
---|
555 | /*@globals fileSystem, internalState @*/ |
---|
556 | /*@modifies fileSystem, internalState @*/; |
---|
557 | |
---|
558 | /** |
---|
559 | * FTP and HTTP error codes. |
---|
560 | */ |
---|
561 | /*@-typeuse@*/ |
---|
562 | typedef enum ftperrCode_e { |
---|
563 | FTPERR_BAD_SERVER_RESPONSE = -1, /*!< Bad server response */ |
---|
564 | FTPERR_SERVER_IO_ERROR = -2, /*!< Server I/O error */ |
---|
565 | FTPERR_SERVER_TIMEOUT = -3, /*!< Server timeout */ |
---|
566 | FTPERR_BAD_HOST_ADDR = -4, /*!< Unable to lookup server host address */ |
---|
567 | FTPERR_BAD_HOSTNAME = -5, /*!< Unable to lookup server host name */ |
---|
568 | FTPERR_FAILED_CONNECT = -6, /*!< Failed to connect to server */ |
---|
569 | FTPERR_FILE_IO_ERROR = -7, /*!< Failed to establish data connection to server */ |
---|
570 | FTPERR_PASSIVE_ERROR = -8, /*!< I/O error to local file */ |
---|
571 | FTPERR_FAILED_DATA_CONNECT = -9, /*!< Error setting remote server to passive mode */ |
---|
572 | FTPERR_FILE_NOT_FOUND = -10, /*!< File not found on server */ |
---|
573 | FTPERR_NIC_ABORT_IN_PROGRESS= -11, /*!< Abort in progress */ |
---|
574 | FTPERR_UNKNOWN = -100 /*!< Unknown or unexpected error */ |
---|
575 | } ftperrCode; |
---|
576 | /*@=typeuse@*/ |
---|
577 | |
---|
578 | /** |
---|
579 | */ |
---|
580 | /*@-redecl@*/ |
---|
581 | /*@observer@*/ const char *const ftpStrerror(int errorNumber) |
---|
582 | /*@*/; |
---|
583 | /*@=redecl@*/ |
---|
584 | |
---|
585 | /** |
---|
586 | */ |
---|
587 | /*@unused@*/ |
---|
588 | /*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd) |
---|
589 | /*@modifies fd @*/; |
---|
590 | |
---|
591 | /** |
---|
592 | */ |
---|
593 | /*@-redecl@*/ |
---|
594 | /*@unused@*/ |
---|
595 | /*@observer@*/ const char * urlStrerror(const char * url) |
---|
596 | /*@globals internalState @*/ |
---|
597 | /*@modifies internalState @*/; |
---|
598 | /*@=redecl@*/ |
---|
599 | |
---|
600 | /** |
---|
601 | */ |
---|
602 | /*@-exportlocal@*/ |
---|
603 | int ufdCopy(FD_t sfd, FD_t tfd) |
---|
604 | /*@globals fileSystem @*/ |
---|
605 | /*@modifies sfd, tfd, fileSystem @*/; |
---|
606 | /*@=exportlocal@*/ |
---|
607 | |
---|
608 | /** |
---|
609 | */ |
---|
610 | int ufdGetFile( /*@killref@*/ FD_t sfd, FD_t tfd) |
---|
611 | /*@globals fileSystem, internalState @*/ |
---|
612 | /*@modifies sfd, tfd, fileSystem, internalState @*/; |
---|
613 | |
---|
614 | /** |
---|
615 | */ |
---|
616 | /*@unused@*/ int timedRead(FD_t fd, /*@out@*/ void * bufptr, int length) |
---|
617 | /*@globals fileSystem @*/ |
---|
618 | /*@modifies fd, *bufptr, fileSystem @*/; |
---|
619 | #define timedRead ufdio->read |
---|
620 | |
---|
621 | /*@-exportlocal@*/ |
---|
622 | /** |
---|
623 | */ |
---|
624 | /*@observer@*/ /*@unchecked@*/ extern FDIO_t fdio; |
---|
625 | |
---|
626 | /** |
---|
627 | */ |
---|
628 | /*@observer@*/ /*@unchecked@*/ extern FDIO_t fpio; |
---|
629 | |
---|
630 | /** |
---|
631 | */ |
---|
632 | /*@observer@*/ /*@unchecked@*/ extern FDIO_t ufdio; |
---|
633 | |
---|
634 | /** |
---|
635 | */ |
---|
636 | /*@observer@*/ /*@unchecked@*/ extern FDIO_t gzdio; |
---|
637 | |
---|
638 | /** |
---|
639 | */ |
---|
640 | /*@observer@*/ /*@unchecked@*/ extern FDIO_t bzdio; |
---|
641 | |
---|
642 | /** |
---|
643 | */ |
---|
644 | /*@observer@*/ /*@unchecked@*/ extern FDIO_t fadio; |
---|
645 | /*@=exportlocal@*/ |
---|
646 | /*@}*/ |
---|
647 | |
---|
648 | /*@unused@*/ static inline int xislower(int c) /*@*/ { |
---|
649 | return (c >= 'a' && c <= 'z'); |
---|
650 | } |
---|
651 | /*@unused@*/ static inline int xisupper(int c) /*@*/ { |
---|
652 | return (c >= 'A' && c <= 'Z'); |
---|
653 | } |
---|
654 | /*@unused@*/ static inline int xisalpha(int c) /*@*/ { |
---|
655 | return (xislower(c) || xisupper(c)); |
---|
656 | } |
---|
657 | /*@unused@*/ static inline int xisdigit(int c) /*@*/ { |
---|
658 | return (c >= '0' && c <= '9'); |
---|
659 | } |
---|
660 | /*@unused@*/ static inline int xisalnum(int c) /*@*/ { |
---|
661 | return (xisalpha(c) || xisdigit(c)); |
---|
662 | } |
---|
663 | /*@unused@*/ static inline int xisblank(int c) /*@*/ { |
---|
664 | return (c == ' ' || c == '\t'); |
---|
665 | } |
---|
666 | /*@unused@*/ static inline int xisspace(int c) /*@*/ { |
---|
667 | return (xisblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v'); |
---|
668 | } |
---|
669 | |
---|
670 | /*@unused@*/ static inline int xtolower(int c) /*@*/ { |
---|
671 | return ((xisupper(c)) ? (c | ('a' - 'A')) : c); |
---|
672 | } |
---|
673 | /*@unused@*/ static inline int xtoupper(int c) /*@*/ { |
---|
674 | return ((xislower(c)) ? (c & ~('a' - 'A')) : c); |
---|
675 | } |
---|
676 | |
---|
677 | /** \ingroup rpmio |
---|
678 | * Locale insensitive strcasecmp(3). |
---|
679 | */ |
---|
680 | int xstrcasecmp(const char * s1, const char * s2) /*@*/; |
---|
681 | |
---|
682 | /** \ingroup rpmio |
---|
683 | * Locale insensitive strncasecmp(3). |
---|
684 | */ |
---|
685 | int xstrncasecmp(const char *s1, const char * s2, size_t n) /*@*/; |
---|
686 | |
---|
687 | #ifdef __cplusplus |
---|
688 | } |
---|
689 | #endif |
---|
690 | |
---|
691 | #endif /* H_RPMIO */ |
---|