This file is indexed.

/usr/include/ncbi-vdb/rdbms/rdbms.h is in libncbi-vdb-dev 2.8.1+dfsg-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#ifndef _h_rdbms_rdbms_
#define _h_rdbms_rdbms_

#ifndef _h_klib_text_
#include <klib/text.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* logdberr
 *  like logerr, but interprets error code as a db error code
 */
void logdberr ( int err, const char *fmt, ... );

/* strdberror
 *  a version of strerror that operates within db error code space
 *  returned string is owned by library
 */
const char *strdberror ( int dberr );

/* strdberror_r
 *  a version of strerror_r that operates within db error code space
 *  returns 0 on success, EINVAL if "dberr" is invalid, and
 *  ERANGE if insufficient space was provided to copy the data.
 */
int strdberror_r ( int dberr, char *buf, size_t n );

/*--------------------------------------------------------------------------
 * DBColumnType
 *  for discovering column type at runtime
 */
enum
{
    colUnsupported,
    colBool,
    colI8,
    colU8,
    colI16,
    colU16,
    colI32,
    colU32,
    colI64,
    colU64,
    colF32,
    colF64,
    colText,
    colBlob
};


/*--------------------------------------------------------------------------
 * DBRow
 */
typedef struct DBBlob DBBlob;
struct DBBlob
{
    /* the blob is in here */
    void *addr;
    size_t size;

    /* when finished with the blob, whack it thus */
    void *priv;
    void ( * whack ) ( void *priv );
};

/* DBBlobWhack
 */
#define DBBlobWhack( blob ) \
    ( ( blob ) -> priv != NULL ? \
      ( * ( blob ) -> whack ) ( ( blob ) -> priv ) : ( void ) 0 )

typedef struct DBRow DBRow;
typedef struct DBRow_vt DBRow_vt;
struct DBRow_vt
{
    rc_t ( * whack ) ( DBRow *self );
    rc_t ( * numColumns ) ( const DBRow *self, unsigned int *num_cols );
    rc_t ( * colInfo ) ( const DBRow *self, unsigned int idx,
        int *col_type, const String **name );
    rc_t ( * colIdx ) ( const DBRow *self, const String *name,
        unsigned int *idx );
    bool ( * isNull ) ( const DBRow *self, unsigned int idx );

    rc_t ( * getAsNum ) ( const DBRow *self, unsigned int idx, int64_t *i, double *d, bool *is_floating );
    rc_t ( * getAsString ) ( const DBRow *self, unsigned int idx,
        const String **value );
    rc_t ( * getAsBlob ) ( const DBRow *self, unsigned int idx,
        const void **value, size_t *bytes );
    rc_t ( * stealBlob ) ( DBRow *self, unsigned int idx, DBBlob *blob );
};
struct DBRow
{
    const DBRow_vt *vt;
};

/* DBRowNumColumns
 *  read the number of columns in row
 */
#define DBRowNumColumns( row, num_cols ) \
    ( * ( row ) -> vt -> numColumns ) ( row, num_cols )

/* DBRowColumnInfo
 *  read the type for indexed column as DBColumnType
 *  index is zero-based
 *  optionally reads column name if "name" is not NULL
 */
#define DBRowColumnInfo( row, idx, col_type, name ) \
    ( * ( row ) -> vt -> colInfo ) ( row, idx, col_type, name )

/* DBRowColumnIdx
 *  determine zero-based index for named column
 */
#define DBRowColumnIdx( row, name, idx ) \
    ( * ( row ) -> vt -> colIdx ) ( row, name, idx )

/* DBRowIsNull
 *  determine whether an indexed column value is NULL
 *  index is zero-based
 *  returns true only if row and column are valid,
 *  and column is NULL, obviously
 */
#define DBRowIsNull( row, idx ) \
    ( * ( row ) -> vt -> isNull ) ( row, idx )

/* DBRowGetAs...
 *  column access functions
 *  all indices are zero-based
 */
