diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /vendor/voclient/libvoclient/examples/simple.c | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'vendor/voclient/libvoclient/examples/simple.c')
-rw-r--r-- | vendor/voclient/libvoclient/examples/simple.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/vendor/voclient/libvoclient/examples/simple.c b/vendor/voclient/libvoclient/examples/simple.c new file mode 100644 index 00000000..670be8d7 --- /dev/null +++ b/vendor/voclient/libvoclient/examples/simple.c @@ -0,0 +1,81 @@ +/************************************************************************ + * Call a cone/siap search service and print a summary selected fields of the + * results. + * + * Usage: simple [cone|siap] ra dec sr [type [serviceURL]] + * + * Or call with no args for the built-in unit test. + * + * M. Fitzpatrick, NOAO, June 2006 + */ + + +#include <stdio.h> +#include <stdlib.h> +#include "VOClient.h" + + +double ra = 12.0; /* default values */ +double dec = 12.0; +double sr = 0.1; + +char *cone_service = \ + "http://www.nofs.navy.mil/cgi-bin/vo_cone.cgi?CAT=USNO-B1&"; +char *siap_service = "http://skyview.gsfc.nasa.gov/cgi-bin/vo/sia.pl?"; + + + +int main (int argc, char *argv[]) +{ + char *result = NULL; + char *service = cone_service; + int svc_type = CONE_SERVICE; + int type = VOC_CSV; + int status = 0; + + /* Process command line arguments. + */ + if (argc <= 1) { + /* Use builtin defaults. */ + + } else if (argc == 2) { + /* Use builtin defaults with requested service type. */ + if (argv[1][0] == 'c') { + svc_type = CONE_SERVICE, service = cone_service; + } else { + svc_type = SIAP_SERVICE, service = siap_service; + } + + } else if (argc >= 3) { + int arg = 1; + + svc_type = (argv[arg++][0] == 'c' ? CONE_SERVICE : SIAP_SERVICE); + ra = atof (argv[arg++]); /* parse arguments */ + dec = atof (argv[arg++]); + sr = atof (argv[arg++]); + if (arg < argc) + type = (argv[arg++][0] == 'v' ? VOC_VOTABLE : VOC_CSV); + if (arg < argc) + service = argv[arg++]; + + } else { + fprintf (stderr, "Usage: simpleCone ra dec sr [type [coneURL]]\n"); + exit(1); + } + + /* Now call the Cone Service and print the results. + */ + if (svc_type == CONE_SERVICE) + result = voc_coneCaller (service, ra, dec, sr, type); + else if (svc_type == SIAP_SERVICE) + result = voc_siapCaller (service, ra, dec, sr, sr, "image/fits", type); + + if (result) + write (fileno(stdout), result, strlen (result)); + else { + fprintf (stderr, "Error executing query\n"); + status = 1; + } + + return (status); +} |