-
Notifications
You must be signed in to change notification settings - Fork 1
/
datRefct.c
110 lines (90 loc) · 3.34 KB
/
datRefct.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include "f77.h" /* F77 <-> C interface macros */
#include "cnf.h" /* F77 <-> C string handling functions */
#include "ems.h" /* EMS error reporting routines */
#include "ems_par.h" /* EMS public constants */
#include "hds1.h" /* Global definitions for HDS */
#include "rec.h" /* Public rec_ definitions */
#include "dat1.h" /* Internal dat_ definitions */
#include "dat_err.h" /* DAT__ error code definitions */
#include "hds.h"
int
datRefct(const HDSLoc *loc,
int *refct,
int *status)
{
/*
*+
* Name:
* DAT_REFCT
* Purpose:
* Enquire the reference count for a container file.
* Language:
* ANSI C
* Invocation:
* CALL DAT_REFCT( LOC, REFCT, STATUS )
* Description:
* The routine returns a count of the number of "primary" locators
* associated with an HDS container file (its reference count). The
* file will remain open for as long as this number is greater than
* zero.
* Arguments:
* LOC = CHARACTER * ( * ) (Given)
* Locator associated with any object in the container file.
* REFCT = INTEGER (Returned)
* Number of primary locators currently associated with the file.
* STATUS = INTEGER (Given and Returned)
* The global status.
* Notes:
* This routine may be used to determine whether annulling a primary
* locator will cause a container file to be closed (also see the
* routine DAT_PRMRY).
* Copyright:
* Copyright (C) 1992 Science & Engineering Research Council
* Authors:
* RFWS: R.F. Warren-Smith (STARLINK, RAL)
* BKM: B.K. McIlwrath (STARLINK, RAL)
* {enter_new_authors_here}
* History:
* 25-SEP-1992 (RFWS):
* Original version.
* 23-APR-2002 (BKM);
* C-callable version.
* {enter_changes_here}
* Bugs:
* {note_any_bugs_here}
*-
*/
/* Local Variables: */
int refcnt; /* Container file reference count */
struct LCP *lcp; /* Pointer to LCP */
/*. */
/* Check the inherited global status. */
if ( !_ok( *status ) ) return *status;
hds_gl_status = *status;
/* Import the locator. */
dat1_import_loc(loc, &lcp );
if ( _ok( hds_gl_status ) )
{
/* Obtain the reference count for the container file and copy it to the */
/* returned argument. */
rec_refcnt( &lcp->data.han, 0, &refcnt, &hds_gl_status );
if ( _ok( hds_gl_status ) )
{
*refct = refcnt;
}
}
/* If an error occurred, then report contextual information. */
if ( !_ok( hds_gl_status ) )
{
emsRep( "DAT_REFCT_ERR",
"DAT_REFCT: Error enquiring the reference count for a \
container file.",
&hds_gl_status );
}
/* Return the current global status value. */
*status = hds_gl_status;
return *status;
}