xref: /illumos-gate/usr/src/lib/libnisdb/db_item_c.x (revision e3ae4b35c024af1196582063ecee3ab79367227d)
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_item_c.x
24  *
25  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 %
30 % /* A 'counted' string. */
31 %
32 
33 #if RPC_HDR
34 %#ifndef _DB_ITEM_H
35 %#define _DB_ITEM_H
36 #endif /* RPC_HDR */
37 
38 #if RPC_HDR || RPC_XDR
39 #ifdef USINGC
40 struct item{
41   char itemvalue<>;
42 };
43 #endif /* USINGC */
44 #endif /* RPC_HDR */
45 
46 #ifndef USINGC
47 #ifdef RPC_HDR
48 %class item {
49 %  int len;
50 %  char *value;
51 % public:
52 %/* Constructor: creates item using given character sequence and length */
53 %  item( char* str, int len);
54 %
55 %/* Constructor: creates item by copying given item */
56 %  item( item* );
57 %
58 %/* Constructor: creates empty item (zero length and null value). */
59 %  item() {len = 0; value = NULL;}
60 %
61 %/* Destructor: recover space occupied by characters and delete item. */
62 %  ~item() {delete value;}
63 %
64 %/* Equality test.  'casein' TRUE means case insensitive test. */
65 %  bool_t equal( item *, bool_t casein = FALSE );
66 %
67 %/* Equality test.  'casein' TRUE means case insensitive test. */
68 %  bool_t equal( char *, int, bool_t casein = FALSE );
69 %
70 %/* Assignment:  update item by setting pointers.  No space is allocated. */
71 %  void update( char* str, int n) {len = n; value = str;}
72 %
73 %/* Return contents of item. */
74 %  void get_value( char** s, int * n ) { *s = value; *n=len;}
75 %
76 %/* Prints contents of item to stdout */
77 %  void print();
78 %
79 %/* Return hash value.  'casein' TRUE means case insensitive test. */
80 %  unsigned int get_hashval( bool_t casein = FALSE );
81 %};
82 #endif /* RPC_HDR */
83 #endif /* USINGC */
84 
85 #if RPC_HDR
86 %#endif /* _DB_ITEM_H */
87 #endif /* RPC_HDR */
88