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
|
##
# SPPINFO -- SPP test program to print the structure of a votable.
#
# @file votget_spp.x
# @author M. Fitzpatrick
# @date 4/16/2011
task info = t_info
include "sppvotable.h"
define DEF_FILE "sample.xml"
# INFO -- Trivial SPP task to print the structure of a VOTable. This is
# similar to the C program of the same name.
procedure t_info ()
char fname[SZ_FNAME]
char name[SZ_FNAME], ucd[SZ_FNAME], desc[SZ_LINE], value[SZ_LINE]
int vot, res, tab, data, tdata, field, handle
int i, len, ncols, nrows
bool verbose, clgetb()
int vx_openVOTABLE()
int vx_getRESOURCE(), vx_getTABLE(), vx_getDATA(), vx_getPARAM()
int vx_getTABLEDATA(), vx_getFIELD(), vx_getINFO(), vx_getNext()
int vx_getDESCRIPTION(), vx_getCOOSYS()
int vx_getNCols(), vx_getNRows(), vx_getLength()
begin
# Get the parameters.
call clgstr ("fname", fname, SZ_FNAME)
verbose = clgetb ("verbose")
# Open and parse the votable.
vot = vx_openVOTABLE (fname)
if (vot <= 0) {
call eprintf ("Cannot open file: '%s'\n")
call pargstr (fname)
return
}
# Now get various handles from the table.
res = vx_getRESOURCE (vot)
tab = vx_getTABLE (res)
data = vx_getDATA (tab)
tdata = vx_getTABLEDATA (data)
ncols = vx_getNCols (tdata)
nrows = vx_getNRows (tdata)
# Print a table summary.
call printf ("%s\n\n")
call pargstr (fname)
call printf (" Resources: %d\t Table Size: %d x %d\n")
call pargi (vx_getLength (res))
call pargi (ncols)
call pargi (nrows)
handle = vx_getINFO (res)
call printf (" INFO: %d\n")
call pargi (vx_getLength (handle))
# Print the table PARAMs.
handle = vx_getPARAM (res)
len = vx_getLength (handle)
call printf (" PARAM: %d\t")
call pargi (len)
if (verbose) {
while (handle > 0) {
call vx_getAttr (handle, "id", name, SZ_FNAME)
call vx_getAttr (handle, "value", value, SZ_LINE)
call printf ("%s = %s ")
call pargstr (name)
call pargstr (value)
if (len > 1)
call printf ("\n\t\t\t")
len = len - 1
handle = vx_getNext (handle)
}
}
call printf ("\n")
# Print and table desccription.
call vx_getValue (vx_getDESCRIPTION (res), desc, SZ_LINE)
call printf (" Description: %s\n\n ")
call pargstr (desc)
# Print the column info in verbose mode.
if (verbose) {
call printf ("\n\t\t\tName\t\t\tUCD\n\n")
i = 0
for (field=vx_getFIELD(tab); field > 0; field=vx_getNext (field)) {
call vx_getAttr (field, "name", name, SZ_FNAME)
call vx_getAttr (field, "ucd", ucd, SZ_FNAME)
call printf (" Field %2d: %-20.20s\t%-30.30s\n")
call pargi (i)
call pargstr (name)
call pargstr (ucd)
handle = vx_getDESCRIPTION (field)
call vx_getValue (handle, desc, SZ_LINE)
call printf ("\t Desc: %-s\n\n")
call pargstr (desc)
i = i + 1
}
}
# Clean up.
call vx_closeVOTABLE (vot)
end
|