rpm 5.2.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

Defines | Functions | Variables
rpmio/rpmio.c File Reference
RPMIO.
`#include "system.h"`
`#include <stdarg.h>`
`#include <netdb.h>`
`#include <netinet/in.h>`
`#include <arpa/inet.h>`
`#include <rpmiotypes.h>`
`#include <rpmmacro.h>`
`#include <rpmficl.h>`
`#include <rpmjs.h>`
`#include <rpmlua.h>`
`#include <rpmperl.h>`
`#include <rpmpython.h>`
`#include <rpmruby.h>`
`#include <rpmtcl.h>`
`#include <rpmio_internal.h>`
`#include <ugid.h>`
`#include <rpmcb.h>`
`#include <rpmdav.h>`
`#include "debug.h"`
Include dependency graph for rpmio.c:

Go to the source code of this file.

## Defines

#define | NI_MAXHOST 1025
#define | IPPORT_FTP 21
#define | IPPORT_HTTP 80
#define | inet_aton(cp, inp) rpm_inet_aton(cp,inp)
#define | fdOpen __fdOpen
#define | fdRead __fdRead
#define | fdWrite __fdWrite
#define | fdClose __fdClose
#define | FDTO(fd) (fd ? ((FD_t)fd)->rd_timeoutsecs : -99)
#define | FDCPIOPOS(fd) (fd ? ((FD_t)fd)->fd_cpioPos : -99)
#define | FDONLY(fd) assert(fdGetIo(fd) == fdio)
#define | UFDONLY(fd) /* assert(fdGetIo(fd) == ufdio) */
#define | fdGetFILE(_fd) ((FILE *)fdGetFp(_fd))
#define | TIMEOUT_SECS 60
#define | IAC ((unsigned char)255) /* interpret as command: */
#define | IP ((unsigned char)244) /* interrupt process--permanently */
#define | DM ((unsigned char)242) /* data mark--for connect. cleaning */
#define | SHUT_RDWR 1+1
#define | FDIOVEC(_fd, _vec) ((fdGetIo(_fd) && fdGetIo(_fd)->_vec) ? fdGetIo(_fd)->_vec : NULL)
#define | _PATH "/bin:/usr/bin:/sbin:/usr/sbin"
#define | alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))

## Functions

static int | rpm_inet_aton (const char *cp, struct in_addr *inp)
const char * | fdbg (FD_t fd)
FD_t | fdDup (int fdno)
static int | fdSeekNot (void *cookie, _libio_pos_t pos, int whence)
static void | fdFini (void *_fd)
static FD_t | fdGetPool (rpmioPool pool)
FD_t | XfdNew (const char *msg, const char *fn, unsigned ln)
static ssize_t | __fdRead (void *cookie, char *buf, size_t count)
static ssize_t | __fdWrite (void *cookie, const char *buf, size_t count)
static int | fdSeek (void *cookie, _libio_pos_t pos, int whence)
static int | __fdClose (void *cookie)
static FD_t | __fdOpen (const char *path, int flags, mode_t mode)
int | fdWritable (FD_t fd, int secs)
int | fdReadable (FD_t fd, int secs)
int | fdFgets (FD_t fd, char *buf, size_t len)
const char * | ftpStrerror (int errorNumber)
const char * | urlStrerror (const char *url)
static int | mygethostbyname (const char *host, struct in_addr *address)
static int | getHostAddress (const char *host, struct in_addr *address)
static int | tcpConnect (FD_t ctrl, const char *host, int port)
static int | checkResponse (void *uu, FD_t ctrl, int *ecp, char **str)
static int | ftpCheckResponse (urlinfo u, char **str)
static int | ftpCommand (urlinfo u, char **str,...)
static int | ftpLogin (urlinfo u)
int | ftpReq (FD_t data, const char *ftpCmd, const char *ftpArg)
int | ufdCopy (FD_t sfd, FD_t tfd)
static int | urlConnect (const char *url, urlinfo *uret)
int | ufdGetFile (FD_t sfd, FD_t tfd)
int | ftpCmd (const char *cmd, const char *url, const char *arg2)
static int | ftpAbort (urlinfo u, FD_t data)
static int | ftpFileDone (urlinfo u, FD_t data)
static int | httpResp (urlinfo u, FD_t ctrl, char **str)
static int | httpReq (FD_t ctrl, const char *httpCmd, const char *httpArg)
void * | ufdGetUrlinfo (FD_t fd)
static ssize_t | ufdRead (void *cookie, char *buf, size_t count)
static ssize_t | ufdWrite (void *cookie, const char *buf, size_t count)
static int | ufdSeek (void *cookie, _libio_pos_t pos, int whence)
int | ufdClose (void *cookie)
FD_t | ftpOpen (const char *url, int flags, mode_t mode, urlinfo *uret)
static FD_t | ufdOpen (const char *url, int flags, mode_t mode)
static const char * | getFdErrstr (FD_t fd)
const char * | Fstrerror (FD_t fd)
| strerror(3) clone.
size_t | Fread (void *buf, size_t size, size_t nmemb, FD_t fd)
| fread(3) clone.
size_t | Fwrite (const void *buf, size_t size, size_t nmemb, FD_t fd)
| fwrite(3) clone.
int | Fseek (FD_t fd, _libio_off_t offset, int whence)
| fseek(3) clone.
int | Fclose (FD_t fd)
| fclose(3) clone.
static void | cvtfmode (const char *m, char *stdio, size_t nstdio, char *other, size_t nother, const char **end, int *f)
| Convert stdio fmode to open(2) mode, filtering out zlib/bzlib flags.
FD_t | Fdopen (FD_t ofd, const char *fmode)
FD_t | Fopen (const char *path, const char *_fmode)
| fopen(3) clone.
int | Fflush (FD_t fd)
| fflush(3) clone.
int | Ferror (FD_t fd)
| ferror(3) clone.
int | Fileno (FD_t fd)
| fileno(3) clone.
int | Fcntl (FD_t fd, int op, void *lip)
| fcntl(2) clone.
int | rpmioMkpath (const char *path, mode_t mode, uid_t uid, gid_t gid)
| Insure that directories in path exist, creating as needed.
int | rpmioAccess (const char *FN, const char *path, int mode)
| Check FN access, expanding relative paths and twiddles.
void | rpmioClean (void)
| Free all memory allocated by rpmio usage.

