/*
* 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
* 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_table_c.x
*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
%#pragma ident "%Z%%M% %I% %E% SMI"
#if RPC_HDR
%#ifndef _DB_TABLE_H
%#define _DB_TABLE_H
#ifdef USINGC
%#include "db_query_c.h"
%#include "db_scheme_c.h"
#else
%#include "db_query.h"
%#include "db_scheme.h"
#endif /* USINGC */
#endif /* RPC_HDR */
%
%#include "nisdb_ldap.h"
%#include "nisdb_rw.h"
%#include "ldap_parse.h"
%#include "ldap_map.h"
%#include "ldap_util.h"
%#include "ldap_nisdbquery.h"
%#include "ldap_print.h"
%#include "ldap_xdr.h"
%
typedef long entryp; /* specifies location of an entry within table */
struct db_free_entry {
struct db_free_entry *next;
};
typedef struct db_free_entry * db_free_entry_p;
#ifdef USINGC
struct db_free_list {
long count;
};
typedef struct db_free_list * db_free_list_p;
#endif /* USINGC */
#endif /* RPC_HDR */
#ifndef USINGC
#ifdef RPC_HDR
% long count;
% public:
% db_free_list() { /* free list constructor */
% count = 0;
% }
%
% ~db_free_list();
%
% void reset(); /* empty contents of free list */
%
% void init(); /* Empty free list */
%
%/* Returns the location of a free entry, or NULL, if there aren't any. */
%
%/* Adds given location to the free list.
% Returns TRUE if successful, FALSE otherwise (when out of memory). */
%
%/* Returns in a vector the information in the free list.
% Vector returned is of form: <n free cells><n1><n2><loc1>,..<locn>.
% Leave the first 'n' cells free.
% n1 is the number of entries that should be in the freelist.
% n2 is the number of entries actually found in the freelist.
% <loc1...locn> are the entries. n2 <= n1 because we never count beyond n1.
% It is up to the caller to free the returned vector when he is through. */
% long* stats( int n );
%
%/* Locking methods */
%
% int acqexcl(void) {
% }
%
% int relexcl(void) {
% }
%
% int acqnonexcl(void) {
% }
%
% int relnonexcl(void) {
% }
%};
#endif /* RPC_HDR */
#endif /* USINGC */
#ifdef USINGC
struct db_table
{
entry_object_p tab <>;
long last_used; /* last entry used; maintained for quick insertion */
long count; /* measures fullness of table */
};
typedef struct db_table * db_table_p;
#endif /* USINGC */
#endif /* RPC_HDR */
#ifndef USINGC
#ifdef RPC_HDR
%{
% long table_size;
% long last_used; /* last entry used; maintained for quick insertion */
% long count; /* measures fullness of table */
% STRUCTRWLOCK(table);
%
% void grow(); /* Expand the table.
% Fatal error if insufficient error. */
%
%/* Allocate expiration time array */
%
% public:
%
% db_table(); /* constructor for brand new, empty table. */
% db_table( char * ); /* constructor for creating a table by loading
% in an existing one. */
%
% void db_table_ldap_init(void);
% ulong_t oldstructsize(void) {
% }
%/* Mark this instance as deferred */
% void markDeferred(void) {
% }
%/* Remove deferred mark */
% void unmarkDeferred(void) {
% }
%
%/* Return the current 'tab' */
%/* Return how many entries there are in table. */
%
%/* Deletes table, entries, and free list */
% ~db_table();
%
% int tryacqexcl(void) {
% }
%
% int acqexcl(void) {
% }
%
% int relexcl(void) {
% }
%
% int acqnonexcl(void) {
% }
%
% int relnonexcl(void) {
% }
%
%/* empties table by deleting all entries and other associated data structures */
% void reset();
%
% int dump( char *);
%
%/* Returns whether location is valid. */
%
%/* Returns table size. */
% long getsize() { return table_size; }
%
%/* Returns the first entry in table, also return its position in
% 'where'. Return NULL in both if no next entry is found. */
%
%/* Returns the next entry in table from 'prev', also return its position in
% 'newentry'. Return NULL in both if no next entry is found. */
%
%/* Returns entry at location 'where', NULL if location is invalid. */
%
%/* Adds given entry to table in first available slot (either look in freelist
% or add to end of table) and return the the position of where the record
% is placed. 'count' is incremented if entry is added. Table may grow
% as a side-effect of the addition. Copy is made of the input. */
%
% /* Replaces object at specified location by given entry.
% Returns TRUE if replacement successful; FALSE otherwise.
% There must something already at the specified location, otherwise,
% replacement fails. Copy is not made of the input.
% The pre-existing entry is freed.*/
%
%/* Deletes entry at specified location. Returns TRUE if location is valid;
% FALSE if location is invalid, or the freed location cannot be added to
% the freelist. 'count' is decremented if the deletion occurs. The object
% at that location is freed. */
%
%/* Returns statistics of table.
% <table_size><last_used><count>[freelist].
% It is up to the caller to free the returned vector when his is through
% The free list is included if 'fl' is TRUE. */
%
%/* Configure LDAP mapping */
%
%/* Initialize the mapping structure with default values */
%
%/* Check if entry at 'loc' is valid (not expired) */
%
%/* Update expiration time if supplied object same as the one at 'loc' */
%
%/* Set expiration time for entry */
%
%/* Enable enum mode */
% void setEnumMode(long count);
%/* Clear enum mode */
% void clearEnumMode(void);
%/* End enum mode, return array of untouched entries */
%/* Mark the indicated entry used for enum purposes */
%/* Add entry to enumIndex array */
%/* Touch the indicated entry */
%
%};
%#ifdef __cplusplus
%#endif
#endif /* RPC_HDR */
#endif /* USINGC */
#if RPC_HDR
%#endif /* _DB_TABLE_H */
#endif /* RPC_HDR */