blob: c983ec95fece7f7adb84f82aaaa3e4110d96f393 (
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
|
/**
* VOTCOMP
*
* Example program to "compress" a VOTable by deleting pretty-print
* whitespace.
*
* Usage:
* votcomp [-o <fname> | '-'] [-i N] <votable>
* Where
* -i <N> Number of indention spaces (zero by default)
* -o <fname> Name of output file (or '-' for stdout)
* <votable> Name of file to compress
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "votParse.h"
int vot = 0; /* VOTable handle */
int indent = 0; /* indentation flag */
char *fname = NULL, /* input file name */
*oname = NULL; /* output filename */
/**
* Program entry point.
*/
int main (int argc, char **argv)
{
/* Parse the arguments.
*/
if (argc < 2) {
fprintf (stderr,
"Usage: votcomp [-o <fname> | '-'] [-i N] <votable>\n");
return (ERR);
} else if (argc >= 2) {
register int i;
for (i=1; i < argc; i++) {
if (argv[i][0] == '-' && strlen (argv[i]) > 1) {
switch (argv[i][1]) {
case 'i': indent = atoi(argv[++i]); break;
case 'o': oname = argv[++i]; break;
default:
fprintf (stderr, "Invalid argument '%c'\n", argv[i][1]);
return (1);
}
} else
fname = argv[i];
}
}
/* Open the table (this also parses it). In a real application we
* would do an access() check on the file, but the open call below will
* print error information.
*/
if ((vot = vot_openVOTABLE (fname)) <= 0) {
fprintf (stderr, "Error opening VOTable '%s'\n", fname);
return (ERR);
}
/* Output the XML file. */
vot_writeVOTable (vot, (oname ? oname : "stdout"), indent);
vot_closeVOTABLE (vot); /* close the table */
return (OK);
}
|