## Variables

int | noLibio = 1
static int | ftpTimeoutSecs = 60
int | _rpmio_debug = 0
int | _av_debug = 0
int | _ftp_debug = 0
int | _dav_debug = 0
rpmioPool | _fdPool
static struct FDIO_s | fdio_s
FDIO_t | fdio = &fdio_s
static struct FDIO_s | ufdio_s
FDIO_t | ufdio = &ufdio_s
static const char * | _path = "/bin:/usr/bin:/sbin:/usr/sbin"
static struct FDIO_s | fpio_s
FDIO_t | fpio = &fpio_s

## Detailed Description

Definition in file rpmio.c.

## Define Documentation

#define _PATH "/bin:/usr/bin:/sbin:/usr/sbin"

Definition at line 2986 of file rpmio.c.

#define alloca_strdup | ( |  | _s | ) | strcpy(alloca(strlen(_s)+1), (_s))

Definition at line 2990 of file rpmio.c.

Referenced by rpmioAccess().

#define DM ((unsigned char)242) /* data mark--for connect. cleaning */

Definition at line 1663 of file rpmio.c.

Referenced by ftpAbort().

#define fdClose __fdClose

Definition at line 121 of file rpmio.c.

Referenced by Fclose(), Fopen(), ftpAbort(), ftpLogin(), ftpReq(), httpReq(), and ufdClose().

#define FDCPIOPOS | ( |  | fd | ) | (fd ? ((FD_t)fd)->fd_cpioPos : -99)

Definition at line 136 of file rpmio.c.

#define fdGetFILE | ( |  | _fd | ) | ((FILE *)fdGetFp(_fd))

Definition at line 142 of file rpmio.c.

Referenced by argvFgets(), Fclose(), Ferror(), Fflush(), Fread(), Fseek(), Fwrite(), mtreeReadExcludes(), rdcl(), rpmdcParseCoreutils(), rpmdsSysinfoFile(), and ufdClose().

#define FDIOVEC | ( |  | _fd,
|  |  | _vec
| ) |  | ((fdGetIo(_fd) && fdGetIo(_fd)->_vec) ? fdGetIo(_fd)->_vec : NULL)

Definition at line 2376 of file rpmio.c.

Referenced by Fclose(), Fread(), Fseek(), and Fwrite().

#define FDONLY | ( |  | fd | ) | assert(fdGetIo(fd) == fdio)

Definition at line 138 of file rpmio.c.

#define fdOpen __fdOpen

Definition at line 115 of file rpmio.c.

Referenced by Fopen(), and ufdOpen().

#define fdRead __fdRead

Definition at line 117 of file rpmio.c.

Referenced by fdFgets(), and ufdRead().

#define FDTO | ( |  | fd | ) | (fd ? ((FD_t)fd)->rd_timeoutsecs : -99)

Definition at line 135 of file rpmio.c.

#define fdWrite __fdWrite

Definition at line 119 of file rpmio.c.

Referenced by ftpAbort(), ftpCommand(), ftpReq(), httpReq(), and ufdWrite().

#define IAC ((unsigned char)255) /* interpret as command: */

Definition at line 1657 of file rpmio.c.

Referenced by ftpAbort().

#define inet_aton | ( |  | cp,
|  |  | inp
| ) |  | rpm_inet_aton(cp,inp)

Definition at line 94 of file rpmio.c.

Referenced by ftpReq(), and getHostAddress().

#define IP ((unsigned char)244) /* interrupt process--permanently */

Definition at line 1660 of file rpmio.c.

Referenced by ftpAbort(), and runScript().

#define IPPORT_FTP 21

Definition at line 87 of file rpmio.c.

Referenced by ftpLogin().

#define IPPORT_HTTP 80

Definition at line 90 of file rpmio.c.

#define NI_MAXHOST 1025

Definition at line 17 of file rpmio.c.

Referenced by ftpReq(), httpReq(), and tcpConnect().

#define SHUT_RDWR 1+1

Definition at line 1666 of file rpmio.c.

Referenced by ftpAbort().

#define TIMEOUT_SECS 60

Definition at line 153 of file rpmio.c.

#define UFDONLY | ( |  | fd | ) | /* assert(fdGetIo(fd) == ufdio) */

Definition at line 140 of file rpmio.c.

