# rpmio/rpmrpc.c File Reference

`#include "system.h"`
`#include <rpmio_internal.h>`
`#include <popt.h>`
`#include "ugid.h"`
`#include "debug.h"`

Go to the source code of this file.

## Defines

#define | g_strdup xstrdup
#define | g_free free
#define | MAXCOLS 30
#define | alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))

## Enumerations

enum | ftpSysCall_t { DO_FTP_STAT = 1, DO_FTP_LSTAT = 2, DO_FTP_READLINK = 3, DO_FTP_ACCESS = 4, DO_FTP_GLOB = 5 }

## Functions

static int | ftpMkdir (const char *path, mode_t mode)
static int | ftpChdir (const char *path)
static int | ftpRmdir (const char *path)
static int | ftpRename (const char *oldpath, const char *newpath)
static int | ftpUnlink (const char *path)
int | Mkdir (const char *path, mode_t mode)
| mkdir(2) clone.
int | Chdir (const char *path)
| chdir(2) clone.
int | Rmdir (const char *path)
| rmdir(2) clone.
int | Rename (const char *oldpath, const char *newpath)
| rename(2) clone.
int | Link (const char *oldpath, const char *newpath)
| link(2) clone.
int | Unlink (const char *path)
| unlink(2) clone.
static int | vfs_split_text (char *p)
static int | is_num (int idx)
static int | is_dos_date (const char *str)
static int | is_week (const char *str, struct tm *tim)
static int | is_month (const char *str, struct tm *tim)
static int | is_time (const char *str, struct tm *tim)
static int | is_year (const char *str, struct tm *tim)
static int | vfs_parse_filetype (char c)
static int | vfs_parse_filemode (const char *p)
static int | vfs_parse_filedate (int idx, time_t *t)
static int | vfs_parse_ls_lga (char *p, struct stat *st, const char **filename, const char **linkname)
static int | ftpNLST (const char *url, ftpSysCall_t ftpSysCall, struct stat *st, char *rlbuf, size_t rlbufsiz)
static int | ftpStat (const char *path, struct stat *st)
static int | ftpLstat (const char *path, struct stat *st)
static int | ftpReadlink (const char *path, char *buf, size_t bufsiz)
static int | ftpGlob (const char *path, int flags, int errfunc(const char *epath, int eerno), glob_t *pglob)
static void | ftpGlobfree (glob_t *pglob)
int | Stat (const char *path, struct stat *st)
| stat(2) clone.
int | Lstat (const char *path, struct stat *st)
| lstat(2) clone.
int | Readlink (const char *path, char *buf, size_t bufsiz)
| readlink(2) clone.
int | Access (const char *path, int amode)
| access(2) clone.
int | Glob (const char *pattern, int flags, int errfunc(const char *epath, int eerrno), glob_t *pglob)
| glob(3) clone.
void | Globfree (glob_t *pglob)
| globfree(3) clone.
DIR * | Opendir (const char *path)
| opendir(3) clone.
direct * | Readdir (DIR *dir)
| readdir(3) clone.
int | Closedir (DIR *dir)
| closedir(3) clone.

## Variables

int | _rpmio_debug
static int | current_mday
static int | current_mon
static int | current_year
static char * | columns [30]
static int | column_ptr [30]
static size_t | ftpBufAlloced = 0
static char * | ftpBuf = NULL

## Detailed Description

Definition in file rpmrpc.c.

## Define Documentation

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

| Definition at line 811 of file rpmrpc.c.

#define g_free free

| Definition at line 256 of file rpmrpc.c. Referenced by vfs_parse_ls_lga().

#define g_strdup xstrdup

| Definition at line 255 of file rpmrpc.c. Referenced by vfs_parse_ls_lga().

#define MAXCOLS 30

| Definition at line 269 of file rpmrpc.c. Referenced by vfs_split_text().

## Enumeration Type Documentation

enum ftpSysCall_t

Enumerator:

  DO_FTP_STAT |
  DO_FTP_LSTAT |
  DO_FTP_READLINK |
  DO_FTP_ACCESS |
  DO_FTP_GLOB |

Definition at line 793 of file rpmrpc.c.

## Function Documentation

int Access | ( | const char * | path,
|  | int | amode
| ) |

| access(2) clone. Definition at line 1137 of file rpmrpc.c. References _rpmio_debug, URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath(). Referenced by chkdir().

int Chdir | ( | const char * | path | ) |

| chdir(2) clone. Definition at line 92 of file rpmrpc.c. References ftpChdir(), URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath().

int Closedir | ( | DIR * | dir | ) |

| closedir(3) clone. Definition at line 1233 of file rpmrpc.c. References _rpmio_debug. Referenced by myftw(), and myftw_dir().

