blob: 1c768c5441183040369426aa71336674ce89f5cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#ifndef H_RPMURL
#define H_RPMURL
/** \ingroup rpmio
* \file rpmio/rpmurl.h
*/
#include <assert.h>
/**
* Supported URL types.
*/
typedef enum urltype_e {
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://... */
URL_IS_HTTPS = 5, /*!< https://... */
URL_IS_HKP = 6 /*!< hkp://... */
} urltype;
#define URLMAGIC 0xd00b1ed0
#define URLSANE(u) assert(u && u->magic == URLMAGIC)
typedef struct urlinfo_s * urlinfo;
/**
* URL control structure.
*/
struct urlinfo_s {
const char * url; /*!< copy of original url */
const char * scheme; /*!< URI scheme. */
const char * user; /*!< URI user. */
const char * password; /*!< URI password. */
const char * host; /*!< URI host. */
const char * portstr; /*!< URI port string. */
const char * proxyu; /*!< FTP: proxy user */
const char * proxyh; /*!< FTP/HTTP: proxy host */
int proxyp; /*!< FTP/HTTP: proxy port */
int port; /*!< URI port. */
int urltype; /*!< URI type. */
int openError; /*!< Type of open failure */
int magic;
};
#ifdef __cplusplus
extern "C" {
#endif
extern int _url_debug; /*!< URL debugging? */
/**
* Create a URL info structure instance.
* @return new instance
*/
urlinfo urlNew(void);
/**
* Free a URL info structure instance.
* @param u URL control structure
* @return dereferenced instance (NULL if freed)
*/
urlinfo urlFree(urlinfo u);
/**
* Return type of URL.
* @param url url string
* @return type of url
*/
urltype urlIsURL(const char * url);
/**
* Return path component of URL.
* @param url url string
* @retval pathp pointer to path component of url
* @return type of url
*/
urltype urlPath(const char * url, const char ** pathp);
/**
* Parse URL string into a control structure.
* @param url url string
* @retval uret address of new control instance pointer
* @return 0 on success, -1 on error
*/
int urlSplit(const char * url, urlinfo * uret);
/**
* 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
*/
int urlGetFile(const char * url, const char * dest);
#ifdef __cplusplus
}
#endif
#endif /* H_RPMURL */
|