2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
24 /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
25 /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
26 /*%% (c) Copyright 1993, 1994 Novell, Inc. */
27 /*%% $XConsortium: isindexconv.c /main/3 1995/10/23 11:40:48 rswiston $ */
29 * Copyright (c) 1988 by Sun Microsystems, Inc.
36 * Encode/decode key descriptor
39 #include "isam_impl.h"
42 stkey(Keydesc2 *pkeydesc2, char *p)
45 struct keypart2 *ppart;
49 stshort(pkeydesc2->k2_flags, p + K2_FLAGS_OFF);
50 stshort(pkeydesc2->k2_nparts, p + K2_NPARTS_OFF);
51 stshort(pkeydesc2->k2_len, p + K2_LEN_OFF);
52 stblkno(pkeydesc2->k2_rootnode, p + K2_ROOT_OFF);
53 stlong((long)pkeydesc2->k2_keyid, p + K2_KEYID_OFF);
55 ppart = pkeydesc2->k2_part;
56 pp = p + K2_KEYPART_OFF;
57 nparts = pkeydesc2->k2_nparts + 1; /* +1 for recno part */
59 if (ALLOWS_DUPS2(pkeydesc2)) /* +1 for dups serial number*/
62 for (i = 0; i < nparts;i++) {
63 stshort(ppart->kp2_start, pp);
66 stshort(ppart->kp2_leng, pp);
69 stshort(ppart->kp2_type, pp);
72 stshort(ppart->kp2_offset, pp);
80 ldkey(struct keydesc2 *pkeydesc2, char *p)
83 struct keypart2 *ppart;
87 memset ((char *) pkeydesc2, 0, sizeof (*pkeydesc2));
88 pkeydesc2->k2_flags = ldshort(p + K2_FLAGS_OFF);
89 pkeydesc2->k2_nparts = ldshort(p + K2_NPARTS_OFF);
90 pkeydesc2->k2_len = ldshort(p + K2_LEN_OFF);
91 pkeydesc2->k2_rootnode = ldblkno(p + K2_ROOT_OFF);
92 pkeydesc2->k2_keyid = ldlong(p + K2_KEYID_OFF);
94 ppart = pkeydesc2->k2_part;
95 pp = p + K2_KEYPART_OFF;
96 nparts = pkeydesc2->k2_nparts + 1; /* +1 for recno part */
98 if (ALLOWS_DUPS2(pkeydesc2)) /* +1 for dups serial number*/
101 for (i = 0; i < nparts;i++) {
102 ppart->kp2_start = ldunshort(pp);
105 ppart->kp2_leng = ldshort(pp);
108 ppart->kp2_type = ldshort(pp);
111 ppart->kp2_offset = ldunshort(pp);