Referenced by ufdClose(), ufdRead(), and ufdWrite().

## Function Documentation

static int __fdClose | ( | void * | cookie | ) | `[static]`

Definition at line 471 of file rpmio.c.

References c2f(), davClose(), DBGIO, fdbg(), fdFileno(), fdFree(), fdSetFdno(), FDSTAT_CLOSE, fdstat_enter(), fdstat_exit(), and _FD_s::req.

static FD_t __fdOpen | ( | const char * | path,
|  | int | flags,
|  | mode_t | mode
| ) |  | `[static]`

Definition at line 503 of file rpmio.c.

References DBGIO, fdbg(), fdNew(), fdSetFdno(), fdSetOpen(), and _FD_s::flags.

static ssize_t __fdRead | ( | void * | cookie,
|  | char * | buf,
|  | size_t | count
| ) |  | `[static]`

Definition at line 373 of file rpmio.c.

References _FD_s::bytesRemain, c2f(), davRead(), DBGIO, fdbg(), fdFileno(), fdstat_enter(), fdstat_exit(), FDSTAT_READ, fdUpdateDigests(), _FD_s::ndigests, _FD_s::req, _FD_s::xar, and xarRead().

static ssize_t __fdWrite | ( | void * | cookie,
|  | const char * | buf,
|  | size_t | count
| ) |  | `[static]`

Definition at line 415 of file rpmio.c.

References _FD_s::bytesRemain, c2f(), davWrite(), DBGIO, fdbg(), fdFileno(), fdstat_enter(), fdstat_exit(), FDSTAT_WRITE, fdUpdateDigests(), _FD_s::ndigests, and _FD_s::req.

static int checkResponse | ( | void * | uu,
|  | FD_t | ctrl,
|  | int * | ecp,
|  | char ** | str
| ) |  | `[static]`

Definition at line 940 of file rpmio.c.

References _ftp_debug, _url_iobuf_size, urlinfo_s::allow, urlinfo_s::buf, urlinfo_s::bufAlloced, _FD_s::contentLength, fdFgets(), fdWritable(), FTPERR_BAD_SERVER_RESPONSE, urlinfo_s::httpVersion, _FD_s::persist, RPMURL_SERVER_HASRANGE, URLSANE, _FD_s::wr_chunked, and xcalloc().

Referenced by ftpCheckResponse(), and httpResp().

static void cvtfmode | ( | const char * | m,
|  | char * | stdio,
|  | size_t | nstdio,
|  | char * | other,
|  | size_t | nother,
|  | const char ** | end,
|  | int * | f
| ) |  | `[inline, static]`

Convert stdio fmode to open(2) mode, filtering out zlib/bzlib flags.

        returns stdio[0] = NUL on error.

Todo:
  glibc also supports ",ccs="

- glibc: m use mmap'd input
  - glibc: c no cancel
  - gzopen: [0-9] is compression level
  - gzopen: 'f' is filtered (Z_FILTERED)
  - gzopen: 'h' is Huffman encoding (Z_HUFFMAN_ONLY)
  - bzopen: [1-9] is block size (in 100K units)
  - bzopen: 's' is smallmode
  - bzopen: 'q' sets verbosity to 0
  - bzopen: 'v' does verbosity++ (up to 4)
  - HACK: '.' terminates, rest is type of I/O

Definition at line 2564 of file rpmio.c.

Referenced by Fdopen(), and Fopen().

int Fclose | ( | FD_t | fd | ) |

fclose(3) clone.

Definition at line 2456 of file rpmio.c.

References FDIO_s::close, davDisconnect(), DBGIO, fdbg(), fdClose, fdFree(), fdGetFdno(), fdGetFILE, FDIOVEC, fdLink(), _FDSTACK_s::fdno, fdPop(), FDSANE, fdSetFp(), _FDSTACK_s::fp, fpio, _FD_s::fps, _FDSTACK_s::io, _FD_s::nfps, noLibio, _FD_s::persist, _FD_s::req, and ufdClose().

Referenced by addFileToTagAux(), closeCallback(), closeSpec(), compare(), cpio_doio(), dodigest(), doIcon(), IDTXglob(), iosmStage(), isCompressed(), main(), makeGPGSignature(), makeHDRSignature(), manageFile(), mtreeReadExcludes(), mtreeVisitF(), processPackageFiles(), readLineFromOFI(), repoFclose(), repoReadHeader(), rpmcliSign(), rpmdbExportInfo(), rpmdcFiniFile(), rpmdcInitFile(), rpmdcParseCoreutils(), rpmdsSysinfoFile(), rpmfd_dealloc(), rpmfd_free(), rpmfd_init(), rpmgiFini(), rpmgiLoadManifest(), rpmgiNext(), rpmgiOpen(), rpmgiReadHeader(), rpmHeaderFromFD(), rpmHeaderFromFile(), rpmHeaderToFD(), rpmHeaderToFile(), rpmInstallSource(), rpmInstallSourcePackage(), rpmiobSlurp(), rpmLoadMacroFile(), rpmpsmStage(), rpmShowProgress(), rpmSingleHeaderFromFD(), rpmTempFile(), rpmts_dealloc(), rpmts_free(), rpmts_HdrFromFdno(), rpmtsCallback(), rpmtsRollback(), rpmtsSolve(), runScript(), showVerifyPackage(), statFormat(), ufdGetFile(), unsatisfiedDepend(), urlFini(), urlGetFile(), and writeRPM().

