Axe the rpmsq debug code which was never getting built anyway
[platform/upstream/rpm.git] / rpmio / rpmio.h
1 #ifndef H_RPMIO
2 #define H_RPMIO
3
4 /** \ingroup rpmio
5  * \file rpmio/rpmio.h
6  *
7  */
8
9 #include <sys/types.h>
10 #include <sys/stat.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <unistd.h>
14
15 #include <rpm/rpmtypes.h>
16 #include <rpm/rpmsw.h>
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 /** \ingroup rpmio
23  * Hide libio API lossage.
24  * The libio interface changed after glibc-2.1.3 to pass the seek offset
25  * argument as a pointer rather than as an off_t. The snarl below defines
26  * typedefs to isolate the lossage.
27  */
28 #if defined(__GLIBC__) && \
29         (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
30 #define USE_COOKIE_SEEK_POINTER 1
31 typedef _IO_off64_t     _libio_off_t;
32 typedef _libio_off_t *  _libio_pos_t;
33 #else
34 typedef off_t           _libio_off_t;
35 typedef off_t           _libio_pos_t;
36 #endif
37
38 /** \ingroup rpmio
39  */
40 typedef const struct FDIO_s * FDIO_t;
41
42
43 /** \ingroup rpmio
44  * \name RPMIO Interface.
45  */
46
47 /** \ingroup rpmio
48  * strerror(3) clone.
49  */
50 const char * Fstrerror(FD_t fd);
51
52 /** \ingroup rpmio
53  * fread(3) clone.
54  */
55 ssize_t Fread(void * buf, size_t size, size_t nmemb, FD_t fd);
56
57 /** \ingroup rpmio
58  * fwrite(3) clone.
59  */
60 ssize_t Fwrite(const void * buf, size_t size, size_t nmemb, FD_t fd);
61
62 /** \ingroup rpmio
63  * fseek(3) clone.
64  */
65 int Fseek(FD_t fd, _libio_off_t offset, int whence);
66
67 /** \ingroup rpmio
68  * ftell(3) clone.
69  */
70 off_t Ftell(FD_t fd);
71
72 /** \ingroup rpmio
73  * fclose(3) clone.
74  */
75 int Fclose( FD_t fd);
76
77 /** \ingroup rpmio
78  */
79 FD_t    Fdopen(FD_t ofd, const char * fmode);
80
81 /** \ingroup rpmio
82  * fopen(3) clone.
83  */
84 FD_t    Fopen(const char * path,
85                         const char * fmode);
86
87
88 /** \ingroup rpmio
89  * fflush(3) clone.
90  */
91 int Fflush(FD_t fd);
92
93 /** \ingroup rpmio
94  * ferror(3) clone.
95  */
96 int Ferror(FD_t fd);
97
98 /** \ingroup rpmio
99  * fileno(3) clone.
100  */
101 int Fileno(FD_t fd);
102
103 /** \ingroup rpmio
104  * fcntl(2) clone.
105  */
106 int Fcntl(FD_t fd, int op, void *lip);
107
108 /** \ingroup rpmio
109  * \name RPMIO Utilities.
110  */
111
112 /** \ingroup rpmio
113  */
114 off_t   fdSize(FD_t fd);
115
116 /** \ingroup rpmio
117  */
118 FD_t fdDup(int fdno);
119
120 /** \ingroup rpmio
121  * Get associated FILE stream from fd (if any)
122  */
123 FILE * fdGetFILE(FD_t fd);
124
125 /** \ingroup rpmio
126  */
127 FD_t fdLink(void * cookie);
128
129 /** \ingroup rpmio
130  */
131 FD_t fdFree(FD_t fd);
132
133 /** \ingroup rpmio
134  */
135 FD_t fdNew (void);
136
137 /**
138  */
139 int ufdCopy(FD_t sfd, FD_t tfd);
140
141 /**
142  * XXX the name is misleading, this is a legacy wrapper that ensures 
143  * only S_ISREG() files are read, nothing to do with timed... 
144  * TODO: get this out of the API
145  */
146 ssize_t timedRead(FD_t fd, void * bufptr, size_t length);
147
148 /** \ingroup rpmio
149  * Identify per-desciptor I/O operation statistics.
150  */
151 typedef enum fdOpX_e {
152     FDSTAT_READ         = 0,    /*!< Read statistics index. */
153     FDSTAT_WRITE        = 1,    /*!< Write statistics index. */
154     FDSTAT_SEEK         = 2,    /*!< Seek statistics index. */
155     FDSTAT_CLOSE        = 3,    /*!< Close statistics index */
156     FDSTAT_DIGEST       = 4,    /*!< Digest statistics index. */
157     FDSTAT_MAX          = 5
158 } fdOpX;
159
160 /** \ingroup rpmio
161  *
162  */
163 rpmop fdOp(FD_t fd, fdOpX opx);
164
165 #ifdef __cplusplus
166 }
167 #endif
168
169 #endif  /* H_RPMIO */