18 * Hide libio API lossage.
19 * The libio interface changed after glibc-2.1.3 to pass the seek offset
20 * argument as a pointer rather than as an off_t. The snarl below defines
21 * typedefs to isolate the lossage.
25 #if !defined(__LCLINT__) && defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 2
26 #define USE_COOKIE_SEEK_POINTER 1
27 typedef _IO_off64_t _libio_off_t;
28 typedef _libio_off_t * _libio_pos_t;
30 typedef off_t _libio_off_t;
31 typedef off_t _libio_pos_t;
37 typedef /*@abstract@*/ /*@refcounted@*/ struct _FD_s * FD_t;
41 typedef /*@observer@*/ struct FDIO_s * FDIO_t;
48 * \name RPMIO Vectors.
54 typedef ssize_t fdio_read_function_t (void *cookie, char *buf, size_t nbytes);
58 typedef ssize_t fdio_write_function_t (void *cookie, const char *buf, size_t nbytes);
62 typedef int fdio_seek_function_t (void *cookie, _libio_pos_t pos, int whence);
66 typedef int fdio_close_function_t (void *cookie);
71 typedef /*@only@*/ /*@null@*/ FD_t fdio_ref_function_t ( /*@only@*/ void * cookie,
72 const char * msg, const char * file, unsigned line);
76 typedef /*@only@*/ /*@null@*/ FD_t fdio_deref_function_t ( /*@only@*/ FD_t fd,
77 const char * msg, const char * file, unsigned line);
82 typedef /*@only@*/ /*@null@*/ FD_t fdio_new_function_t (const char * msg,
83 const char * file, unsigned line);
88 typedef int fdio_fileno_function_t (void * cookie);
93 typedef FD_t fdio_open_function_t (const char * path, int flags, mode_t mode);
97 typedef FD_t fdio_fopen_function_t (const char * path, const char * fmode);
101 typedef void * fdio_ffileno_function_t (FD_t fd);
105 typedef int fdio_fflush_function_t (FD_t fd);
110 * \name RPMRPC Vectors.
113 typedef int fdio_mkdir_function_t (const char * path, mode_t mode);
114 typedef int fdio_chdir_function_t (const char * path);
115 typedef int fdio_rmdir_function_t (const char * path);
116 typedef int fdio_rename_function_t (const char * oldpath, const char * newpath);
117 typedef int fdio_unlink_function_t (const char * path);
118 typedef int fdio_stat_function_t (const char * path, struct stat * st);
119 typedef int fdio_lstat_function_t (const char * path, struct stat * st);
120 typedef int fdio_access_function_t (const char * path, int amode);
127 fdio_read_function_t * read;
128 fdio_write_function_t * write;
129 fdio_seek_function_t * seek;
130 fdio_close_function_t * close;
132 fdio_ref_function_t * _fdref;
133 fdio_deref_function_t * _fdderef;
134 fdio_new_function_t * _fdnew;
135 fdio_fileno_function_t * _fileno;
137 fdio_open_function_t * _open;
138 fdio_fopen_function_t * _fopen;
139 fdio_ffileno_function_t * _ffileno;
140 fdio_fflush_function_t * _fflush;
142 fdio_mkdir_function_t * _mkdir;
143 fdio_chdir_function_t * _chdir;
144 fdio_rmdir_function_t * _rmdir;
145 fdio_rename_function_t * _rename;
146 fdio_unlink_function_t * _unlink;
151 * \name RPMIO Interface.
158 /*@observer@*/ const char * Fstrerror(FD_t fd);
163 size_t Fread (/*@out@*/ void * buf, size_t size, size_t nmemb, FD_t fd);
168 size_t Fwrite (const void *buf, size_t size, size_t nmemb, FD_t fd);
174 int Fseek (FD_t fd, _libio_off_t offset, int whence);
179 int Fclose ( /*@killref@*/ FD_t fd);
183 FD_t Fdopen (FD_t fd, const char * fmode);
188 FD_t Fopen (const char * path, const char * fmode);
194 int Fflush (FD_t fd);
199 int Ferror (FD_t fd);
204 int Fileno (FD_t fd);
210 int Fcntl (FD_t fd, int op, void *lip);
215 ssize_t Pread(FD_t fd, void * buf, size_t count, _libio_off_t offset);
220 ssize_t Pwrite(FD_t fd, const void * buf, size_t count, _libio_off_t offset);
224 * \name RPMRPC Interface.
231 int Mkdir (const char * path, mode_t mode);
236 int Chdir (const char * path);
241 int Rmdir (const char * path);
246 int Rename (const char * oldpath, const char * newpath);
251 int Link (const char * oldpath, const char * newpath);
256 int Unlink (const char * path);
261 int Readlink(const char * path, char * buf, size_t bufsiz);
267 int Stat (const char * path, /*@out@*/ struct stat * st);
272 int Lstat (const char * path, /*@out@*/ struct stat * st);
277 int Access (const char * path, int amode);
283 int Glob (const char * pattern, int flags,
284 int errfunc(const char * epath, int eerrno), /*@out@*/ glob_t * pglob);
289 void Globfree( /*@only@*/ glob_t * pglob);
295 DIR * Opendir (const char * name);
300 struct dirent * Readdir (DIR * dir);
305 int Closedir(DIR * dir);
310 * \name RPMIO Utilities.
316 off_t fdSize (FD_t fd);
320 /*@null@*/ FD_t fdDup(int fdno);
322 /*@null@*/ FILE *fdFdopen( /*@only@*/ void * cookie, const char * mode);
325 /* XXX Legacy interfaces needed by gnorpm, rpmfind et al */
330 int fdFileno(void * cookie);
336 /*@null@*/ FD_t fdOpen(const char *path, int flags, mode_t mode);
340 ssize_t fdRead(void * cookie, /*@out@*/ char * buf, size_t count);
344 ssize_t fdWrite(void * cookie, const char * buf, size_t count);
348 int fdClose( /*@only@*/ void * cookie);
350 /* XXX FD_t reference count debugging wrappers */
351 #define fdLink(_fd, _msg) fdio->_fdref(_fd, _msg, __FILE__, __LINE__)
352 #define fdFree(_fd, _msg) fdio->_fdderef(_fd, _msg, __FILE__, __LINE__)
353 #define fdNew(_msg) fdio->_fdnew(_msg, __FILE__, __LINE__)
358 int fdWritable(FD_t fd, int secs);
362 int fdReadable(FD_t fd, int secs);
365 * FTP and HTTP error codes.
367 typedef enum ftperrCode_e {
368 FTPERR_BAD_SERVER_RESPONSE = -1, /*!< Bad server response */
369 FTPERR_SERVER_IO_ERROR = -2, /*!< Server I/O error */
370 FTPERR_SERVER_TIMEOUT = -3, /*!< Server timeout */
371 FTPERR_BAD_HOST_ADDR = -4, /*!< Unable to lookup server host address */
372 FTPERR_BAD_HOSTNAME = -5, /*!< Unable to lookup server host name */
373 FTPERR_FAILED_CONNECT = -6, /*!< Failed to connect to server */
374 FTPERR_FILE_IO_ERROR = -7, /*!< Failed to establish data connection to server */
375 FTPERR_PASSIVE_ERROR = -8, /*!< I/O error to local file */
376 FTPERR_FAILED_DATA_CONNECT = -9, /*!< Error setting remote server to passive mode */
377 FTPERR_FILE_NOT_FOUND = -10, /*!< File not found on server */
378 FTPERR_NIC_ABORT_IN_PROGRESS= -11, /*!< Abort in progress */
379 FTPERR_UNKNOWN = -100 /*!< Unknown or unexpected error */
384 /*@observer@*/ const char *const ftpStrerror(int errorNumber);
388 /*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd);
392 /*@observer@*/ const char * urlStrerror(const char * url);
396 int ufdCopy(FD_t sfd, FD_t tfd);
400 int ufdGetFile( /*@killref@*/ FD_t sfd, FD_t tfd);
404 int timedRead(FD_t fd, /*@out@*/ void * bufptr, int length);
405 #define timedRead ufdio->read
410 /*@observer@*/ extern FDIO_t fdio;
414 /*@observer@*/ extern FDIO_t fpio;
418 /*@observer@*/ extern FDIO_t ufdio;
422 /*@observer@*/ extern FDIO_t gzdio;
426 /*@observer@*/ extern FDIO_t bzdio;
430 /*@observer@*/ extern FDIO_t fadio;
434 * Locale insensitive strcasecmp(3).
436 int xstrcasecmp(const char *s1, const char * s2) /*@*/;
439 * Locale insensitive strncasecmp(3).
441 int xstrncasecmp(const char *s1, const char * s2, size_t n) /*@*/;