int Fcntl | ( | FD_t | fd,
|  | int | op,
|  | void * | lip
| ) |  |

fcntl(2) clone.

Definition at line 2929 of file rpmio.c.

References Fileno().

FD_t fdDup | ( | int | fdno | ) |

Definition at line 249 of file rpmio.c.

References DBGIO, fdbg(), fdNew(), fdSetFdno(), and fdSetOpen().

Referenced by cpio_doio(), dodigest(), main(), rpmHeaderFromFD(), rpmHeaderToFD(), rpmpsmStage(), rpmSingleHeaderFromFD(), rpmts_HdrFromFdno(), rpmts_setattro(), rpmtsCallback(), runScript(), showVerifyPackage(), and ufdOpen().

static void fdFini | ( | void * | _fd | ) | `[static]`

Definition at line 280 of file rpmio.c.

References _fd, _free(), _FD_s::contentDisposition, _FD_s::contentType, _FD_s::dig, _FD_s::digests, _FDDIGEST_s::hashctx, _FD_s::ndigests, _FD_s::opath, pgpDigFree(), rpmDigestFinal(), rpmxarFree(), _FD_s::stats, and _FD_s::xar.

Referenced by fdGetPool().

static FD_t fdGetPool | ( | rpmioPool | pool | ) | `[static]`

Definition at line 311 of file rpmio.c.

References _fdPool, _rpmio_debug, fdbg(), fdFini(), rpmioGetPool(), and rpmioNewPool().

Referenced by XfdNew().

FD_t Fdopen | ( | FD_t | ofd,
|  | const char * | fmode
| ) |  |

Definition at line 2640 of file rpmio.c.

References FDIO_s::_fdopen, _rpmio_debug, bzdio, FDIO_s::close, cvtfmode(), DBGIO, fdbg(), fdGetFp(), fdio, fdLink(), fdPush(), FDSANE, fdSetFp(), Fileno(), fpio, gzdio, lzdio, noLibio, FDIO_s::read, FDIO_s::seek, stpcpy(), ufdio, FDIO_s::write, and xzdio.

Referenced by cpio_doio(), Fopen(), main(), rpmpsmStage(), and rpmReadPackageManifest().

int fdReadable | ( | FD_t | fd,
|  | int | secs
| ) |  |

Definition at line 605 of file rpmio.c.

References errno, fdFileno(), and _FD_s::req.

Referenced by fdFgets(), ftpAbort(), ufdClose(), and ufdRead().

static int fdSeek | ( | void * | cookie,
|  | _libio_pos_t | pos,
|  | int | whence
| ) |  | `[inline, static]`

Definition at line 449 of file rpmio.c.

References _FD_s::bytesRemain, c2f(), DBGIO, fdbg(), fdFileno(), fdstat_enter(), fdstat_exit(), and FDSTAT_SEEK.

Referenced by ufdSeek().

static int fdSeekNot | ( | void * | cookie,
|  | _libio_pos_t | pos,
|  | int | whence
| ) |  | `[inline, static]`

Definition at line 268 of file rpmio.c.

References c2f(), and FDSANE.

int fdWritable | ( | FD_t | fd,
|  | int | secs
| ) |  |

Definition at line 550 of file rpmio.c.

References _rpmio_debug, errno, fdFileno(), and _FD_s::req.

Referenced by checkResponse(), ftpLogin(), httpReq(), and ufdWrite().

int Ferror | ( | FD_t | fd | ) |

ferror(3) clone.

Definition at line 2864 of file rpmio.c.

References bzdio, DBGIO, _FD_s::errcookie, fdbg(), fdFileno(), fdGetFILE, fpio, _FD_s::fps, gzdio, _FDSTACK_s::io, lzdio, _FD_s::nfps, _FD_s::req, _FD_s::syserrno, and xzdio.

Referenced by addFileToTagAux(), compare(), cpio_copy(), crc(), dodigest(), doIcon(), IDTXglob(), iosmStage(), isCompressed(), main(), makeGPGSignature(), makeHDRSignature(), manageFile(), mtreeReadExcludes(), mtreeVisitF(), processPackageFiles(), rdLead(), readFile(), readLineFromOFI(), repoReadHeader(), repoRfileDigest(), rpmcliSign(), rpmdcCalcFile(), rpmdcInitFile(), rpmdcParseCoreutils(), rpmdsSysinfoFile(), rpmfd_Fopen(), rpmfd_init(), rpmgiOpen(), rpmInstallSource(), rpmiobSlurp(), rpmLoadMacroFile(), rpmpsmStage(), rpmReadPackageManifest(), rpmShowProgress(), rpmTempFile(), rpmtsSolve(), rpmWriteHeader(), runScript(), statFormat(), unsatisfiedDepend(), urlGetFile(), and writeRPM().

int Fflush | ( | FD_t | fd | ) |

fflush(3) clone.

Definition at line 2836 of file rpmio.c.

References FDIO_s::_flush, bzdio, fdGetFILE, fdGetFp(), fdGetIo(), fpio, gzdio, lzdio, and xzdio.

Referenced by copyFile(), cpio_doio(), extractRegular(), rpmdcPrintFile(), rpmpsmStage(), and writeRPM().