static int ftpChdir | ( | const char * | path | ) | `[static]`

| Definition at line 36 of file rpmrpc.c. References ftpCmd(). Referenced by Chdir(), and ftpNLST().

static int ftpGlob | ( | const char * | path,
|  | int | flags,
|  | int | errfunc(const char *epath, int eerno),
|  | glob_t * | pglob
| ) | `[static]`

| Definition at line 1029 of file rpmrpc.c. References _rpmio_debug, DO_FTP_GLOB, ftpNLST(), and poptParseArgvString(). Referenced by Glob().

static void ftpGlobfree | ( | glob_t * | pglob | ) | `[static]`

| Definition at line 1051 of file rpmrpc.c. References _rpmio_debug. Referenced by Globfree().

static int ftpLstat | ( | const char * | path,
|  | struct stat * | st
| ) | `[static]`

| Definition at line 1011 of file rpmrpc.c. References _rpmio_debug, DO_FTP_LSTAT, and ftpNLST(). Referenced by Lstat().

static int ftpMkdir | ( | const char * | path,
|  | mode_t | mode
| ) | `[static]`

| Definition at line 20 of file rpmrpc.c. References ftpCmd(). Referenced by Mkdir().

static int ftpNLST | ( | const char * | url,
|  | ftpSysCall_t | ftpSysCall,
|  | struct stat * | st,
|  | char * | rlbuf,
|  | size_t | rlbufsiz
| ) | `[static]`

| Definition at line 814 of file rpmrpc.c. References _url_iobuf_size, alloca_strdup, DO_FTP_GLOB, fdFgets(), fdLink, ftpChdir(), ftpOpen(), ftpReq(), urlinfo_s::openError, urlPath(), xcalloc(), and xrealloc(). Referenced by ftpGlob(), ftpLstat(), ftpReadlink(), and ftpStat().

static int ftpReadlink | ( | const char * | path,
|  | char * | buf,
|  | size_t | bufsiz
| ) | `[static]`

| Definition at line 1022 of file rpmrpc.c. References DO_FTP_READLINK, and ftpNLST(). Referenced by Readlink().

static int ftpRename | ( | const char * | oldpath,
|  | const char * | newpath
| ) | `[static]`

| Definition at line 50 of file rpmrpc.c. References ftpCmd(). Referenced by Rename().

static int ftpRmdir | ( | const char * | path | ) | `[static]`

| Definition at line 43 of file rpmrpc.c. References ftpCmd(). Referenced by Rmdir().

static int ftpStat | ( | const char * | path,
|  | struct stat * | st
| ) | `[static]`

| Definition at line 1004 of file rpmrpc.c. References DO_FTP_STAT, and ftpNLST(). Referenced by Stat().

static int ftpUnlink | ( | const char * | path | ) | `[static]`

| Definition at line 60 of file rpmrpc.c. References ftpCmd(). Referenced by Unlink().

int Glob | ( | const char * | pattern,
|  | int | flags,
|  | int | errfunc(const char *epath, int eerrno),
|  | glob_t * | pglob
| ) |

| glob(3) clone. Definition at line 1160 of file rpmrpc.c. References _rpmio_debug, ftpGlob(), URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath().

void Globfree | ( | glob_t * | pglob | ) |

| globfree(3) clone. Definition at line 1188 of file rpmrpc.c. References _rpmio_debug, and ftpGlobfree().

static int is_dos_date | ( | const char * | str | ) | `[static]`

| Definition at line 308 of file rpmrpc.c. Referenced by vfs_parse_filedate(), and vfs_parse_ls_lga().

static int is_month | ( | const char * | str,
|  | struct tm * | tim
| ) | `[static]`

| Definition at line 335 of file rpmrpc.c. Referenced by vfs_parse_filedate(), and vfs_parse_ls_lga().

static int is_num | ( | int | idx | ) | `[static]`

| Definition at line 299 of file rpmrpc.c. References columns. Referenced by vfs_parse_filedate(), and vfs_parse_ls_lga().

static int is_time | ( | const char * | str,
|  | struct tm * | tim
| ) | `[static]`

| Definition at line 352 of file rpmrpc.c. References pgpDig_s::p. Referenced by vfs_parse_filedate().

static int is_week | ( | const char * | str,
|  | struct tm * | tim
| ) | `[static]`

| Definition at line 318 of file rpmrpc.c. Referenced by vfs_parse_filedate(), and vfs_parse_ls_lga().

static int is_year | ( | const char * | str,
|  | struct tm * | tim
| ) | `[static]`

| Definition at line 371 of file rpmrpc.c. Referenced by vfs_parse_filedate().

int Link | ( | const char * | oldpath,
|  | const char * | newpath
| ) |

| link(2) clone. Definition at line 187 of file rpmrpc.c. References _rpmio_debug, URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, urlPath(), and xstrncasecmp().

