aboutsummaryrefslogtreecommitdiff
path: root/vendor/voclient/libvotable/votParse_f77.c
blob: 0d52caa9c087f09d566c53f35af04faebd27e1da (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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
/**
 *  VOTPARSE_F77.C -- Public interface for the libVOTable F77 wrapper
 *
 *  @file       votParse_f77.c
 *  @author     Mike Fitzpatrick and Eric Timmermann
 *  @date       8/03/09
 *
 *  @brief      Public interface for the libVOTable F77 wrapper
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <expat.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>

#include "votParseP.h"
#include "votParse.h"



/*  Fortran Interface Definitions.
 *
 *  Fortran compilers on various platforms may append one or more trailing
 *  underscores to symbol names, we'll use macros for the interface names
 *  and use defines to see what the symbol name is.
 */
#ifdef  _NO_US_			/*  MACHDEP	*/

#define VF_OPENVOTABLE   	vf_openvotable
#define VF_CLOSEVOTABLE   	vf_closevotable
#define VF_GETRESOURCE   	vf_getresource
#define VF_GETTABLE   		vf_gettable
#define VF_GETFIELD   		vf_getfield
#define VF_GETDATA   		vf_getdata
#define VF_GETTABLEDATA   	vf_gettabledata
#define VF_GETTR   		vf_gettr
#define VF_GETTD   		vf_gettd
#define VF_GETBINARY   		vf_getbinary
#define VF_GETBINARY2  		vf_getbinary2
#define VF_GETFITS   		vf_getfits
#define VF_GETGROUP   		vf_getgroup
#define VF_GETFIELDREF   	vf_getfieldref
#define VF_GETPARAMREF   	vf_getparamref
#define VF_GETDESCRIPTION   	vf_getdescription
#define VF_GETPARAM   		vf_getparam
#define VF_GETINFO   		vf_getinfo
#define VF_GETSTREAM   		vf_getstream
#define VF_GETVALUES   		vf_getvalues
#define VF_GETMIN   		vf_getmin
#define VF_GETMAX   		vf_getmax
#define VF_GETOPTION   		vf_getoption
#define VF_GETLINK   		vf_getlink
#define VF_GETCOOSYS   		vf_getcoosys
#define VF_GETDATATYPE   	vf_getdatatype
#define VF_GETDATATYPESTR       vf_getdatatypestr

#define VF_NEWRESOURCE   	vf_newresource
#define VF_NEWTABLE   		vf_newtable
#define VF_NEWFIELD   		vf_newfield
#define VF_NEWDATA   		vf_newdata
#define VF_NEWTABLEDATA   	vf_newtabledata
#define VF_NEWTR   		vf_newtr
#define VF_NEWTD   		vf_newtd
#define VF_NEWBINARY   		vf_newbinary
#define VF_NEWBINARY2  		vf_newbinary2
#define VF_NEWFITS   		vf_newfits
#define VF_NEWGROUP   		vf_newgroup
#define VF_NEWFIELDREF   	vf_newfieldref
#define VF_NEWPARAMREF   	vf_newparamref
#define VF_NEWDESCRIPTION   	vf_newdescription
#define VF_NEWPARAM   		vf_newparam
#define VF_NEWINFO   		vf_newinfo
#define VF_NEWSTREAM   		vf_newstream
#define VF_NEWVALUES   		vf_newvalues
#define VF_NEWMIN   		vf_newmin
#define VF_NEWMAX   		vf_newmax
#define VF_NEWOPTION   		vf_newoption
#define VF_NEWLINK   		vf_newlink
#define VF_NEWCOOSYS   		vf_newcoosys

#define VF_NEWNODE   		vf_newnode
#define VF_FREENODE   		vf_freenode
#define VF_ATTACHNODE   	vf_attachnode
#define VF_DELETENODE   	vf_deletenode
#define VF_COPYELEMENT   	vf_copyelement
#define VF_GETNCOLS   		vf_getncols
#define VF_GETNROWS   		vf_getnrows
#define VF_GETTABLECELL   	vf_gettablecell
#define VF_GETTABLEINT   	vf_gettableint
#define VF_GETTABLEREAL   	vf_gettablereal
#define VF_GETLENGTH   		vf_getlength
#define VF_GETNUMBEROF   	vf_getnumberof
#define VF_FINDBYATTR   	vf_findbyattr
#define VF_FINDINGROUP   	vf_findingroup
#define VF_NEXTINGROUP   	vf_nextingroup
#define VF_GETNEXT   		vf_getnext
#define VF_GETSIBLING		vf_getsibling
#define VF_GETCHILD   		vf_getchild
#define VF_GETPARENT   		vf_getparent
#define VF_CHILDOFTYPE   	vf_childoftype
#define VF_VALUEOF   		vf_valueof
#define VF_TYPEOF   		vf_typeof
#define VF_SETVALUE   		vf_setvalue
#define VF_GETVALUE   		vf_getvalue
#define VF_GETINTVALUE   	vf_getintvalue
#define VF_GETREALVALUE   	vf_getrealvalue
#define VF_SETATTR   		vf_setattr
#define VF_GETATTR   		vf_getattr
#define VF_WRITEXML		vf_writexml
#define VF_WRITEHTML            vf_writehtml
#define VF_WRITESHTML           vf_writeshtml
#define VF_WRITEASV             vf_writeasv
#define VF_WRITEBSV             vf_writebsv
#define VF_WRITECSV             vf_writecsv
#define VF_WRITETSV             vf_writetsv
#define VF_SETWARN		vf_setwarn

#else

#define VF_OPENVOTABLE   	vf_openvotable_
#define VF_CLOSEVOTABLE   	vf_closevotable_

#define VF_GETRESOURCE   	vf_getresource_
#define VF_GETTABLE   		vf_gettable_
#define VF_GETFIELD   		vf_getfield_
#define VF_GETDATA   		vf_getdata_
#define VF_GETTABLEDATA   	vf_gettabledata_
#define VF_GETTR   		vf_gettr_
#define VF_GETTD   		vf_gettd_
#define VF_GETBINARY   		vf_getbinary_
#define VF_GETBINARY2   	vf_getbinary2_
#define VF_GETFITS   		vf_getfits_
#define VF_GETGROUP   		vf_getgroup_
#define VF_GETFIELDREF   	vf_getfieldref_
#define VF_GETPARAMREF   	vf_getparamref_
#define VF_GETDESCRIPTION   	vf_getdescription_
#define VF_GETPARAM   		vf_getparam_
#define VF_GETINFO   		vf_getinfo_
#define VF_GETSTREAM   		vf_getstream_
#define VF_GETVALUES   		vf_getvalues_
#define VF_GETMIN   		vf_getmin_
#define VF_GETMAX   		vf_getmax_
#define VF_GETOPTION   		vf_getoption_
#define VF_GETLINK   		vf_getlink_
#define VF_GETCOOSYS   		vf_getcoosys_
#define VF_GETDATATYPE   	vf_getdatatype_
#define VF_GETDATATYPESTR       vf_getdatatypestr_

#define VF_NEWRESOURCE   	vf_newresource_
#define VF_NEWTABLE   		vf_newtable_
#define VF_NEWFIELD   		vf_newfield_
#define VF_NEWDATA   		vf_newdata_
#define VF_NEWTABLEDATA   	vf_newtabledata_
#define VF_NEWTR   		vf_newtr_
#define VF_NEWTD   		vf_newtd_
#define VF_NEWBINARY   		vf_newbinary_
#define VF_NEWBINARY2  		vf_newbinary2_
#define VF_NEWFITS   		vf_newfits_
#define VF_NEWGROUP   		vf_newgroup_
#define VF_NEWFIELDREF   	vf_newfieldref_
#define VF_NEWPARAMREF   	vf_newparamref_
#define VF_NEWDESCRIPTION   	vf_newdescription_
#define VF_NEWPARAM   		vf_newparam_
#define VF_NEWINFO   		vf_newinfo_
#define VF_NEWSTREAM   		vf_newstream_
#define VF_NEWVALUES   		vf_newvalues_
#define VF_NEWMIN   		vf_newmin_
#define VF_NEWMAX   		vf_newmax_
#define VF_NEWOPTION   		vf_newoption_
#define VF_NEWLINK   		vf_newlink_
#define VF_NEWCOOSYS   		vf_newcoosys_

#define VF_NEWNODE   		vf_newnode_
#define VF_FREENODE   		vf_freenode_
#define VF_ATTACHNODE   	vf_attachnode_
#define VF_DELETENODE   	vf_deletenode_
#define VF_COPYELEMENT   	vf_copyelement_
#define VF_GETNCOLS   		vf_getncols_
#define VF_GETNROWS   		vf_getnrows_
#define VF_GETTABLECELL   	vf_gettablecell_
#define VF_GETTABLEINT   	vf_gettableint_
#define VF_GETTABLEREAL   	vf_gettablereal_
#define VF_GETLENGTH   		vf_getlength_
#define VF_GETNUMBEROF   	vf_getnumberof_
#define VF_FINDBYATTR   	vf_findbyattr_
#define VF_FINDINGROUP   	vf_findingroup_
#define VF_NEXTINGROUP   	vf_nextingroup_
#define VF_GETNEXT   		vf_getnext_
#define VF_GETSIBLING		vf_getsibling_
#define VF_GETCHILD   		vf_getchild_
#define VF_GETPARENT   		vf_getparent_
#define VF_CHILDOFTYPE   	vf_childoftype_
#define VF_VALUEOF   		vf_valueof_
#define VF_TYPEOF   		vf_typeof_
#define VF_SETVALUE   		vf_setvalue_
#define VF_GETVALUE   		vf_getvalue_
#define VF_GETINTVALUE   	vf_getintvalue_
#define VF_GETREALVALUE   	vf_getrealvalue_
#define VF_SETATTR   		vf_setattr_
#define VF_GETATTR   		vf_getattr_
#define VF_WRITEXML		vf_writexml_
#define VF_WRITEHTML            vf_writehtml_
#define VF_WRITESHTML           vf_writeshtml_
#define VF_WRITEASV             vf_writeasv_
#define VF_WRITEBSV             vf_writebsv_
#define VF_WRITECSV             vf_writecsv_
#define VF_WRITETSV             vf_writetsv_
#define VF_SETWARN		vf_setwarn_

#endif


/**
 *   Public function prototypes.
 */
handle_t  VF_OPENVOTABLE (char *arg, int alen);
void 	  VF_CLOSEVOTABLE (handle_t *vot);

handle_t  VF_GETRESOURCE (handle_t *handle);
handle_t  VF_GETTABLE (handle_t *handle);
handle_t  VF_GETFIELD (handle_t *handle);
handle_t  VF_GETDATA (handle_t *handle);
handle_t  VF_GETTABLEDATA (handle_t *handle);
handle_t  VF_GETTR (handle_t *handle);
handle_t  VF_GETTD (handle_t *handle);
handle_t  VF_GETBINARY (handle_t *handle);
handle_t  VF_GETBINARY2 (handle_t *handle);
handle_t  VF_GETFITS (handle_t *handle);
handle_t  VF_GETGROUP (handle_t *handle);
handle_t  VF_GETFIELDRef (handle_t *handle);
handle_t  VF_GETPARAMREF (handle_t *handle);
handle_t  VF_GETDESCRIPTION (handle_t *handle);
handle_t  VF_GETPARAM (handle_t *handle);
handle_t  VF_GETINFO (handle_t *handle);
handle_t  VF_GETSTREAM (handle_t *handle);
handle_t  VF_GETVALUES (handle_t *handle);
handle_t  VF_GETMIN (handle_t *handle);
handle_t  VF_GETMAX (handle_t *handle);
handle_t  VF_GETOPTION (handle_t *handle);
handle_t  VF_GETLINK (handle_t *handle);
handle_t  VF_GETCOOSYS (handle_t *handle);

handle_t  VF_NEWRESOURCE (handle_t *parent_h);
handle_t  VF_NEWTABLE (handle_t *parent_h);
handle_t  VF_NEWFIELD (handle_t *parent_h);
handle_t  VF_NEWDATA (handle_t *parent_h);
handle_t  VF_NEWTABLEDATA (handle_t *parent_h);
handle_t  VF_NEWTR (handle_t *parent_h);
handle_t  VF_NEWTD (handle_t *parent_h);
handle_t  VF_NEWBINARY (handle_t *parent_h);
handle_t  VF_NEWBINARY2 (handle_t *parent_h);
handle_t  VF_NEWFITS (handle_t *parent_h);
handle_t  VF_NEWGROUP (handle_t *parent_h);
handle_t  VF_NEWFIELDRef (handle_t *parent_h);
handle_t  VF_NEWPARAMREF (handle_t *parent_h);
handle_t  VF_NEWDESCRIPTION (handle_t *parent_h);
handle_t  VF_NEWPARAM (handle_t *parent_h);
handle_t  VF_NEWINFO (handle_t *parent_h);
handle_t  VF_NEWSTREAM (handle_t *parent_h);
handle_t  VF_NEWVALUES (handle_t *parent_h);
handle_t  VF_NEWMIN (handle_t *parent_h);
handle_t  VF_NEWMAX (handle_t *parent_h);
handle_t  VF_NEWOPTION (handle_t *parent_h);
handle_t  VF_NEWLINK (handle_t *parent_h);
handle_t  VF_NEWCOOSYS (handle_t *parent_h);

int 	  VF_GETDATAType (handle_t *data);
void 	  VF_GETDATATYPESTR (handle_t *data, char *type, int *len, int tlen);

handle_t  VF_NEWNODE (handle_t *parent, int *type);
void 	  VF_ATTACHNODE (handle_t *parent, handle_t *new);
void 	  VF_FREENODE (handle_t *elem);
void 	  VF_DELETENODE (handle_t *elem);
handle_t  VF_COPYELEMENT (handle_t *src, handle_t *parent);
;
int 	  VF_GETNCOLS (handle_t *tdata);
int 	  VF_GETNROWS (handle_t *tdata);
void 	  VF_GETTABLECELL (handle_t *tdata, int *row, int *col, char *value, 
		int *maxch);
int 	  VF_GETTABLEINT (handle_t *tdata, int *row, int *col);
float 	  VF_GETTABLEREAL (handle_t *tdata, int *row, int *col);
int 	  VF_GETLENGTH (handle_t *elem);
int 	  VF_GETNUMBEROF (handle_t *elem, int *type);
handle_t  VF_FINDBYATTR (handle_t *parent, char *name, char *value, int nlen, 
		int vlen);
handle_t  VF_FINDINGROUP (handle_t *group, int *type);
handle_t  VF_NEXTINGROUP (void);
handle_t  VF_GETNEXT (handle_t *elem);
handle_t  VF_GETSIBLING (handle_t *elem);
handle_t  VF_GETCHILD (handle_t *elem);
handle_t  VF_GETPARENT (handle_t *elem);
handle_t  VF_CHILDOFTYPE (handle_t *elem, int *type);
int 	  VF_VALUEOF (handle_t *elem);
int 	  VF_TYPEOF (handle_t *elem);
;
int 	  VF_SETVALUE (handle_t *elem, char *value, int vlen);
void 	  VF_GETVALUE (handle_t *elem, char *value, int *maxch, int vlen);
int 	  VF_GETINTVALUE (handle_t *elem);
float 	  VF_GETREALVALUE (handle_t *elem);
void 	  VF_GETATTR (handle_t *elem, char *name, char *val, int *len, 
		int nlen, int vlen);
int 	  VF_SETATTR (handle_t *elem, char *attr, char *value, int alen, 
		int vlen);
void 	  VF_WRITEXML (handle_t *elem, char *fname, int flen);
void 	  VF_WRITEHTML (handle_t *elem, char *ifname, char *ofname, 
		int iflen, int oflen);
void 	  VF_WRITESHTML (handle_t *elem, char *ifname, char *ofname, 
		int iflen, int oflen);
void 	  VF_WRITEASV (handle_t *elem, char *fname, int flen);
void 	  VF_WRITEBSV (handle_t *elem, char *fname, int flen);
void 	  VF_WRITECSV (handle_t *elem, char *fname, int flen);
void 	  VF_WRITETSV (handle_t *elem, char *fname, int flen);
void 	  VF_SETWARN (int *value);



/** 
 *  Local interface declarations.
 */
static char *sstrip (char *instr, int len);
static void  spad (char *outstr, int len);

static handle_t	handle     = 0;			/* global value		*/
static handle_t *s_group   = (handle_t *) NULL;



/*****************************************************************************
 *
 ****************************************************************************/


/** VF_OPENVOTABLE
 *
 *  @brief		This will create a tree holding the VOTable build from
 *  			an XML file parser or just a blank VOTable.
 *  @param[in] *arg 	the source of the table.
 *  @return	 	The root node of the VOTable.
 */
handle_t
VF_OPENVOTABLE (char *arg, int alen)
{
    char *_arg = sstrip (arg, alen);

    handle = vot_openVOTABLE (_arg);

    if (_arg) free ((char *) _arg);

    return (handle);
}


/** VF_CLOSEVOTABLE
 *
 *  @brief		Destroys the node and all of it's children.
 *  @param[in] vot 	A handle to the Element that you want deleted.
 *  @warning 		Destroys the node and all of it's children.
 */
void
VF_CLOSEVOTABLE (handle_t *vot)
{
    vot_closeVOTABLE (*vot);
}




/*****************************************************************************
 *  Routines to get nodes of a VOTable as a handle.
 ****************************************************************************/

/** VF_GETRESOURCE
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETRESOURCE (handle_t *handle)
{
    return ( vot_getRESOURCE (*handle) );
}


/** VF_GETTABLE
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETTABLE (handle_t *handle)
{
    return ( vot_getTABLE (*handle) );
}


/** VF_GETFIELD
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETFIELD (handle_t *handle)
{
    return ( vot_getFIELD (*handle) );
}


/** VF_GETDATA
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETDATA (handle_t *handle)
{
    return ( vot_getDATA (*handle) );
}


/** VF_GETTABLEDATA
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETTABLEDATA (handle_t *handle)
{
    return ( vot_getTABLEDATA (*handle) );
}


/** VF_GETTR
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETTR (handle_t *handle)
{
    return ( vot_getTR (*handle) );
}


/** VF_GETTD
 * 
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETTD (handle_t *handle)
{
    return ( vot_getTD (*handle) );
}


/** VF_GETBINARY
 * 
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETBINARY (handle_t *handle)
{
    return ( vot_getBINARY (*handle) );
}


/** VF_GETBINARY2
 * 
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETBINARY2 (handle_t *handle)
{
    return ( vot_getBINARY2 (*handle) );
}


/** VF_GETFITS
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETFITS (handle_t *handle)
{
    return ( vot_getFITS (*handle) );
}


/** VF_GETGROUP
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETGROUP (handle_t *handle)
{
    return ( vot_getGROUP (*handle) );
}


/** VF_GETFIELDRef
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETFIELDRef (handle_t *handle)
{
    return ( vot_getFIELDRef (*handle) );
}


/** VF_GETPARAMREF
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETPARAMREF (handle_t *handle)
{
    return ( vot_getPARAMRef (*handle) );
}


/** VF_GETDESCRIPTION
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETDESCRIPTION (handle_t *handle)
{
    return ( vot_getDESCRIPTION (*handle) );
}


/** VF_GETPARAM
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETPARAM (handle_t *handle)
{
    return ( vot_getPARAM (*handle) );
}


/** VF_GETINFO
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETINFO (handle_t *handle)
{
    return ( vot_getINFO (*handle) );
}


/** VF_GETSTREAM
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETSTREAM (handle_t *handle)
{
    return ( vot_getSTREAM (*handle) );
}


/** VF_GETVALUES
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETVALUES (handle_t *handle)
{
    return ( vot_getVALUES (*handle) );
}


/** VF_GETMIN
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETMIN (handle_t *handle)
{
    return ( vot_getMIN (*handle) );
}


/** VF_GETMAX
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETMAX (handle_t *handle)
{
    return ( vot_getMAX (*handle) );
}


/** VF_GETOPTION
 *
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETOPTION (handle_t *handle)
{
    return ( vot_getOPTION (*handle) );
}


/** VF_GETLINK
 * 
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETLINK (handle_t *handle)
{
    return ( vot_getLINK (*handle) );
}


/** VF_GETCOOSYS
 * 
 *  @brief		Gets the node of a specified type.
 *  @param[in] handle 	A handle to the Element will you wish to search from.
 *  @return 		A handle to the found node. Zero otherwise.
 */
handle_t
VF_GETCOOSYS (handle_t *handle)
{
    return ( vot_getCOOSYS (*handle) );
}



/*************************************************************************/

/** VF_GETDATAType
 * 
 *  @brief	Returns the type of the DATA element.
 *  @param[in] data 	A handle to a DATA element
 *  @return	The type as an int.
 */
int
VF_GETDATAType (handle_t *data)
{
    return ( vot_getDATAType (*data) );
}


/** VF_GETDATATypeString
 * 
 *  @brief	Returns the type of the DATA element.
 *  @param[in] data 	A handle to a DATA element
 *  @return	The type as an string.
 */
void
VF_GETDATATYPESTR (handle_t *data, char *type, int *len, int tlen)
{
    char *_val = vot_getDATATypeString (*data);

    memset (type, 0, *len);
    spad ( strncpy (type, _val, *len), *len );
}




/*****************************************************************************
 *  Routines to create new nodes of a VOTable.
 ****************************************************************************/

/** VF_NEWRESOURCE
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWRESOURCE (handle_t *parent_h)
{
    return ( vot_newRESOURCE (*parent_h) );
}


/** VF_NEWTABLE
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWTABLE (handle_t *parent_h)
{
    return ( vot_newTABLE (*parent_h) );
}


/** VF_NEWFIELD
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWFIELD (handle_t *parent_h)
{
    return ( vot_newFIELD (*parent_h) );
}


/** VF_NEWDATA
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWDATA (handle_t *parent_h)
{
    return ( vot_newDATA (*parent_h) );
}


/** VF_NEWTABLEDATA
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWTABLEDATA (handle_t *parent_h)
{
    return ( vot_newTABLEDATA (*parent_h) );
}


/** VF_NEWTR
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWTR (handle_t *parent_h)
{
    return ( vot_newTR (*parent_h) );
}


/** VF_NEWTD
 * 
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWTD (handle_t *parent_h)
{
    return ( vot_newTD (*parent_h) );
}


/** VF_NEWBINARY
 * 
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWBINARY (handle_t *parent_h)
{
    return ( vot_newBINARY (*parent_h) );
}


/** VF_NEWBINARY2
 * 
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWBINARY2 (handle_t *parent_h)
{
    return ( vot_newBINARY2 (*parent_h) );
}


/** VF_NEWFITS
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWFITS (handle_t *parent_h)
{
    return ( vot_newFITS (*parent_h) );
}


/** VF_NEWGROUP
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWGROUP (handle_t *parent_h)
{
    return ( vot_newGROUP (*parent_h) );
}


/** VF_NEWFIELDRef
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWFIELDRef (handle_t *parent_h)
{
    return ( vot_newFIELDRef (*parent_h) );
}


/** VF_NEWPARAMREF
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWPARAMREF (handle_t *parent_h)
{
    return ( vot_newPARAMRef (*parent_h) );
}


/** VF_NEWDESCRIPTION
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWDESCRIPTION (handle_t *parent_h)
{
    return ( vot_newDESCRIPTION (*parent_h) );
}


/** VF_NEWPARAM
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWPARAM (handle_t *parent_h)
{
    return ( vot_newPARAM (*parent_h) );
}


/** VF_NEWINFO
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWINFO (handle_t *parent_h)
{
    return ( vot_newINFO (*parent_h) );
}


/** VF_NEWSTREAM
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWSTREAM (handle_t *parent_h)
{
    return ( vot_newSTREAM (*parent_h) );
}


/** VF_NEWVALUES
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWVALUES (handle_t *parent_h)
{
    return ( vot_newVALUES (*parent_h) );
}


/** VF_NEWMIN
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWMIN (handle_t *parent_h)
{
    return ( vot_newMIN (*parent_h) );
}


/** VF_NEWMAX
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWMAX (handle_t *parent_h)
{
    return ( vot_newMAX (*parent_h) );
}


/** VF_NEWOPTION
 *
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWOPTION (handle_t *parent_h)
{
    return ( vot_newOPTION (*parent_h) );
}


/** VF_NEWLINK
 * 
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWLINK (handle_t *parent_h)
{
    return ( vot_newLINK (*parent_h) );
}


/** VF_NEWCOOSYS
 * 
 *  @brief		   Create the node of a specified type.
 *  @param[in] parent_h    A handle to the parent node. from.
 *  @return 		   A handle to the new node. Zero otherwise.
 */
handle_t
VF_NEWCOOSYS (handle_t *parent_h)
{
    return ( vot_newCOOSYS (*parent_h) );
}



/*****************************************************************************
 ****************************************************************************/


/** VF_NEWNODE
 * 
 *  @brief		Creates a new blank unlinked node.
 *  @param[in] parent 	A handle to the Element that you want to add a node to.
 *  @param[in] type 	The type of node you wish to create.
 *  @return 		A handle to the created node.
 */
handle_t
VF_NEWNODE (handle_t *parent, int *type)
{
    return ( vot_newNode (*parent, *type) );
}


/** VF_ATTACHNODE
 *
 *  @brief		Adds a node as a child of parent.
 *  @param[in] parent 	A handle to the Element that you want to add a node to.
 *  @param[in] new 	A handle to the Element that you want to add.
 */
void
VF_ATTACHNODE (handle_t *parent, handle_t *new)
{
    vot_attachNode (*parent, *new);
}


/** VF_FREENODE
 *
 *  @brief		Destroys the node and all of it's children.
 *  @param[in] elem 	A handle to the Element that you want deleted.
 *  @warning 		Destroys the node and all of it's children.
 */
void
VF_FREENODE (handle_t *elem)
{
    vot_freeNode (*elem);
}


/** VF_DELETENODE
 *
 *  @brief		Destroys the node and all of it's children.
 *  @param[in] elem 	A handle to the Element that you want deleted.
 *  @warning 		Destroys the node and all of it's children.
 */
void
VF_DELETENODE (handle_t *elem)
{
    vot_deleteNode (*elem);
}


/** VF_COPYELEMENT
 *
 *  @brief		Adds a node as a child of parent.
 *  @param[in] src 	A handle to the Element to copy.
 *  @param[in] parent 	A handle to the Elements parent.
 *  @return 		A handle of the copy of the structure.
 */
handle_t
VF_COPYELEMENT (handle_t *src, handle_t *parent)
{
    return ( vot_copyElement (*src, *parent) );
}


/*****************************************************************************
 *  Utility methods
 ****************************************************************************/


/** VF_GETNCOLS
 * 
 *  @brief		Return the nuber of columns in the structure.
 *  @param[in]  tdata 	A handle to a TABLEDATA
 *  @return		The number of cols.
 */
int
VF_GETNCOLS (handle_t *tdata)
{
    return ( vot_getNCols (*tdata) );
}


/** VF_GETNROWS
 * 
 *  @brief		Return the nuber of columns in the structure.
 *  @param[in]  tdata 	A handle to a TABLEDATA
 *  @return		The number of cols.
 */
int
VF_GETNROWS (handle_t *tdata)
{
    return ( vot_getNRows (*tdata) );
}


/** VF_GETTABLECELL
 * 
 *  @brief		Return the nuber of contents of a table cell 
 *  @param[in]  tdata 	A handle to a TABLEDATA.
 *  @param[in]  row 	An int for a row.
 *  @param[in]  col 	An int for a col.
 *  @return		The content of the cell.
 */
void
VF_GETTABLECELL (handle_t *tdata, int *row, int *col, char *value, int *maxch)
{
    char *_val = vot_getTableCell (*tdata, (*row - 1), (*col - 1));

    memset (value, 0, *maxch);
    spad ( strncpy (value, _val, *maxch), *maxch);
}


/** VF_GETTABLEINT
 * 
 *  @brief		Return the nuber of contents of a table cell as an int
 *  @param[in]  tdata 	A handle to a TABLEDATA.
 *  @param[in]  row 	An int for a row.
 *  @param[in]  col 	An int for a col.
 *  @return		The content of the cell as an int.
 */
int
VF_GETTABLEINT (handle_t *tdata, int *row, int *col)
{
    return ( atoi (vot_getTableCell (*tdata, (*row - 1), (*col - 1))) );
}


/** VF_GETTABLEREAL
 * 
 *  @brief		Return the nuber of contents of a table cell as an real
 *  @param[in]  tdata 	A handle to a TABLEDATA.
 *  @param[in]  row 	An int for a row.
 *  @param[in]  col 	An int for a col.
 *  @return		The content of the cell as a real.
 */
float
VF_GETTABLEREAL (handle_t *tdata, int *row, int *col)
{
    return ( atof (vot_getTableCell (*tdata, (*row - 1), (*col - 1))) );
}


/** VF_GETLENGTH
 * 
 *  @brief		Return the number of sibling Elements of the same type.
 *  @param[in]  elem 	A handle the Element.
 *  @return		The status of the set.
 */
int
VF_GETLENGTH (handle_t *elem)
{
    return ( vot_getLength (*elem) );
}


/** VF_GETNUMBEROF
 *
 *  @brief		Return the number of sibling Elements of the type.
 *  @param[in]  elem 	A handle the Element.
 *  @param[in]  type 	An int of the type of element you wish to count.
 *  @return		The status of the set.
 */
int
VF_GETNUMBEROF (handle_t *elem, int *type)
{
    return ( vot_getNumberOf (*elem, *type) );
}


/** VF_FINDBYATTR.
 * 
 *  @brief		Return a handle to an Element with the requested attr.
 *  @param[in]  parent 	A handle the parent Element.
 *  @param[in]  name 	A string holding the Value type.
 *  @param[in]  value 	A string holding the Value value.
 *  @return		The handle to the element.
 */
handle_t
VF_FINDBYATTR (handle_t *parent, char *name, char *value, int nlen, int vlen)
{

    return ( vot_findByAttr (*parent, name, value) );
}


/** VF_FINDINGROUP.
 * 
 *  @brief		Return an array of handle_ts of the requested type.
 *  @param[in]  group 	A handle the parent Element.
 *  @param[in]  type 	Value of the type.
 *  @return		An array of handles.
 */
handle_t
VF_FINDINGROUP (handle_t *group, int *type)
{
    s_group = vot_findInGroup (*group, *type);
    return ( (handle_t) *s_group );
}


/** VF_NEXTINGROUP.
 * 
 *  @brief		Return an array of handle_ts of the requested type.
 *  @param[in]  group 	A handle the parent Element.
 *  @param[in]  type 	Value of the type.
 *  @return		An array of handles.
 */
handle_t
VF_NEXTINGROUP (void)
{
    s_group++;
    return ( (handle_t) *s_group );
}


/** VF_GETNEXT
 *  
 *  @brief		Return a handle of the next Element of the same type.
 *  @param[in]  elem 	A handle the Element.
 *  @return		A handle of the next Element of the same type.
 */
handle_t
VF_GETNEXT (handle_t *elem)
{
    return ( vot_getNext (*elem) );
}


/** VF_GETSIBLING.
 * 
 *  @brief		Return a handle of the next Element.
 *  @param[in]  elem 	A handle the Element.
 *  @return		A handle of the next Element.
 */
handle_t
VF_GETSIBLING (handle_t *elem)
{
    return ( vot_getSibling (*elem) );
}


/** VF_GETCHILD
 *
 *  @brief		Return a handle of the child Element.
 *  @param[in]  elem 	A handle the Element.
 *  @return		A handle of the child Element.
 */
handle_t
VF_GETCHILD (handle_t *elem)
{
    return ( vot_getChild (*elem) );
}


/** VF_GETPARENT
 *
 *  @brief		Return a handle of the parent Element.
 *  @param[in]  elem 	A handle the Element.
 *  @return		A handle of the paretn Element.
 */
handle_t
VF_GETPARENT (handle_t *elem)
{
    return ( vot_getParent (*elem) );
}


/** VF_GETCHILDOfTYPE
 *  @brief		Return a handle of the next Element of the same type.
 *  @param[in]  elem 	A handle the Element.
 *  @param[in]  type 	An integer of the Element type for find.
 *  @return		A handle of the Element.
 */
handle_t
VF_CHILDOFTYPE (handle_t *elem, int *type)
{
    return ( vot_getChildOfType (*elem, *type) );
}


/** VF_VALUEOF
 *
 *  @brief 		Return type of the Element.
 *  @param[in]  elem 	A handle the Element.
 *  @return		An integer of the type.
 */
int
VF_VALUEOF (handle_t *elem)
{
    return ( vot_valueOf (*elem) );
}


/** VF_TYPEOF
 *
 *  @brief 		Return type of the Element.
 *  @param[in]  elem 	A handle the Element.
 *  @return		An integer of the type.
 */
int
VF_TYPEOF (handle_t *elem)
{
    return ( vot_typeOf (*elem) );
}


/** VF_SETWARN
 * 
 *  @brief		Set the warning level
 *  @param[in]  value 	Warning level
 *  @return		Nothing
 */
void
VF_SETWARN (int *value)
{
    vot_setWarnings (*value);
}



/****************************************************************************
 *
 ***************************************************************************/

/** VF_SETVALUE
 *
 *  @brief		Return the Value for the ELEMENT.
 *  @param[in]  elem 	A handle the ELEMENT.
 *  @param[in]  value 	A string holding the Value value.
 *  @return 		The status of the set.
 */
int
VF_SETVALUE (handle_t *elem, char *value, int vlen)
{
    int  retval = -1;

    char *_value = sstrip (value, vlen);

    retval = vot_setValue (*elem, _value);

    if (_value) free ((char *) _value);

    return (retval);
}


/** VF_GETVALUE
 *
 *  @brief		Return the Value for the ELEMENT.
 *  @param[in]  elem 	A handle the ELEMENT.
 *  @return 		A string of the value or the Value.
 */
void
VF_GETVALUE (handle_t *elem, char *value, int *maxch, int vlen)
{
    char *_val = vot_getValue (*elem);

    memset (value, 0, *maxch);
    spad ( strncpy (value, _val, *maxch), *maxch);
}


/** VF_GETINTVALUE
 *
 *  @brief		Return the Value for the ELEMENT as an int.
 *  @param[in]  elem 	A handle the ELEMENT.
 *  @return 		An int value
 */
int
VF_GETINTVALUE (handle_t *elem)
{
    return ( atoi (vot_getValue (*elem)) );
}


/** VF_GETREALVALUE
 *
 *  @brief		Return the Value for the ELEMENT.
 *  @param[in]  elem 	A handle the ELEMENT.
 *  @return 		A real value
 */
float
VF_GETREALVALUE (handle_t *elem)
{
    return ( atof (vot_getValue (*elem)) );
}


/** VF_GETATTR
 * 
 *  @brief		Return the attribute for the Element.
 *  @param[in]  elem 	A handle the Element.
 *  @param[in]  attr 	A string holding the attribute name.
 *  @return		A string of the value or the attr.
 */
void
VF_GETATTR (handle_t *elem, char *name, char *val, int *len, int nlen, int vlen)
{
    char *_name  = sstrip (name, nlen);
    char *res  = vot_getAttr (*elem, _name);

    memset (val, 0, *len);

    if (res) {
        int rlen = strlen (res); 		/*  found a value */
        strncpy (val, res, rlen);
        spad (val, vlen);
    }

    free ((char *) _name);
}


/** VF_SETATTR
 * 
 *  @brief		Return the attribute for the Element.
 *  @param[in]  elem 	A handle the Element.
 *  @param[in]  attr 	A string holding the attribute name.
 *  @param[in]  value 	A string holding the attribute value.
 *  @return		The status of the set.
 */
int
VF_SETATTR (handle_t *elem, char *attr, char *value, int alen, int vlen)
{
    int  retval = -1;

    char *_attr  = sstrip (attr, alen);
    char *_value = sstrip (value, vlen);

    retval = vot_setAttr (*elem, _attr, _value);

    if (_attr)  free ((char *) _attr);
    if (_value) free ((char *) _value);

    return (retval);
}


/** VF_WRITEXML
 * 
 *  @brief		Dump the XML to the named file (or stdout).
 *  @param[in]  elem 	A handle the root node
 *  @param[in]  fname 	Output file name
 *  @param[in]  flen 	Length of utput file name
 *  @return		Nothing
 */
void
VF_WRITEXML (handle_t *elem, char *fname, int flen)
{
    char *_fname  = sstrip (fname, flen);

    vot_writeVOTable (*elem, _fname, 0);

    free ((char *) _fname);
}



/** VF_WRITEHTML
 * 
 *  @brief              Print the XML to the named file (or stdout)
 *  @param[in]  elem    A handle the root Element.
 *  @param[in]  fname   Output file name
 */
void
VF_WRITEHTML (handle_t *elem, char *ifname, char *ofname, int iflen, int oflen)
{
    char *_ifname = sstrip (ifname, iflen);
    char *_ofname = sstrip (ofname, oflen);

    vot_writeHTML (*elem, _ifname, _ofname);

    free ((char *) _ifname);
    free ((char *) _ofname);
}



/** VF_WRITESHTML
 * 
 *  @brief              Print the XML to the named file (or stdout)
 *  @param[in]  elem    A handle the root Element.
 *  @param[in]  fname   Output file name
 */
void
VF_WRITESHTML (handle_t *elem, char *ifname, char *ofname, int iflen, int oflen)
{
    char *_ifname = sstrip (ifname, iflen);
    char *_ofname = sstrip (ofname, oflen);

    vot_writeSHTML (*elem, _ifname, _ofname);

    free ((char *) _ifname);
    free ((char *) _ofname);
}




/** VF_WRITEASV
 * 
 *  @brief              Print the XML as Ascii-Separated Values
 *  @param[in]  elem    A handle the root Element.
 *  @param[in]  fname   Output file name
 */
void
VF_WRITEASV (handle_t *elem, char *fname, int flen)
{
    char *_fname = sstrip (fname, flen);

    vot_writeASV (*elem, _fname, 1);

    free ((char *) _fname);
}


/** VF_WRITEBSV
 * 
 *  @brief              Print the XML as Ascii-Separated Values
 *  @param[in]  elem    A handle the root Element.
 *  @param[in]  fname   Output file name
 */
void
VF_WRITEBSV (handle_t *elem, char *fname, int flen)
{
    char *_fname = sstrip (fname, flen);

    vot_writeBSV (*elem, _fname, 1);

    free ((char *) _fname);
}


/** VF_WRITECSV
 * 
 *  @brief              Print the XML as Ascii-Separated Values
 *  @param[in]  elem    A handle the root Element.
 *  @param[in]  fname   Output file name
 */
void
VF_WRITECSV (handle_t *elem, char *fname, int flen)
{
    char *_fname = sstrip (fname, flen);

    vot_writeCSV (*elem, _fname, 1);

    free ((char *) _fname);
}


/** VF_WRITEASV
 * 
 *  @brief              Print the XML as Ascii-Separated Values
 *  @param[in]  elem    A handle the root Element.
 *  @param[in]  fname   Output file name
 */
void
VF_WRITETSV (handle_t *elem, char *fname, int flen)
{
    char *_fname = sstrip (fname, flen);

    vot_writeTSV (*elem, _fname, 1);

    free ((char *) _fname);
}






/****************************************************************************
 *  Private utility procedures
 ****************************************************************************/

/**
 *  sstrip
 *
 *  Utility to trim trailing blanks from string and add a null terminator.
 */
static char *
sstrip (char *instr, int len)
{
    if (len > 0 && instr) {
        char *newstr = calloc (1, len+1);
	int i = len;

        strncpy (newstr, instr, len);

	/* trim trailing blanks */
	for (i=len; newstr[i] == ' ' || newstr[i] == '\0'; i--)	
	    newstr[i] = '\0';
	    
        return (newstr);
    }

    return ((char *) NULL);
}


/**
 *  spad 
 *
 *  Pad a string to length 'len' with blanks, as Fortran requires.
 */
void
spad (char *outstr, int len)
{
    int i=0;
        
    for (i = strlen(outstr); i < len; i++)
        outstr[i] = ' ';
}