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 $ */
30 * Copyright (c) 1988 by Sun Microsystems, Inc.
37 * NetISAM minimum and maximum values functions
40 #include "isam_impl.h"
42 static unsigned char ismaxlongarr[LONGSIZE] = ISMAXLONG;
43 static unsigned char isminlongarr[LONGSIZE] = ISMINLONG;
45 static unsigned char ismaxshortarr[SHORTSIZE] = ISMAXSHORT;
46 static unsigned char isminshortarr[SHORTSIZE] = ISMINSHORT;
48 static unsigned char ismaxdoublearr[DOUBLESIZE] = ISMAXDOUBLE;
49 static unsigned char ismindoublearr[DOUBLESIZE] = ISMINDOUBLE;
51 static unsigned char ismaxfloatarr[FLOATSIZE] = ISMAXFLOAT;
52 static unsigned char isminfloatarr[FLOATSIZE] = ISMINFLOAT;
54 /* These two are used globally. */
55 long *ismaxlong = (long *)ismaxlongarr;
56 long *isminlong = (long *)isminlongarr;
58 static short *ismaxshort = (short *)ismaxshortarr;
59 static short *isminshort = (short *)isminshortarr;
61 static double *ismaxdouble = (double *)ismaxdoublearr;
62 static double *ismindouble = (double *)ismindoublearr;
64 static float *ismaxfloat = (float *)ismaxfloatarr;
65 static float *isminfloat = (float *)isminfloatarr;
71 * Fill key buffer with maximum values
75 _iskey_fillmax(struct keydesc2 *pkeydesc2, char *keybuf)
78 struct keypart2 *ppart;
81 nparts = pkeydesc2->k2_nparts;
82 ppart = pkeydesc2->k2_part;
84 for (i = 0; i < nparts + 1;i++) { /* +1 is for recnum part */
85 switch (ppart->kp2_type) {
87 (void) memset (keybuf + ppart->kp2_offset, ISMAXCHAR,
91 (void) memset (keybuf + ppart->kp2_offset, ISMAXBIN,
95 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxlong, LONGSIZE);
98 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxshort, SHORTSIZE);
101 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxfloat, FLOATSIZE);
104 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxdouble, DOUBLESIZE);
107 case CHARTYPE + ISDESC:
108 (void) memset (keybuf + ppart->kp2_offset, ISMINCHAR,
111 case BINTYPE + ISDESC:
112 (void) memset (keybuf + ppart->kp2_offset, ISMINBIN,
115 case LONGTYPE + ISDESC:
116 memcpy ( keybuf + ppart->kp2_offset,(char *)isminlong, LONGSIZE);
118 case SHORTTYPE + ISDESC:
119 memcpy ( keybuf + ppart->kp2_offset,(char *)isminshort, SHORTSIZE);
121 case FLOATTYPE + ISDESC:
122 memcpy ( keybuf + ppart->kp2_offset,(char *)isminfloat, FLOATSIZE);
124 case DOUBLETYPE + ISDESC:
125 memcpy ( keybuf + ppart->kp2_offset,(char *)ismindouble, DOUBLESIZE);
128 _isfatal_error("_iskey_fillmax");
137 * Fill key buffer with minimum values
141 _iskey_fillmin(struct keydesc2 *pkeydesc2, char *keybuf)
144 struct keypart2 *ppart;
147 nparts = pkeydesc2->k2_nparts;
148 ppart = pkeydesc2->k2_part;
150 for (i = 0; i < nparts + 1;i++) { /* +1 is for recnum part */
151 switch (ppart->kp2_type) {
153 (void) memset (keybuf + ppart->kp2_offset, ISMINCHAR,
157 (void) memset (keybuf + ppart->kp2_offset, ISMINBIN,
161 memcpy ( keybuf + ppart->kp2_offset,(char *)isminlong, LONGSIZE);
164 memcpy ( keybuf + ppart->kp2_offset,(char *)isminshort, SHORTSIZE);
167 memcpy ( keybuf + ppart->kp2_offset,(char *)isminfloat, FLOATSIZE);
170 memcpy ( keybuf + ppart->kp2_offset,(char *)ismindouble, DOUBLESIZE);
173 case CHARTYPE + ISDESC:
174 (void) memset (keybuf + ppart->kp2_offset, ISMAXCHAR,
177 case BINTYPE + ISDESC:
178 (void) memset (keybuf + ppart->kp2_offset, ISMAXBIN,
181 case LONGTYPE + ISDESC:
182 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxlong, LONGSIZE);
184 case SHORTTYPE + ISDESC:
185 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxshort, SHORTSIZE);
187 case FLOATTYPE + ISDESC:
188 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxfloat, FLOATSIZE);
190 case DOUBLETYPE + ISDESC:
191 memcpy ( keybuf + ppart->kp2_offset,(char *)ismaxdouble, DOUBLESIZE);
194 _isfatal_error("_iskey_fillmin");