1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* db_log_c.x
*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#if RPC_HDR
%#ifndef _DB_LOG_H
%#define _DB_LOG_H
#ifdef USINGC
%#include "db_log_entry_c.h"
#else
%#include "db_pickle.h"
%#include "db_log_entry.h"
#endif /* USINGC */
#endif /* RPC_HDR */
%
%#include "nisdb_rw.h"
%
#ifndef USINGC
#ifdef RPC_HDR
%class db_log: public pickle_file {
% private:
% int syncstate; /* 0 if changes xfrd to <table>.log */
% char *tmplog; /* <table>.log.tmp */
% char *stablelog; /* <table>.log.stable */
% char *oldlog; /* remember name of <table>.log */
% STRUCTRWLOCK(log);
%
% public:
%
%/* Constructor: create log file; default is PICKLE_READ mode. */
% db_log( char* f, pickle_mode m = PICKLE_READ ): pickle_file(f, m) {
% syncstate = 0;
% tmplog = stablelog = oldlog = 0;
% INITRW(log);
% }
%
% ~db_log(void) {
% DESTROYRW(log);
% }
%
%/* Execute given function 'func' on log.
% function takes as arguments: pointer to log entry, character pointer to
% another argument, and pointer to an integer, which is used as a counter.
% 'func' should increment this value for each successful application.
% The log is traversed until either 'func' returns FALSE, or when the log
% is exhausted. The second argument to 'execute_on_log' is passed as the
% second argument to 'func'. The third argument, 'clean' determines whether
% the log entry is deleted after the function has been applied.
% Returns the number of times that 'func' incremented its third argument. */
% int execute_on_log( bool_t(* f) (db_log_entry *, char *, int *),
% char *, bool_t = TRUE );
%
%
%/* Print contents of log file to stdout */
% int print();
%
%/* Make copy of current log to log pointed to by 'f'. */
% int copy( db_log*);
%
%/*Rewinds current log */
% int rewind();
%
%/*Append given log entry to log. */
% int append( db_log_entry * );
%
%/* Flush and sync log file. */
% int sync_log();
%
%/* Return the next element in current log; return NULL if end of log or error.
% Log must have been opened for READ. */
% db_log_entry *get();
%
%/* bool_t dump( pptr ) {return TRUE;}*/ // does nothing.
%
%/* Open log file */
% bool_t open(void);
%/* Close log file */
% int close();
%/* Do we need to copy the log file */
% bool_t copylog;
%
%/* Locking methods */
%
% int acqexcl(void) {
% return (WLOCK(log));
% }
%
% int relexcl(void) {
% return (WULOCK(log));
% }
%
% int acqnonexcl(void) {
% return (RLOCK(log));
% }
%
% int relnonexcl(void) {
% return (RULOCK(log));
% }
%};
#endif /* RPC_HDR */
#endif /* USINGC */
#if RPC_HDR
%#endif /* _DB_LOG_H */
#endif /* RPC_HDR */
|