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: fillnew.c /main/3 1996/08/12 12:33:46 cde-ibm $ */
25 * COMPONENT_NAME: austext
27 * FUNCTIONS: d_fillnew
31 * OBJECT CODE ONLY SOURCE MATERIALS
33 /*-----------------------------------------------------------------------
34 fillnew.c -- db_VISTA (filled) record creation module
36 (C) Copyright 1987 by Raima Corp.
37 -----------------------------------------------------------------------*/
39 /* ********************** EDIT HISTORY *******************************
41 SCR DATE INI DESCRIPTION
42 ----- --------- --- -----------------------------------------------------
43 158 15-JUN-88 RSC inform key_bldcom NOT to complement compound keys
44 04-Aug-88 RTK MULTI_TASK changes
55 /* Create and fill a new record
57 d_fillnew( nrec, recval TASK_PARM DBN_PARM )
58 int nrec; /* record number */
59 CONST char FAR *recval; /* record value */
61 DBN_DECL /* database number */
72 RECORD_ENTRY FAR *rec_ptr;
73 FIELD_ENTRY FAR *fld_ptr;
76 DB_ENTER(DB_ID TASK_ID LOCK_SET(RECORD_IO));
78 if (nrec_check(nrec, &nrec, (RECORD_ENTRY FAR * FAR *)&rec_ptr) != S_OKAY)
80 recnum = NUM2EXT(nrec, rt_offset);
82 /* check for duplicate keys */
84 for (fld = rec_ptr->rt_fields, fldtot = fld + rec_ptr->rt_fdtot,
85 fld_ptr = &field_table[fld];
86 (fld < fldtot) || (fld_ptr->fd_type == COMKEY);
88 if ((fld_ptr->fd_key == UNIQUE) && !(fld_ptr->fd_flags & OPTKEYMASK)) {
89 if (fld_ptr->fd_type != COMKEY)
90 ptr = (char FAR *)recval + fld_ptr->fd_ptr - rec_ptr->rt_data;
92 key_bldcom(fld, (char FAR *)recval, ptr = key, FALSE); /* Don't complement */
93 d_keyfind(FLDMARK*(long)recnum + (fld - rec_ptr->rt_fields), ptr
96 if ( db_status == S_OKAY )
97 RETURN( db_status = S_DUPLICATE );
100 /* pull out the file number */
101 file = rec_ptr->rt_file;
102 db_addr = (NUM2EXT(file, ft_offset) & FILEMASK) << FILESHIFT;
104 /* select a record pointer to use */
105 if ( dio_pzalloc(file, &rec_addr) != S_OKAY )
111 if (dio_read(db_addr, (char FAR * FAR *)&ptr, PGHOLD) != S_OKAY)
114 /* zero fill the record */
115 byteset(ptr, 0, rec_ptr->rt_len);
117 /* place the record number and db_addr at the start of the record */
118 bytecpy( ptr, &recnum, sizeof(INT) );
119 bytecpy( ptr+sizeof(INT), &db_addr, DB_ADDR_SIZE );
121 /* check for timestamp */
122 if ( rec_ptr->rt_flags & TIMESTAMPED ) {
123 timestamp = dio_pzgetts(file);
124 bytecpy( ptr + RECCRTIME, ×tamp, sizeof(LONG));
125 bytecpy( ptr + RECUPTIME, ×tamp, sizeof(LONG));
129 /* copy the record value into place */
130 bytecpy( ptr+rec_ptr->rt_data, recval, rec_ptr->rt_len-rec_ptr->rt_data );
132 /* for each keyed field, enter the key value into the key file */
133 for (fld = rec_ptr->rt_fields, fldtot = fld + rec_ptr->rt_fdtot,
134 fld_ptr = &field_table[fld];
135 (fld < fldtot) || (fld_ptr->fd_type == COMKEY);
137 if ((fld_ptr->fd_key != 'n') && !(fld_ptr->fd_flags & OPTKEYMASK)) {
138 if ( fld_ptr->fd_type != COMKEY )
139 ptr = (char FAR *)recval + fld_ptr->fd_ptr - rec_ptr->rt_data;
141 key_bldcom(fld, (char FAR *)recval, ptr = key, TRUE);
142 if ((stat = key_insert(fld, ptr, db_addr)) != S_OKAY) {
143 r_delrec( nrec, db_addr );
144 dio_write(db_addr, NULL, PGFREE);
145 RETURN( db_status = stat );
149 /* 'touch' page, do page's update housekeeping */
150 if ( dio_write(db_addr, NULL, PGFREE) == S_OKAY ) {
154 if ( db_tsrecs ) cr_time = timestamp;
159 /* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin fillnew.c */