4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
34 %#include "db_log_entry_c.h"
36 %#include "db_pickle.h"
37 %#include "db_log_entry.h"
41 %#include "nisdb_rw.h"
45 %class db_log: public pickle_file {
47 % int syncstate; /* 0 if changes xfrd to <table>.log */
48 % char *tmplog; /* <table>.log.tmp */
49 % char *stablelog; /* <table>.log.stable */
50 % char *oldlog; /* remember name of <table>.log */
55 %/* Constructor: create log file; default is PICKLE_READ mode. */
56 % db_log( char* f, pickle_mode m = PICKLE_READ ): pickle_file(f, m) {
58 % tmplog = stablelog = oldlog = 0;
66 %/* Execute given function 'func' on log.
67 % function takes as arguments: pointer to log entry, character pointer to
68 % another argument, and pointer to an integer, which is used as a counter.
69 % 'func' should increment this value for each successful application.
70 % The log is traversed until either 'func' returns FALSE, or when the log
71 % is exhausted. The second argument to 'execute_on_log' is passed as the
72 % second argument to 'func'. The third argument, 'clean' determines whether
73 % the log entry is deleted after the function has been applied.
74 % Returns the number of times that 'func' incremented its third argument. */
75 % int execute_on_log( bool_t(* f) (db_log_entry *, char *, int *),
76 % char *, bool_t = TRUE );
79 %/* Print contents of log file to stdout */
82 %/* Make copy of current log to log pointed to by 'f'. */
85 %/*Rewinds current log */
88 %/*Append given log entry to log. */
89 % int append( db_log_entry * );
91 %/* Flush and sync log file. */
94 %/* Return the next element in current log; return NULL if end of log or error.
95 % Log must have been opened for READ. */
96 % db_log_entry *get();
98 %/* bool_t dump( pptr ) {return TRUE;}*/ // does nothing.
102 %/* Close log file */
104 %/* Do we need to copy the log file */
107 %/* Locking methods */
109 % int acqexcl(void) {
110 % return (WLOCK(log));
113 % int relexcl(void) {
114 % return (WULOCK(log));
117 % int acqnonexcl(void) {
118 % return (RLOCK(log));
121 % int relnonexcl(void) {
122 % return (RULOCK(log));
129 %#endif /* _DB_LOG_H */