1 /* $NetBSD: fetch.h,v 1.16 2010/01/22 13:21:09 joerg Exp $ */
3 * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer
11 * in this position and unchanged.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * $FreeBSD: fetch.h,v 1.26 2004/09/21 18:35:20 des Exp $
32 #ifndef _FETCH_H_INCLUDED
33 #define _FETCH_H_INCLUDED
35 #include <sys/types.h>
39 #define _LIBFETCH_VER "libfetch/2.0"
41 #define URL_HOSTLEN 255
42 #define URL_SCHEMELEN 16
43 #define URL_USERLEN 256
44 #define URL_PWDLEN 256
46 typedef struct fetchIO fetchIO
;
49 char scheme
[URL_SCHEMELEN
+ 1];
50 char user
[URL_USERLEN
+ 1];
51 char pwd
[URL_PWDLEN
+ 1];
52 char host
[URL_HOSTLEN
+ 1];
72 /* Recognized schemes */
73 #define SCHEME_FTP "ftp"
74 #define SCHEME_HTTP "http"
75 #define SCHEME_HTTPS "https"
76 #define SCHEME_FILE "file"
82 #define FETCH_EXISTS 4
85 #define FETCH_MEMORY 7
87 #define FETCH_NETWORK 9
89 #define FETCH_PROTO 11
90 #define FETCH_RESOLV 12
91 #define FETCH_SERVER 13
93 #define FETCH_TIMEOUT 15
94 #define FETCH_UNAVAIL 16
95 #define FETCH_UNKNOWN 17
97 #define FETCH_VERBOSE 19
98 #define FETCH_UNCHANGED 20
100 #if defined(__cplusplus)
104 void fetchIO_close(fetchIO
*);
105 ssize_t
fetchIO_read(fetchIO
*, void *, size_t);
106 ssize_t
fetchIO_write(fetchIO
*, const void *, size_t);
108 /* fetchIO-specific functions */
109 fetchIO
*fetchXGetFile(struct url
*, struct url_stat
*, const char *);
110 fetchIO
*fetchGetFile(struct url
*, const char *);
111 fetchIO
*fetchPutFile(struct url
*, const char *);
112 int fetchStatFile(struct url
*, struct url_stat
*, const char *);
113 int fetchListFile(struct url_list
*, struct url
*, const char *,
116 /* HTTP-specific functions */
117 fetchIO
*fetchXGetHTTP(struct url
*, struct url_stat
*, const char *);
118 fetchIO
*fetchGetHTTP(struct url
*, const char *);
119 fetchIO
*fetchPutHTTP(struct url
*, const char *);
120 int fetchStatHTTP(struct url
*, struct url_stat
*, const char *);
121 int fetchListHTTP(struct url_list
*, struct url
*, const char *,
124 /* FTP-specific functions */
125 fetchIO
*fetchXGetFTP(struct url
*, struct url_stat
*, const char *);
126 fetchIO
*fetchGetFTP(struct url
*, const char *);
127 fetchIO
*fetchPutFTP(struct url
*, const char *);
128 int fetchStatFTP(struct url
*, struct url_stat
*, const char *);
129 int fetchListFTP(struct url_list
*, struct url
*, const char *,
132 /* Generic functions */
133 fetchIO
*fetchXGetURL(const char *, struct url_stat
*, const char *);
134 fetchIO
*fetchGetURL(const char *, const char *);
135 fetchIO
*fetchPutURL(const char *, const char *);
136 int fetchStatURL(const char *, struct url_stat
*, const char *);
137 int fetchListURL(struct url_list
*, const char *, const char *,
139 fetchIO
*fetchXGet(struct url
*, struct url_stat
*, const char *);
140 fetchIO
*fetchGet(struct url
*, const char *);
141 fetchIO
*fetchPut(struct url
*, const char *);
142 int fetchStat(struct url
*, struct url_stat
*, const char *);
143 int fetchList(struct url_list
*, struct url
*, const char *,
147 struct url
*fetchMakeURL(const char *, const char *, int,
148 const char *, const char *, const char *);
149 struct url
*fetchParseURL(const char *);
150 struct url
*fetchCopyURL(const struct url
*);
151 char *fetchStringifyURL(const struct url
*);
152 void fetchFreeURL(struct url
*);
155 void fetchInitURLList(struct url_list
*);
156 int fetchAppendURLList(struct url_list
*, const struct url_list
*);
157 void fetchFreeURLList(struct url_list
*);
158 char *fetchUnquotePath(struct url
*);
159 char *fetchUnquoteFilename(struct url
*);
161 /* Connection caching */
162 void fetchConnectionCacheInit(int, int);
163 void fetchConnectionCacheClose(void);
166 typedef int (*auth_t
)(struct url
*);
167 extern auth_t fetchAuthMethod
;
169 /* Last error code */
170 extern int fetchLastErrCode
;
171 #define MAXERRSTRING 256
172 extern char fetchLastErrString
[MAXERRSTRING
];
175 extern int fetchTimeout
;
177 /* Restart interrupted syscalls */
178 extern volatile int fetchRestartCalls
;
180 /* Extra verbosity */
181 extern int fetchDebug
;
183 #if defined(__cplusplus)