1 /*
2  * Please do not edit this file.
3  * It was generated using rpcgen.
4  */
5 
6 #ifndef _DB_SCHEME_H_RPCGEN
7 #define	_DB_SCHEME_H_RPCGEN
8 
9 #include <rpc/rpc.h>
10 #ifndef _DB_SCHEMA_H
11 #define _DB_SCHEMA_H
12 #include "db_item.h"
13 #include "db_entry.h"
14 #define	DB_KEY_CASE TA_CASE
15 
16 #include "nisdb_rw.h"
17 
18 /* Positional information of where field starts within record
19    and its maximum length in terms of bytes. */
20 
21 struct db_posn_info {
22 	short start_column;
23 	short max_len;
24 };
25 typedef struct db_posn_info db_posn_info;
26 /* Description of a key */
27 
28 struct db_key_desc {
29 	item *key_name;
30 	u_long key_flags;
31 	int column_number;
32 	db_posn_info where;
33 	short store_type;
34 };
35 typedef struct db_key_desc db_key_desc;
36 /* Description of the data field. */
37 
38 struct db_data_desc {
39 	db_posn_info where;
40 	short store_type;
41 };
42 typedef struct db_data_desc db_data_desc;
43 /* A scheme is a description of the fields of a table. */
44 
45 class db_scheme {
46  protected:
47   struct {
48 	int keys_len;
49 	db_key_desc *keys_val;
50   } keys;
51   short int max_columns;  /* applies to data only ? */
52   db_data_desc data;
53   STRUCTRWLOCK(scheme);
54 
55  public:
56 /* Accessor: return number of keys in scheme. */
57   int numkeys() { return keys.keys_len; }
58 
59 /* Accessor:  return location of array of key_desc's. */
60   db_key_desc* keyloc () { return keys.keys_val; }
61 
62 /* Constructor:  create empty scheme */
63   db_scheme() {
64 	keys.keys_len = 0;
65 	keys.keys_val = NULL;
66 	(void) __nisdb_rwinit(&scheme_rwlock);
67   }
68 
69 /* Constructor:  create new scheme by making copy of 'orig'.
70    All items within old scheme are also copied (i.e. no shared pointers). */
71   db_scheme( db_scheme* orig );
72 
73 /* Constructor:  create new sheme by using information in 'zdesc'. */
74   db_scheme( table_obj * );
75 
76 /* Destructor:  delete all keys associated with scheme and scheme itself. */
77   ~db_scheme();
78 
79 /* Free space occupied by columns. */
80   void clear_columns( int );
81 
82 /* Predicate:  return whether given string is one of the index names
83    of this scheme.  If so, return in 'result' the index's number. */
84   bool_t find_index( char*, int* );
85 
86 /* Print out description of table. */
87   void print();
88 
89 /* Size of the non-MT/LDAP portion of the db_scheme structure */
90   ulong_t oldstructsize(void) {
91 	return ((ulong_t)&(this->scheme_rwlock) - (ulong_t)this);
92   }
93 
94 /* Locking methods */
95 
96   int acqexcl(void) {
97 	return (WLOCK(scheme));
98   }
99 
100   int relexcl(void) {
101 	return (WULOCK(scheme));
102   }
103 
104   int acqnonexcl(void) {
105 	return (RLOCK(scheme));
106   }
107 
108   int relnonexcl(void) {
109 	return (RULOCK(scheme));
110   }
111 };
112 typedef class db_scheme * db_scheme_p;
113 #endif /* _DB_SCHEMA_H */
114 
115 /* the xdr functions */
116 extern bool_t xdr_db_posn_info();
117 extern bool_t xdr_db_key_desc();
118 extern bool_t xdr_db_data_desc();
119 
120 #endif /* !_DB_SCHEME_H_RPCGEN */
121