00001 #ifndef H_RPMIO
00002 #define H_RPMIO
00003
00009 #include <sys/types.h>
00010 #include <sys/stat.h>
00011 #include <dirent.h>
00012
00013 #include "glob.h"
00014
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017 #include <unistd.h>
00018
00021 typedef struct pgpDig_s * pgpDig;
00022
00025 typedef struct pgpDigParams_s * pgpDigParams;
00026
00034 #if !defined(__LCLINT__) && defined(__GLIBC__) && \
00035 (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
00036 #define USE_COOKIE_SEEK_POINTER 1
00037 typedef _IO_off64_t _libio_off_t;
00038 typedef _libio_off_t * _libio_pos_t;
00039 #else
00040 typedef off_t _libio_off_t;
00041 typedef off_t _libio_pos_t;
00042 #endif
00043
00047 typedef struct _FD_s * FD_t;
00048
00051 typedef struct FDIO_s * FDIO_t;
00052
00053 #ifdef __cplusplus
00054 extern "C" {
00055 #endif
00056
00061
00064 typedef ssize_t (*fdio_read_function_t) (void *cookie, char *buf, size_t nbytes)
00065
00066
00067
00068 ;
00069
00072 typedef ssize_t (*fdio_write_function_t) (void *cookie, const char *buf, size_t nbytes)
00073
00074 ;
00075
00078 typedef int (*fdio_seek_function_t) (void *cookie, _libio_pos_t pos, int whence)
00079
00080 ;
00081
00084 typedef int (*fdio_close_function_t) (void *cookie)
00085
00086 ;
00087
00090 typedef FD_t (*fdio_fopen_function_t) (const char * path, const char * fmode)
00091
00092 ;
00093
00096 typedef FD_t (*fdio_fdopen_function_t) (void * cookie, const char * fmode)
00097
00098 ;
00099
00105 struct FDIO_s {
00106 fdio_read_function_t read;
00107 fdio_write_function_t write;
00108 fdio_seek_function_t seek;
00109 fdio_close_function_t close;
00110 fdio_fopen_function_t _fopen;
00111 fdio_fdopen_function_t _fdopen;
00112 };
00113
00114
00119
00123 const char * Fstrerror( FD_t fd)
00124 ;
00125
00129
00130 size_t Fread( void * buf, size_t size, size_t nmemb, FD_t fd)
00131
00132
00133
00134 ;
00135
00136
00140
00141 size_t Fwrite(const void * buf, size_t size, size_t nmemb, FD_t fd)
00142
00143
00144 ;
00145
00146
00150 int Fseek(FD_t fd, _libio_off_t offset, int whence)
00151
00152 ;
00153
00157 int Fclose( FD_t fd)
00158
00159 ;
00160
00163 FD_t Fdopen(FD_t ofd, const char * fmode)
00164
00165 ;
00166
00170 FD_t Fopen( const char * path,
00171 const char * fmode)
00172
00173 ;
00174
00175
00179 int Fflush( FD_t fd)
00180
00181 ;
00182
00186 int Ferror( FD_t fd)
00187 ;
00188
00192 int Fileno(FD_t fd)
00193
00194 ;
00195
00199
00200 int Fcntl(FD_t fd, int op, void *lip)
00201
00202 ;
00203
00210
00214 int Mkdir(const char * path, mode_t mode)
00215
00216 ;
00217
00221 int Chdir(const char * path)
00222
00223 ;
00224
00228 int Rmdir(const char * path)
00229
00230 ;
00231
00232
00233 extern const char * _chroot_prefix;
00234
00239 int Chroot(const char * path)
00240
00241 ;
00242
00247 int Open(const char * path, int flags, mode_t mode)
00248
00249 ;
00250
00254 int Rename(const char * oldpath, const char * newpath)
00255
00256 ;
00257
00261 int Link(const char * oldpath, const char * newpath)
00262
00263 ;
00264
00268 int Unlink(const char * path)
00269
00270 ;
00271
00275 int Stat(const char * path, struct stat * st)
00276
00277 ;
00278
00282 int Lstat(const char * path, struct stat * st)
00283
00284 ;
00285
00290 int Chown(const char * path, uid_t owner, gid_t group)
00291
00292 ;
00293
00298 int Lchown(const char * path, uid_t owner, gid_t group)
00299
00300 ;
00301
00306 int Chmod(const char * path, mode_t mode)
00307
00308 ;
00309
00314 int Mkfifo(const char * path, mode_t mode)
00315
00316 ;
00317
00322 int Mknod(const char * path, mode_t mode, dev_t dev)
00323
00324 ;
00325
00330 int Utime(const char * path, const struct utimbuf * buf)
00331
00332 ;
00333
00338 int Utimes(const char * path, const struct timeval * times)
00339
00340 ;
00341
00346 int Symlink(const char * oldpath, const char * newpath)
00347
00348 ;
00349
00354
00355 int Readlink(const char * path, char * buf, size_t bufsiz)
00356
00357
00358
00359 ;
00360
00361
00366 int Access(const char * path, int amode)
00367
00368 ;
00369
00373 int Glob_pattern_p (const char *pattern, int quote)
00374 ;
00375
00379 int Glob_error(const char * epath, int eerrno)
00380 ;
00381
00385 int Glob(const char * pattern, int flags,
00386 int errfunc(const char * epath, int eerrno),
00387 glob_t * pglob)
00388
00389 ;
00390
00394 void Globfree( glob_t * pglob)
00395
00396 ;
00397
00398
00402
00403 DIR * Opendir(const char * path)
00404
00405 ;
00406
00410
00411 struct dirent * Readdir(DIR * dir)
00412
00413 ;
00414
00418 int Closedir( DIR * dir)
00419
00420 ;
00421
00425 char * Realpath(const char * path, char * resolved_path)
00426
00427 ;
00428
00433 off_t Lseek(int fdno, off_t offset, int whence)
00434
00435 ;
00436
00444
00447 off_t fdSize(FD_t fd)
00448
00449 ;
00450
00453 FD_t fdDup(int fdno)
00454
00455 ;
00456
00457
00460
00461 ssize_t fdRead(void * cookie, char * buf, size_t count)
00462
00463
00464
00465 ;
00466 #define fdRead(_fd, _buf, _count) fdio->read((_fd), (_buf), (_count))
00467
00468
00471 ssize_t fdWrite(void * cookie, const char * buf, size_t count)
00472
00473 ;
00474 #define fdWrite(_fd, _buf, _count) fdio->write((_fd), (_buf), (_count))
00475
00478 int fdClose( void * cookie)
00479
00480 ;
00481 #define fdClose(_fd) fdio->close(_fd)
00482
00485 FD_t fdOpen(const char *path, int flags, mode_t mode)
00486
00487 ;
00488 #define fdOpen(_path, _flags, _mode) fdio->_open((_path), (_flags), (_mode))
00489
00492
00493
00494 FD_t fdLink ( void * cookie, const char * msg)
00495
00496 ;
00497
00498
00499 FD_t XfdLink ( void * cookie, const char * msg, const char * fn, unsigned ln)
00500
00501 ;
00502 #define fdLink(_fd, _msg) XfdLink(_fd, _msg, __FILE__, __LINE__)
00503
00506
00507
00508 FD_t fdFree( FD_t fd, const char * msg)
00509
00510 ;
00511
00512
00513 FD_t XfdFree( FD_t fd, const char * msg, const char * fn, unsigned ln)
00514
00515 ;
00516 #define fdFree(_fd, _msg) XfdFree(_fd, _msg, __FILE__, __LINE__)
00517
00520
00521
00522 FD_t fdNew (const char * msg)
00523
00524 ;
00525
00526
00527 FD_t XfdNew (const char * msg, const char * fn, unsigned ln)
00528
00529 ;
00530 #define fdNew(_msg) XfdNew(_msg, __FILE__, __LINE__)
00531
00534 int fdWritable(FD_t fd, int secs)
00535
00536 ;
00537
00540 int fdReadable(FD_t fd, int secs)
00541
00542 ;
00543
00544
00553 int rpmioMkpath(const char * path, mode_t mode, uid_t uid, gid_t gid)
00554
00555 ;
00556
00564 int rpmioAccess(const char *FN, const char * path, int mode)
00565
00566 ;
00567
00573 extern char * (*Getpass) (const char * prompt)
00574 ;
00575 char * _GetPass (const char * prompt)
00576 ;
00577 char * _RequestPass (const char * prompt)
00578 ;
00579
00583
00584 typedef enum ftperrCode_e {
00585 FTPERR_NE_ERROR = -1,
00586 FTPERR_NE_LOOKUP = -2,
00587 FTPERR_NE_AUTH = -3,
00588 FTPERR_NE_PROXYAUTH = -4,
00589 FTPERR_NE_CONNECT = -5,
00590 FTPERR_NE_TIMEOUT = -6,
00591 FTPERR_NE_FAILED = -7,
00592 FTPERR_NE_RETRY = -8,
00593 FTPERR_NE_REDIRECT = -9,
00595 FTPERR_BAD_SERVER_RESPONSE = -81,
00596 FTPERR_SERVER_IO_ERROR = -82,
00597 FTPERR_SERVER_TIMEOUT = -83,
00598 FTPERR_BAD_HOST_ADDR = -84,
00599 FTPERR_BAD_HOSTNAME = -85,
00600 FTPERR_FAILED_CONNECT = -86,
00601 FTPERR_FILE_IO_ERROR = -87,
00602 FTPERR_PASSIVE_ERROR = -88,
00603 FTPERR_FAILED_DATA_CONNECT = -89,
00604 FTPERR_FILE_NOT_FOUND = -90,
00605 FTPERR_NIC_ABORT_IN_PROGRESS= -91,
00606 FTPERR_UNKNOWN = -100
00607 } ftperrCode;
00608
00609
00612
00613 const char * ftpStrerror(int errorNumber)
00614 ;
00615
00616
00619
00620 void * ufdGetUrlinfo(FD_t fd)
00621 ;
00622
00625
00626
00627 const char * urlStrerror(const char * url)
00628
00629 ;
00630
00631
00634
00635 int ufdCopy(FD_t sfd, FD_t tfd)
00636
00637 ;
00638
00639
00642 int ufdGetFile( FD_t sfd, FD_t tfd)
00643
00644 ;
00645
00648 int timedRead(FD_t fd, void * bufptr, int length)
00649
00650 ;
00651 #define timedRead (ufdio->read)
00652
00653
00656 extern FDIO_t fdio;
00657
00660 extern FDIO_t fpio;
00661
00664 extern FDIO_t ufdio;
00665
00668 extern FDIO_t gzdio;
00669
00672 extern FDIO_t bzdio;
00673
00676 extern FDIO_t lzdio;
00677
00678
00681 static inline int xislower(int c) {
00682 return (c >= 'a' && c <= 'z');
00683 }
00684 static inline int xisupper(int c) {
00685 return (c >= 'A' && c <= 'Z');
00686 }
00687 static inline int xisalpha(int c) {
00688 return (xislower(c) || xisupper(c));
00689 }
00690 static inline int xisdigit(int c) {
00691 return (c >= '0' && c <= '9');
00692 }
00693 static inline int xisalnum(int c) {
00694 return (xisalpha(c) || xisdigit(c));
00695 }
00696 static inline int xisblank(int c) {
00697 return (c == ' ' || c == '\t');
00698 }
00699 static inline int xisspace(int c) {
00700 return (xisblank(c) || c == '\n' || c == '\r' || c == '\f' || c == '\v');
00701 }
00702 static inline int xiscntrl(int c) {
00703 return (c < ' ');
00704 }
00705 static inline int xisascii(int c) {
00706 return ((c & 0x80) != 0x80);
00707 }
00708 static inline int xisprint(int c) {
00709 return (c >= ' ' && xisascii(c));
00710 }
00711 static inline int xisgraph(int c) {
00712 return (c > ' ' && xisascii(c));
00713 }
00714 static inline int xispunct(int c) {
00715 return (xisgraph(c) && !xisalnum(c));
00716 }
00717
00718 static inline int xtolower(int c) {
00719 return ((xisupper(c)) ? (c | ('a' - 'A')) : c);
00720 }
00721 static inline int xtoupper(int c) {
00722 return ((xislower(c)) ? (c & ~('a' - 'A')) : c);
00723 }
00724
00728 int xstrcasecmp(const char * s1, const char * s2) ;
00729
00733 int xstrncasecmp(const char *s1, const char * s2, size_t n) ;
00734
00738
00739 const char * xstrtolocale( const char *str)
00740 ;
00741
00742 #if !defined(SWIG)
00743
00748 static inline
00749 void * _free( const void * p)
00750
00751 {
00752 if (p != NULL) free((void *)p);
00753 return NULL;
00754 }
00755 #endif
00756
00757 #ifdef __cplusplus
00758 }
00759 #endif
00760
00761 #endif