fetch.h revision 1.1.2.2 1 1.1.2.2 matt /*-
2 1.1.2.2 matt * Copyright (c) 1998-2004 Dag-Erling Codan Smrgrav
3 1.1.2.2 matt * All rights reserved.
4 1.1.2.2 matt *
5 1.1.2.2 matt * Redistribution and use in source and binary forms, with or without
6 1.1.2.2 matt * modification, are permitted provided that the following conditions
7 1.1.2.2 matt * are met:
8 1.1.2.2 matt * 1. Redistributions of source code must retain the above copyright
9 1.1.2.2 matt * notice, this list of conditions and the following disclaimer
10 1.1.2.2 matt * in this position and unchanged.
11 1.1.2.2 matt * 2. Redistributions in binary form must reproduce the above copyright
12 1.1.2.2 matt * notice, this list of conditions and the following disclaimer in the
13 1.1.2.2 matt * documentation and/or other materials provided with the distribution.
14 1.1.2.2 matt * 3. The name of the author may not be used to endorse or promote products
15 1.1.2.2 matt * derived from this software without specific prior written permission
16 1.1.2.2 matt *
17 1.1.2.2 matt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 1.1.2.2 matt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 1.1.2.2 matt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 1.1.2.2 matt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 1.1.2.2 matt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 1.1.2.2 matt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 1.1.2.2 matt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 1.1.2.2 matt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 1.1.2.2 matt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 1.1.2.2 matt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 1.1.2.2 matt *
28 1.1.2.2 matt * $FreeBSD: src/lib/libfetch/fetch.h,v 1.25.8.1 2006/11/11 00:16:07 des Exp $
29 1.1.2.2 matt */
30 1.1.2.2 matt
31 1.1.2.2 matt #ifndef _FETCH_H_INCLUDED
32 1.1.2.2 matt #define _FETCH_H_INCLUDED
33 1.1.2.2 matt
34 1.1.2.2 matt #define _LIBFETCH_VER "libfetch/2.0"
35 1.1.2.2 matt
36 1.1.2.2 matt #define URL_SCHEMELEN 16
37 1.1.2.2 matt #define URL_USERLEN 256
38 1.1.2.2 matt #define URL_PWDLEN 256
39 1.1.2.2 matt
40 1.1.2.2 matt struct url {
41 1.1.2.2 matt char scheme[URL_SCHEMELEN+1];
42 1.1.2.2 matt char user[URL_USERLEN+1];
43 1.1.2.2 matt char pwd[URL_PWDLEN+1];
44 1.1.2.2 matt char host[MAXHOSTNAMELEN+1];
45 1.1.2.2 matt int port;
46 1.1.2.2 matt char *doc;
47 1.1.2.2 matt off_t offset;
48 1.1.2.2 matt size_t length;
49 1.1.2.2 matt };
50 1.1.2.2 matt
51 1.1.2.2 matt struct url_stat {
52 1.1.2.2 matt off_t size;
53 1.1.2.2 matt time_t atime;
54 1.1.2.2 matt time_t mtime;
55 1.1.2.2 matt };
56 1.1.2.2 matt
57 1.1.2.2 matt struct url_ent {
58 1.1.2.2 matt char name[PATH_MAX];
59 1.1.2.2 matt struct url_stat stat;
60 1.1.2.2 matt };
61 1.1.2.2 matt
62 1.1.2.2 matt /* Recognized schemes */
63 1.1.2.2 matt #define SCHEME_FTP "ftp"
64 1.1.2.2 matt #define SCHEME_HTTP "http"
65 1.1.2.2 matt #define SCHEME_HTTPS "https"
66 1.1.2.2 matt #define SCHEME_FILE "file"
67 1.1.2.2 matt
68 1.1.2.2 matt /* Error codes */
69 1.1.2.2 matt #define FETCH_ABORT 1
70 1.1.2.2 matt #define FETCH_AUTH 2
71 1.1.2.2 matt #define FETCH_DOWN 3
72 1.1.2.2 matt #define FETCH_EXISTS 4
73 1.1.2.2 matt #define FETCH_FULL 5
74 1.1.2.2 matt #define FETCH_INFO 6
75 1.1.2.2 matt #define FETCH_MEMORY 7
76 1.1.2.2 matt #define FETCH_MOVED 8
77 1.1.2.2 matt #define FETCH_NETWORK 9
78 1.1.2.2 matt #define FETCH_OK 10
79 1.1.2.2 matt #define FETCH_PROTO 11
80 1.1.2.2 matt #define FETCH_RESOLV 12
81 1.1.2.2 matt #define FETCH_SERVER 13
82 1.1.2.2 matt #define FETCH_TEMP 14
83 1.1.2.2 matt #define FETCH_TIMEOUT 15
84 1.1.2.2 matt #define FETCH_UNAVAIL 16
85 1.1.2.2 matt #define FETCH_UNKNOWN 17
86 1.1.2.2 matt #define FETCH_URL 18
87 1.1.2.2 matt #define FETCH_VERBOSE 19
88 1.1.2.2 matt
89 1.1.2.2 matt __BEGIN_DECLS
90 1.1.2.2 matt
91 1.1.2.2 matt /* FILE-specific functions */
92 1.1.2.2 matt FILE *fetchXGetFile(struct url *, struct url_stat *, const char *);
93 1.1.2.2 matt FILE *fetchGetFile(struct url *, const char *);
94 1.1.2.2 matt FILE *fetchPutFile(struct url *, const char *);
95 1.1.2.2 matt int fetchStatFile(struct url *, struct url_stat *, const char *);
96 1.1.2.2 matt struct url_ent *fetchListFile(struct url *, const char *);
97 1.1.2.2 matt
98 1.1.2.2 matt /* HTTP-specific functions */
99 1.1.2.2 matt FILE *fetchXGetHTTP(struct url *, struct url_stat *, const char *);
100 1.1.2.2 matt FILE *fetchGetHTTP(struct url *, const char *);
101 1.1.2.2 matt FILE *fetchPutHTTP(struct url *, const char *);
102 1.1.2.2 matt int fetchStatHTTP(struct url *, struct url_stat *, const char *);
103 1.1.2.2 matt struct url_ent *fetchListHTTP(struct url *, const char *);
104 1.1.2.2 matt
105 1.1.2.2 matt /* FTP-specific functions */
106 1.1.2.2 matt FILE *fetchXGetFTP(struct url *, struct url_stat *, const char *);
107 1.1.2.2 matt FILE *fetchGetFTP(struct url *, const char *);
108 1.1.2.2 matt FILE *fetchPutFTP(struct url *, const char *);
109 1.1.2.2 matt int fetchStatFTP(struct url *, struct url_stat *, const char *);
110 1.1.2.2 matt struct url_ent *fetchListFTP(struct url *, const char *);
111 1.1.2.2 matt
112 1.1.2.2 matt /* Generic functions */
113 1.1.2.2 matt FILE *fetchXGetURL(const char *, struct url_stat *, const char *);
114 1.1.2.2 matt FILE *fetchGetURL(const char *, const char *);
115 1.1.2.2 matt FILE *fetchPutURL(const char *, const char *);
116 1.1.2.2 matt int fetchStatURL(const char *, struct url_stat *, const char *);
117 1.1.2.2 matt struct url_ent *fetchListURL(const char *, const char *);
118 1.1.2.2 matt FILE *fetchXGet(struct url *, struct url_stat *, const char *);
119 1.1.2.2 matt FILE *fetchGet(struct url *, const char *);
120 1.1.2.2 matt FILE *fetchPut(struct url *, const char *);
121 1.1.2.2 matt int fetchStat(struct url *, struct url_stat *, const char *);
122 1.1.2.2 matt struct url_ent *fetchList(struct url *, const char *);
123 1.1.2.2 matt
124 1.1.2.2 matt /* URL parsing */
125 1.1.2.2 matt struct url *fetchMakeURL(const char *, const char *, int,
126 1.1.2.2 matt const char *, const char *, const char *);
127 1.1.2.2 matt struct url *fetchParseURL(const char *);
128 1.1.2.2 matt void fetchFreeURL(struct url *);
129 1.1.2.2 matt
130 1.1.2.2 matt __END_DECLS
131 1.1.2.2 matt
132 1.1.2.2 matt /* Authentication */
133 1.1.2.2 matt typedef int (*auth_t)(struct url *);
134 1.1.2.2 matt extern auth_t fetchAuthMethod;
135 1.1.2.2 matt
136 1.1.2.2 matt /* Last error code */
137 1.1.2.2 matt extern int fetchLastErrCode;
138 1.1.2.2 matt #define MAXERRSTRING 256
139 1.1.2.2 matt extern char fetchLastErrString[MAXERRSTRING];
140 1.1.2.2 matt
141 1.1.2.2 matt /* I/O timeout */
142 1.1.2.2 matt extern int fetchTimeout;
143 1.1.2.2 matt
144 1.1.2.2 matt /* Restart interrupted syscalls */
145 1.1.2.2 matt extern int fetchRestartCalls;
146 1.1.2.2 matt
147 1.1.2.2 matt /* Extra verbosity */
148 1.1.2.2 matt extern int fetchDebug;
149 1.1.2.2 matt
150 1.1.2.2 matt #endif
151