int Fileno | ( | FD_t | fd | ) |

fileno(3) clone.

Definition at line 2911 of file rpmio.c.

References DBGIO, fdbg(), _FDSTACK_s::fdno, _FD_s::fps, _FD_s::nfps, and _FD_s::req.

Referenced by cpio_doio(), extractRegular(), Fchmod(), Fchown(), Fcntl(), Fdopen(), Fstat(), printSize(), repoRfileDigest(), rpmiobSlurp(), rpmpsmStage(), rpmTempFile(), rpmtsCallback(), runScript(), ufdOpen(), writeFile(), and writeRPM().

FD_t Fopen | ( | const char * | path,
|  | const char * | _fmode
| ) |  |

fopen(3) clone.

Definition at line 2755 of file rpmio.c.

References _free(), _rpmio_debug, cvtfmode(), fdClose, fdFileno(), fdGetFdno(), fdGetFp(), fdOpen, Fdopen(), fdPush(), fpio, _FD_s::req, rpmExpand(), ufdOpen(), URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_PATH, URL_IS_UNKNOWN, and urlIsURL().

Referenced by addFileToTagAux(), compare(), dodigest(), doIcon(), IDTXglob(), iosmStage(), isCompressed(), main(), makeGPGSignature(), makeHDRSignature(), manageFile(), mtreeReadExcludes(), mtreeVisitF(), processPackageFiles(), readLineFromOFI(), repoDoRepoMetadata(), repoOpenMDFile(), repoReadHeader(), repoRfileDigest(), rpmcliSign(), rpmdbExportInfo(), rpmdcInitFile(), rpmdcParseCoreutils(), rpmdsSysinfoFile(), rpmfd_Fopen(), rpmfd_init(), rpmgiOpen(), rpmHeaderFromFile(), rpmHeaderToFile(), rpmInstallSource(), rpmiobSlurp(), rpmLoadMacroFile(), rpmpsmStage(), rpmShowProgress(), rpmTempFile(), rpmtsRollback(), rpmtsSolve(), runScript(), statFormat(), unsatisfiedDepend(), urlGetFile(), and writeRPM().

size_t Fread | ( | void * | buf,
|  | size_t | size,
|  | size_t | nmemb,
|  | FD_t | fd
| ) |  |

fread(3) clone.

Definition at line 2379 of file rpmio.c.

References DBGIO, fdbg(), fdGetFILE, fdGetIo(), FDIOVEC, FDSANE, fpio, and FDIO_s::read.

Referenced by compare(), copyFile(), cpio_copy(), crc(), dodigest(), doIcon(), iosmStage(), isCompressed(), makeGPGSignature(), mtreeVisitF(), readFile(), repoReadHeader(), repoRfileDigest(), rpmdcCalcFile(), rpmiobSlurp(), rpmReadPackageFile(), statFormat(), ufdCopy(), unsatisfiedDepend(), and writeRPM().

int Fseek | ( | FD_t | fd,
|  | _libio_off_t | offset,
|  | int | whence
| ) |  |

fseek(3) clone.

Definition at line 2424 of file rpmio.c.

References DBGIO, fdbg(), fdGetFILE, fdGetIo(), FDIOVEC, FDSANE, fpio, and FDIO_s::seek.

const char* Fstrerror | ( | FD_t | fd | ) |

strerror(3) clone.

Definition at line 2368 of file rpmio.c.

References errno, FDSANE, and getFdErrstr().

Referenced by compare(), copyFile(), cpio_copy(), doIcon(), IDTXglob(), isCompressed(), main(), manageFile(), mtreeReadExcludes(), mtreeVisitF(), processPackageFiles(), rdLead(), readFile(), readLineFromOFI(), repoOpenMDFile(), repoReadHeader(), rfileXMLWrite(), rpmcliSign(), rpmdcInitFile(), rpmdcParseCoreutils(), rpmfd_Fopen(), rpmfd_init(), rpmgiOpen(), rpmInstallSource(), rpmpsmStage(), rpmReadPackageFile(), rpmReadPackageManifest(), rpmReSign(), rpmShowProgress(), rpmtsSolve(), rpmWriteHeader(), statFormat(), urlGetFile(), and writeRPM().

static int ftpAbort | ( | urlinfo | u,
|  | FD_t | data
| ) |  | `[static]`

Definition at line 1669 of file rpmio.c.

References urlinfo_s::buf, urlinfo_s::bufAlloced, urlinfo_s::ctrl, DBGIO, DM, fdClose, fdFileno(), fdFree(), _FDSTACK_s::fdno, fdReadable(), fdWrite, _FD_s::fps, ftpCheckResponse(), FTPERR_NIC_ABORT_IN_PROGRESS, FTPERR_SERVER_IO_ERROR, _FD_s::ftpFileDoneNeeded, IAC, IP, _FD_s::rd_timeoutsecs, FDIO_s::read, SHUT_RDWR, ufdio, and URLSANE.

Referenced by ufdClose().

static int ftpCheckResponse | ( | urlinfo | u,
|  | char ** | str
| ) |  | `[static]`

Definition at line 1103 of file rpmio.c.

References checkResponse(), urlinfo_s::ctrl, FTPERR_BAD_SERVER_RESPONSE, FTPERR_FILE_NOT_FOUND, FTPERR_NIC_ABORT_IN_PROGRESS, and URLSANE.