rc_t DBRowGetAsBool ( const DBRow *row, unsigned int idx, bool *value );
rc_t DBRowGetAsI8 ( const DBRow *row, unsigned int idx, int8_t *value );
rc_t DBRowGetAsU8 ( const DBRow *row, unsigned int idx, uint8_t *value );
rc_t DBRowGetAsI16 ( const DBRow *row, unsigned int idx, int16_t *value );
rc_t DBRowGetAsU16 ( const DBRow *row, unsigned int idx, uint16_t *value );
rc_t DBRowGetAsI32 ( const DBRow *row, unsigned int idx, int32_t *value );
rc_t DBRowGetAsU32 ( const DBRow *row, unsigned int idx, uint32_t *value );
rc_t DBRowGetAsI64 ( const DBRow *row, unsigned int idx, int64_t *value );
rc_t DBRowGetAsU64 ( const DBRow *row, unsigned int idx, uint64_t *value );
rc_t DBRowGetAsF32 ( const DBRow *row, unsigned int idx, float *value );
rc_t DBRowGetAsF64 ( const DBRow *row, unsigned int idx, double *value );
#define DBRowGetAsString( row, idx, value ) \
    ( * ( row ) -> vt -> getAsString ) ( row, idx, value )

/* DBRowGetAsBlob
 *  special access that returns direct pointer to internal data
 *  only guaranteed to live while row exists
 *  ( here's where reference counting saves the day... )
 */
#define DBRowGetAsBlob( row, idx, value, bytes ) \
    ( * ( row ) -> vt -> getAsBlob ) ( row, idx, value, bytes )

/* DBRowStealBlob
 *  even more special access that steals internal data from row
 *  or at least returns an allocation that is no longer associated
 *  with the column.
 *
 *  intended to invalidate the column and cause it to be NULL,
 *  but this is implementation dependent.
 */
#define DBRowStealBlob( row, idx, blob ) \
    ( * ( row ) -> vt -> stealBlob ) ( row, idx, blob )

/* DBRowWhack
 *  whacks the row
 */
#define DBRowWhack( row ) \
    ( ( row ) == NULL ? 0 : ( * ( row ) -> vt -> whack ) ( row ) )


/*--------------------------------------------------------------------------
 * DBResultSet
 */
typedef struct DBResultSet DBResultSet;
typedef struct DBResultSet_vt DBResultSet_vt;
struct DBResultSet_vt
{
    rc_t ( * whack ) ( DBResultSet *self );
    rc_t ( * numColumns ) ( const DBResultSet *self, unsigned int *num_cols );
    rc_t ( * colInfo ) ( const DBResultSet *self, unsigned int idx,
        int *col_type, const String **name );
    rc_t ( * colIdx ) ( const DBResultSet *self, const String *name,
        unsigned int *idx );

    rc_t ( * getStatus ) ( const DBResultSet *self, int32_t *status );
    rc_t ( * nextRow ) ( DBResultSet *self, DBRow **row );
};
struct DBResultSet
{
    const DBResultSet_vt *vt;
};

/* DBResultSetNumColumns
 *  read the number of columns in result
 */
#define DBResultSetNumColumns( rs, num_cols ) \
    ( * ( rs ) -> vt -> numColumns ) ( rs, num_cols )

/* DBResultSetColumnInfo
 *  read the type for indexed column as DBColumnType
 *  index is zero-based
 *  optionally reads column name if "name" is not NULL
 */
#define DBResultSetColumnInfo( rs, idx, col_type, name ) \
    ( * ( rs ) -> vt -> colInfo ) ( rs, idx, col_type, name )

/* DBResultSetColumnIdx
 *  determine zero-based index for named column
 */
#define DBResultSetColumnIdx( rs, name, idx ) \
    ( * ( rs ) -> vt -> colIdx ) ( rs, name, idx )

/* DBResultSetGetStatus
 */
#define DBResultSetGetStatus( rs, status ) \
    ( * ( rs ) -> vt -> getStatus ) ( rs, status )

/* DBResultSetNextRow
 *  returns dbNoErr if row was created
 *  returns dbEndData if no more rows were available
 *  returns something more sinister if an error occurred
 */
#define DBResultSetNextRow( rs, row ) \
    ( * ( rs ) -> vt -> nextRow ) ( rs, row )

/* DBResultSetForEach
 *  iterates across all rows
 */
rc_t DBResultSetForEach ( DBResultSet *rs,
    void ( * f ) ( DBRow *row, void *data ), void * data );

/* DBResultSetDoUntil
 *  iterates across all rows
 *  until the function returns true
 */
rc_t DBResultSetDoUntil ( DBResultSet *rs,
    bool ( * f ) ( DBRow *row, void *data ), void * data );

/* DBResultSetWhack
 *  whacks the result set
 */
