00001
00002
00003
00004
00005
00006
00007 #include <stdio.h>
00008 #include <unistd.h>
00009 #include <string.h>
00010 #include <ctype.h>
00011 #include <sys/file.h>
00012 #include <sys/types.h>
00013 #include <sys/socket.h>
00014 #include <netinet/in.h>
00015 #include <arpa/inet.h>
00016 #include <sys/un.h>
00017 #include <netdb.h>
00018 #include <fcntl.h>
00019
00020
00021
00022 #ifdef __STDC__
00023 #include <stddef.h>
00024 #include <stdlib.h>
00025 #else
00026 char *getenv();
00027 #endif
00028
00029
00030
00031 typedef void (*SIGFUNC)();
00032
00033
00034
00035
00036
00037
00038
00039 #ifdef OK
00040 #undef OK
00041 #endif
00042 #define OK 0
00043
00044 #ifdef ERR
00045 #undef ERR
00046 #endif
00047 #define ERR 1
00048
00049 #ifdef TRUE
00050 #undef TRUE
00051 #endif
00052 #define TRUE 1
00053
00054 #ifdef FALSE
00055 #undef FALSE
00056 #endif
00057 #define FALSE 0
00058
00059 #define DEF_SERVER "6200:localhost"
00060 #define DEF_NET_SERVER "9000:iraf-nvo.noao.edu"
00061
00062 #define MSG_CALL 1
00063 #define MSG_RESULT 2
00064 #define MSG_MESSAGE 3
00065
00066 #define TY_INT 1
00067 #define TY_FLOAT 2
00068 #define TY_STRING 3
00069 #define TY_BULK 4
00070
00071 #define SZ_MSGBUF 102400
00072 #define SZ_METHOD 64
00073 #define SZ_CLASS 64
00074 #define SZ_MSGSTR 65535
00075 #define SZ_PBUF 128
00076 #define SZ_FNAME 128
00077 #define MAX_VALUES 64
00078
00079 #define DAL_CONN 1
00080 #define CONE_CONN 2
00081 #define SIAP_CONN 3
00082 #define SSAP_CONN 4
00083 #define TAP_CONN 5
00084
00085 #define CONE_SERVICE 1
00086 #define SIAP_SERVICE 2
00087 #define SSAP_SERVICE 3
00088 #define TAP_SERVICE 4
00089 #define REG_SERVICE 5
00090 #define SKYNODE_SERVICE 6
00091 #define WEB_SERVICE 7
00092 #define REST_SERVICE 8
00093
00094 #define VOC_RAW 0
00095 #define VOC_CSV 1
00096 #define VOC_TSV 2
00097 #define VOC_ASCII 3
00098 #define VOC_VOTABLE 4
00099
00100
00101
00102 typedef int ObjectID;
00103 typedef int DAL;
00104 typedef int Query;
00105 typedef int QResponse;
00106 typedef int QRecord;
00107 typedef int QRAttribute;
00108
00109 typedef int Sesame;
00110
00111 typedef int Skybot;
00112
00113 typedef int RegQuery;
00114 typedef int RegResult;
00115
00116 #ifdef _VOCLIENT_LIB_
00117
00118 typedef struct vocMsg {
00119 int type;
00120
00121 ObjectID objId;
00122 char method[SZ_METHOD];
00123 int nparams;
00124
00125 int status;
00126 int restype;
00127 int nitems;
00128
00129 char class[SZ_CLASS];
00130 char msgstr[SZ_MSGSTR];
00131
00132 char message[SZ_MSGBUF];
00133 } vocMsg_t;
00134
00135
00136
00137 typedef struct vocRes {
00138 int status;
00139 int type;
00140 int nitems;
00141 char value[MAX_VALUES][SZ_MSGSTR];
00142
00143 void *buf;
00144 int buflen;
00145 } vocRes_t;
00146
00147
00148 typedef struct VOClient {
00149 char *server_host;
00150 int server_port;
00151 int io_chan;
00152
00153 int msg_port;
00154 int msg_chan;
00155
00156 int onetrip;
00157 int debug;
00158 int quiet;
00159 int use_cache;
00160
00161 } VOClient, *VOClientPtr;
00162
00163
00164 #define VOC_DEBUG (vo->debug > 0)
00165 #define MSG_DEBUG (vo->debug > 1)
00166
00167 #endif
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 char *voc_coneCaller (char *url, double ra, double dec, double sr,
00179 int otype);
00180 int voc_coneCallerToFile (char *url, double ra, double dec, double sr,
00181 int otype, char *file);
00182
00183 char *voc_siapCaller (char *url, double ra, double dec, double rsize,
00184 double dsize, char *fmt, int otype);
00185 int voc_siapCallerToFile (char *url, double ra, double dec,
00186 double rsize, double dsize, char *fmt, int otype, char *file);
00187 char *voc_ssapCaller (char *url, double ra, double dec,
00188 double size, char *band, char *time, char *fmt, int otype);
00189 int voc_ssapCallerToFile (char *url, double ra, double dec,
00190 double size, char *band, char *time, char *fmt, int otype,
00191 char *file);
00192 char *voc_getRawURL (char *url, int *nbytes);
00193 int voc_validateObject (int hcode);
00194 void voc_freePointer (char *ptr);
00195
00196
00197 int voc_initVOClient (char *opts);
00198 void voc_closeVOClient (int shutdown);
00199 void voc_abortVOClient (int code, char *msg);
00200
00201 DAL voc_openConnection (char *service_url, int type);
00202 DAL voc_openConeConnection (char *service_url);
00203 DAL voc_openSiapConnection (char *service_url);
00204 DAL voc_openSsapConnection (char *service_url);
00205 void voc_closeConnection (DAL dal);
00206
00207 int voc_getServiceCount (DAL dal);
00208 void voc_addServiceURL (DAL dal, char *service_url);
00209 char *voc_getServiceURL (DAL dal, int index);
00210
00211 Query voc_getQuery (DAL dal, int type);
00212 Query voc_getConeQuery (DAL dal, double ra, double dec, double sr);
00213 Query voc_getSiapQuery (DAL dal, double ra, double dec,
00214 double ra_size, double dec_size, char *format);
00215 Query voc_getSsapQuery (DAL dal, double ra, double dec,
00216 double size, char *band, char *time, char *format);
00217
00218 int voc_addIntParam (Query query, char *name, int value);
00219 int voc_addFloatParam (Query query, char *name, double value);
00220 int voc_addStringParam (Query query, char *name, char *value);
00221
00222 char *voc_getQueryString (Query query, int type, int index);
00223
00224 QResponse voc_executeQuery (Query query);
00225 QResponse voc_getQueryResponse (Query query);
00226 char *voc_executeCSV (Query query);
00227 char *voc_executeTSV (Query query);
00228 char *voc_executeASCII (Query query);
00229 char *voc_executeVOTable (Query query);
00230 int voc_executeQueryAs (Query query, char *fname, int type);
00231 int voc_getRecordCount (QResponse qr);
00232
00233 QRecord voc_getRecord (QResponse qr, int recnum);
00234 char *voc_getFieldAttr (QResponse qr, int fieldnum, char *attr);
00235
00236 QRAttribute voc_getAttribute (QRecord rec, char *attrname);
00237
00238 int voc_intValue (QRAttribute v);
00239 double voc_floatValue (QRAttribute v);
00240 char *voc_stringValue (QRAttribute v);
00241
00242 int voc_getIntAttr (QRecord rec, char *attr_name);
00243 double voc_getFloatAttr (QRecord rec, char *attr_name);
00244 char *voc_getStringAttr (QRecord rec, char *attr_name);
00245
00246 char *voc_getAttrList (QRecord rec);
00247 int voc_getAttrCount (QRecord rec);
00248
00249 void voc_setIntAttr (QRecord rec, char *attrname, int ival);
00250 void voc_setFloatAttr (QRecord rec, char *attrname, double dval) ;
00251 void voc_setStringAttr (QRecord rec, char *attrname, char *str);
00252
00253 int voc_getDataset (QRecord rec, char *acref, char *fname);
00254
00255
00256
00257
00258
00259
00260 RegResult voc_regSearch (char *term1, char *term2, int orValues);
00261 RegResult voc_regSearchByService (char *svc, char *term, int orValues);
00262 RegQuery voc_regQuery (char *term, int orValues);
00263 void voc_regConstSvcType (RegQuery query, char *svc);
00264 void voc_regConstWaveband (RegQuery query, char *bpass);
00265 void voc_regDALOnly (RegQuery query, int value);
00266 void voc_regSortRes (RegQuery query, int value);
00267 void voc_regAddSearchTerm (RegQuery query, char *term, int orValue);
00268 void voc_regRemoveSearchTerm (RegQuery query, char *term);
00269 int voc_regGetSTCount (RegQuery query);
00270 char *voc_regGetQueryString (RegQuery query);
00271 RegResult voc_regExecute (RegQuery query);
00272 char *voc_regExecuteRaw (RegQuery query);
00273
00274 int voc_resGetCount (RegResult res);
00275 char *voc_resGetStr (RegResult res, char *attribute, int index);
00276 double voc_resGetFloat (RegResult res, char *attribute, int index);
00277 int voc_resGetInt (RegResult res, char *attribute, int index);
00278
00279
00280
00281
00282
00283 Sesame voc_nameResolver (char *target);
00284 char *voc_resolverPos (Sesame sr);
00285 double voc_resolverRA (Sesame sr);
00286 double voc_resolverDEC (Sesame sr);
00287 double voc_resolverRAErr (Sesame sr);
00288 double voc_resolverDECErr (Sesame sr);
00289 char *voc_resolverOtype (Sesame sr);
00290
00291
00292
00293
00294
00295 Skybot voc_skybot (double ra, double dec, double rsz, double dsz,
00296 double epoch);
00297 int voc_skybotNObjs (Skybot sb);
00298 char *voc_skybotStrAttr (Skybot sb, char *attr, int index);
00299 double voc_skybotDblAttr (Skybot sb, char *attr, int index);
00300
00301
00302
00303
00304
00305
00306 #ifdef _VOCLIENT_LIB_
00307
00308 vocMsg_t *msg_newCallMsg (ObjectID objid, char *method, int nparams);
00309 vocMsg_t *msg_newResultMsg (int status, int type, int nitems);
00310 vocMsg_t *msg_newMsg (char *class, char *str);
00311
00312 vocMsg_t *msg_shutdownMsg ();
00313 vocMsg_t *msg_quitMsg ();
00314 vocMsg_t *msg_ackMsg ();
00315
00316 vocRes_t *msg_sendMsg (int fd, vocMsg_t *msg);
00317 int msg_sendRawMsg (int fd, vocMsg_t *msg);
00318
00319 vocRes_t *msg_getResult (int fd);
00320 vocRes_t *msg_getResultToFile (int fd, char *fname, int overwrite);
00321
00322 void msg_addIntParam (vocMsg_t *msg, int ival);
00323 void msg_addFloatParam (vocMsg_t *msg, double dval);
00324 void msg_addStringParam (vocMsg_t *msg, char *str);
00325 void msg_addIntResult (vocMsg_t *msg, int ival);
00326 void msg_addFloatResult (vocMsg_t *msg, double dval);
00327 void msg_addStringResult (vocMsg_t *msg, char *str);
00328
00329 int msg_resultStatus (vocRes_t *res);
00330 int msg_resultType (vocRes_t *res);
00331 int msg_resultLength (vocRes_t *res);
00332
00333 int msg_getIntResult (vocRes_t *res, int index);
00334 double msg_getFloatResult (vocRes_t *res, int index);
00335 char *msg_getStringResult (vocRes_t *res, int index);
00336 void *msg_getBuffer (vocRes_t *res);
00337 char *msg_getFilename (vocRes_t *res);
00338
00339 #endif