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