2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * db_dictlog_c.x
2N/A *
2N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A%#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#if RPC_HDR
2N/A%#ifndef _DB_DICTLOG_H
2N/A%#define _DB_DICTLOG_H
2N/A
2N/A%
2N/A%/* A log entry that describes an action to be performed and its parameters. */
2N/A%
2N/A#endif /* RPC_HDR */
2N/A
2N/A#if RPC_HDR || RPC_XDR
2N/A#ifdef USINGC
2N/A%#include "db_vers_c.h"
2N/A#else
2N/A%#include "db_vers.h"
2N/A%#include "db_pickle.h"
2N/A#endif /* USINGC */
2N/A%#include <rpcsvc/nis.h>
2N/A#endif /* RPC_HDR */
2N/A%
2N/A%#include "nisdb_rw.h"
2N/A%
2N/A%#define DB_ADD_TABLE 1
2N/A%#define DB_REMOVE_TABLE 2
2N/A
2N/A#if RPC_HDR || RPC_XDR
2N/A#ifdef USINGC
2N/Astruct db_dictlog_entry {
2N/A vers aversion; /* version of log entry */
2N/A int action; /* action to be invoked */
2N/A string table_name<>; /* table_name supplied with action */
2N/A table_obj *table_object; /* object involved in action (if any) */
2N/A struct db_dictlog_entry *next; /* Used in constructing list */
2N/A vers bversion; /* sanity check;should be same as aversion*/
2N/A};
2N/Atypedef struct db_dictlog_entry* db_dictlog_entry_p;
2N/A#endif /* USINGC */
2N/A#endif /* RPC_HDR */
2N/A
2N/A#ifdef USINGC
2N/A#if RPC_HDR
2N/A%bool_t xdr_table_obj();
2N/A#endif
2N/A#endif /* USINGC */
2N/A
2N/A#ifndef USINGC
2N/A#ifdef RPC_HDR
2N/A%class db_dictlog_entry {
2N/A% vers aversion; /* version of log entry */
2N/A% int action; /* action to be invoked */
2N/A% char *table_name; /* table_name supplied with action (if any) */
2N/A% table_obj *table_object; /* object involved in action (if any) */
2N/A% db_dictlog_entry *next; /* Used in constructing list */
2N/A% vers bversion; /* sanity check */
2N/A% public:
2N/A%
2N/A%/*Constructor: Create an empty log entry, with no table_name and not object */
2N/A% db_dictlog_entry() { table_name = NULL, table_object = NULL; next = NULL; }
2N/A%
2N/A%/*Constructor: Create a log entry using the given parameters. Note that
2N/A% pointers to table_name and table_object are simply assigned, not copied. */
2N/A% db_dictlog_entry(int, vers *, char*, table_obj*);
2N/A%
2N/A% ~db_dictlog_entry();
2N/A%
2N/A%/* Print this log entry to stdout */
2N/A% void print();
2N/A%
2N/A%/* Accessor: return version of log entry */
2N/A% vers *get_version() { return( &aversion ); }
2N/A%
2N/A%/* Accessor: return pointer to action of log entry */
2N/A% int get_action() { return( action ); }
2N/A%
2N/A%/* Accessor: return pointer to table_name part of log entry */
2N/A% char* get_table_name() { return( table_name ); }
2N/A%
2N/A%/* Predicate: return whether log entry is complete and not truncated */
2N/A% bool_t sane() { return( aversion.equal( &bversion ) ); }
2N/A%
2N/A%/* Accessor: return pointer to copy of object in log entry */
2N/A% table_obj *get_table_object() { return( table_object ); }
2N/A%
2N/A%/* Accessor: return pointer to to next log entry */
2N/A% db_dictlog_entry * getnextptr() { return( next ); }
2N/A%
2N/A%/* Accessor: return pointer to copy of object in log entry */
2N/A% void setnextptr( db_dictlog_entry *p ) { next = p; }
2N/A%};
2N/A%#ifdef __cplusplus
2N/A%extern "C" bool_t xdr_db_dictlog_entry(XDR*, db_dictlog_entry*);
2N/A%#elif __STDC__
2N/A%extern bool_t xdr_db_dictlog_entry(XDR*, db_dictlog_entry*);
2N/A%#endif
2N/A%typedef class db_dictlog_entry * db_dictlog_entry_p;
2N/A#endif /* RPC_HDR */
2N/A#endif /* USINGC */
2N/A
2N/Astruct db_dictlog_list {
2N/A db_dictlog_entry_p list<>;
2N/A};
2N/A
2N/A#ifndef USINGC
2N/A#ifdef RPC_HDR
2N/A%class db_dictlog: public pickle_file {
2N/A% STRUCTRWLOCK(dictlog);
2N/A% public:
2N/A%
2N/A%/* Constructor: create log file; default is PICKLE_READ mode. */
2N/A% db_dictlog( char* f, pickle_mode m = PICKLE_READ ): pickle_file(f,m) {
2N/A% INITRW(dictlog);
2N/A% }
2N/A%
2N/A% ~db_dictlog(void) {
2N/A% DESTROYRW(dictlog);
2N/A% }
2N/A%
2N/A%/* Execute given function 'func' on log.
2N/A% function takes as arguments: pointer to log entry, character pointer to
2N/A% another argument, and pointer to an integer, which is used as a counter.
2N/A% 'func' should increment this value for each successful application.
2N/A% The log is traversed until either 'func' returns FALSE, or when the log
2N/A% is exhausted. The second argument to 'execute_on_log' is passed as the
2N/A% second argument to 'func'. The third argument, 'clean' determines whether
2N/A% the log entry is deleted after the function has been applied.
2N/A% Returns the number of times that 'func' incremented its third argument. */
2N/A% int execute_on_log( bool_t(* func) (db_dictlog_entry *, char *, int *),
2N/A% char *, bool_t = TRUE );
2N/A%
2N/A%/* Print contents of log file to stdout */
2N/A% int print();
2N/A%
2N/A%/*Append given log entry to log. */
2N/A% int append( db_dictlog_entry * );
2N/A%
2N/A%/* Return the next element in current log; return NULL if end of log or error.
2N/A% Log must have been opened for READ. */
2N/A% db_dictlog_entry *get();
2N/A%
2N/A%/*
2N/A% * Locking methods. Protect the db_dictlog as well as db_dictlog_entries
2N/A% * hanging off of it.
2N/A% */
2N/A% int acqexcl(void) {
2N/A% return (WLOCK(dictlog));
2N/A% }
2N/A%
2N/A% int relexcl(void) {
2N/A% return (WULOCK(dictlog));
2N/A% }
2N/A%
2N/A% int acqnonexcl(void) {
2N/A% return (RLOCK(dictlog));
2N/A% }
2N/A%
2N/A% int relnonexcl(void) {
2N/A% return (RULOCK(dictlog));
2N/A% }
2N/A%
2N/A%};
2N/A#endif /* RPC_HDR */
2N/A#endif /* USINGC */
2N/A
2N/A#if RPC_HDR
2N/A%#endif /* _DB_DICTLOG_H */
2N/A#endif /* RPC_HDR */