rpm 5.2.1

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

- File List
- Globals

Data Structures | Macros | Functions | Variables
url.c File Reference
RPMIO.
`#include "system.h"`
`#include <netinet/in.h>`
`#include <rpmmacro.h>`
`#include <rpmcb.h>`
`#include <rpmio_internal.h>`
`#include "debug.h"`
Include dependency graph for url.c:

Go to the source code of this file.

## Data Structures
struct | urlstring

## Macros
#define | IPPORT_FTP 21
#define | IPPORT_HTTP 80
#define | IPPORT_HTTPS 443
#define | IPPORT_PGPKEYSERVER 11371
#define | URLDBG(_f, _m, _x) if ((_url_debug | (_f)) & (_m)) fprintf _x
#define | URLDBGIO(_f, _x) URLDBG((_f), RPMURL_DEBUG_IO, _x)
#define | URLDBGREFS(_f, _x) URLDBG((_f), RPMURL_DEBUG_REFS, _x)

## Functions
static void | urlFini (void *_u)
static urlinfo | urlGetPool (rpmioPool pool)
urlinfo | XurlNew (const char *msg, const char *fn, unsigned ln)
void | urlFreeCache (void)
| Free cached URL control structures. More...
static int | urlStrcmp (const char *str1, const char *str2)
static void | urlFind (urlinfo *uret, int mustAsk)
urltype | urlIsURL (const char *url)
| Return type of URL. More...
urltype | urlPath (const char *url, const char **pathp)
| Return path component of URL. More...
static const char * | urlStrdup (const char *url)
| Copy a URL, adding extra byte for the pesky trailing '/'. More...
int | urlSplit (const char *url, urlinfo *uret)
| Parse URL string into a control structure. More...
int | urlGetFile (const char *url, const char *dest)
| Copy data from URL to local file. More...

## Variables
int(* | urlNotify )(const urlinfo u, unsigned status)
void * | urlNotifyArg
int | _url_iobuf_size = 4096
int | _url_debug = 0
urlinfo * | _url_cache = NULL
int | _url_count = 0
rpmioPool | _urlPool
static struct urlstring | urlstrings []

## Macro Definition Documentation

#define IPPORT_FTP 21

Definition at line 22 of file url.c.

Referenced by urlSplit().

#define IPPORT_HTTP 80

Definition at line 25 of file url.c.

Referenced by urlSplit().

#define IPPORT_HTTPS 443

Definition at line 28 of file url.c.

Referenced by urlSplit().

#define IPPORT_PGPKEYSERVER 11371

Definition at line 31 of file url.c.

Referenced by urlSplit().

#define URLDBG | ( |  | _f,
|  |  | _m,
|  |  | _x
| ) |  | if ((_url_debug | (_f)) & (_m)) fprintf _x

Definition at line 56 of file url.c.

#define URLDBGIO | ( |  | _f,
|  |  | _x
| ) |  | URLDBG((_f), RPMURL_DEBUG_IO, _x)

Definition at line 58 of file url.c.

#define URLDBGREFS | ( |  | _f,
|  |  | _x
| ) |  | URLDBG((_f), RPMURL_DEBUG_REFS, _x)

Definition at line 59 of file url.c.

## Function Documentation

static void urlFind | ( | urlinfo * | uret,
|  | int | mustAsk
| ) |  |
| static

Definition at line 217 of file url.c.

References _, _free(), _url_count, alloca(), Getpass, urlinfo_s::host, urlinfo_s::password, urlinfo_s::portstr, urlinfo_s::proxyh, urlinfo_s::proxyp, urlinfo_s::proxyu, rpmExpand(), urlinfo_s::scheme, stpcpy(), URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, urlFree(), urlLink(), URLSANE, urlStrcmp(), urlinfo_s::urltype, urlinfo_s::user, xmalloc(), xrealloc(), and xstrdup().

Referenced by urlSplit().

static void urlFini | ( | void * | _u | ) |
| static

Definition at line 67 of file url.c.

References _, _free(), urlinfo_s::buf, FDIO_s::close, urlinfo_s::ctrl, urlinfo_s::data, davFree(), urlinfo_s::etag, Fclose(), fdFileno(), fdGetFp(), fdio, fdPush(), fpio, urlinfo_s::fragment, urlinfo_s::host, urlinfo_s::location, urlinfo_s::password, urlinfo_s::portstr, urlinfo_s::proxyh, urlinfo_s::proxyu, urlinfo_s::query, urlinfo_s::rop, rpmioFreePoolItem(), urlinfo_s::scheme, urlinfo_s::sop, urlinfo_s::top, urlinfo_s::url, and urlinfo_s::user.

Referenced by urlGetPool().

void urlFreeCache | ( | void |  | ) |

Free cached URL control structures.

Definition at line 183 of file url.c.

References _, _free(), _url_count, urlinfo_s::host, urlinfo_s::scheme, and urlFree().

Referenced by rpmioClean().

int urlGetFile | ( | const char * | url,
|  | const char * | dest
| ) |  |

Copy data from URL to local file.

Parameters

  url | url string of source
  dest | file name of destination

Returns
  0 on success, otherwise FTPERR_* code

Definition at line 573 of file url.c.

References _free(), _url_debug, D_, Fclose(), Ferror(), Fopen(), Fstrerror(), FTPERR_UNKNOWN, rpmExpand(), rpmExpandNumeric(), rpmlog(), RPMLOG_DEBUG, ufdGetFile(), Unlink(), URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath().

Referenced by prepFetch().

static urlinfo urlGetPool | ( | rpmioPool | pool | ) |
| static

Definition at line 143 of file url.c.

References _url_debug, _urlPool, rpmioGetPool(), rpmioNewPool(), and urlFini().

Referenced by XurlNew().