Referenced by ftpAbort(), ftpCommand(), ftpFileDone(), ftpLogin(), and ftpReq().

static int ftpCommand | ( | urlinfo | u,
|  | char ** | str,
|  |  | ...
| ) |  | `[static]`

Definition at line 1129 of file rpmio.c.

References _ftp_debug, alloca(), urlinfo_s::ctrl, fdWrite, ftpCheckResponse(), FTPERR_SERVER_IO_ERROR, stpcpy(), and URLSANE.

Referenced by ftpCmd(), ftpLogin(), and ftpReq().

static int ftpFileDone | ( | urlinfo | u,
|  | FD_t | data
| ) |  | `[static]`

Definition at line 1733 of file rpmio.c.

References urlinfo_s::ctrl, fdFree(), ftpCheckResponse(), _FD_s::ftpFileDoneNeeded, and URLSANE.

Referenced by ufdClose().

static int ftpLogin | ( | urlinfo | u | ) | `[static]`

Definition at line 1167 of file rpmio.c.

References alloca(), urlinfo_s::ctrl, errno, fdClose, fdFileno(), fdLink(), fdSetSyserrno(), fdWritable(), ftpCheckResponse(), ftpCommand(), FTPERR_BAD_HOSTNAME, ftpStrerror(), urlinfo_s::host, IPPORT_FTP, urlinfo_s::password, urlinfo_s::port, urlinfo_s::proxyh, urlinfo_s::proxyp, urlinfo_s::proxyu, tcpConnect(), URLSANE, and urlinfo_s::user.

Referenced by urlConnect().

const char* ftpStrerror | ( | int | errorNumber | ) |

Definition at line 723 of file rpmio.c.

References _, FTPERR_BAD_HOST_ADDR, FTPERR_BAD_HOSTNAME, FTPERR_BAD_SERVER_RESPONSE, FTPERR_FAILED_CONNECT, FTPERR_FAILED_DATA_CONNECT, FTPERR_FILE_IO_ERROR, FTPERR_FILE_NOT_FOUND, FTPERR_NE_AUTH, FTPERR_NE_CONNECT, FTPERR_NE_ERROR, FTPERR_NE_FAILED, FTPERR_NE_LOOKUP, FTPERR_NE_PROXYAUTH, FTPERR_NE_REDIRECT, FTPERR_NE_RETRY, FTPERR_NE_TIMEOUT, FTPERR_NIC_ABORT_IN_PROGRESS, FTPERR_PASSIVE_ERROR, FTPERR_SERVER_IO_ERROR, FTPERR_SERVER_TIMEOUT, and FTPERR_UNKNOWN.

Referenced by ftpLogin(), ftpReq(), httpReq(), prepFetch(), tcpConnect(), ufdCopy(), and urlStrerror().

size_t Fwrite | ( | const void * | buf,
|  | size_t | size,
|  | size_t | nmemb,
|  | FD_t | fd
| ) |  |

fwrite(3) clone.

Definition at line 2401 of file rpmio.c.

References DBGIO, fdbg(), fdGetFILE, fdGetIo(), FDIOVEC, FDSANE, fpio, and FDIO_s::write.

Referenced by copyFile(), cpio_copy(), iosmStage(), main(), repoOpenMDFile(), rfileXMLWrite(), rpmdcPrintFile(), rpmWriteHeader(), runScript(), ufdCopy(), writeRPM(), wrLead(), and wrSignature().

static const char* getFdErrstr | ( | FD_t | fd | ) | `[static]`

Definition at line 2333 of file rpmio.c.

References bzdio, _FD_s::errcookie, fdGetIo(), gzdio, lzdio, _FD_s::syserrno, and xzdio.

Referenced by Fstrerror().

static int getHostAddress | ( | const char * | host,
|  | struct in_addr * | address
| ) |  | `[static]`

Definition at line 820 of file rpmio.c.

References errno, FTPERR_BAD_HOST_ADDR, FTPERR_BAD_HOSTNAME, inet_aton, mygethostbyname(), and xisdigit().

Referenced by tcpConnect().

static int httpReq | ( | FD_t | ctrl,
|  | const char * | httpCmd,
|  | const char * | httpArg
| ) |  | `[static]`

Definition at line 1781 of file rpmio.c.

References _ftp_debug, alloca(), errno, fdClose, fdFileno(), fdLink(), fdSetSyserrno(), fdWritable(), fdWrite, FTPERR_BAD_HOSTNAME, FTPERR_SERVER_IO_ERROR, ftpStrerror(), urlinfo_s::host, httpResp(), urlinfo_s::httpVersion, NI_MAXHOST, urlinfo_s::port, urlinfo_s::proxyh, urlinfo_s::proxyp, tcpConnect(), urlinfo_s::url, _FD_s::url, URLSANE, VERSION, and _FD_s::wr_chunked.

Referenced by ufdOpen().

static int httpResp | ( | urlinfo | u,
|  | FD_t | ctrl,
|  | char ** | str
| ) |  | `[static]`

Definition at line 1752 of file rpmio.c.

References _ftp_debug, checkResponse(), FTPERR_FILE_NOT_FOUND, FTPERR_UNKNOWN, _FD_s::syserrno, and URLSANE.

Referenced by httpReq().

