Back to index

lightning-sunbird  0.9+nobinonly
icalbdbset.h
Go to the documentation of this file.
00001 /* -*- Mode: C -*- */
00002 /*======================================================================
00003  FILE: icalbdbset.h
00004  CREATOR: dml 12 December 2001
00005  (C) COPYRIGHT 2001, Critical Path
00006 
00007  $Id: icalbdbset.h,v 1.4 2002/09/26 22:24:52 lindner Exp $
00008  $Locker:  $
00009 ======================================================================*/
00010 
00011 #ifndef ICALBDBSET_H
00012 #define ICALBDBSET_H
00013 
00014 #include "ical.h"
00015 #include "icalset.h"
00016 #include "icalgauge.h"
00017 #include <db.h>
00018 
00019 typedef struct icalbdbset_impl icalbdbset;
00020 
00021 enum icalbdbset_subdb_type {ICALBDB_CALENDARS, ICALBDB_EVENTS, ICALBDB_TODOS, ICALBDB_REMINDERS};
00022 typedef enum icalbdbset_subdb_type icalbdbset_subdb_type;
00023 
00025 int icalbdbset_init_dbenv(char *db_env_dir, void (*logDbFunc)(const char*, char*));
00026 
00027 icalset*  icalbdbset_init(icalset* set, const char *dsn, void *options);
00028 int icalbdbset_cleanup(void);
00029 void icalbdbset_checkpoint(void);
00030 void icalbdbset_rmdbLog(void);
00031 
00034 icalset * icalbdbset_new(const char* database_filename, 
00035                       icalbdbset_subdb_type subdb_type,
00036                       int dbtype, int flag);
00037 
00038 DB * icalbdbset_bdb_open_secondary(DB *dbp,
00039                             const char *subdb,
00040                             const char *sindex, 
00041                             int (*callback) (DB *db, 
00042                                           const DBT *dbt1, 
00043                                           const DBT *dbt2, 
00044                                           DBT *dbt3),
00045                             int type);
00046                             
00047 char *icalbdbset_parse_data(DBT *dbt, char *(*pfunc)(const DBT *dbt)) ;
00048 
00049 void icalbdbset_free(icalset* set);
00050 
00051 /* cursor operations */
00052 int icalbdbset_acquire_cursor(DB *dbp, DB_TXN* tid, DBC **rdbcp);
00053 int icalbdbset_cget(DBC *dbcp, DBT *key, DBT *data, int access_method);
00054 int icalbdbset_cput(DBC *dbcp, DBT *key, DBT *data, int access_method);
00055 
00056 int icalbdbset_get_first(DBC *dbcp, DBT *key, DBT *data);
00057 int icalbdbset_get_next(DBC *dbcp, DBT *key, DBT *data);
00058 int icalbdbset_get_last(DBC *dbcp, DBT *key, DBT *data);
00059 int icalbdbset_get_key(DBC *dbcp, DBT *key, DBT *data);
00060 int icalbdbset_delete(DB *dbp, DBT *key);
00061 int icalbdbset_put(DB *dbp, DBT *key, DBT *data, int access_method);
00062 int icalbdbset_get(DB *dbp, DB_TXN *tid, DBT *key, DBT *data, int flags);
00063 
00064 const char* icalbdbset_path(icalset* set);
00065 const char* icalbdbset_subdb(icalset* set);
00066 
00067 /* Mark the set as changed, so it will be written to disk when it
00068    is freed. Commit writes to disk immediately. */
00069 void icalbdbset_mark(icalset* set);
00070 icalerrorenum icalbdbset_commit(icalset *set);
00071 
00072 icalerrorenum icalbdbset_add_component(icalset* set,
00073                                    icalcomponent* child);
00074 
00075 icalerrorenum icalbdbset_remove_component(icalset* set,
00076                                       icalcomponent* child);
00077 
00078 int icalbdbset_count_components(icalset* set,
00079                              icalcomponent_kind kind);
00080 
00081 /* Restrict the component returned by icalbdbset_first, _next to those
00082    that pass the gauge. _clear removes the gauge */
00083 icalerrorenum icalbdbset_select(icalset* store, icalgauge* gauge);
00084 void icalbdbset_clear(icalset* store);
00085 
00086 /* Get and search for a component by uid */
00087 icalcomponent* icalbdbset_fetch(icalset* set, icalcomponent_kind kind, const char* uid);
00088 int icalbdbset_has_uid(icalset* set, const char* uid);
00089 icalcomponent* icalbdbset_fetch_match(icalset* set, icalcomponent *c);
00090 
00091 
00092 icalerrorenum icalbdbset_modify(icalset* set, icalcomponent *old,
00093                             icalcomponent *newc);
00094 
00095 /* cluster management functions */
00096 icalerrorenum  icalbdbset_set_cluster(icalset* set, icalcomponent* cluster);
00097 icalerrorenum  icalbdbset_free_cluster(icalset* set);
00098 icalcomponent* icalbdbset_get_cluster(icalset* set);
00099 
00100 /* Iterate through components. If a gauge has been defined, these
00101    will skip over components that do not pass the gauge */
00102 
00103 icalcomponent* icalbdbset_get_current_component (icalset* set);
00104 icalcomponent* icalbdbset_get_first_component(icalset* set);
00105 icalcomponent* icalbdbset_get_next_component(icalset* set);
00106 
00107 /* External iterator for thread safety */
00108 icalsetiter icalbdbset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge, const char* tzid);
00109 
00110 icalcomponent* icalbdbset_form_a_matched_recurrence_component(icalsetiter* itr);
00111 
00112 icalcomponent* icalbdbsetiter_to_next(icalset* set, icalsetiter* i);
00113 icalcomponent* icalbdbsetiter_to_prior(icalset* set, icalsetiter* i);
00114 
00115 /* Return a reference to the internal component. You probably should
00116    not be using this. */
00117 
00118 icalcomponent* icalbdbset_get_component(icalset* set);
00119 
00120 DB_ENV *icalbdbset_get_env(void);
00121 
00122 
00123 int icalbdbset_begin_transaction(DB_TXN* parent_id, DB_TXN** txnid);
00124 int icalbdbset_commit_transaction(DB_TXN* txnid);
00125 
00126 DB* icalbdbset_bdb_open(const char* path, 
00127                      const char *subdb,
00128                      int type,
00129                      mode_t mode, int flag);
00130 
00131 
00132 typedef struct icalbdbset_options {
00133   icalbdbset_subdb_type subdb;        
00134   int                   dbtype;       
00135   mode_t                mode;         
00136   u_int32_t             flag;      
00137   char *(*pfunc)(const DBT *dbt);  
00138   int (*callback) (DB *db,     
00139                  const DBT *dbt1, 
00140                  const DBT *dbt2, 
00141                  DBT *dbt3);
00142 } icalbdbset_options;
00143 
00144 #endif /* !ICALBDBSET_H */
00145 
00146 
00147