rpm  5.4.14
Data Structures | Macros | Functions | Variables
#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 IPPORT_MONGO   27017
 
#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 urlType (void *_u)
 
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)
 
voidurlNotifyArg
 
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 27 of file url.c.

Referenced by urlSplit().

#define IPPORT_HTTP   80

Definition at line 30 of file url.c.

Referenced by urlSplit().

#define IPPORT_HTTPS   443

Definition at line 33 of file url.c.

Referenced by urlSplit().

#define IPPORT_MONGO   27017

Definition at line 39 of file url.c.

Referenced by urlSplit().

#define IPPORT_PGPKEYSERVER   11371

Definition at line 36 of file url.c.

Referenced by urlSplit().

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

Definition at line 73 of file url.c.

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

Definition at line 75 of file url.c.

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

Definition at line 76 of file url.c.

Function Documentation

static void urlFind ( urlinfo uret,
int  mustAsk 
)
static
static void urlFini ( void _u)
static
void urlFreeCache ( void  )

Free cached URL control structures.

Definition at line 202 of file url.c.

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

Referenced by rpmioClean().

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

Copy data from URL to local file.

Parameters
urlurl string of source
destfile name of destination
Returns
0 on success, otherwise FTPERR_* code

Definition at line 598 of file url.c.

References _free(), D_, exit, Fclose(), Ferror(), Fopen(), fprintf(), Fstrerror(), FTPERR_UNKNOWN, NULL, rc, result, rpmExpand(), rpmExpandNumeric(), rpmlog(), RPMLOG_DEBUG, strcmp(), ufdGetFile(), Unlink(), URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_MONGO, URL_IS_PATH, URL_IS_UNKNOWN, urlPath(), urlType(), and void.

Referenced by prepFetch().

static urlinfo urlGetPool ( rpmioPool  pool)
static

Definition at line 160 of file url.c.

References urlinfo_s::_item, _urlPool, memset(), NULL, rpmioGetPool(), rpmioNewPool(), u, and urlFini().

Referenced by XurlNew().

urltype urlIsURL ( const char *  url)

Return type of URL.

Parameters
urlurl string
Returns
type of url

Definition at line 409 of file url.c.

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

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

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

Return path component of URL.

Parameters
urlurl string
Return values
pathppointer to path component of url
Returns
type of url

Definition at line 430 of file url.c.

References urlstring::leadin, urlstring::len, NULL, path, urlstring::ret, URL_IS_UNKNOWN, and urlstrings.

Referenced by Access(), addFile(), arSetup(), Chdir(), Chflags(), Chmod(), Chown(), Chroot(), compareFileListRecs(), compressFilelist(), cpioStrCmp(), db3close(), db3open(), dncmp(), dnlInitIterator(), dodigest(), doFoo(), doIcon(), doPatch(), doSetupMacro(), doUntar(), Fadvise(), Fallocate(), Fchflags(), Fchmod(), Fchown(), for(), fsmMkdirs(), fsmStage(), Fstat(), ftpCmd(), ftpNLST(), fts_safe_changedir(), genCpioListAndHeader(), Glob(), Glob_pattern_p(), handlePreambleTag(), iosmMkdirs(), iosmStage(), iosmStrCmp(), Lchflags(), Lchmod(), Lchown(), Link(), Lstat(), Lutimes(), main(), Mkdir(), Mkfifo(), Mknod(), Open(), packagedDir(), parseForSimple(), populateInstallHeader(), processBinaryFile(), processMetadataFile(), processSourceFiles(), Readlink(), Realpath(), Rename(), Rmdir(), rpmalAllFileSatisfiesDepend(), rpmdbURIPath(), rpmdsNew(), rpmfcClassify(), rpmfcGenerateDepends(), rpmfiBuildFNames(), rpmfiFN(), rpmfiFNBF(), rpmGenPath(), rpmGlob(), rpmmgFile(), rpmMkdirPath(), rpmpsmStage(), rpmReadHeader(), rpmrepoInitPopt(), rpmrepoMkdir(), rpmrepoRfileDigest(), rpmShowProgress(), rpmTempFile(), rpmtsOpenSDB(), 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
urlurl string
Return values
uretaddress of new control instance pointer
Returns
0 on success, -1 on error

Definition at line 476 of file url.c.

References _, _free(), assert(), f, fe, urlinfo_s::fragment, urlinfo_s::host, int, IPPORT_FTP, IPPORT_HTTP, IPPORT_HTTPS, IPPORT_MONGO, IPPORT_PGPKEYSERVER, NULL, urlinfo_s::password, urlinfo_s::port, urlinfo_s::portstr, urlinfo_s::query, rpmlog(), RPMLOG_ERR, s, urlinfo_s::scheme, se, u, urlinfo_s::url, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_MONGO, urlFind(), urlFree(), urlIsURL(), urlNew(), urlStrdup(), urlinfo_s::user, urlinfo_s::ut, and xstrdup().

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

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

Definition at line 224 of file url.c.

References strcmp().

Referenced by urlFind().

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

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

Definition at line 457 of file url.c.

References nb, t, and xmalloc.

Referenced by urlSplit().

urltype urlType ( void _u)

Definition at line 424 of file url.c.

References NULL, and URL_IS_UNKNOWN.

Referenced by ufdClose(), ufdSeek(), urlConnect(), and urlGetFile().

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

Variable Documentation

urlinfo* _url_cache = NULL

URL cache.

Definition at line 82 of file url.c.

int _url_count = 0

No. of cached URL's.

Definition at line 155 of file url.c.

Referenced by urlFind(), and urlFreeCache().

int _url_debug = 0

URL debugging?

Definition at line 71 of file url.c.

int _url_iobuf_size = 4096

Initial size of URL I/O buffer.

Definition at line 66 of file url.c.

Referenced by checkResponse(), and ftpNLST().

rpmioPool _urlPool

Definition at line 158 of file url.c.

Referenced by rpmioClean(), and urlGetPool().

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

Definition at line 54 of file url.c.

Referenced by XurlNew().

void* urlNotifyArg

Definition at line 61 of file url.c.

Referenced by XurlNew().

struct urlstring urlstrings[]
static
Initial value:
= {
{ "file://", sizeof("file://")-1, URL_IS_PATH },
{ "ftp://", sizeof("ftp://")-1, URL_IS_FTP },
{ "hkp://", sizeof("hkp://")-1, URL_IS_HKP },
{ "http://", sizeof("http://")-1, URL_IS_HTTP },
{ "https://", sizeof("https://")-1, URL_IS_HTTPS },
{ "mongo://", sizeof("mongo://")-1, URL_IS_MONGO },
{ "mongodb://", sizeof("mongodb://")-1, URL_IS_MONGO },
{ "git://", sizeof("git://")-1, (urltype)16 },
{ "svn://", sizeof("svn://")-1, (urltype)17 },
{ "sqlite://", sizeof("sqlite://")-1, (urltype)32 },
{ "mysql://", sizeof("mysql://")-1, (urltype)33 },
{ "postgres://", sizeof("postgres://")-1, (urltype)34 },
{ "mssql://", sizeof("mssql://")-1, (urltype)35 },
{ "sqlserver://", sizeof("sqlserver://")-1, (urltype)35 },
{ "-", sizeof("-")-1, URL_IS_DASH },
}
enum urltype_e urltype
Supported URL types.
return NULL
Definition: poptALL.c:613

Referenced by urlIsURL(), and urlPath().