urltype urlIsURL | ( | const char * | url | ) |

Return type of URL.

Parameters

  url | url string

Returns
  type of url

Definition at line 377 of file url.c.

References urlstring::leadin, urlstring::ret, URL_IS_UNKNOWN, and urlstrings.

Referenced by Fopen(), Fts_open(), main(), urlPath(), urlSplit(), and urlStrerror().

urltype urlPath | ( | const char * | url,
|  | const char ** | pathp
| ) |  |

Return path component of URL.

Parameters

  url | url string

Return values

  pathp | pointer to path component of url

Returns
  type of url

Definition at line 393 of file url.c.

References 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 Access(), addFile(), arSetup(), Chdir(), Chmod(), Chown(), Chroot(), compareFileListRecs(), compressFilelist(), cpioStrCmp(), db3close(), db3open(), dncmp(), dnlInitIterator(), dodigest(), doFoo(), doIcon(), doPatch(), doSetupMacro(), doUntar(), Fchmod(), Fchown(), fsmMkdirs(), fsmStage(), Fstat(), ftpCmd(), ftpNLST(), fts_safe_changedir(), genCpioListAndHeader(), Glob(), Glob_pattern_p(), handlePreambleTag(), iosmMkdirs(), iosmStage(), iosmStrCmp(), Lchown(), Link(), Lstat(), main(), Mkdir(), Mkfifo(), Mknod(), Open(), Opendir(), parseForSimple(), populateInstallHeader(), processBinaryFile(), processMetadataFile(), processSourceFiles(), Readlink(), Realpath(), Rename(), repoMkdir(), repoRfileDigest(), Rmdir(), rpmdbRebuild(), rpmdbURIPath(), rpmdsNew(), rpmfcClassify(), rpmfcGenerateDepends(), rpmfiBuildFNames(), rpmfiFN(), rpmGenPath(), rpmGlob(), rpmioFileExists(), rpmMkdirPath(), rpmpsmStage(), rpmReadHeader(), rpmShowProgress(), rpmTempFile(), rpmtsRootDir(), sql_close(), sql_open(), Stat(), Symlink(), ufdOpen(), Unlink(), urlGetFile(), Utime(), Utimes(), writeFile(), and writeLinkedFile().

int urlSplit | ( | const char * | url,
|  | urlinfo * | uret
| ) |  |

Parse URL string into a control structure.

Parameters

  url | url string

Return values

  uret | address of new control instance pointer

Returns
  0 on success, -1 on error

Definition at line 462 of file url.c.

References _, _free(), urlinfo_s::fragment, urlinfo_s::host, IPPORT_FTP, IPPORT_HTTP, IPPORT_HTTPS, IPPORT_PGPKEYSERVER, urlinfo_s::password, urlinfo_s::port, urlinfo_s::portstr, urlinfo_s::query, rpmlog(), RPMLOG_ERR, urlinfo_s::scheme, urlinfo_s::url, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, urlFind(), urlFree(), urlIsURL(), urlNew(), urlStrdup(), urlinfo_s::urltype, urlinfo_s::user, and xstrdup().

Referenced by avContextCreate(), httpOpen(), urlConnect(), and urlStrerror().

static int urlStrcmp | ( | const char * | str1,
|  | const char * | str2
| ) |  |
| static

Definition at line 205 of file url.c.

Referenced by urlFind().

static const char* urlStrdup | ( | const char * | url | ) |
| static

Copy a URL, adding extra byte for the pesky trailing '/'.

Definition at line 443 of file url.c.

References xmalloc().

Referenced by urlSplit().

urlinfo XurlNew | ( | const char * | msg,
|  | const char * | fn,
|  | unsigned | ln
| ) |  |

Todo:
  Remove debugging entry from the ABI.

Definition at line 157 of file url.c.

References urlinfo_s::allow, urlinfo_s::arg, urlinfo_s::buf, urlinfo_s::bufAlloced, urlinfo_s::ctrl, urlinfo_s::data, urlinfo_s::etag, urlinfo_s::httpVersion, urlinfo_s::location, urlinfo_s::magic, urlinfo_s::notify, urlinfo_s::port, urlinfo_s::proxyp, urlinfo_s::rop, rpmioLinkPoolItem(), RPMURL_SERVER_HASRANGE, urlinfo_s::sop, urlinfo_s::top, URL_IS_UNKNOWN, urlGetPool(), URLMAGIC, urlNotify, urlNotifyArg, urlinfo_s::urltype, and xcalloc().

## Variable Documentation

urlinfo* _url_cache = NULL

URL cache.

Definition at line 65 of file url.c.

int _url_count = 0

No. of cached URL's.

Definition at line 138 of file url.c.

Referenced by urlFind(), and urlFreeCache().

int _url_debug = 0

URL debugging?

Definition at line 54 of file url.c.

Referenced by urlGetFile(), and urlGetPool().

int _url_iobuf_size = 4096

Initial size of URL I/O buffer.

Definition at line 49 of file url.c.

Referenced by checkResponse(), and ftpNLST().

rpmioPool _urlPool

Definition at line 141 of file url.c.

Referenced by rpmioClean(), and urlGetPool().

int(* urlNotify)(const urlinfo u, unsigned status)

Definition at line 37 of file url.c.

Referenced by XurlNew().

void* urlNotifyArg

Definition at line 44 of file url.c.

Referenced by XurlNew().

struct urlstring urlstrings[]
| static

Initial value:
= {
{ "file://", URL_IS_PATH },
{ "ftp://", URL_IS_FTP },
{ "hkp://", URL_IS_HKP },
{ "http://", URL_IS_HTTP },
{ "https://", URL_IS_HTTPS },
{ "-", URL_IS_DASH },
{ NULL, URL_IS_UNKNOWN }
}

Referenced by urlIsURL().