xref: /illumos-gate/usr/src/lib/libnisdb/db_vers_c.x (revision e8d3efa1c56e5f2b5368600a2baeb7b1d54a07f8)
1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *	db_vers_c.x
24  *
25  * Copyright 2015 Gary Mills
26  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  */
29 
30 #if RPC_XDR
31 %#include "ldap_xdr.h"
32 #endif /* RPC_XDR */
33 
34 #if RPC_HDR
35 %#include <stdio_tag.h>
36 %#ifndef _DB_VERS_H
37 %#define _DB_VERS_H
38 #endif /* RPC_HDR */
39 
40 %/* 'vers' is the version identifier.  */
41 
42 %
43 %#include "nisdb_rw.h"
44 %
45 #if RPC_HDR || RPC_XDR
46 #ifdef USINGC
47 struct vers {
48 	u_int vers_high;
49 	u_int vers_low;
50 	u_int time_sec;
51 	u_int time_usec;
52 	__nisdb_rwlock_t vers_rwlock;
53 };
54 #endif /* USINGC */
55 #endif /* RPC_HDR */
56 
57 #ifndef USINGC
58 #ifdef RPC_HDR
59 %class vers {
60 %  unsigned int vers_high;     /* major version number, tracks checkpoints */
61 %  unsigned int vers_low;      /* minor version number, tracks updates. */
62 %  unsigned int time_sec;      /* time stamp */
63 %  unsigned int time_usec;
64 %  STRUCTRWLOCK(vers);
65 % public:
66 %/* No argument constructor.  All entries initialized to zero. */
67 %  vers() {
68 %	vers_high = vers_low = time_sec = time_usec = 0;
69 %	INITRW(vers);
70 %  }
71 %
72 %/* Constructor that makes copy of 'other'. */
73 %  vers( vers *other );
74 %
75 %/* Constructor:  create version with specified version numbers */
76 %  vers( unsigned int high, unsigned int low) {
77 %	vers_high = high; vers_low = low; time_sec = time_usec = 0;
78 %	INITRW(vers);
79 %  }
80 %
81 %/* Creates new 'vers' with next higher minor version.
82 %   If minor version exceeds MAXLOW, bump up major version instead.
83 %   Set timestamp to that of the current time. */
84 %  vers* nextminor();
85 %
86 %/* Creates new 'vers' with next higher major version.
87 %   Set timestamp to that of the current time. */
88 %  vers* nextmajor();
89 %
90 %/* Set this 'vers' to hold values found in 'others'. */
91 %  void assign( vers *other );
92 %
93 %/* Predicate indicating whether this vers is earlier than 'other' in
94 %   terms of version numbers. */
95 %  bool_t earlier_than( vers *other );
96 %
97 %/* Print the value of this 'vers' to specified file. */
98 %  void print( __FILE *file );
99 %
100 %/* Zero out this vers. */
101 %  void zero();
102 %
103 %/* Predicate indicating whether this vers is equal to 'other'. */
104 %  bool_t  equal( vers *other);
105 %
106 %/* Locking methods */
107 %
108 %  int acqexcl(void) {
109 %	return (WLOCK(vers));
110 %  }
111 %
112 %  int relexcl(void) {
113 %	return (WULOCK(vers));
114 %  }
115 %
116 %  int acqnonexcl(void) {
117 %	return (RLOCK(vers));
118 %  }
119 %
120 %  int relnonexcl(void) {
121 %	return (RULOCK(vers));
122 %  }
123 %};
124 #endif /* RPC_HDR */
125 #endif /* USINGC */
126 
127 #if RPC_HDR
128 %#endif /* VERS_H */
129 #endif /* RPC_HDR */
130