#define DBResultSetWhack( rs ) \
    ( ( rs ) == NULL ? 0 : ( * ( rs ) -> vt -> whack ) ( rs ) )


/*--------------------------------------------------------------------------
 * Database
 */
typedef struct Database Database;
typedef struct Database_vt Database_vt;
struct Database_vt
{
    rc_t ( * whack ) ( Database *self );
    rc_t ( * setReturnSize ) ( Database *self, size_t max_size );
    rc_t ( * execute ) ( Database *self, DBResultSet **rs, char *sql );
};
struct Database
{
    const Database_vt *vt;
};

/* DatabaseSetReturnSize
 *  sets maximum size for returns
 */
#define DatabaseSetReturnSize( db, max_size ) \
    ( * ( db ) -> vt -> setReturnSize ) ( db, max_size )

/* DatabaseExecute
 *  issue an sql request
 */
rc_t DatabaseExecute ( Database *db, DBResultSet **rs, const char *sql, ... );

/* DatabaseGetStatus
 *  executes a stored procedure and returns status code
 */
rc_t DatabaseGetStatus ( Database *db, int32_t *status, const char *sql, ... );

/* DatabaseGetAs...
 *  column access functions on first row of a query
 *  all indices are zero-based
 */
rc_t DatabaseGetAsBool ( Database *db, unsigned int idx,
    bool *value, const char *sql, ... );
rc_t DatabaseGetAsI8 ( Database *db, unsigned int idx,
    int8_t *value, const char *sql, ... );
rc_t DatabaseGetAsU8 ( Database *db, unsigned int idx,
    uint8_t *value, const char *sql, ... );
rc_t DatabaseGetAsI16 ( Database *db, unsigned int idx,
    int16_t *value, const char *sql, ... );
rc_t DatabaseGetAsU16 ( Database *db, unsigned int idx,
    uint16_t *value, const char *sql, ... );
rc_t DatabaseGetAsI32 ( Database *db, unsigned int idx,
    int32_t *value, const char *sql, ... );
rc_t DatabaseGetAsU32 ( Database *db, unsigned int idx,
    uint32_t *value, const char *sql, ... );
rc_t DatabaseGetAsI64 ( Database *db, unsigned int idx,
    int64_t *value, const char *sql, ... );
rc_t DatabaseGetAsU64 ( Database *db, unsigned int idx,
    uint64_t *value, const char *sql, ... );
rc_t DatabaseGetAsF32 ( Database *db, unsigned int idx,
    float *value, const char *sql, ... );
rc_t DatabaseGetAsF64 ( Database *db, unsigned int idx,
    double *value, const char *sql, ... );
rc_t DatabaseGetAsString ( Database *db, unsigned int idx,
    const String **value, const char *sql, ... );

/* DatabaseWhack
 *  tear down a connection
 */
#define DatabaseWhack( db ) \
    ( ( db ) == NULL ? 0 : ( * ( db ) -> vt -> whack ) ( db ) )


/*--------------------------------------------------------------------------
 * DBManager
 *  something such as Sybase, ORACLE, etc.
 */
typedef struct DBManager DBManager;
struct DBManager
{
    rc_t ( * whack ) ( DBManager *self );
    rc_t ( * connect ) ( const DBManager *self, const char *server,
        const char *dbname, const char *user, const char *pass, Database **db );
};

/* DBManagerInit
 *  initialize object reference
 *  returns 0 if manager has been registered
 */
rc_t DBManagerInit ( const DBManager **mgr, const char *name );


/* DBManagerRegister
 *  makes an object known to DBManager
 */
rc_t DBManagerRegister ( const DBManager *mgr, const char *name );


/* DBManagerUnregister
 *  makes an object unknown to DBManager
 */
rc_t DBManagerUnregister ( const DBManager *mgr, const char *name );


/* DBManagerConnect
 *  establish a connection
 */
#define DBManagerConnect( mgr, server, dbname, user, pass, db ) \
    ( * ( mgr ) -> connect ) ( mgr, server, dbname, user, pass, db )

/* DBManagerWhack
 */
#define DBManagerWhack( mgr ) \
    ( ( mgr ) == NULL ? 0 : ( * ( mgr ) -> whack ) ( mgr ) )

rc_t DBManagerRelease(const DBManager *mgr);

#ifdef __cplusplus
}
#endif

#endif /* _h_rdbms_rdbms_ */