aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/catquery/cqget.x
blob: ea259bb5a4e5b2f4b13aad21a8fcdfcf9b339770 (plain) (blame)
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
219
220
221
222
223
224
225
include "cqdef.h"
include "cq.h"

# These routines fetch fields from the catalog configuation by field name.
# They can be used by the calling program to read quantities of interest
# directly from the configuration file. In most applications it should
# not be necessary to use these routines as the main interface routines
# provide most of the desired functionality, but they are included for
# completeness.

# CQ_FGETI -- Fetch an integer field from the current catalog.

int procedure cq_fgeti (cq, field)

pointer	cq				#I the catalog descriptor
char	field[ARB]			#I the field name

int	ival
int	cq_dgeti()
errchk	cq_dgeti()

begin
	if (CQ_CAT(cq) == NULL)
	    call error (0, "The current catalog is undefined")
	if (CQ_CATNO(cq) < 1 || CQ_CATNO(cq) > CQ_NRECS(cq))
	    call error (0, "The current catalog is undefined")

	ival = cq_dgeti (cq, CQ_CATNO(cq), field)

	return (ival)
end


# CQ_FGETR -- Fetch a real field from the current catalog.

real procedure cq_fgetr (cq, field)

pointer	cq				#I the catalog descriptor
char	field[ARB]			#I the field name

real	rval
real	cq_dgetr()
errchk	cq_dgetr()

begin
	if (CQ_CAT(cq) == NULL)
	    call error (0, "The current catalog is undefined")
	if (CQ_CATNO(cq) < 1 || CQ_CATNO(cq) > CQ_NRECS(cq))
	    call error (0, "The current catalog is undefined")

	rval = cq_dgetr (cq, CQ_CATNO(cq), field)

	return (rval)
end


# CQ_FGETD -- Fetch a double precision field from the current catalog.

double procedure cq_fgetd (cq, field)

pointer	cq				#I the catalog descriptor
char	field[ARB]			#I the field name

double	dval
double	cq_dgetd()
errchk	cq_dgetd()

begin
	if (CQ_CAT(cq) == NULL)
	    call error (0, "The current catalog is undefined")
	if (CQ_CATNO(cq) < 1 || CQ_CATNO(cq) > CQ_NRECS(cq))
	    call error (0, "The current catalog is undefined")

	dval = cq_dgetd (cq, CQ_CATNO(cq), field)

	return (dval)
end


# CQ_FGAI -- Get an array valued integer parameter.

int procedure cq_fgai (cq, field, array, max_len)

pointer	cq				#I the catalog descriptor
char	field[ARB]			#I the field name
int	array[ARB]			#O the output array
int	max_len				#I the maximum length of the array

int	npts

begin
	if (CQ_CAT(cq) == NULL)
	    call error (0, "The current catalog is undefined")
	if (CQ_CATNO(cq) < 1 || CQ_CATNO(cq) > CQ_NRECS(cq))
	    call error (0, "The current catalog is undefined")

	call cq_dgai (cq, CQ_CATNO(cq), field, array, max_len, npts)

	return (npts)
end


# CQ_FGAR -- Get an array valued real parameter.

int procedure cq_fgar (cq, field, array, max_len)

pointer	cq				#I the catalog descriptor
char	field[ARB]			#I the field name
real	array[ARB]			#O the output array
int	max_len				#I the maximum length of the array

int	npts

begin
	if (CQ_CAT(cq) == NULL)
	    call error (0, "The current catalog is undefined")
	if (CQ_CATNO(cq) < 1 || CQ_CATNO(cq) > CQ_NRECS(cq))
	    call error (0, "The current catalog is undefined")

	call cq_dgar (cq, CQ_CATNO(cq), field, array, max_len, npts)

	return (npts)
end


# CQ_FGAD -- Get an array valued double parameter.

int procedure cq_fgad (cq, field, array, max_len)

pointer	cq				#I the catalog descriptor
char	field[ARB]			#I the field name
double	array[ARB]			#O the output array
int	max_len				#I the maximum length of the array

int	npts

begin
	if (CQ_CAT(cq) == NULL)
	    call error (0, "The current catalog is undefined")
	if (CQ_CATNO(cq) < 1 || CQ_CATNO(cq) > CQ_NRECS(cq))
	    call error (0, "The current catalog is undefined")

	call cq_dgad (cq, CQ_CATNO(cq), field, array, max_len, npts)

	return (npts)
end


# CQ_FGWRD -- Fetch a single word field from the current catalog.

procedure cq_fgwrd (cq, field, str, maxch)

pointer	cq				#I the catalog descriptor
char	field[ARB]			#I the field name
char	str[ARB]			#O the output string
int	maxch				#I the maximum number of characters

errchk	cq_dgwrd()

begin
	if (CQ_CAT(cq) == NULL)
	    call error (0, "The current catalog is undefined")
	if (CQ_CATNO(cq) < 1 || CQ_CATNO(cq) > CQ_NRECS(cq))
	    call error (0, "The current catalog is undefined")

	call cq_dgwrd (cq, CQ_CATNO(cq), field, str, maxch)
end


# CQ_FGSTR -- Fetch a string field from the current catalog.

procedure cq_fgstr (cq, field, str, maxch)

pointer	cq				#I the catalog descriptor
char	field[ARB]			#I the field name
char	str[ARB]			#O the output string
int	maxch				#I the maximum number of characters

errchk	cq_dgwrd()

begin
	if (CQ_CAT(cq) == NULL)
	    call error (0, "The current catalog is undefined")
	if (CQ_CATNO(cq) < 1 || CQ_CATNO(cq) > CQ_NRECS(cq))
	    call error (0, "The current catalog is undefined")

	call cq_dgstr (cq, CQ_CATNO(cq), field, str, maxch)
end


# CQ_FGTEXT -- Fetch a multi-line text field from the current catalog.

int procedure cq_fgtext (cq, field, str, maxch)

pointer	cq				#I the catalog descriptor
char	field[ARB]			#I the field name
char	str[ARB]			#O the output string
int	maxch				#I the maximum number of characters

int	nlines
errchk	cq_dgatxt()

begin
	if (CQ_CAT(cq) == NULL)
	    call error (0, "The current catalog is undefined")
	if (CQ_CATNO(cq) < 1 || CQ_CATNO(cq) > CQ_NRECS(cq))
	    call error (0, "The current catalog is undefined")

	call cq_dgatxt (cq, CQ_CATNO(cq), field, str, maxch, nlines)

	return (nlines)
end


# CQ_SCAN -- Scan the database at the current position.

int procedure cq_scan (cq)

pointer cq                              # The catalog database descriptor.

int     fscan()

begin
        return (fscan (CQ_FD(cq)))
end