1 /* 2 * Please do not edit this file. 3 * It was generated using rpcgen. 4 */ 5 6 #ifndef _DB_LOG_H_RPCGEN 7 #define _DB_LOG_H_RPCGEN 8 9 #include <rpc/rpc.h> 10 #pragma ident "%Z%%M% %I% %E% SMI" 11 #ifndef _DB_LOG_H 12 #define _DB_LOG_H 13 #include "db_pickle.h" 14 #include "db_log_entry.h" 15 16 #include "nisdb_rw.h" 17 18 class db_log: public pickle_file { 19 private: 20 int syncstate; /* 0 if changes xfrd to <table>.log */ 21 char *tmplog; /* <table>.log.tmp */ 22 char *stablelog; /* <table>.log.stable */ 23 char *oldlog; /* remember name of <table>.log */ 24 STRUCTRWLOCK(log); 25 26 public: 27 28 /* Constructor: create log file; default is PICKLE_READ mode. */ 29 db_log( char* f, pickle_mode m = PICKLE_READ ): pickle_file(f, m) { 30 syncstate = 0; 31 tmplog = stablelog = oldlog = 0; 32 INITRW(log); 33 } 34 35 ~db_log(void) { 36 DESTROYRW(log); 37 } 38 39 /* Execute given function 'func' on log. 40 function takes as arguments: pointer to log entry, character pointer to 41 another argument, and pointer to an integer, which is used as a counter. 42 'func' should increment this value for each successful application. 43 The log is traversed until either 'func' returns FALSE, or when the log 44 is exhausted. The second argument to 'execute_on_log' is passed as the 45 second argument to 'func'. The third argument, 'clean' determines whether 46 the log entry is deleted after the function has been applied. 47 Returns the number of times that 'func' incremented its third argument. */ 48 int execute_on_log( bool_t(* f) (db_log_entry *, char *, int *), 49 char *, bool_t = TRUE ); 50 51 52 /* Print contents of log file to stdout */ 53 int print(); 54 55 /* Make copy of current log to log pointed to by 'f'. */ 56 int copy( db_log*); 57 58 /*Rewinds current log */ 59 int rewind(); 60 61 /*Append given log entry to log. */ 62 int append( db_log_entry * ); 63 64 /* Flush and sync log file. */ 65 int sync_log(); 66 67 /* Return the next element in current log; return NULL if end of log or error. 68 Log must have been opened for READ. */ 69 db_log_entry *get(); 70 71 /* bool_t dump( pptr ) {return TRUE;}*/ // does nothing. 72 73 /* Open log file */ 74 int open(void); 75 /* Close log file */ 76 int close(); 77 /* Do we need to copy the log file */ 78 bool_t copylog; 79 80 /* Locking methods */ 81 82 int acqexcl(void) { 83 return (WLOCK(log)); 84 } 85 86 int relexcl(void) { 87 return (WULOCK(log)); 88 } 89 90 int acqnonexcl(void) { 91 return (RLOCK(log)); 92 } 93 94 int relnonexcl(void) { 95 return (RULOCK(log)); 96 } 97 }; 98 #endif /* _DB_LOG_H */ 99 100 #endif /* !_DB_LOG_H_RPCGEN */ 101