1999-07-04 07:36:35 +08:00
|
|
|
#ifndef H_RPMURL
|
|
|
|
#define H_RPMURL
|
|
|
|
|
2000-08-28 02:34:02 +08:00
|
|
|
/** \ingroup rpmio
|
|
|
|
* \file rpmio/rpmurl.h
|
|
|
|
*/
|
|
|
|
|
1999-11-10 04:57:38 +08:00
|
|
|
#include <assert.h>
|
|
|
|
|
2000-08-28 02:34:02 +08:00
|
|
|
/**
|
|
|
|
* Supported URL types.
|
|
|
|
*/
|
2001-10-18 00:43:36 +08:00
|
|
|
typedef enum urltype_e {
|
2000-08-28 02:34:02 +08:00
|
|
|
URL_IS_UNKNOWN = 0, /*!< unknown (aka a file) */
|
|
|
|
URL_IS_DASH = 1, /*!< stdin/stdout */
|
|
|
|
URL_IS_PATH = 2, /*!< file://... */
|
|
|
|
URL_IS_FTP = 3, /*!< ftp://... */
|
|
|
|
URL_IS_HTTP = 4 /*!< http://... */
|
1999-07-04 07:36:35 +08:00
|
|
|
} urltype;
|
|
|
|
|
1999-11-10 04:57:38 +08:00
|
|
|
#define URLMAGIC 0xd00b1ed0
|
|
|
|
#define URLSANE(u) assert(u && u->magic == URLMAGIC)
|
|
|
|
|
2001-11-13 04:51:05 +08:00
|
|
|
typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo_s * urlinfo;
|
2000-08-28 02:34:02 +08:00
|
|
|
/**
|
|
|
|
* URL control structure.
|
|
|
|
*/
|
2001-11-13 04:51:05 +08:00
|
|
|
struct urlinfo_s {
|
2000-08-28 02:34:02 +08:00
|
|
|
/*@refs@*/ int nrefs; /*!< no. of references */
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@owned@*/ /*@null@*/
|
|
|
|
const char * url; /*!< copy of original url */
|
|
|
|
/*@owned@*/ /*@null@*/
|
|
|
|
const char * service;
|
|
|
|
/*@owned@*/ /*@null@*/
|
|
|
|
const char * user;
|
|
|
|
/*@owned@*/ /*@null@*/
|
|
|
|
const char * password;
|
|
|
|
/*@owned@*/ /*@null@*/
|
|
|
|
const char * host;
|
|
|
|
/*@owned@*/ /*@null@*/
|
|
|
|
const char * portstr;
|
|
|
|
/*@owned@*/ /*@null@*/
|
|
|
|
const char * proxyu; /*!< FTP: proxy user */
|
|
|
|
/*@owned@*/ /*@null@*/
|
|
|
|
const char * proxyh; /*!< FTP/HTTP: proxy host */
|
2000-08-28 02:34:02 +08:00
|
|
|
int proxyp; /*!< FTP/HTTP: proxy port */
|
1999-07-04 07:36:35 +08:00
|
|
|
int port;
|
1999-11-24 08:03:54 +08:00
|
|
|
int urltype;
|
2000-08-28 02:34:02 +08:00
|
|
|
FD_t ctrl; /*!< control channel */
|
|
|
|
FD_t data; /*!< per-xfer data channel */
|
|
|
|
int bufAlloced; /*!< sizeof I/O buffer */
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@owned@*/ char * buf; /*!< I/O buffer */
|
2000-08-28 02:34:02 +08:00
|
|
|
int openError; /*!< Type of open failure */
|
1999-11-06 04:00:26 +08:00
|
|
|
int httpVersion;
|
|
|
|
int httpHasRange;
|
1999-11-10 04:57:38 +08:00
|
|
|
int magic;
|
2001-11-13 04:51:05 +08:00
|
|
|
};
|
1999-07-04 07:36:35 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@checked@*/
|
|
|
|
extern int _url_count; /*!< No. of cached URL's. */
|
|
|
|
|
|
|
|
/*@checked@*/
|
|
|
|
/*@only@*/ /*@null@*/
|
|
|
|
extern urlinfo * _url_cache; /*!< URL cache. */
|
|
|
|
|
|
|
|
/*@unchecked@*/
|
|
|
|
extern int _url_iobuf_size; /*!< Initial size of URL I/O buffer. */
|
|
|
|
#define RPMURL_IOBUF_SIZE 4096
|
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2001-10-18 00:43:36 +08:00
|
|
|
extern int _url_debug; /*!< URL debugging? */
|
|
|
|
#define RPMURL_DEBUG_IO 0x40000000
|
|
|
|
#define RPMURL_DEBUG_REFS 0x20000000
|
|
|
|
|
1999-07-04 07:36:35 +08:00
|
|
|
|
2000-08-28 02:34:02 +08:00
|
|
|
/**
|
|
|
|
* Create a URL control structure instance.
|
|
|
|
* @param msg debugging identifier (unused)
|
|
|
|
* @return new instance
|
|
|
|
*/
|
2001-09-21 23:07:11 +08:00
|
|
|
/*@unused@*/ urlinfo urlNew(const char * msg) /*@*/;
|
2001-06-18 06:18:03 +08:00
|
|
|
|
|
|
|
/** @todo Remove debugging entry from the ABI. */
|
2001-06-06 03:26:22 +08:00
|
|
|
urlinfo XurlNew(const char * msg, const char * file, unsigned line) /*@*/;
|
1999-11-02 22:33:14 +08:00
|
|
|
#define urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__)
|
|
|
|
|
2000-08-28 02:34:02 +08:00
|
|
|
/**
|
|
|
|
* Reference a URL control structure instance.
|
|
|
|
* @param u URL control structure
|
|
|
|
* @param msg debugging identifier (unused)
|
|
|
|
* @return referenced instance
|
|
|
|
*/
|
2001-09-21 23:07:11 +08:00
|
|
|
/*@unused@*/ urlinfo urlLink(urlinfo u, const char * msg)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies u @*/;
|
2001-06-18 06:18:03 +08:00
|
|
|
|
|
|
|
/** @todo Remove debugging entry from the ABI. */
|
2001-06-06 03:26:22 +08:00
|
|
|
urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line)
|
|
|
|
/*@modifies u @*/;
|
2000-08-28 02:34:02 +08:00
|
|
|
#define urlLink(_u, _msg) XurlLink(_u, _msg, __FILE__, __LINE__)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dereference a URL control structure instance.
|
|
|
|
* @param u URL control structure
|
|
|
|
* @param msg debugging identifier (unused)
|
|
|
|
* @return dereferenced instance (NULL if freed)
|
|
|
|
*/
|
2001-09-21 23:07:11 +08:00
|
|
|
/*@unused@*/ urlinfo urlFree( /*@killref@*/ urlinfo u, const char * msg)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies u @*/;
|
2001-06-18 06:18:03 +08:00
|
|
|
|
|
|
|
/** @todo Remove debugging entry from the ABI. */
|
2001-06-06 03:26:22 +08:00
|
|
|
urlinfo XurlFree( /*@killref@*/ urlinfo u, const char * msg,
|
|
|
|
const char * file, unsigned line)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals fileSystem@*/
|
|
|
|
/*@modifies u, fileSystem @*/;
|
1999-11-02 22:33:14 +08:00
|
|
|
#define urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__)
|
|
|
|
|
2000-08-28 02:34:02 +08:00
|
|
|
/**
|
|
|
|
* Free cached URL control structures.
|
|
|
|
*/
|
2001-06-06 03:26:22 +08:00
|
|
|
void urlFreeCache(void)
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@globals _url_cache, _url_count, fileSystem @*/
|
|
|
|
/*@modifies _url_cache, _url_count, fileSystem @*/;
|
1999-10-31 00:43:29 +08:00
|
|
|
|
2000-08-28 02:34:02 +08:00
|
|
|
/**
|
|
|
|
* Return type of URL.
|
|
|
|
* @param url url string
|
|
|
|
* @return type of url
|
|
|
|
*/
|
2001-06-06 03:26:22 +08:00
|
|
|
urltype urlIsURL(const char * url)
|
|
|
|
/*@*/;
|
2000-08-28 02:34:02 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return path component of URL.
|
|
|
|
* @param url url string
|
|
|
|
* @retval pathp pointer to path component of url
|
|
|
|
* @return type of url
|
|
|
|
*/
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@-incondefs@*/
|
2000-11-01 00:18:34 +08:00
|
|
|
urltype urlPath(const char * url, /*@out@*/ const char ** pathp)
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@ensures maxSet(*pathp) == 0 /\ maxRead(*pathp) == 0 @*/
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@modifies *pathp @*/;
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@=incondefs@*/
|
2000-08-28 02:34:02 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse URL string into a control structure.
|
|
|
|
* @param url url string
|
2001-10-16 01:53:34 +08:00
|
|
|
* @retval uret address of new control instance pointer
|
2000-08-28 02:34:02 +08:00
|
|
|
* @return 0 on success, -1 on error
|
|
|
|
*/
|
2001-10-16 01:53:34 +08:00
|
|
|
int urlSplit(const char * url, /*@out@*/ urlinfo * uret)
|
|
|
|
/*@modifies *uret @*/;
|
1999-07-04 07:36:35 +08:00
|
|
|
|
2000-08-28 02:34:02 +08:00
|
|
|
/**
|
|
|
|
* Copy data from URL to local file.
|
|
|
|
* @param url url string of source
|
|
|
|
* @param dest file name of destination
|
|
|
|
* @return 0 on success, otherwise FTPERR_* code
|
|
|
|
*/
|
2001-06-06 03:26:22 +08:00
|
|
|
int urlGetFile(const char * url, /*@null@*/ const char * dest)
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@modifies fileSystem @*/;
|
1999-07-04 07:36:35 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* H_RPMURL */
|