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
|
# This file contains tbpsta, tbtszd, and tbrlen.
include <fset.h>
include <tbset.h>
include "tbtables.h"
include "tblerr.h"
# tbpsta -- get status of table
# Get integer-valued information about a table which has been opened
# or at least initialized.
#
# Phil Hodge, 30-Sep-1987 FIO options added.
# Phil Hodge, 15-Nov-1988 Remove option to get max buffer size.
# Phil Hodge, 10-Jul-1991 Modify IF statement for TBL_DATA_SIZE.
# Phil Hodge, 8-Apr-1993 Modify for short datatype by including
# TBL_ROWLEN_CHAR and TBL_ROWLEN_CHAR_USED; round up
# for TBL_ROWLEN and TBL_ROWLEN_USED; add TBL_VERSION.
# Phil Hodge, 30-Sep-1997 Return reduced values for nrows or ncols
# if selectors were used. Add tbrlen function, and
# include tbtszd in this file.
# Phil Hodge, 7-Jun-1999 Add table subtype.
# Phil Hodge, 25-May-2000 For buffer size for a FITS table, call tbfsiz.
int procedure tbpsta (tp, param)
pointer tp # i: pointer to table descriptor
int param # i: the parameter to be determined.
#--
int value
int fstati(), tbfsiz(), tbrlen(), tbtszd()
errchk fstati, tbfsiz
begin
switch (param) {
case TBL_NROWS: # How many rows have been written?
if (TB_ROW_SELECT(tp) == YES)
value = TB_NSEL_ROWS(tp)
else
value = TB_NROWS(tp)
return (value)
case TBL_NCOLS: # How many columns have been defined?
if (TB_COLUMN_SELECT(tp) == YES)
value = TB_NSEL_COLS(tp)
else
value = TB_NCOLS(tp)
return (value)
case TBL_ROWLEN: # row length, unit = SZ_REAL
value = tbrlen (tp, param)
return ((value + SZ_REAL - 1) / SZ_REAL)
case TBL_ROWLEN_USED: # Length of row used, unit=SZ_REAL
value = tbrlen (tp, param)
return ((value + SZ_REAL - 1) / SZ_REAL)
case TBL_ROWLEN_CHAR: # row length, unit = SZ_CHAR
value = tbrlen (tp, param)
return (value)
case TBL_ROWLEN_CHAR_USED: # Length of row used, unit=SZ_CHAR
value = tbrlen (tp, param)
return (value)
case TBL_ALLROWS: # Number of allocated rows
return (TB_ALLROWS(tp))
case TBL_WHTYPE: # What type (row- or column-ordered)?
return (TB_TYPE(tp))
case TBL_SUBTYPE: # What subtype of table?
return (TB_SUBTYPE(tp))
case TBL_NPAR: # number of user parameters
return (TB_NPAR(tp))
case TBL_MAXPAR: # space allocated for user parameters
return (TB_MAXPAR(tp))
case TBL_MAXCOLS: # space allocated for column descriptors
return (TB_MAXCOLS(tp))
case TBL_VERSION:
# version number (zero indexed) of software that created the table
return (TB_VERSION(tp))
case TBL_BUFSIZE: # size of FIO buffer in chars
if ( ! TB_IS_OPEN(tp) )
call error (ER_TBNOTOPEN,
"table must be open to get buffer size")
if (TB_TYPE(tp) == TBL_TYPE_FITS)
return (tbfsiz (tp))
else
return (fstati (TB_FILE(tp), F_BUFSIZE))
case TBL_DATA_SIZE: # size of data portion of table in chars
if (TB_IS_OPEN(tp))
return (tbtszd(tp))
return (0)
default:
call error (ER_TBUNKPARAM, "unknown parameter for tbpsta")
}
end
# tbtszd -- get size of data portion
# This function returns the size in chars of the data portion of a table.
# The complete table will be larger than this, as it also contains a record
# of size information, possible header parameters, and possible column
# definitions.
# The size returned is the space used, not allocated. If row and/or column
# selectors are used, the size will be appropriately reduced.
int procedure tbtszd (tp)
pointer tp # i: pointer to table descriptor
#--
int nrows # number of selected rows
int rowlen # row length (selected columns) in chars
int tbrlen()
begin
if (TB_ROW_SELECT(tp) == YES)
nrows = TB_NSEL_ROWS(tp) # row selection is in effect
else
nrows = TB_NROWS(tp)
rowlen = tbrlen (tp, TBL_ROWLEN_USED)
return (nrows * rowlen)
end
# tbrlen -- get row length
# This function returns the row length in units of SZ_CHAR.
# If a column selector was specified, the row length includes only the
# selected columns, and it is independent of the param argument.
# If no column selector is in effect, the row length returned will be
# either the allocated length or used length, depending on whether the
# param argument is TBL_ROWLEN or TBL_ROWLEN_USED respectively.
# (Values are returned in units of SZ_CHAR regardless of the _CHAR
# suffix in this routine.)
int procedure tbrlen (tp, param)
pointer tp # i: pointer to table descriptor
int param # i: either TBL_ROWLEN or TBL_ROWLEN_USED
#--
pointer cp
int value
int colnum, tcs_column()
begin
if (TB_COLUMN_SELECT(tp) == YES) {
# Column selection is in effect.
value = 0
do colnum = 1, TB_NSEL_COLS(tp) {
cp = tcs_column (TB_SELCOL(tp,colnum))
value = value + COL_LEN(cp)
}
} else {
if (param == TBL_ROWLEN || param == TBL_ROWLEN_CHAR)
value = TB_ROWLEN(tp)
else if (param == TBL_ROWLEN_USED || param == TBL_ROWLEN_CHAR_USED)
value = TB_COLUSED(tp)
else
value = 0
}
return (value)
end
|