static int mygethostbyname | ( | const char * | host,
|  | struct in_addr * | address
| ) |  | `[static]`

Definition at line 802 of file rpmio.c.

Referenced by getHostAddress().

static int rpm_inet_aton | ( | const char * | cp,
|  | struct in_addr * | inp
| ) |  | `[static]`

Definition at line 95 of file rpmio.c.

int rpmioAccess | ( | const char * | FN,
|  | const char * | path,
|  | int | mode
| ) |  |

Check FN access, expanding relative paths and twiddles.

Parameters:

  FN | file path to check
  path | colon separated search path (NULL uses $PATH)
  mode | type of access(2) to check (0 uses X_OK)

Returns:
  0 if accessible

Definition at line 2992 of file rpmio.c.

References _path, _rpmio_debug, Access(), alloca_strdup, F_OK, getenv(), R_OK, rpmCleanPath(), stpcpy(), W_OK, and X_OK.

Referenced by rpmtsPRCO(), and unsatisfiedDepend().

void rpmioClean | ( | void |  | ) |

Free all memory allocated by rpmio usage.

Definition at line 3133 of file rpmio.c.

References _digPool, _htPool, _mirePool, _rpmiobPool, _rpmluaPool, _rpmluavPool, _rpmmgPool, _urlPool, _xarPool, davDestroy(), rpmioFreePool(), rpmlogClose(), rpmluaFree(), and urlFreeCache().

Referenced by rpmcliFini(), and rpmioFini().

int rpmioMkpath | ( | const char * | path,
|  | mode_t | mode,
|  | uid_t | uid,
|  | gid_t | gid
| ) |  |

Insure that directories in path exist, creating as needed.

Parameters:

  path | directory path
  mode | directory mode (if created)
  uid | directory uid (if created), or -1 to skip
  gid | directory uid (if created), or -1 to skip

Returns:
  0 on success, errno (or -1) on error

Definition at line 2937 of file rpmio.c.

References alloca(), Chown(), D_, errno, Mkdir(), rpmlog(), RPMLOG_DEBUG, Stat(), and stpcpy().

Referenced by db3open(), doSetupMacro(), packageBinaries(), packageSources(), repoMkdir(), rpmTempFile(), and sql_open().

static int tcpConnect | ( | FD_t | ctrl,
|  | const char * | host,
|  | int | port
| ) |  | `[static]`

Definition at line 849 of file rpmio.c.

References _ftp_debug, errno, fdSetFdno(), fdSetSyserrno(), FTPERR_FAILED_CONNECT, ftpStrerror(), getHostAddress(), and NI_MAXHOST.

Referenced by ftpLogin(), and httpReq().

int ufdCopy | ( | FD_t | sfd,
|  | FD_t | tfd
| ) |  |

Definition at line 1514 of file rpmio.c.

References DBGIO, Fread(), FTPERR_FILE_IO_ERROR, ftpStrerror(), Fwrite(), RPMCALLBACK_INST_OPEN_FILE, and RPMCALLBACK_INST_PROGRESS.

Referenced by main(), and ufdGetFile().

int ufdGetFile | ( | FD_t | sfd,
|  | FD_t | tfd
| ) |  |

Definition at line 1626 of file rpmio.c.

References Fclose(), FDSANE, and ufdCopy().

Referenced by urlGetFile().

void* ufdGetUrlinfo | ( | FD_t | fd | ) |

Definition at line 1895 of file rpmio.c.

References FDSANE, _FD_s::url, and urlLink().

static FD_t ufdOpen | ( | const char * | url,
|  | int | flags,
|  | mode_t | mode
| ) |  | `[static]`

Definition at line 2220 of file rpmio.c.

References _rpmio_debug, _FD_s::bytesRemain, _FD_s::contentLength, davOpen(), davReq(), DBGIO, fdbg(), fdDup(), fdLink(), fdOpen, fdSetIo(), fdSetOpen(), Fileno(), ftpOpen(), ftpReq(), httpOpen(), httpReq(), urlinfo_s::openError, _FD_s::rd_timeoutsecs, ufdClose(), ufdio, URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_PATH, URL_IS_UNKNOWN, urlPath(), _FD_s::urlType, and _FD_s::wr_chunked.

Referenced by Fopen().

static ssize_t ufdRead | ( | void * | cookie,
|  | char * | buf,
|  | size_t | count
| ) |  | `[static]`

Definition at line 1906 of file rpmio.c.

References _rpmio_debug, _FD_s::bytesRemain, c2f(), errno, fdFileno(), fdGetIo(), fdRead, fdReadable(), _FD_s::rd_timeoutsecs, and UFDONLY.

static int ufdSeek | ( | void * | cookie,
|  | _libio_pos_t | pos,
|  | int | whence
| ) |  | `[inline, static]`

Definition at line 2034 of file rpmio.c.

References c2f(), fdSeek(), URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_PATH, URL_IS_UNKNOWN, and _FD_s::urlType.

static ssize_t ufdWrite | ( | void * | cookie,
|  | const char * | buf,
|  | size_t | count
| ) |  | `[static]`

Definition at line 1969 of file rpmio.c.

References _rpmio_debug, _FD_s::bytesRemain, c2f(), errno, fdGetFdno(), fdGetIo(), fdWritable(), fdWrite, and UFDONLY.

