# rpmdb/rpmdb.h

Go to the documentation of this file.

    00001 #ifndef H_RPMDB
    00002 #define H_RPMDB
    00003
    00009 #include <rpmlib.h>
    00010
    00013 typedef /*@abstract@*/ struct _dbiIndexItem * dbiIndexItem;
    00014
    00017 typedef /*@abstract@*/ struct _dbiIndex * dbiIndex;
    00018
    00019 /* this will break if sizeof(int) != 4 */
    00025 struct _dbiIndexItem {
    00026     unsigned int hdrNum;
    00027     unsigned int tagNum;
    00028     unsigned int fpNum;
    00029     unsigned int dbNum;
    00030 };
    00031
    00035 struct _dbiIndexSet {
    00036 /*@owned@*/ struct _dbiIndexItem * recs;
    00037     int count;
    00038 };
    00039
    00040 /* XXX hack to get prototypes correct */
    00041 #if !defined(DB_VERSION_MAJOR)
    00042 #define DB      void
    00043 #define DB_ENV  void
    00044 #define DBC     void
    00045 #define DBT     void
    00046 #define DB_LSN  void
    00047 #endif
    00048
    00052 struct _dbiVec {
    00053     int dbv_major;
    00054     int dbv_minor;
    00055     int dbv_patch;
    00063     int (*open) (rpmdb rpmdb, int rpmtag, /*@out@*/ dbiIndex * dbip)
    00064         /*@globals fileSystem@*/
    00065         /*@modifies *dbip, fileSystem @*/;
    00066
    00073     int (*close) (/*@only@*/ dbiIndex dbi, unsigned int flags)
    00074         /*@globals fileSystem@*/
    00075         /*@modifies dbi, fileSystem @*/;
    00076
    00083     int (*sync) (dbiIndex dbi, unsigned int flags)
    00084         /*@globals fileSystem@*/
    00085         /*@modifies fileSystem @*/;
    00086
    00093     int (*copen) (dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int flags)
    00094         /*@globals fileSystem@*/
    00095         /*@modifies dbi, *dbcp, fileSystem @*/;
    00096
    00103     int (*cclose) (dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags)
    00104         /*@globals fileSystem@*/
    00105         /*@modifies dbi, *dbcursor, fileSystem @*/;
    00106
    00116     int (*cdel) (dbiIndex dbi, DBC * dbcursor,
    00117                         const void * keyp, size_t keylen, unsigned int flags)
    00118         /*@globals fileSystem@*/
    00119         /*@modifies *dbcursor, fileSystem @*/;
    00120
    00132     int (*cget) (dbiIndex dbi, DBC * dbcursor,
    00133                         /*@null@*/ void ** keypp, /*@null@*/ size_t * keylenp,
    00134                         /*@null@*/ void ** datapp, /*@null@*/ size_t * datalenp,
    00135                         unsigned int flags)
    00136         /*@globals fileSystem@*/
    00137         /*@modifies *dbcursor, *keypp, *keylenp, *datapp, *datalenp,
    00138                 fileSystem @*/;
    00139
    00151     int (*cput) (dbiIndex dbi, DBC * dbcursor,
    00152                         const void * keyp, size_t keylen,
    00153                         const void * datap, size_t datalen,
    00154                         unsigned int flags)
    00155         /*@globals fileSystem@*/
    00156         /*@modifies *dbcursor, fileSystem @*/;
    00157
    00166     int (*ccount) (dbiIndex dbi, DBC * dbcursor,
    00167                         /*@out@*/ unsigned int * countp,
    00168                         unsigned int flags)
    00169         /*@globals fileSystem@*/
    00170         /*@modifies *dbcursor, fileSystem @*/;
    00171
    00177     int (*byteswapped) (dbiIndex dbi)
    00178         /*@globals fileSystem@*/
    00179         /*@modifies fileSystem@*/;
    00180
    00187     int (*stat) (dbiIndex dbi, unsigned int flags)
    00188         /*@globals fileSystem@*/
    00189         /*@modifies dbi, fileSystem @*/;
    00190
    00191 };
    00192
    00196 struct _dbiIndex {
    00197 /*@null@*/ const char * dbi_root;
    00198 /*@null@*/ const char * dbi_home;
    00199 /*@null@*/ const char * dbi_file;
    00200 /*@null@*/ const char * dbi_subfile;
    00201 /*@null@*/ const char * dbi_tmpdir;
    00203     int                 dbi_ecflags;
    00204     int                 dbi_cflags;
    00205     int                 dbi_oeflags;
    00206     int                 dbi_eflags;
    00207     int                 dbi_oflags;
    00208     int                 dbi_tflags;
    00210     int                 dbi_type;
    00211     unsigned            dbi_mode;
    00212     int                 dbi_perms;
    00213     long                dbi_shmkey;
    00214     int                 dbi_api;
    00216     int                 dbi_verify_on_close;
    00217     int                 dbi_tear_down;
    00218     int                 dbi_use_cursors;
    00219     int                 dbi_use_dbenv;
    00220     int                 dbi_permit_dups;
    00221     int                 dbi_get_rmw_cursor;
    00222     int                 dbi_no_fsync;
    00223     int                 dbi_no_dbsync;
    00224     int                 dbi_lockdbfd;
    00225     int                 dbi_temporary;
    00226     int                 dbi_debug;
    00227     int                 dbi_byteswapped;
    00228
    00229 /*@null@*/ char *       dbi_host;
    00230     long                dbi_cl_timeout;
    00231     long                dbi_sv_timeout;
    00232
    00233         /* dbenv parameters */
    00234     int                 dbi_lorder;
    00235 /*@unused@*/ /*@null@*/ void            (*db_errcall) (const char *db_errpfx, char *buffer)
    00236         /*@globals fileSystem@*/
    00237         /*@modifies fileSystem @*/;
    00238 /*@unused@*/ /*@shared@*/ FILE *        dbi_errfile;
    00239     const char *        dbi_errpfx;
    00240     int                 dbi_verbose;
    00241     int                 dbi_region_init;
    00242     int                 dbi_tas_spins;
    00243         /* mpool sub-system parameters */
    00244     int                 dbi_mp_mmapsize;
    00245     int                 dbi_mp_size;
    00246         /* lock sub-system parameters */
    00247     unsigned int        dbi_lk_max;
    00248     unsigned int        dbi_lk_detect;
    00249 /*@unused@*/ int        dbi_lk_nmodes;
    00250 /*@unused@*/ unsigned char * dbi_lk_conflicts;
    00251         /* log sub-system parameters */
    00252     unsigned int        dbi_lg_max;
    00253     unsigned int        dbi_lg_bsize;
    00254         /* transaction sub-system parameters */
    00255     unsigned int        dbi_tx_max;
    00256 #if 0
    00257     int                 (*dbi_tx_recover) (DB_ENV *dbenv, DBT *log_rec,
    00258                                 DB_LSN *lsnp, int redo, void *info)
    00259         /*@globals fileSystem@*/
    00260         /*@modifies fileSystem @*/;
    00261 #endif
    00262         /* dbinfo parameters */
    00263     int                 dbi_cachesize;
    00264     int                 dbi_pagesize;
    00265 /*@unused@*/ /*@null@*/ void *  (*dbi_malloc) (size_t nbytes)
    00266         /*@*/;
    00267         /* hash access parameters */
    00268     unsigned int        dbi_h_ffactor;
    00269 /*@null@*/ unsigned int (*dbi_h_hash_fcn) (DB *, const void *bytes, unsigned int length) /*@*/;
    00270     unsigned int        dbi_h_nelem;
    00271     unsigned int        dbi_h_flags;
    00272 /*@null@*/ int          (*dbi_h_dup_compare_fcn) (DB *, const DBT *, const DBT *) /*@*/;
    00273         /* btree access parameters */
    00274     int                 dbi_bt_flags;
    00275     int                 dbi_bt_minkey;
    00276 /*@null@*/ int          (*dbi_bt_compare_fcn) (DB *, const DBT *, const DBT *) /*@*/;
    00277 /*@null@*/ int          (*dbi_bt_dup_compare_fcn) (DB *, const DBT *, const DBT *) /*@*/;
    00278 /*@null@*/ size_t       (*dbi_bt_prefix_fcn) (DB *, const DBT *, const DBT *) /*@*/;
    00279         /* recno access parameters */
    00280     int                 dbi_re_flags;
    00281     int                 dbi_re_delim;
    00282     unsigned int        dbi_re_len;
    00283     int                 dbi_re_pad;
    00284     const char *        dbi_re_source;
    00285         /* queue access parameters */
    00286     unsigned int        dbi_q_extentsize;
    00287
    00288 /*@kept@*/ rpmdb        dbi_rpmdb;
    00289     rpmTag      dbi_rpmtag;
    00290     int         dbi_jlen;
    00292     unsigned int dbi_lastoffset;
    00294 /*@only@*//*@null@*/ void * dbi_db;
    00295 /*@only@*//*@null@*/ void * dbi_rmw;
    00296 /*@only@*//*@null@*/ void * dbi_stats;
    00298 /*@observer@*/ const struct _dbiVec * dbi_vec;
    00300 };
    00301
    00305 struct rpmdb_s {
    00306 /*@owned@*/ const char * db_root;
    00307 /*@owned@*/ const char * db_home;
    00308     int         db_flags;
    00309     int         db_mode;
    00310     int         db_perms;
    00311     int         db_api;
    00312 /*@owned@*/ const char * db_errpfx;
    00313     int         db_remove_env;
    00314     int         db_filter_dups;
    00315     int         db_chrootDone;
    00316     void (*db_errcall) (const char *db_errpfx, char *buffer)
    00317         /*@*/;
    00318 /*@shared@*/ FILE *     db_errfile;
    00319 /*@only@*/ void * (*db_malloc) (size_t nbytes)
    00320         /*@*/;
    00321 /*@only@*/ void * (*db_realloc) (/*@only@*//*@null@*/ void * ptr,
    00322                                                 size_t nbytes)
    00323         /*@*/;
    00324     void (*db_free) (/*@only@*/ void * ptr)
    00325         /*@modifies *ptr @*/;
    00326     int         db_opens;
    00327 /*@only@*//*@null@*/ void * db_dbenv;
    00328     int         db_ndbi;
    00329     dbiIndex *  _dbi;
    00331     int nrefs;
    00332 };
    00333
    00334 /* for RPM's internal use only */
    00335
    00338 enum rpmdbFlags {
    00339         RPMDB_FLAG_JUSTCHECK    = (1 << 0),
    00340         RPMDB_FLAG_MINIMAL      = (1 << 1),
    00341 /*@-enummemuse@*/
    00342         RPMDB_FLAG_CHROOT       = (1 << 2)
    00343 /*@=enummemuse@*/
    00344 };
    00345
    00346 #ifdef __cplusplus
    00347 extern "C" {
    00348 #endif
    00349
    00350 /*@-exportlocal@*/
    00355 /*@only@*/ /*@null@*/ dbiIndex db3New(rpmdb rpmdb, int rpmtag)
    00356         /*@globals rpmGlobalMacroContext @*/
    00357         /*@modifies rpmGlobalMacroContext @*/;
    00358
    00364 /*@null@*/ dbiIndex db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi)
    00365         /*@*/;
    00366
    00373 /*@-redecl@*/
    00374 /*@exposed@*/ extern const char *const prDbiOpenFlags(int dbflags,
    00375                                                 int print_dbenv_flags)
    00376         /*@*/;
    00377 /*@=redecl@*/
    00378
    00386 /*@only@*/ /*@null@*/ dbiIndex dbiOpen(/*@null@*/ rpmdb db, int rpmtag,
    00387                 unsigned int flags)
    00388         /*@modifies db @*/;
    00389
    00394 int dbiCopen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int flags)
    00395         /*@globals fileSystem@*/
    00396         /*@modifies dbi, *dbcp, fileSystem @*/;
    00397
    00398 #define DBI_WRITECURSOR         (1 << 0)
    00399 #define DBI_ITERATOR            (1 << 1)
    00400
    00405 int dbiCclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags)
    00406         /*@globals fileSystem@*/
    00407         /*@modifies dbi, *dbcursor, fileSystem @*/;
    00408
    00417 int dbiDel(dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen,
    00418                 unsigned int flags)
    00419         /*@globals fileSystem@*/
    00420         /*@modifies *dbcursor, fileSystem @*/;
    00421
    00432 int dbiGet(dbiIndex dbi, DBC * dbcursor, void ** keypp,
    00433                 /*@null@*/ size_t * keylenp,
    00434                 /*@null@*/ void ** datapp,
    00435                 /*@null@*/ size_t * datalenp,
    00436                 unsigned int flags)
    00437         /*@globals fileSystem@*/
    00438         /*@modifies *dbcursor, **keypp, *keylenp, **datapp, *datalenp,
    00439                 fileSystem @*/;
    00440
    00451 int dbiPut(dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen,
    00452                 const void * datap, size_t datalen, unsigned int flags)
    00453         /*@globals fileSystem@*/
    00454         /*@modifies *dbcursor, fileSystem @*/;
    00455
    00464 /*@unused@*/
    00465 int dbiCount(dbiIndex dbi, DBC * dbcursor, /*@out@*/ unsigned int * countp,
    00466                 unsigned int flags)
    00467         /*@globals fileSystem@*/
    00468         /*@modifies *dbcursor, fileSystem @*/;
    00469
    00476 int dbiVerify(/*@only@*/ dbiIndex dbi, unsigned int flags)
    00477         /*@globals fileSystem@*/
    00478         /*@modifies dbi, fileSystem @*/;
    00479
    00486 int dbiClose(/*@only@*/ dbiIndex dbi, unsigned int flags)
    00487         /*@globals fileSystem@*/
    00488         /*@modifies dbi, fileSystem @*/;
    00489
    00496 int dbiSync (dbiIndex dbi, unsigned int flags)
    00497         /*@globals fileSystem@*/
    00498         /*@modifies fileSystem @*/;
    00499
    00505 int dbiByteSwapped(dbiIndex dbi)
    00506         /*@*/;
    00507
    00513 char * db1basename(int rpmtag)
    00514         /*@*/;
    00515 /*@=exportlocal@*/
    00516
    00519 /*@unused@*/
    00520 unsigned int rpmdbGetIteratorFileNum(rpmdbMatchIterator mi)
    00521         /*@*/;
    00522
    00528 /*@null@*/ dbiIndexSet dbiFreeIndexSet(/*@only@*/ /*@null@*/ dbiIndexSet set)
    00529         /*@modifies set @*/;
    00530
    00536 unsigned int dbiIndexSetCount(dbiIndexSet set)
    00537         /*@*/;
    00538
    00545 unsigned int dbiIndexRecordOffset(dbiIndexSet set, int recno)
    00546         /*@*/;
    00547
    00554 unsigned int dbiIndexRecordFileNumber(dbiIndexSet set, int recno)
    00555         /*@*/;
    00556
    00557 #ifdef __cplusplus
    00558 }
    00559 #endif
    00560
    00561 #endif  /* H_RPMDB */