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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
#ifndef H_RPMIO
#define H_RPMIO
/** \ingroup rpmio
* \file rpmio/rpmio.h
*
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include "misc/glob.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <rpmsw.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \ingroup rpmio
* Hide libio API lossage.
* The libio interface changed after glibc-2.1.3 to pass the seek offset
* argument as a pointer rather than as an off_t. The snarl below defines
* typedefs to isolate the lossage.
*/
#if defined(__GLIBC__) && \
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
#define USE_COOKIE_SEEK_POINTER 1
typedef _IO_off64_t _libio_off_t;
typedef _libio_off_t * _libio_pos_t;
#else
typedef off_t _libio_off_t;
typedef off_t _libio_pos_t;
#endif
/** \ingroup rpmio
*/
typedef struct _FD_s * FD_t;
/** \ingroup rpmio
*/
typedef struct FDIO_s * FDIO_t;
/** \ingroup rpmio
* \name RPMIO Interface.
*/
/**
* strerror(3) clone.
*/
const char * Fstrerror(FD_t fd);
/**
* fread(3) clone.
*/
ssize_t Fread(void * buf, size_t size, size_t nmemb, FD_t fd);
/**
* fwrite(3) clone.
*/
ssize_t Fwrite(const void * buf, size_t size, size_t nmemb, FD_t fd);
/**
* fseek(3) clone.
*/
int Fseek(FD_t fd, _libio_off_t offset, int whence);
/**
* fclose(3) clone.
*/
int Fclose( FD_t fd);
/**
*/
FD_t Fdopen(FD_t ofd, const char * fmode);
/**
* fopen(3) clone.
*/
FD_t Fopen(const char * path,
const char * fmode);
/**
* fflush(3) clone.
*/
int Fflush(FD_t fd);
/**
* ferror(3) clone.
*/
int Ferror(FD_t fd);
/**
* fileno(3) clone.
*/
int Fileno(FD_t fd);
/**
* fcntl(2) clone.
*/
int Fcntl(FD_t fd, int op, void *lip);
/** \ingroup rpmrpc
* \name RPMRPC Interface.
*/
/**
* mkdir(2) clone.
*/
int Mkdir(const char * path, mode_t mode);
/**
* chdir(2) clone.
*/
int Chdir(const char * path);
/**
* rmdir(2) clone.
*/
int Rmdir(const char * path);
/**
* rename(2) clone.
*/
int Rename(const char * oldpath, const char * newpath);
/**
* link(2) clone.
*/
int Link(const char * oldpath, const char * newpath);
/**
* unlink(2) clone.
*/
int Unlink(const char * path);
/**
* readlink(2) clone.
*/
int Readlink(const char * path, char * buf, size_t bufsiz);
/**
* stat(2) clone.
*/
int Stat(const char * path, struct stat * st);
/**
* lstat(2) clone.
*/
int Lstat(const char * path, struct stat * st);
/**
* access(2) clone.
*/
int Access(const char * path, int amode);
/**
* glob_pattern_p(3) clone.
*/
int Glob_pattern_p (const char *pattern, int quote);
/**
* glob_error(3) clone.
*/
int Glob_error(const char * epath, int eerrno);
/**
* glob(3) clone.
*/
int Glob(const char * pattern, int flags,
int errfunc(const char * epath, int eerrno),
glob_t * pglob);
/**
* globfree(3) clone.
*/
void Globfree( glob_t * pglob);
/**
* opendir(3) clone.
*/
DIR * Opendir(const char * path);
/**
* readdir(3) clone.
*/
struct dirent * Readdir(DIR * dir);
/**
* closedir(3) clone.
*/
int Closedir(DIR * dir);
/** \ingroup rpmio
* \name RPMIO Utilities.
*/
/**
*/
off_t fdSize(FD_t fd);
/**
*/
FD_t fdDup(int fdno);
/** \ingroup rpmio
* Get associated FILE stream from fd (if any)
*/
FILE * fdGetFILE(FD_t fd);
/**
*/
extern FD_t fdLink (void * cookie, const char * msg);
/**
*/
extern FD_t fdFree(FD_t fd, const char * msg);
/**
*/
extern FD_t fdNew (const char * msg);
/**
*/
int fdWritable(FD_t fd, int secs);
/**
*/
int fdReadable(FD_t fd, int secs);
/**
* FTP and HTTP error codes.
*/
typedef enum ftperrCode_e {
FTPERR_NE_ERROR = -1, /*!< Generic error. */
FTPERR_NE_LOOKUP = -2, /*!< Hostname lookup failed. */
FTPERR_NE_AUTH = -3, /*!< Server authentication failed. */
FTPERR_NE_PROXYAUTH = -4, /*!< Proxy authentication failed. */
FTPERR_NE_CONNECT = -5, /*!< Could not connect to server. */
FTPERR_NE_TIMEOUT = -6, /*!< Connection timed out. */
FTPERR_NE_FAILED = -7, /*!< The precondition failed. */
FTPERR_NE_RETRY = -8, /*!< Retry request. */
FTPERR_NE_REDIRECT = -9, /*!< Redirect received. */
FTPERR_BAD_SERVER_RESPONSE = -81, /*!< Bad server response */
FTPERR_SERVER_IO_ERROR = -82, /*!< Server I/O error */
FTPERR_SERVER_TIMEOUT = -83, /*!< Server timeout */
FTPERR_BAD_HOST_ADDR = -84, /*!< Unable to lookup server host address */
FTPERR_BAD_HOSTNAME = -85, /*!< Unable to lookup server host name */
FTPERR_FAILED_CONNECT = -86, /*!< Failed to connect to server */
FTPERR_FILE_IO_ERROR = -87, /*!< Failed to establish data connection to server */
FTPERR_PASSIVE_ERROR = -88, /*!< I/O error to local file */
FTPERR_FAILED_DATA_CONNECT = -89, /*!< Error setting remote server to passive mode */
FTPERR_FILE_NOT_FOUND = -90, /*!< File not found on server */
FTPERR_NIC_ABORT_IN_PROGRESS= -91, /*!< Abort in progress */
FTPERR_UNKNOWN = -100 /*!< Unknown or unexpected error */
} ftperrCode;
/**
*/
const char * ftpStrerror(int errorNumber);
/**
*/
int ufdCopy(FD_t sfd, FD_t tfd);
/**
*/
int ufdGetFile( FD_t sfd, FD_t tfd);
/**
* XXX the name is misleading, this is a legacy wrapper that ensures
* only S_ISREG() files are read, nothing to do with timed...
* TODO: get this out of the API
*/
int timedRead(FD_t fd, void * bufptr, int length);
/** \ingroup rpmio
* Identify per-desciptor I/O operation statistics.
*/
typedef enum fdOpX_e {
FDSTAT_READ = 0, /*!< Read statistics index. */
FDSTAT_WRITE = 1, /*!< Write statistics index. */
FDSTAT_SEEK = 2, /*!< Seek statistics index. */
FDSTAT_CLOSE = 3, /*!< Close statistics index */
FDSTAT_DIGEST = 4, /*!< Digest statistics index. */
FDSTAT_MAX = 5
} fdOpX;
/** \ingroup rpmio
*
*/
rpmop fdOp(FD_t fd, fdOpX opx);
#ifdef __cplusplus
}
#endif
#endif /* H_RPMIO */
|