Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

lib/rpmdb.h

Go to the documentation of this file.
00001 #ifndef H_RPMDB
00002 #define H_RPMDB
00003 
00009 #include <rpmlib.h>
00010 
00011 #include "fprint.h"
00012 
00013 typedef /*@abstract@*/ struct _dbiIndexItem * dbiIndexItem;
00014 typedef /*@abstract@*/ struct _dbiIndex * dbiIndex;
00015 
00016 /* this will break if sizeof(int) != 4 */
00022 struct _dbiIndexItem {
00023     unsigned int hdrNum;                
00024     unsigned int tagNum;                
00025     unsigned int fpNum;                 
00026     unsigned int dbNum;                 
00027 };
00028 
00032 struct _dbiIR {
00033     unsigned int recOffset;             
00034     unsigned int fileNumber;            
00035 };
00036 typedef struct _dbiIR * DBIR_t;
00037 
00041 struct _dbiIndexSet {
00042 /*@owned@*/ struct _dbiIndexItem * recs; 
00043     int count;                          
00044 };
00045 
00046 /* XXX hack to get prototypes correct */
00047 #if !defined(DB_VERSION_MAJOR)
00048 #define DB_ENV  void
00049 #define DBC     void
00050 #define DBT     void
00051 #define DB_LSN  void
00052 #endif
00053 
00057 struct _dbiVec {
00058     int dbv_major;                      
00059     int dbv_minor;                      
00060     int dbv_patch;                      
00068     int (*open) (rpmdb rpmdb, int rpmtag, /*@out@*/ dbiIndex * dbip);
00069 
00076     int (*close) (/*@only@*/ dbiIndex dbi, unsigned int flags);
00077 
00084     int (*sync) (dbiIndex dbi, unsigned int flags);
00085 
00092     int (*copen) (dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int flags);
00093 
00100     int (*cclose) (dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags);
00101 
00111     int (*cdel) (dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen, unsigned int flags);
00112 
00124     int (*cget) (dbiIndex dbi, DBC * dbcursor,
00125                         /*@out@*/ void ** keypp, /*@out@*/ size_t * keylenp,
00126                         /*@out@*/ void ** datapp, /*@out@*/ size_t * datalenp,
00127                         unsigned int flags);
00128 
00140     int (*cput) (dbiIndex dbi, DBC * dbcursor,
00141                         const void * keyp, size_t keylen,
00142                         const void * datap, size_t datalen,
00143                         unsigned int flags);
00144 
00150     int (*byteswapped) (dbiIndex dbi);
00151 
00152 };
00153 
00157 struct _dbiIndex {
00158     const char *        dbi_root;
00159     const char *        dbi_home;
00160     const char *        dbi_file;
00161     const char *        dbi_subfile;
00162 
00163     int                 dbi_cflags;     
00164     int                 dbi_oeflags;    
00165     int                 dbi_eflags;     
00166     int                 dbi_oflags;     
00167     int                 dbi_tflags;     
00169     int                 dbi_type;       
00170     int                 dbi_mode;       
00171     int                 dbi_perms;      
00172     int                 dbi_api;        
00174     int                 dbi_tear_down;
00175     int                 dbi_use_cursors;
00176     int                 dbi_use_dbenv;
00177     int                 dbi_get_rmw_cursor;
00178     int                 dbi_no_fsync;   
00179     int                 dbi_no_dbsync;  
00180     int                 dbi_lockdbfd;   
00181     int                 dbi_temporary;  
00182     int                 dbi_debug;
00183 
00184         /* dbenv parameters */
00185     int                 dbi_lorder;
00186     void                (*db_errcall) (const char *db_errpfx, char *buffer);
00187 /*@shared@*/ FILE *     dbi_errfile;
00188     const char *        dbi_errpfx;
00189     int                 dbi_verbose;
00190     int                 dbi_region_init;
00191     int                 dbi_tas_spins;
00192         /* mpool sub-system parameters */
00193     int                 dbi_mp_mmapsize;        
00194     int                 dbi_mp_size;    
00195         /* lock sub-system parameters */
00196     unsigned int        dbi_lk_max;
00197     unsigned int        dbi_lk_detect;
00198     int                 dbi_lk_nmodes;
00199     unsigned char       *dbi_lk_conflicts;
00200         /* log sub-system parameters */
00201     unsigned int        dbi_lg_max;
00202     unsigned int        dbi_lg_bsize;
00203         /* transaction sub-system parameters */
00204     unsigned int        dbi_tx_max;
00205 #if 0
00206     int                 (*dbi_tx_recover) (DB_ENV *dbenv, DBT *log_rec, DB_LSN *lsnp, int redo, void *info);
00207 #endif
00208         /* dbinfo parameters */
00209     int                 dbi_cachesize;  
00210     int                 dbi_pagesize;   
00211     void *              (*dbi_malloc) (size_t nbytes);
00212         /* hash access parameters */
00213     unsigned int        dbi_h_ffactor;  
00214     unsigned int        (*dbi_h_hash_fcn) (const void *bytes, unsigned int length);
00215     unsigned int        dbi_h_nelem;    
00216     unsigned int        dbi_h_flags;    
00217     int                 (*dbi_h_dup_compare_fcn) (const DBT *, const DBT *);
00218         /* btree access parameters */
00219     int                 dbi_bt_flags;
00220     int                 dbi_bt_minkey;
00221     int                 (*dbi_bt_compare_fcn)(const DBT *, const DBT *);
00222     int                 (*dbi_bt_dup_compare_fcn) (const DBT *, const DBT *);
00223     size_t              (*dbi_bt_prefix_fcn) (const DBT *, const DBT *);
00224         /* recno access parameters */
00225     int                 dbi_re_flags;
00226     int                 dbi_re_delim;
00227     unsigned int        dbi_re_len;
00228     int                 dbi_re_pad;
00229     const char *        dbi_re_source;
00230 
00231     rpmdb       dbi_rpmdb;
00232     int         dbi_rpmtag;             
00233     int         dbi_jlen;               
00235     unsigned int dbi_lastoffset;        
00237     void *      dbi_db;                 
00238     void *      dbi_dbenv;
00239     void *      dbi_dbinfo;
00240     void *      dbi_rmw;                
00242 /*@observer@*/ const struct _dbiVec * dbi_vec;  
00244 };
00245 
00249 struct rpmdb_s {
00250     const char *        db_root;        
00251     const char *        db_home;        
00252     int                 db_flags;
00253 
00254     int                 db_mode;        
00255     int                 db_perms;       
00257     int                 db_api;         
00259     int                 db_remove_env;
00260     int                 db_filter_dups;
00261 
00262     const char *        db_errpfx;
00263 
00264     void                (*db_errcall) (const char *db_errpfx, char *buffer);
00265 /*@shared@*/ FILE *     db_errfile;
00266     void *              (*db_malloc) (size_t nbytes);
00267 
00268     int                 db_ndbi;
00269     dbiIndex            *_dbi;
00270 };
00271 
00272 /* for RPM's internal use only */
00273 
00276 enum rpmdbFlags {
00277         RPMDB_FLAG_JUSTCHECK    = (1 << 0),
00278         RPMDB_FLAG_MINIMAL      = (1 << 1),
00279         RPMDB_FLAG_CHROOT       = (1 << 2)
00280 };
00281 
00282 #ifdef __cplusplus
00283 extern "C" {
00284 #endif
00285 
00290 /*@only@*/ /*@null@*/ dbiIndex db3New(/*@keep@*/ rpmdb rpmdb, int rpmtag);
00291 
00296 void db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi);
00297 
00304 /*@exposed@*/ const char *const prDbiOpenFlags(int dbflags,
00305                                                 int print_dbenv_flags);
00306 
00314 /*@only@*/ /*@null@*/ dbiIndex dbiOpen(rpmdb rpmdb, int rpmtag,
00315                 unsigned int flags);
00316 
00321 int dbiCopen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int flags);
00322 int XdbiCopen(dbiIndex dbi, /*@out@*/ DBC ** dbcp, unsigned int flags, const char *f, unsigned int l);
00323 #define dbiCopen(_a,_b,_c) \
00324         XdbiCopen(_a, _b, _c, __FILE__, __LINE__)
00325 
00330 int dbiCclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags);
00331 int XdbiCclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags, const char *f, unsigned int l);
00332 #define dbiCclose(_a,_b,_c) \
00333         XdbiCclose(_a, _b, _c, __FILE__, __LINE__)
00334 
00343 int dbiDel(dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen,
00344         unsigned int flags);
00345 
00356 int dbiGet(dbiIndex dbi, DBC * dbcursor, void ** keypp, size_t * keylenp,
00357         void ** datapp, size_t * datalenp, unsigned int flags);
00358 
00369 int dbiPut(dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen,
00370         const void * datap, size_t datalen, unsigned int flags);
00371 
00378 int dbiClose(/*@only@*/ dbiIndex dbi, unsigned int flags);
00379 
00386 int dbiSync (dbiIndex dbi, unsigned int flags);
00387 
00393 int dbiByteSwapped(dbiIndex dbi);
00394 
00400 char * db1basename(int rpmtag);
00401 
00404 unsigned int rpmdbGetIteratorFileNum(rpmdbMatchIterator mi);
00405 
00409 int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, /*@out@*/dbiIndexSet * matchList, 
00410                     int numItems);
00411 
00416 void dbiFreeIndexSet(/*@only@*/ /*@null@*/ dbiIndexSet set);
00417 
00423 unsigned int dbiIndexSetCount(dbiIndexSet set);
00424 
00431 unsigned int dbiIndexRecordOffset(dbiIndexSet set, int recno);
00432 
00439 unsigned int dbiIndexRecordFileNumber(dbiIndexSet set, int recno);
00440 
00441 #ifdef __cplusplus
00442 }
00443 #endif
00444 
00445 #endif  /* H_RPMDB */

Generated at Mon May 21 08:53:40 2001 for rpm by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001