aboutsummaryrefslogtreecommitdiff
path: root/vendor/voclient/libvoclient/vocSesame_spp.c
blob: d72af9ab7245cef67c02508b18acc66dbf5420ab (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
/**
 *  VOCSESAME_SPP.C -- SPP Interface to the Sesame name resolver service.
 *
 *  @section DESCRIPTION
 *
 *  Sesame Name Resolver SPP Interface:
 *  -----------------------------------
 *
 *          sr = vx_nameResolver  (target)
 *      pos_str = vx_resolverPos  (sr)
 *         radeg = vx_resolverRA  (sr)
 *       decdeg = vx_resolverDEC  (sr)
 *    typ_str = vx_resolverOtype  (sr)
 *      raerr = vx_resolverRAErr  (sr)
 *    decerr = vx_resolverDECErr  (sr)
 * 
 *  @file       vocSesame_spp.c
 *  @author     Michael Fitzpatrick
 *  @version    June 2006
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>

#define _VOCLIENT_LIB_
#include "VOClient.h"

#ifdef _NO_US_

#define vx_nameresolver		vxnamr
#define vx_resolverra		vxresa
#define vx_resolverdec		vxresc
#define vx_resolverpos		vxress
#define vx_resolverotype	vxrese

#define vx_errresolverra	vxerra
#define vx_errresolverdec	vxerrc

#else

#define vx_nameresolver		vxnamr_
#define vx_resolverra		vxresa_
#define vx_resolverdec		vxresc_
#define vx_resolverpos		vxress_
#define vx_resolverotype	vxrese_

#define vx_errresolverra	vxerra_
#define vx_errresolverdec	vxerrc_


#endif


/* SPP Type definitions.
*/
#define XCHAR           short
#define PKCHAR          char
#define XINT            int
#define XEOS            NULL


/*  Public interface procedures
*/
int	vx_nameresolver (XCHAR *target);
int	vx_resolverpos (int *sr, XCHAR *pos, int *len);
double	vx_resolverra (int *sr);
double	vx_resolverdec (int *sr);
int	vx_resolverotype (int *sr, XCHAR *type, int *len);
double	vx_errresolverra (int *sr);
double	vx_errresolverdec (int *sr);


/*  Private interface procedures.
*/
extern PKCHAR *spp2c (XCHAR *instr,  int maxch);
extern int     c2spp (PKCHAR *instr, XCHAR *outstr, int maxch);
extern int    spplen (XCHAR *str);



/**
 *  VX_NAMERESOLVER -- Query the CDS Sesame service to resolve the target
 *  name to coordinates.  The query is done when creating the Sesame object, 
 *  thereafter we simply query the object data.
 *
 *  @brief      Query the CDS Sesame name resolver service.
 *  @fn         sr = vx_nameresolver (XCHAR *target)
 *
 *  @param  target      name of target to be resolved
 *  @returns            handle to Sesame object
 */
int
vx_nameresolver (XCHAR *target)
{
    char *_target = spp2c (target, spplen (target));

    Sesame   ier = (Sesame) voc_nameResolver (_target);

    free ((char *) _target);
    return (ier);
}


/**
 *  VX_RESOLVERPOS --  Return a string containing the (ra,dec) position as
 *  sexagesimal strings. 
 *
 *  @brief      Return a string containing the (ra,dec) position.
 *  @fn         len = vx_resolverpos (int *sr, XCHAR *pos, int *maxch)
 *
 *  @param  sr      	handle to Sesame object
 *  @param  pos         returned position string
 *  @param  maxch       max size of position string
 *  @returns            length of position string
 */
int
vx_resolverpos (int *sr, XCHAR *pos, int *maxch)
{
    char *_result = voc_resolverPos ((Sesame) *sr);
    int  len = c2spp (_result, pos, *maxch);

    free ((char *) _result);
    return (len);
}


/**
 *  VX_RESOLVEROTYPE --  Return a string containing the object type description.
 *
 *  @brief      Return a string containing the object type description.
 *  @fn         len = vx_resolvertype (int *sr, XCHAR *type, int *maxch)
 *
 *  @param  sr      	handle to Sesame object
 *  @param  pos         returned object type
 *  @param  maxch       max size of type string
 *  @returns            length of type string
 */
int
vx_resolverotype (int *sr, XCHAR *type, int *maxch)
{
    char *_result = voc_resolverOtype ((Sesame) *sr);
    int  len = c2spp (_result, type, *maxch);

    free ((char *) _result);
    return (len);
}


/**
 *  VX_RESOLVERRA --  Return the RA as a double precision value.
 *
 *  @brief      Return the RA as a double precision value.
 *  @fn         ra = vx_resolverra (int *sr)
 *
 *  @param  sr      	handle to Sesame object
 *  @returns            RA of object position (decimal degrees)
 */
double      
vx_resolverra (int *sr)
{
   return ( voc_resolverRA ((Sesame) *sr) );
}


/**
 *  VX_RESOLVERDEC --  Return the DEC as a double precision value. 
 *
 *  @brief      Return the DEC as a double precision value. 
 *  @fn         dec = vx_resolverdec (int *sr)
 *
 *  @param  sr      	handle to Sesame object
 *  @returns            Dec of object position (decimal degrees)
 */
double      
vx_resolverdec (int *sr)
{
   return ( voc_resolverDEC ((Sesame) *sr) );
}


/**
 *  VX_ERRRESOLVERRA --  Return the RA error as a double precision value.
 *
 *  @brief      Return the RA error as a double precision value.
 *  @fn         err = vx_errresolverra (int *sr)
 *
 *  @param  sr      	handle to Sesame object
 *  @returns            RA error of object position (decimal degrees)
 */
double      
vx_errresolverra (int *sr)
{
   return ( voc_resolverRAErr ((Sesame) *sr) );
}


/**
 *  VX_ERRRESOLVERDEC --  Return the DEC as a double precision value. 
 *
 *  @brief      Return the Dec error as a double precision value.
 *  @fn         err = vx_errresolverdec (int *sr)
 *
 *  @param  sr      	handle to Sesame object
 *  @returns            Dec error of object position (decimal degrees)
 */
double      
vx_errresolverdec (int *sr)
{
   return ( voc_resolverDECErr ((Sesame) *sr) );
}