-
Notifications
You must be signed in to change notification settings - Fork 1
/
datget0x.c
218 lines (166 loc) · 5.61 KB
/
datget0x.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include "hds1.h"
#include "rec.h"
#include "dat1.h"
#include "hds_types.h"
#include "dat_err.h"
#include "hds.h"
#include "f77.h" /* For CNF string "import" routine */
/*
*+
* Name:
* datGet0X
* Purpose:
* Get a scalar value from an HDS component
* Invocation:
* status = datGut0X( HDSLoc * loc, <type> value, int * status );
* Description:
* This routine reads a value from a scalar primitive object.
* There is a routine for each access type,
*
* datGet0D DOUBLE PRECISION
* datGet0R REAL / FLOAT
* datGet0I INTEGER
* datGet0W WORD / SHORT
* datGet0UW UWORD / unsigned short
* datGet0L LOGICAL
* datGet0C CHARACTER[*n]
*
* If the object data type differs from the access type, then
* conversion is performed.
*
* Note that a Vector (1-D) object containing a single value is
* different from a Scalar (0-D).
* Arguments
* HDSLoc * loc = Given
* HDS locator associated with a primitive data object.
* <type> *value = Returned
* Pointer to variable to receive the value. For string
* data types the buffer must be preallocated by the caller
* and the size of the buffer provided as a 3rd argument. The
* string will be nul-terminated on return.
* int * status = Given & Returned
* Global inherited status.
* Authors:
* Jack Giddings (UCL::JRG)
* Sid Wright (UCL::SLW)
* Dennis Kelly (REVAD::BDK)
* Alan Chipperfield (RAL::AJC)
* Tim Jenness (JAC, Hawaii)
* David Berry (JAC, Hawaii)
* History:
* 3-JAN-1983 (UCL::JRG):
* Original.
* 31-AUG-1983 (UCL::SLW):
* Standardise.
* 05-NOV-1984: (REVAD::BDK)
* Remove calls to error system
* 15-APR-1987 (RAL::AJC):
* Improved prologue layout
* 21-NOV-2005 (TIMJ):
* Rewrite in C
* 25-NOV-2005 (TIMJ):
* NUL terminate
* 4-MAR-2009 (TIMJ):
* Do not call CNF if datGetC returns bad status.
* 8-MAY-2009 (DSB):
* Call CNF if datGetC returns a status indicating that the
* returned string may still be useful.
* Notes:
* For datGet0C the buffer must be preallocated by the caller
* and the size provided as a 3rd argument. The specified string
* size must allow for the terminating nul.
* Copyright:
* Copyright (C) 2009 Science and Technology Facilities Council.
* Copyright (C) 2005 Particle Physics and Astronomy Research Council.
* All Rights Reserved.
* Licence:
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA
* Bugs:
* {note_any_bugs_here}
*-
*/
int datGet0C ( const HDSLoc * loc, char * value, size_t str_len, int * status ) {
int ndims = 0;
hdsdim dim[] = { 0 };
if ( *status != DAT__OK ) return *status;
/* Obtain the unterminated string but pass in a size one less than
the allocated size to allow us to terminate */
value[0] = '\0';
datGetC( loc, ndims, dim, value, str_len-1, status );
/* Terminate the string but first make sure we fool CNF by forcing
a ' ' as the last character in the "fortran" string */
if (*status == DAT__OK || *status == DAT__TRUNC || *status == DAT__CONER ) {
value[str_len-1] = ' ';
cnfImprt( value, str_len, value );
} else {
/* nothing to import */
value[0] = '\0';
}
return *status;
}
int datGet0D ( const HDSLoc * loc, double * value, int * status ) {
int ndims = 0;
hdsdim dim[] = { 0 };
if ( *status != DAT__OK ) return *status;
datGetD( loc, ndims, dim, value, status );
return *status;
}
int datGet0R ( const HDSLoc * loc, float * value, int * status ) {
int ndims = 0;
hdsdim dim[] = { 0 };
if ( *status != DAT__OK ) return *status;
datGetR( loc, ndims, dim, value, status );
return *status;
}
int datGet0I ( const HDSLoc * loc, int * value, int * status ) {
int ndims = 0;
hdsdim dim[] = { 0 };
if ( *status != DAT__OK ) return *status;
datGetI( loc, ndims, dim, value, status );
return *status;
}
int datGet0K ( const HDSLoc * loc, int64_t * value, int * status ) {
int ndims = 0;
hdsdim dim[] = { 0 };
if ( *status != DAT__OK ) return *status;
datGetK( loc, ndims, dim, value, status );
return *status;
}
int datGet0W ( const HDSLoc * loc, short * value, int * status ) {
int ndims = 0;
hdsdim dim[] = { 0 };
if ( *status != DAT__OK ) return *status;
datGetW( loc, ndims, dim, value, status );
return *status;
}
int datGet0UW ( const HDSLoc * loc, unsigned short * value, int * status ) {
int ndims = 0;
hdsdim dim[] = { 0 };
if ( *status != DAT__OK ) return *status;
datGetUW( loc, ndims, dim, value, status );
return *status;
}
int datGet0L ( const HDSLoc * loc, int * value, int * status ) {
int ndims = 0;
hdsdim dim[] = { 0 };
if ( *status != DAT__OK ) return *status;
datGetL( loc, ndims, dim, value, status );
return *status;
}