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