int Lstat | ( | const char * | path,
|  | struct stat * | st
| ) |

| lstat(2) clone. Definition at line 1089 of file rpmrpc.c. References _rpmio_debug, ftpLstat(), URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath(). Referenced by addFile(), checkOwners(), doUntar(), myftw(), myftw_dir(), and rpmVerifyFile().

int Mkdir | ( | const char * | path,
|  | mode_t | mode
| ) |

| mkdir(2) clone. Definition at line 69 of file rpmrpc.c. References ftpMkdir(), URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath(). Referenced by chkdir(), packageBinaries(), and rpmdbRebuild().

DIR* Opendir | ( | const char * | path | ) |

| opendir(3) clone. Definition at line 1200 of file rpmrpc.c. References _rpmio_debug, URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath(). Referenced by myftw(), and myftw_dir().

struct direct* Readdir | ( | DIR * | dir | ) |

| readdir(3) clone. Definition at line 1226 of file rpmrpc.c. References _rpmio_debug. Referenced by myftw_dir().

int Readlink | ( | const char * | path,
|  | char * | buf,
|  | size_t | bufsiz
| ) |

| readlink(2) clone. Definition at line 1114 of file rpmrpc.c. References ftpReadlink(), URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath(). Referenced by genCpioListAndHeader(), and rpmVerifyFile().

int Rename | ( | const char * | oldpath,
|  | const char * | newpath
| ) |

| rename(2) clone. Definition at line 140 of file rpmrpc.c. References _rpmio_debug, ftpRename(), URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, urlPath(), and xstrncasecmp(). Referenced by rpmdbMoveDatabase().

int Rmdir | ( | const char * | path | ) |

| rmdir(2) clone. Definition at line 115 of file rpmrpc.c. References ftpRmdir(), URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath(). Referenced by rpmdbRebuild().

int Stat | ( | const char * | path,
|  | struct stat * | st
| ) |

| stat(2) clone. Definition at line 1064 of file rpmrpc.c. References _rpmio_debug, ftpStat(), URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath(). Referenced by buildForTarget(), chkdir(), packageBinaries(), processSourceFiles(), and rpmioFileExists().

int Unlink | ( | const char * | path | ) |

| unlink(2) clone. Definition at line 231 of file rpmrpc.c. References ftpUnlink(), URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath(). Referenced by buildForTarget(), doRmSource(), doScript(), urlGetFile(), and writeRPM().

static int vfs_parse_filedate | ( | int | idx,
|  | time_t * | t
| ) | `[static]`

| Definition at line 481 of file rpmrpc.c. References columns, current_mday, current_mon, current_year, is_dos_date(), is_month(), is_num(), is_time(), is_week(), is_year(), and pgpDig_s::p.

static int vfs_parse_filemode | ( | const char * | p | ) | `[static]`

| Definition at line 422 of file rpmrpc.c. Referenced by vfs_parse_ls_lga().

static int vfs_parse_filetype | ( | char | c | ) | `[static]`

| Definition at line 403 of file rpmrpc.c. References S_IFSOCK. Referenced by vfs_parse_ls_lga().

static int vfs_parse_ls_lga | ( | char * | p,
|  | struct stat * | st,
|  | const char ** | filename,
|  | const char ** | linkname
| ) | `[static]`

| Definition at line 590 of file rpmrpc.c. References columns, g_free, g_strdup, gnameToGid(), is_dos_date(), is_month(), is_num(), is_week(), unameToUid(), vfs_parse_filemode(), vfs_parse_filetype(), and vfs_split_text().

static int vfs_split_text | ( | char * | p | ) | `[static]`

| Definition at line 277 of file rpmrpc.c. References MAXCOLS. Referenced by vfs_parse_ls_lga().

## Variable Documentation

int _rpmio_debug

| Definition at line 123 of file rpmio.c.

int column_ptr[30]`[static]`

| Definition at line 274 of file rpmrpc.c.

char* columns[30]`[static]`

| Definition at line 272 of file rpmrpc.c. Referenced by is_num(), vfs_parse_filedate(), and vfs_parse_ls_lga().

int current_mday`[static]`

| Definition at line 262 of file rpmrpc.c. Referenced by vfs_parse_filedate().

int current_mon`[static]`

| Definition at line 264 of file rpmrpc.c. Referenced by vfs_parse_filedate().

int current_year`[static]`

| Definition at line 266 of file rpmrpc.c. Referenced by vfs_parse_filedate().

char* ftpBuf = NULL`[static]`

| Definition at line 809 of file rpmrpc.c.

size_t ftpBufAlloced = 0`[static]`

| Definition at line 804 of file rpmrpc.c.