Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtSearch / raima / recread.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: recread.c /main/2 1996/05/09 04:15:18 drk $ */
24 /*
25  *   COMPONENT_NAME: austext
26  *
27  *   FUNCTIONS: d_recread
28  *
29  *   ORIGINS: 157
30  *
31  *   OBJECT CODE ONLY SOURCE MATERIALS
32  */
33 /*-----------------------------------------------------------------------
34    recread.c -- db_VISTA current record read module.
35
36    (C) Copyright 1987 by Raima Corporation.
37 -----------------------------------------------------------------------*/
38
39 /* ********************** EDIT HISTORY *******************************
40
41  SCR    DATE    INI                   DESCRIPTION
42 ----- --------- --- -----------------------------------------------------
43   103 27-Jun-88 RSC Improve generation of single user version
44       04-Aug-88 RTK MULTI_TASK changes
45 */
46
47 #include <stdio.h>
48 #include "vista.h"
49 #include "dbtype.h"
50
51
52 /* Read contents of current record
53 */
54 d_recread(rec TASK_PARM DBN_PARM)
55 char FAR *rec; /* ptr to record area */
56 TASK_DECL
57 DBN_DECL
58 {
59    INT  rt;     /* record type */
60    DB_ADDR dba;
61 #ifndef SINGLE_USER
62    int dbopen_sv;
63 #endif
64    RECORD_ENTRY FAR *rec_ptr;
65
66    DB_ENTER(DB_ID TASK_ID LOCK_SET(RECORD_IO));
67
68    if ( ! dbopen ) RETURN( dberr(S_DBOPEN) );
69
70    /* Make sure we have a current record */
71    if ( ! curr_rec )
72       RETURN( dberr(S_NOCR) );
73
74    /* set up to allow unlocked read access */
75 #ifndef SINGLE_USER
76    dbopen_sv = dbopen;
77    dbopen = 2;
78 #endif
79
80    /* read current record */
81    dio_read( curr_rec, (char FAR * FAR *)&crloc, NOPGHOLD);
82 #ifndef SINGLE_USER
83    dbopen = dbopen_sv;
84 #endif
85    if ( db_status != S_OKAY )
86       RETURN( db_status );
87
88    /* copy record type from record */
89    bytecpy(&rt, crloc, sizeof(INT));
90    if ( rt < 0 )
91       RETURN( db_status = S_DELETED );
92
93 #ifndef SINGLE_USER
94    if ( rt & RLBMASK ) {
95       rt &= ~RLBMASK; /* mask off rlb */
96       rlb_status = S_LOCKED;
97    }
98    else {
99       rlb_status = S_UNLOCKED;
100    }
101 #endif
102    rec_ptr = &record_table[NUM2INT(rt, rt_offset)];
103
104    /* Copy db_addr from record and check with curr_rec */
105    bytecpy(&dba, crloc+sizeof(INT), DB_ADDR_SIZE);
106    if ( ADDRcmp(&dba, &curr_rec) != 0 )
107       RETURN( dberr(S_INVADDR) );
108
109    /* Copy data from crloc into rec */
110    bytecpy(rec, &crloc[rec_ptr->rt_data], rec_ptr->rt_len - rec_ptr->rt_data);
111
112    RETURN( db_status = S_OKAY );
113 }
114 /* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin recread.c */