aboutsummaryrefslogtreecommitdiff
path: root/vendor/voclient/voapps/voApps.h
blob: f5ad6cca294b16c978f230bfa37de3392708e499 (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
/**
 *  VOAPPS.h -- Task declarations for the VOClient Package applications.
 *
 *  @file       voApps.h
 *  @author     Mike Fitzpatrick
 *  @date       6/03/11
 *
 *  @brief      Task declarations for the VOClient Package applications.
 */


#include <getopt.h>


#ifdef  SZ_FORMAT
#undef  SZ_FORMAT
#endif
#define	SZ_FORMAT		32

#ifdef  SZ_FNAME
#undef  SZ_FNAME
#endif
#define SZ_FNAME		256

#ifdef  SZ_PATH
#undef  SZ_PATH
#endif
#define SZ_PATH			512

#ifdef  SZ_LINE
#undef  SZ_LINE
#endif
#define	SZ_LINE			4096

#define PARG_ERR		-127

#define	dabs(x)		((x<0.0?-x:x))

/*  Debug and verbose flags.
 */
#define VOAPP_DEBUG  (getenv("VOAPP_DBG")||access("/tmp/VOAPP_DBG",F_OK)==0)
#define VOAPP_VERB   (getenv("VOAPP_VERB")||access("/tmp/VOAPP_VERB",F_OK)==0)

/**
 *  Output formats.
 */
#define FORMATS "|vot|asv|bsv|csv|tsv|html|shtml|fits|ascii|xml|raw|"

#define VOT     0                       /* A new VOTable                */
#define ASV     1                       /* ascii separated values       */
#define BSV     2                       /* bar separated values         */
#define CSV     3                       /* comma separated values       */
#define TSV     4                       /* tab separated values         */
#define HTML    5                       /* standalone HTML document     */
#define SHTML   6                       /* single HTML <table>          */
#define FITS    7                       /* FITS binary table            */
#define ASCII   8                       /* ASV alias                    */
#define XML     9                       /* VOTable alias                */
#define RAW     10                      /*    "      "                  */



/*  SAMP Definitions.
 */
#define SESS_CALLBACK   0               /* mgr sends callback port      */
#define SESS_QUIT       1               /* mgr sends quit/client quits  */
#define SESS_SEND       2               /* mgr/client forwards cmd      */
#define SESS_READY      3               /* mgr ready on port            */

#define SESS_DEFPORT  3000              /* default session mgr port 	*/
#define SESS_DEFHOST  "140.252.1.86"    /* default session mgr host 	*/

#define SAMP_CMD      000               /* message is a command         */
#define SAMP_DATA     001               /* message is data file         */
#define SAMP_RESULT   002               /* message is cmd result        */
#define SAMP_QUIT     004               /* message is quit request      */
#define SAMP_RELAY    010               /* message is relayed           */
#define SAMP_TEST     020               /* message is a test connect    */


/*  File Formats.
 */
#define	VOT_FITS		0
#define	VOT_VOTABLE		1
#define	VOT_FITS_SPEC		2
#define	VOT_VOTABLE_SPEC	3

/*  URL Formats.
 */
#define	VOS_LOCALURL		0	/* e.g. http://127.0.0.1/foo	*/
#define	VOS_LOCALURI		1	/* e.g. file:///path/foo	*/
#define	VOS_LOCALFILE		2	/* e.g. /path/foo		*/
#define	VOS_REMOTE 		3	/* e.g. http://foo.bar/junk	*/



/******************************************************************************
 *  Image information structure.  Note that although we can report 3-D
 *  images, we're really only setup to deal with equatorial sky coord
 *  systems.
 *****************************************************************************/
typedef struct {
    char   *imname;                             /* image name 		    */
    int     is_image;                           /* is it an image?  	    */
    int     is_table;                           /* is it a table?  	    */
    int     has_wcs;                            /* image has wcs 	    */

    int     extnum;                             /* extension number 	    */
    int     naxis;                              /* number of axes 	    */
    int     naxes[3];                           /* axis dimensions 	    */
    int     bitpix;                             /* pixel size 		    */
    int     axflip;                             /* are axes flipped?	    */

    double  xc[4], yc[4];                       /* corner positions (wcs)   */
    double  cx, cy;                             /* center position (wcs)    */
    double  lx, ly;                             /* LL corner (wcs) 	    */
    double  ux, uy;                             /* UR corner (wcs) 	    */
    double  xrval, yrval;                       /* CRVAL values 	    */
    double  xrpix, yrpix;                       /* CRPIX values 	    */

    double  width, height;                      /* image width/height (deg) */
    double  radius;                             /* cone radius (deg) 	    */
    double  rotang;                             /* rotation angle (deg)     */
    double  scale;                              /* plate scale (""/pix)     */
    char    ctype[5];                           /* coordinate type 	    */
} frameInfo, *frameInfoP;

typedef struct {
    char        imname[SZ_PATH];                /* full image name 	    */
    int         nextend;                        /* number of extensions     */

    frameInfo   frame;                          /* full frame information   */
    frameInfo  *extns;                          /* image extn information   */
} ImInfo, *ImInfoP;


ImInfo *vot_imageInfo (char *name, int do_all);
void    vot_printImageInfo (FILE *fd, ImInfo *im);
int     vot_imageNExtns (char *image);
void    vot_freeImageInfo (ImInfo *img);



/*  Task structure.
 */
typedef struct {
   char	 *name;				/* task name		      	*/
   int  (*func)(int argc, char **argv, size_t *len, void **result);

   int   ntests;			/* number of unit tests		*/
   int   npass;				/* number of passed tests	*/
   int   nfail;				/* number of failed tests	*/
} Task;


/*  Tasking execution procedure.
 */
int  vo_runTask (char *method, Task *apps, int argc, char **argv, size_t *len, 
		    void **result);
int  vo_taskTest (Task *self, char *arg, ...);
void vo_taskTestFile (char *str, char *fname);
void vo_taskTestReport (Task self);
void vo_taskDbg (void);

int  vo_setResultFromFile (char *fname, size_t *len, void **data);
int  vo_setResultFromString (char *str, size_t *len, void **data);
int  vo_setResultFromInt (int value, size_t *len, void **data);
int  vo_setResultFromReal (float value, size_t *len, void **data);
int  vo_appendResultFromString (char *str, size_t *len, void **data, 
		size_t *maxlen);



/*  Tasking parameter procedures.
 */
char **vo_paramInit (int argc, char *argv[],
                char *opts, struct option long_opts[]);
int    vo_paramNext (char *opts, struct option long_opts[], 
		int argc, char *argv[], char *optval, int *posindex);
void   vo_paramFree (int argc, char *argv[]);