aboutsummaryrefslogtreecommitdiff
path: root/vendor/voclient/libvoclient/vocSesame_f77.c
blob: c8ab8d0421dd2463b4b6ad8b6432f6f010f27776 (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
/**
 *  VOCSESAME_F77.C -- F77 Interface to the Sesame name resolver service.
 *
 *  @section DESCRIPTION
 *
 *  Sesame Name Resolver F77 Interface:
 *  -----------------------------------
 *
 *         vf_nameResolver  (target, sr)
 *          vf_resolverPos  (sr, pos_str, len)
 *           vf_resolverRA  (sr, radeg)
 *        vf_resolverRAErr  (sr, radeg)
 *          vf_resolverDEC  (sr, decdeg)
 *       vf_resolverDECErr  (sr, decdeg)
 * 
 *  @file       vocSesame_f77.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 VF_NAMERESOLVER		vfnameresolver
#define VF_RESOLVERRA		vfresolverra
#define VF_RESOLVERDEC		vfresolverdec
#define VF_RESOLVERPOS		vfresolverpos
#define VF_RESOLVERRAERR	vfresolverraerr
#define VF_RESOLVERDECERR	vfresolverdecerr
#define VF_RESOLVEROTYPE	vfresolverotype

#else

#define VF_NAMERESOLVER		vfnameresolver_
#define VF_RESOLVERRA		vfresolverra_
#define VF_RESOLVERDEC		vfresolverdec_
#define VF_RESOLVERPOS		vfresolverpos_
#define VF_RESOLVERRAERR	vfresolverraerr_
#define VF_RESOLVERDECERR	vfresolverdecerr_
#define VF_RESOLVEROTYPE	vfresolverotype_

#endif


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



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

/**
 *  VF_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         call vfnameresolver (char *target, int *sr)
 *
 *  @param  target      name of target to be resolved
 *  @param  sr      	returned Sesame handle
 *  @returns            nothing
 */
void
VF_NAMERESOLVER (char *target, int *sr, int tlen)
{
    char *_target = sstrip (target, tlen);

    *sr = (int) voc_nameResolver (_target);

    free ((char *) _target);
}


/**
 *  VF_RESOLVERPOS --  Return a string containing the (ra,dec) position as
 *  sexagesimal strings. 
 *
 *  @brief      Get the resolved position as a string
 *  @fn         call vfresolverpos (int *srm char *target, int *sr)
 *
 *  @param  sr      	Sesame handle
 *  @param  pos         position string
 *  @returns            nothing
 */
void
VF_RESOLVERPOS (int *sr, char *pos, int *len, int plen)
{
    char *_result = voc_resolverPos ((Sesame) *sr);

    memset (pos, 0, plen);
    if ((*len = strlen(_result)) > plen)
        fprintf (stderr, "Warning: truncating POS string: len=%d maxch=%d\n",
            *len, plen);
    spad (strncpy (pos, _result, *len), plen);

    free ((char *) _result);
}


/**
 *  VF_RESOLVEROTYPE --  Return a string containing the object type description
 *
 *  @brief      Get the object type description string
 *  @fn         call vfresolverotype (int *sr, char *type)
 *
 *  @param  sr      	Sesame handle
 *  @param  type        object type string
 *  @returns            nothing
 */
void
VF_RESOLVEROTYPE (int *sr, char *otype, int *len, int olen)
{
    char *_result = voc_resolverOtype ((Sesame) *sr);

    memset (otype, 0, olen);
    if ((*len = strlen(_result)) > olen)
        fprintf (stderr, "Warning: truncating OType string: len=%d maxch=%d\n",
            *len, olen);
    spad (strncpy (otype, _result, *len), olen);

    free ((char *) _result);
}


/**
 *  VF_RESOLVERRA --  Return the RA as a double precision value.
 *
 *  @brief      Return the RA as a double precision value.
 *  @fn         call vfresolverra (int *sr, double *ra)
 *
 *  @param  sr      	Sesame handle
 *  @param  ra          RA of object (decimal degrees)
 *  @returns            nothing
 */
void
VF_RESOLVERRA (int *sr, double *ra)
{
   *ra = voc_resolverRA ((Sesame) *sr);
}


/**
 *  VF_RESOLVERDEC --  Return the DEC as a double precision value. 
 *
 *  @brief      Return the DEC as a double precision value. 
 *  @fn         call vfresolverdec (int *sr, double *dec)
 *
 *  @param  sr      	Sesame handle
 *  @param  dec      	Dec of object (decimal degrees)
 *  @returns            nothing
 */
void
VF_RESOLVERDEC (int *sr, double *dec)
{
   *dec = voc_resolverDEC ((Sesame) *sr);
}


/**
 *  VF_RESOLVERRAERR --  Return the RA error as a double precision value.
 *
 *  @brief      Return the RA error as a double precision value.
 *  @fn         call vfresolverraerr (int *sr, double *err)
 *
 *  @param  sr      	Sesame handle
 *  @param  target      RA error of position (decimal degrees)
 *  @returns            nothing
 */
void
VF_RESOLVERRAERR (int *sr, double *err)
{
   *err = voc_resolverRAErr ((Sesame) *sr);
}


/**
 *  VF_RESOLVERDECERR --  Return the DEC error as a double precision value. 
 *
 *  @brief      Return the DEC error as a double precision value. 
 *  @fn         call vfresolverdecerr (int *sr, double *err)
 *
 *  @param  sr      	Sesame handle
 *  @param  target      Dec error of position (decimal degrees)
 *  @returns            nothing
 */
void
VF_RESOLVERDECERR (int *sr, double *err)
{
   *err = voc_resolverDECErr ((Sesame) *sr);
}