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 librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: keyfind.c /main/2 1996/05/09 04:09:43 drk $ */
25 * COMPONENT_NAME: austext
33 * OBJECT CODE ONLY SOURCE MATERIALS
35 /*-----------------------------------------------------------------------
36 keyfind.c -- db_VISTA key find module.
38 (C) Copyright 1987 by Raima Corporation.
39 -----------------------------------------------------------------------*/
41 /* ********************** EDIT HISTORY *******************************
43 SCR DATE INI DESCRIPTION
44 ----- --------- --- -----------------------------------------------------
45 04-Aug-88 RTK MULTI_TASK changes
46 310 10-Aug-88 RSC Cleanup function prototype.
53 /* Internal function prototypes */
54 static void chk_desc_key(P1(int) Pi(FIELD_ENTRY FAR *)
55 Pi(CONST char FAR *) Pi(char FAR *));
57 /* Find record thru key field
59 d_keyfind(field, fldval TASK_PARM DBN_PARM)
60 long field; /* field constant */
61 CONST char FAR *fldval; /* value of the data field */
63 DBN_DECL /* database number */
67 RECORD_ENTRY FAR *rec_ptr;
68 FIELD_ENTRY FAR *fld_ptr;
71 DB_ENTER(DB_ID TASK_ID LOCK_SET(RECORD_IO));
73 if ((nfld_check(field, &rec, &fld, (RECORD_ENTRY FAR * FAR *)&rec_ptr, (FIELD_ENTRY FAR * FAR *)&fld_ptr) != S_OKAY) ||
74 /* initialize key function operation */
75 (key_init(fld) != S_OKAY))
79 key_boundary(KEYFIND, &dba);
81 /* locate record with specified key */
82 if (fld_ptr->fd_type == 'k') {
83 chk_desc_key(fld, fld_ptr, fldval, ckey);
87 if ( key_locpos( fldval, &dba ) != S_OKAY )
90 /* set current record to found db addr */
95 if ( curr_rec && db_tsrecs )
96 d_utscr( &cr_time TASK_PARM );
98 RETURN( db_status = S_OKAY );
102 /* Check compound key value for descending fields
104 static void chk_desc_key(fld, fld_ptr, fldval, ckey)
106 FIELD_ENTRY FAR *fld_ptr;
107 CONST char FAR *fldval;
110 register int kt_lc; /* loop control */
117 FIELD_ENTRY FAR *kfld_ptr;
118 register KEY_ENTRY FAR *key_ptr;
120 /* complement descending compound key values */
121 for (kt_lc = size_kt - fld_ptr->fd_ptr,
122 key_ptr = &key_table[fld_ptr->fd_ptr];
123 (--kt_lc >= 0) && (key_ptr->kt_key == fld); ++key_ptr) {
124 kfld_ptr = &field_table[key_ptr->kt_field];
125 fptr = (char FAR *)fldval + key_ptr->kt_ptr;
126 tptr = ckey + key_ptr->kt_ptr;
127 if ( key_ptr->kt_sort == 'd' ) {
128 switch ( kfld_ptr->fd_type ) {
131 bytecpy(&fv, fptr, sizeof(float));
132 fv = (float)0.0 - fv;
133 bytecpy(fptr, &fv, sizeof(float));
136 bytecpy(&dv, fptr, sizeof(double));
138 bytecpy(fptr, &dv, sizeof(double));
142 key_cmpcpy(tptr, fptr, kfld_ptr->fd_len);
143 if ( kfld_ptr->fd_dim[0] > 1 && kfld_ptr->fd_dim[1] == 0 ) {
144 /* make sure a null byte is at the end */
145 tptr[kfld_ptr->fd_len-1] = '\0';
149 key_cmpcpy(tptr, fptr, kfld_ptr->fd_len);
153 bytecpy(tptr, fptr, kfld_ptr->fd_len);
156 /* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin keyfind.c */