Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtSearch / raima / csowrite.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $XConsortium: csowrite.c /main/2 1996/05/09 04:00:40 drk $ */
24 /*
25  *   COMPONENT_NAME: austext
26  *
27  *   FUNCTIONS: d_csowrite
28  *
29  *   ORIGINS: 157
30  *
31  *   OBJECT CODE ONLY SOURCE MATERIALS
32  */
33 /*-----------------------------------------------------------------------
34    csowrite.c -- db_VISTA current set owner field write module.
35
36    (C) Copyright 1987 by Raima Corporation.
37 -----------------------------------------------------------------------*/
38
39 /* ********************** EDIT HISTORY *******************************
40
41  SCR    DATE    INI                   DESCRIPTION
42 ----- --------- --- -----------------------------------------------------
43       04-Aug-88 RTK MULTI_TASK changes
44 */
45
46 #include <stdio.h>
47 #include "vista.h"
48 #include "dbtype.h"
49
50
51 /* Write data to a field in the current set owner
52 */
53 d_csowrite(set, field, data TASK_PARM DBN_PARM)
54 int set;    /* Set constant */
55 long field; /* Field constant */
56 CONST char FAR *data; /* Data area to contain field contents */
57 TASK_DECL
58 DBN_DECL    /* database number */
59 {
60 #ifndef  NO_TIMESTAMP
61    ULONG timestamp;
62 #endif
63    int stat, fld, rec;
64    char FAR *recp;
65    SET_ENTRY FAR *set_ptr;
66    RECORD_ENTRY FAR *rec_ptr;
67    FIELD_ENTRY FAR *fld_ptr;
68    DB_ADDR FAR *co_ptr;
69
70    DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
71
72    if ((nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY) ||
73        (nfld_check(field, &rec, &fld, (RECORD_ENTRY FAR * FAR *)&rec_ptr, (FIELD_ENTRY FAR * FAR *)&fld_ptr) != S_OKAY))
74       RETURN( db_status );
75
76    /* compound keys cannot be updated directly */
77    if ( fld_ptr->fd_type == COMKEY )
78       RETURN( dberr(S_ISCOMKEY) );
79    
80    /* field used in compound keys cannot be updated directly */
81    if ( fld_ptr->fd_flags & COMKEYED )
82       RETURN( dberr(S_COMKEY) );
83
84    /* Make sure we have a current owner */
85    if ( ! *(co_ptr = &curr_own[set]) )
86       RETURN( dberr(S_NOCO) );
87
88    /* Read current owner */
89    if ( dio_read( *co_ptr, (char FAR * FAR *)&recp , PGHOLD) != S_OKAY )
90       RETURN( db_status );
91   
92    /* check out the field */
93    if ( (stat = r_chkfld(fld, fld_ptr, recp, data)) != S_OKAY ) {
94       dio_release(*co_ptr);
95       RETURN( db_status = stat );
96    }
97    /* Put data into record */
98    if ( r_pfld(fld, fld_ptr, recp, data, co_ptr) != S_OKAY )
99       RETURN( db_status );
100 #ifndef  NO_TIMESTAMP
101    /* check for timestamp */
102    if ( rec_ptr->rt_flags & TIMESTAMPED ) {
103       timestamp = dio_pzgetts(rec_ptr->rt_file);
104       bytecpy( recp + RECUPTIME, &timestamp, sizeof(LONG));
105    }
106 #endif
107    dio_write(*co_ptr, (char FAR *)NULL, PGFREE);
108 #ifndef  NO_TIMESTAMP
109    if (( db_status == S_OKAY ) && ( rec_ptr->rt_flags & TIMESTAMPED ))
110       co_time[set] = timestamp;
111 #endif
112    RETURN( db_status );
113 }
114 /* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin csowrite.c */