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: isminmax.c /main/3 1995/10/23 11:42:16 rswiston $ */
29 static char sccsid[] = "@(#)isminmax.c 1.4 89/07/17 Copyr 1988 Sun Micro";
33 * Copyright (c) 1988 by Sun Microsystems, Inc.
40 * NetISAM minimum and maximum values functions
43 #include "isam_impl.h"
45 static unsigned char ismaxlongarr[LONGSIZE] = ISMAXLONG;
46 static unsigned char isminlongarr[LONGSIZE] = ISMINLONG;
48 static unsigned char ismaxshortarr[SHORTSIZE] = ISMAXSHORT;
49 static unsigned char isminshortarr[SHORTSIZE] = ISMINSHORT;
51 static unsigned char ismaxdoublearr[DOUBLESIZE] = ISMAXDOUBLE;
52 static unsigned char ismindoublearr[DOUBLESIZE] = ISMINDOUBLE;
54 static unsigned char ismaxfloatarr[FLOATSIZE] = ISMAXFLOAT;
55 static unsigned char isminfloatarr[FLOATSIZE] = ISMINFLOAT;
57 /* These two are used globally. */
58 long *ismaxlong = (long *)ismaxlongarr;
59 long *isminlong = (long *)isminlongarr;
61 static short *ismaxshort = (short *)ismaxshortarr;
62 static short *isminshort = (short *)isminshortarr;
64 static double *ismaxdouble = (double *)ismaxdoublearr;
65 static double *ismindouble = (double *)ismindoublearr;
67 static float *ismaxfloat = (float *)ismaxfloatarr;
68 static float *isminfloat = (float *)isminfloatarr;
74 * Fill key buffer with maximum values
78 _iskey_fillmax(struct keydesc2 *pkeydesc2, register char *keybuf)
81 register struct keypart2 *ppart;
84 nparts = pkeydesc2->k2_nparts;
85 ppart = pkeydesc2->k2_part;
87 for (i = 0; i < nparts + 1;i++) { /* +1 is for recnum part */
88 switch (ppart->kp2_type) {
90 (void) memset (keybuf + ppart->kp2_offset, ISMAXCHAR,
94 (void) memset (keybuf + ppart->kp2_offset, ISMAXBIN,
98 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxlong, LONGSIZE);
101 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxshort, SHORTSIZE);
104 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxfloat, FLOATSIZE);
107 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxdouble, DOUBLESIZE);
110 case CHARTYPE + ISDESC:
111 (void) memset (keybuf + ppart->kp2_offset, ISMINCHAR,
114 case BINTYPE + ISDESC:
115 (void) memset (keybuf + ppart->kp2_offset, ISMINBIN,
118 case LONGTYPE + ISDESC:
119 memcpy ( keybuf + ppart->kp2_offset,(char *)isminlong, LONGSIZE);
121 case SHORTTYPE + ISDESC:
122 memcpy ( keybuf + ppart->kp2_offset,(char *)isminshort, SHORTSIZE);
124 case FLOATTYPE + ISDESC:
125 memcpy ( keybuf + ppart->kp2_offset,(char *)isminfloat, FLOATSIZE);
127 case DOUBLETYPE + ISDESC:
128 memcpy ( keybuf + ppart->kp2_offset,(char *)ismindouble, DOUBLESIZE);
131 _isfatal_error("_iskey_fillmax");
140 * Fill key buffer with minimum values
144 _iskey_fillmin(struct keydesc2 *pkeydesc2, register char *keybuf)
147 register struct keypart2 *ppart;
150 nparts = pkeydesc2->k2_nparts;
151 ppart = pkeydesc2->k2_part;
153 for (i = 0; i < nparts + 1;i++) { /* +1 is for recnum part */
154 switch (ppart->kp2_type) {
156 (void) memset (keybuf + ppart->kp2_offset, ISMINCHAR,
160 (void) memset (keybuf + ppart->kp2_offset, ISMINBIN,
164 memcpy ( keybuf + ppart->kp2_offset,(char *)isminlong, LONGSIZE);
167 memcpy ( keybuf + ppart->kp2_offset,(char *)isminshort, SHORTSIZE);
170 memcpy ( keybuf + ppart->kp2_offset,(char *)isminfloat, FLOATSIZE);
173 memcpy ( keybuf + ppart->kp2_offset,(char *)ismindouble, DOUBLESIZE);
176 case CHARTYPE + ISDESC:
177 (void) memset (keybuf + ppart->kp2_offset, ISMAXCHAR,
180 case BINTYPE + ISDESC:
181 (void) memset (keybuf + ppart->kp2_offset, ISMAXBIN,
184 case LONGTYPE + ISDESC:
185 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxlong, LONGSIZE);
187 case SHORTTYPE + ISDESC:
188 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxshort, SHORTSIZE);
190 case FLOATTYPE + ISDESC:
191 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxfloat, FLOATSIZE);
193 case DOUBLETYPE + ISDESC:
194 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxdouble, DOUBLESIZE);
197 _isfatal_error("_iskey_fillmin");