/* * Please do not edit this file. * It was generated using rpcgen. */ #ifndef _DB_DICTIONARY_H_RPCGEN #define _DB_DICTIONARY_H_RPCGEN #include #ifndef _DB_DICTIONARY_H #define _DB_DICTIONARY_H #include "nisdb_rw.h" #include "nisdb_ldap.h" #include "db_entry.h" #include "db_scheme.h" #include "db.h" #include "db_vers.h" #include "db_dictlog.h" #include "ldap_xdr.h" struct db_table_desc { char *table_name; u_long hashval; db_scheme *scheme; db *database; struct db_table_desc *next; }; typedef struct db_table_desc db_table_desc; typedef db_table_desc *db_table_desc_p; typedef u_int db_dict_version; bool_t xdr_db_dict_version(); typedef char *db_table_namep; typedef struct { u_int db_table_names_len; db_table_namep *db_table_names_val; } db_table_names; struct db_dict_desc { db_dict_version impl_vers; struct { u_int tables_len; db_table_desc_p *tables_val; } tables; int count; }; typedef struct db_dict_desc db_dict_desc; typedef db_dict_desc *db_dict_desc_p; struct __nisdb_dictionary_defer_struct { db_dict_desc *dictionary; }; typedef struct __nisdb_dictionary_defer_struct __nisdb_dictionary_defer_struct; typedef __nisdb_dictionary_defer_struct __nisdb_dictionary_defer_t; class db_dictionary { db_dict_desc_p dictionary; bool_t initialized; char* filename; char* tmpfilename; char* logfilename; db_dictlog *logfile; bool_t logfile_opened; bool_t changed; __nisdb_dictionary_defer_t deferred; __nisdb_flag_t noWriteThrough; STRUCTRWLOCK(dict); /* Dump contents of this dictionary (minus the database representation) to its file. Returns 0 if operation succeeds, -1 otherwise. */ int dump(); /* Delete old log file and descriptor */ int reset_log(); /* Open log file (and creates descriptor) if it has not been opened */ int open_log(); /* Incorporate updates in log to dictionary already loaded. Does not affect "logfile" */ int incorporate_log( char * ); /* closes log file if opened */ int close_log(); /* Log the given action and execute it. The minor version of the dictionary is updated after the action has been executed and the dictionary is flagged as being changed. Return the structure db_result, or NULL if the loggin failed or the action is unknown. */ db_status log_action(int, char* table, table_obj* tobj =0); db_status create_table_desc(char* table_name, table_obj* table_desc, db_table_desc**); db_dict_desc_p db_copy_dictionary(void); public: /* Constructor: creates an empty, uninitialized dictionary. */ db_dictionary(); /* Destructor: noop. Use db_shutdown if you really want to clean up. */ ~db_dictionary() {} db_status merge_dict (db_dictionary&, char *, char *); db_status massage_dict (char *, char *, char *); int db_clone_bucket (db_table_desc *, db_table_desc_p *); int change_table_name (db_table_desc *, char *, char *); bool_t extract_entries (db_dictionary&, char **, int ); /* Real destructor: deletes filename and table descriptors */ db_status db_shutdown(); /* Initialize dictionary from contents in 'file'. If there is already information in this dictionary, it is removed. Therefore, regardless of whether the load from the file succeeds, the contents of this dictionary will be altered. Returns whether table has been initialized successfully. */ bool_t init( char* fname ); bool_t inittemp( char* fname, db_dictionary&); /* closes any open log files for all tables in dictionary or 'tab'. "tab" is an optional argument. */ db_status db_standby( char* tab = 0 ); /* Write out in-memory copy of dictionary to file. 1. Update major version. 2. Dump contents to temporary file. 3. Rename temporary file to real dictionary file. 4. Remove log file. A checkpoint is done only if it has changed since the previous checkpoint. Returns TRUE if checkpoint was successful; FALSE otherwise. */ db_status checkpoint(); /* Checkpoints table specified by 'tab', or all tables if 'tab' is 0. */ db_status db_checkpoint( char* tab = 0 ); /* Add table with given name 'tab' and description 'zdesc' to dictionary. Returns error code if table already exists, or if no memory can be found to store the descriptor, or if dictionary has not been intialized. Dictionary is updated to stable store before addition. Fatal error occurs if dictionary cannot be saved. Returns DB_SUCCESS if dictionary has been updated successfully. */ db_status add_table_aux(char* table_name, table_obj* table_desc, int mode); /* Delete table with given name 'tab' from dictionary. Returns error code if table does not exist or if dictionary has not been initialized. Dictionary is updated to stable store if deletion is successful. Fatal error occurs if dictionary cannot be saved. Returns DB_SUCCESS if dictionary has been updated successfully. Note that the files associated with the table are also removed. */ db_status delete_table_aux( char* table_name, int mode ); db_status add_table( char* table_name, table_obj* table_desc ); int copyfile( char* infile, char *outfile); db_status delete_table( char* table_name ); /* Return database structure of table named by 'table_name'. If 'where' is set, set it to the table_desc of 'table_name.' The database is loaded in from stable store if it has not been loaded. If it cannot be loaded, it is initialized using the scheme stored in the table_desc. NULL is returned if the initialization fails. */ db* find_table( char* table_name, db_table_desc ** where = NULL ); db *find_table(char *table_name, db_table_desc **where, bool_t searchDeferred); db *find_table(char *table_name, db_table_desc **where, bool_t searchDeferred, bool_t doLDAP, bool_t doLoad); db *find_table_noLDAP(char *table_name, db_table_desc **where, bool_t searchDeferred, bool_t doLoad); /* Returns db_table_desc of table name 'tab'. Use this if you do not want table to be loaded. */ db_table_desc * find_table_desc( char* table_name ); db_table_desc * find_table_desc(char *table_name, bool_t searchDeferred); /* Translate given nis attribute list to a db_query structure. Return FALSE if dictionary has not been initialized, or table does not have a scheme (which should be a fatal error?). */ db_query * translate_to_query( db_table_desc*, int, nis_attr * ); /* Return an array of strings of table names of all tables in dictionary. */ db_table_names * get_table_names(); /* Set/clear no-write-through flag */ void setNoWriteThrough(void); void clearNoWriteThrough(void); /* Locking */ int acqexcl(void) { return(WLOCK(dict)); } int relexcl(void) { return (WULOCK(dict)); } int acqnonexcl(void) { return (RLOCK(dict)); } int relnonexcl(void) { return (RULOCK(dict)); } /* Set deferred commit mode; intended for replica resync */ db_status defer(char *table); /* Commit deferred changes; intended for replica resync */ db_status commit(char *table); /* Roll back deferred changes; intended for replica resync */ db_status rollback(char *table); }; #ifdef __STDC__ extern "C" bool_t xdr_db_table_desc_p(XDR *, db_table_desc_p *); extern "C" bool_t xdr_db_table_desc(XDR *, db_table_desc *); extern "C" bool_t xdr_db_dict_desc_p(XDR *, db_dict_desc_p *); extern "C" bool_t xdr_db_table_namep(XDR *, db_table_namep *); extern "C" bool_t xdr_db_table_names(XDR *, db_table_names *); #endif #endif /* _DB_DICTIONARY_H */ /* the xdr functions */ extern bool_t xdr_db_table_desc(); extern bool_t xdr_db_table_desc_p(); extern bool_t xdr_db_dict_version(); extern bool_t xdr_db_table_namep(); extern bool_t xdr_db_table_names(); extern bool_t xdr_db_dict_desc(); extern bool_t xdr_db_dict_desc_p(); extern bool_t xdr___nisdb_dictionary_defer_struct(); extern bool_t xdr___nisdb_dictionary_defer_t(); #endif /* !_DB_DICTIONARY_H_RPCGEN */