static int urlConnect | ( | const char * | url,
|  | urlinfo * | uret
| ) |  | `[static]`

Definition at line 1578 of file rpmio.c.

References _FD_s::bytesRemain, _FD_s::contentLength, urlinfo_s::ctrl, D_, fdFileno(), fdFree(), fdLink(), fdNew(), fdSetIo(), fdSetOpen(), _FD_s::ftpFileDoneNeeded, ftpLogin(), ftpTimeoutSecs, urlinfo_s::host, urlinfo_s::openError, urlinfo_s::password, _FD_s::rd_timeoutsecs, rpmlog(), RPMLOG_DEBUG, ufdio, _FD_s::url, URL_IS_FTP, urlFree(), urlLink(), urlSplit(), urlinfo_s::urltype, and urlinfo_s::user.

Referenced by ftpCmd(), and ftpOpen().

const char* urlStrerror | ( | const char * | url | ) |

Definition at line 778 of file rpmio.c.

References _, errno, ftpStrerror(), urlinfo_s::openError, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, urlIsURL(), and urlSplit().

FD_t XfdNew | ( | const char * | msg,
|  | const char * | fn,
|  | unsigned | ln
| ) |  |

Definition at line 327 of file rpmio.c.

References _FD_s::bytesRemain, _FD_s::contentDisposition, _FD_s::contentLength, _FD_s::contentType, _FD_s::dig, _FD_s::digests, _FD_s::errcookie, _FD_s::fd_cpioPos, fdGetPool(), FDMAGIC, _FDSTACK_s::fdno, _FD_s::flags, _FDSTACK_s::fp, _FD_s::fps, _FD_s::ftpFileDoneNeeded, _FDSTACK_s::io, _FD_s::lastModified, _FD_s::magic, _FD_s::ndigests, _FD_s::nfps, _FD_s::oflags, _FD_s::omode, _FD_s::opath, _FD_s::rd_timeoutsecs, rpmioLinkPoolItem(), _FD_s::stats, _FD_s::syserrno, ufdio, _FD_s::url, URL_IS_UNKNOWN, _FD_s::urlType, _FD_s::wr_chunked, _FD_s::xar, and xcalloc().

## Variable Documentation

int _av_debug = 0

Definition at line 168 of file rpmio.c.

Referenced by avClosedir(), avContextAdd(), avOpendir(), and avReaddir().

int _dav_debug = 0

Definition at line 178 of file rpmio.c.

rpmioPool _fdPool

Definition at line 309 of file rpmio.c.

Referenced by fdGetPool().

int _ftp_debug = 0

Definition at line 173 of file rpmio.c.

Referenced by checkResponse(), ftpCommand(), ftpLstat(), ftpOpendir(), ftpReadlink(), ftpReq(), ftpStat(), httpReq(), httpResp(), and tcpConnect().

const char* _path = "/bin:/usr/bin:/sbin:/usr/sbin"`[static]`

Definition at line 2988 of file rpmio.c.

Referenced by rpmioAccess().

int _rpmio_debug = 0

Definition at line 163 of file rpmio.c.

Referenced by Access(), Chdir(), Chmod(), Chown(), Chroot(), Closedir(), Fchmod(), Fchown(), fdFgets(), fdGetPool(), Fdopen(), fdWritable(), Fopen(), Fstat(), Glob(), Globfree(), Lchown(), Link(), Lseek(), Lstat(), Mkdir(), Mkfifo(), Mknod(), Open(), Opendir(), Readdir(), Readlink(), Realpath(), Rename(), Rmdir(), rpmioAccess(), Stat(), Symlink(), ufdOpen(), ufdRead(), ufdWrite(), Unlink(), Utime(), and Utimes().

FDIO_t fdio = &fdio_s

Definition at line 548 of file rpmio.c.

Referenced by fdbg(), Fdopen(), and urlFini().

struct FDIO_s fdio_s `[static]`

Initial value:

     {
       __fdRead ,  __fdWrite , fdSeek,  __fdClose , NULL, NULL, NULL,
    }

Definition at line 543 of file rpmio.c.

FDIO_t fpio = &fpio_s

Definition at line 3203 of file rpmio.c.

Referenced by Fclose(), fdbg(), Fdopen(), Ferror(), Fflush(), Fopen(), Fread(), Fseek(), Fwrite(), and urlFini().

struct FDIO_s fpio_s `[static]`

Initial value:

     {
      ufdRead, ufdWrite, fdSeek, ufdClose, NULL, NULL, NULL,
    }

Definition at line 3198 of file rpmio.c.

int ftpTimeoutSecs = 60`[static]`

Definition at line 158 of file rpmio.c.

Referenced by ftpOpen(), and urlConnect().

int noLibio = 1

Definition at line 150 of file rpmio.c.

Referenced by Fclose(), Fdopen(), and ufdClose().

FDIO_t ufdio = &ufdio_s

Definition at line 2329 of file rpmio.c.

Referenced by fdbg(), Fdopen(), ftpAbort(), ftpOpen(), httpOpen(), ufdOpen(), urlConnect(), and XfdNew().

struct FDIO_s ufdio_s `[static]`

Initial value:

     {
      ufdRead, ufdWrite, ufdSeek, ufdClose, NULL, NULL, NULL,
    }

Definition at line 2324 of file rpmio.c.