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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
|
/**
* VOC_REGISTRYQUERY -- Utility code to act as a client interface to
* the NVO Registry service.
*
* RegistryQuery
* ----------------------
*
* High-Level Query:
*
* res = voc_regSearch (sql, keywords, orValues)
* res =voc_regSearchByService (svc, term, orValues)
*
* Programmatic Query:
*
* query = voc_regQuery (term, orValues) // OR keyword list?
*
* voc_regConstSvcType (query, svcType) // search constraints
* voc_regConstWaveband (query, waveband)
* voc_regDALOnly (query, value)
* voc_regSortRes (query, value)
*
* voc_regAddSearchTerm (query, term, orValue) // OR term w/ previous
* voc_regRemoveSearchTerm (query, term) // remove search term
* count = voc_regGetSTCount (query)
*
* str = voc_regGetQueryString (query) // GET form of query
*
* res = voc_regExecute (query) // return result obj
* str = voc_regExecuteRaw (query) // return raw XML
*
* RegistryQueryResult
*
* count = voc_resGetCount (res)
*
* str = voc_resGetStr (res, attribute, index)
* dval = voc_resGetFloat (res, attribute, index)
* ival = voc_resGetInt (res, attribute, index)
*
* For this implementation, we've chose to use the NVO Registry at
* JHU/STScI, specifically the QueryRegistry() method which provides a
* 'SimpleResource' form of the resource record. Support for the newer
* IVOA standard will be added later, for now we can quickly access the most
* commonly used fields of a resource using both a keyword and SQL form of
* the search.
*
*
* @file vocRegistry.c
* @author Michael Fitzpatrick
* @version July 2006
*
*************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#define _VOCLIENT_LIB_
#include "VOClient.h"
extern VOClient *vo; /* Interface runtime struct */
/**
* VOC_REGSEARCH -- High-level procedure to form a query and execute it
* immediately. We allow that 'term1' may be a complex SQL WHERE predicate,
* and that 'term2' (or vice versa) is a search-keyword list. The
* 'orValues' applies to the keyword list (if present), otherwise it applies
* to the two search term elements. The default action if two terms are
* specified is to logically AND them.
*
* The thinking here is that one might want SIAP services for Quasars. This
* is easily expressed in an SQL form to get SIAP resources, however a
* Quasar may be known as a QSO, AGN, active-nuclei, etc and so we need a
* easy way to OR the keywords but AND that result with the SQL predicate.
*
* @brief High-level Registry query interface
* @fn res = voc_regSearch (char *term1, char *term2, int orValues)
*
* @param term1 first search term
* @param term2 second search term
* @param orValues logically OR values?
* @returns handle to Registry result object
*/
RegResult
voc_regSearch (char *term1, char *term2, int orValues)
{
RegResult res = (RegResult) VOC_NULL;
vocRes_t *result = (vocRes_t *) NULL;
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (0, "regSearch", 0);
if (vo == (VOClient *) NULL) {
fprintf(stderr,"FATAL: VOClient not initialized in regSearch()\n");
exit (1);
}
if (term1 && term1[0]) {
msg_addStringParam (msg, term1);
}
if (term2 && term2[0]) {
msg_addStringParam (msg, term2);
msg_addIntParam (msg, orValues);
}
/* Send message and read result.
*/
if (msg_resultStatus ((result = msg_sendMsg (vo->io_chan, msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: regSearch() failed\n");
} else
res = msg_getIntResult (result, 0);
free ((void *)msg); /* free the pointers */
free ((void *)result);
return ((RegResult) res);
}
/**
* VOC_REGSEARCHBYSERVICE -- Search the Registry using a search term and
* constrain by service type.
*
* @brief Search Registry using a search term and service constraint
* @fn res = voc_regSearchByService (char *svc, char *term, int orValues)
*
* @param svc service type constraint
* @param term keyword search term
* @param orValues logically OR values?
* @returns handle to Registry result object
*/
RegResult
voc_regSearchByService (char *svc, char *term, int orValues)
{
RegResult res = (RegResult) VOC_NULL;
vocRes_t *result = (vocRes_t *) NULL;
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (0, "regSearchBySvc", 0);
if (vo == (VOClient *) NULL) {
fprintf(stderr,"FATAL: VOClient not initialized in regSearchBySvc()\n");
exit (1);
}
msg_addStringParam (msg, svc);
msg_addStringParam (msg, term);
msg_addIntParam (msg, orValues);
/* Send message and read result.
*/
if (msg_resultStatus ((result = msg_sendMsg (vo->io_chan, msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: regSearchBySvc() failed\n");
} else
res = msg_getIntResult (result, 0);
free ((void *)msg); /* free the pointers */
free ((void *)result);
return ((RegResult) res);
}
/**
* VOC_REGQUERY -- Create a RegistryQuery object.
*
* @brief Create a RegistryQuery object.
* @fn v = voc_regQuery (char *term, int orValues)
*
* @param term keyword search term
* @param orValues logically OR values?
* @returns handle to Registry Query object
*/
RegQuery
voc_regQuery (char *term, int orValues)
{
RegQuery query = (RegQuery) VOC_NULL;
if (vo == (VOClient *) NULL) {
fprintf(stderr,"FATAL: VOClient not initialized in regQuery()\n");
exit (1);
}
if (term) {
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (0, "regQuery", 0);
vocRes_t *result = (vocRes_t *) NULL;
msg_addStringParam (msg, term);
msg_addIntParam (msg, orValues);
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: regQuery() failed\n");
} else
query = msg_getIntResult (result, 0);
free ((void *)msg); /* free the pointers */
free ((void *)result);
} else if (!vo->quiet)
fprintf (stderr, "ERROR: empty search term\n");
return (query);
}
/**
* VOC_REGADDSEARCHTERM -- Add a search term (sql predicate or keyword list)
* to the specified query.
*
* @brief Add a search term to the specified query
* @fn voc_regAddSearchTerm (RegQuery query, char *term, int orValue)
*
* @param query Registry query handle
* @param term keyword search term
* @param orValues logically OR values?
* @returns nothing
*/
void
voc_regAddSearchTerm (RegQuery query, char *term, int orValue)
{
if (query > 0) {
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (query,
"regAddSearchTerm", 0);
vocRes_t *result = (vocRes_t *) NULL;
msg_addStringParam (msg, term);
msg_addIntParam (msg, orValue);
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: regAddSearchTerm() failed\n");
}
free ((void *)msg); /* free the pointers */
free ((void *)result);
} else if (!vo->quiet)
fprintf (stderr, "ERROR: Null result record to regAddSearchTerm\n");
}
/**
* VOC_REMOVESEARCHTERM -- Remove the search term from the query.
*
* @brief Remove a search term to the specified query
* @fn voc_regRemoveSearchTerm (RegQuery query, char *term)
*
* @param query Registry query handle
* @param term keyword search term
* @returns nothing
*/
void
voc_regRemoveSearchTerm (RegQuery query, char *term)
{
if (query > 0) {
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (query,
"regRemoveSearchTerm", 0);
vocRes_t *result = (vocRes_t *) NULL;
msg_addStringParam (msg, term);
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: regRemoveSearchTerm() failed\n");
}
free ((void *)msg); /* free the pointers */
free ((void *)result);
} else if (!vo->quiet)
fprintf (stderr, "ERROR: Null result record to regRemoveSearchTerm\n");
}
/**
* VOC_REGCONSTWAVEBAND -- Constrain the Registry search by waveband.
*
* @brief Constrain the Registry search by waveband.
* @fn voc_regConstWaveband (RegQuery query, char *waveband)
*
* @param query Registry query handle
* @param waveband waveband string
* @returns nothing
*/
void
voc_regConstWaveband (RegQuery query, char *waveband)
{
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (query, "regConstWaveband", 0);
vocRes_t *result = (vocRes_t *) NULL;
msg_addStringParam (msg, waveband);
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: regConstWaveband() failed\n");
}
free ((void *)msg); /* free the pointers */
free ((void *)result);
}
/**
* VOC_REGCONSTSVCTYPE -- Constraing the Registry search by service type.
*
* @brief Constrain the Registry search by service type.
* @fn voc_regConstWaveband (RegQuery query, char *svcType)
*
* @param query Registry query handle
* @param svcType service type string
* @returns nothing
*/
void
voc_regConstSvcType (RegQuery query, char *svcType)
{
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (query, "regConstSvcType", 0);
vocRes_t *result = (vocRes_t *) NULL;
msg_addStringParam (msg, svcType);
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: regConstSvcType() failed\n");
}
free ((void *)msg); /* free the pointers */
free ((void *)result);
}
/**
* VOC_REGDALONLY -- Set the "DAL Only" flag. If set, we expand a resource
* search to break out the individual DAL services into separate results.
*
* @brief Set the "DAL Only" flag
* @fn voc_regDALOnly (RegQuery query, int value)
*
* @param query Registry query handle
* @param value value of the DAL-only flag
* @returns nothing
*/
void
voc_regDALOnly (RegQuery query, int value)
{
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (query, "regDALOnly", 0);
vocRes_t *result = (vocRes_t *) NULL;
msg_addIntParam (msg, value);
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: regDALOnly() failed\n");
}
free ((void *)msg); /* free the pointers */
free ((void *)result);
}
/**
* VOC_REGSORTRES -- Set the resource "sort" flag. If enabled, we try to
* order the resource table by some logical means.
*
* @brief Set the resource "sort" flag
* @fn voc_regSortRes (RegQuery query, int value)
*
* @param query Registry query handle
* @param value value of the sort flag
* @returns nothing
*/
void
voc_regSortRes (RegQuery query, int value)
{
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (query, "regSortRes", 0);
vocRes_t *result = (vocRes_t *) NULL;
msg_addIntParam (msg, value);
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: regSortRes() failed\n");
}
free ((void *)msg); /* free the pointers */
free ((void *)result);
}
/**
* VOC_REGGETSTCOUNT -- Get the number of search terms in the current query.
*
* @brief Get the number of search terms in the current query.
* @fn count = voc_regGetSTCount (RegQuery query)
*
* @param query Registry query handle
* @returns nothing
*/
int
voc_regGetSTCount (RegQuery query)
{
int count = 0;
if (query > 0) {
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (query, "regGetSTCount", 0);
vocRes_t *result = (vocRes_t *) NULL;
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: regGetSTCount() failed\n");
} else
count = msg_getIntResult (result, 0);
free ((void *)msg); /* free the pointers */
free ((void *)result);
} else if (!vo->quiet)
fprintf (stderr, "ERROR: Null result record to regGetSTCount\n");
return (count);
}
/**
* VOC_REGGETQUERYSTRING -- Get the current query as an http GET URL.
*
* @brief Get the current query as an http GET URL.
* @fn url = voc_regGetQueryString (RegQuery query)
*
* @param query Registry query handle
* @returns query URL
*/
char *
voc_regGetQueryString (RegQuery query)
{
char *val = NULL, *qstring = NULL;
int len = 0;
if (query > 0) {
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (query,
"regGetQueryString", 0);
vocRes_t *result = (vocRes_t *) NULL;
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: resGetQueryStr() failed\n");
} else {
val = msg_getStringResult (result, 0);
qstring = calloc (1, (len = strlen(val)+1));
strncpy (qstring, val, len);
}
free ((void *) msg); /* free the pointers */
free ((void *) result);
free ((void *) val);
}
return (qstring);
}
/**
* VOC_REGEXECUTE -- Execute the specified query, returning a result object
* code or NULL.
*
* @brief Execute the specified query
* @fn res = voc_regExecute (RegQuery query)
*
* @param query Registry query handle
* @returns registry result object handle
*/
RegResult
voc_regExecute (RegQuery query)
{
RegResult res = (RegResult) VOC_NULL;
if (query > 0) {
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (query, "regExecute", 0);
vocRes_t *result = (vocRes_t *) NULL;
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: regExecute() failed\n");
} else
res = msg_getIntResult (result, 0);
free ((void *)msg); /* free the pointers */
free ((void *)result);
}
return ((RegResult) res);
}
/**
* VOC_REGEXECUTERAW -- Execute the specified query and return the raw
* resulting XML string.
*
* @brief Execute the specified query and return raw result string
* @fn str = voc_regExecuteRaw (RegQuery query)
*
* @param query Registry query handle
* @returns raw data return from data
*/
char *
voc_regExecuteRaw (RegQuery query)
{
char *val = NULL, *raw = NULL;
int len = 0;
if (query > 0) {
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (query, "resExecuteRaw", 0);
vocRes_t *result = (vocRes_t *) NULL;
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: resExecuteRaw() failed\n");
} else {
val = msg_getStringResult (result, 0);
raw = calloc (1, (len = strlen(val)+1));
strncpy (raw, val, len);
}
free ((void *) msg); /* free the pointers */
free ((void *) result);
free ((void *) val);
}
return (raw);
}
/*****************************************************************************/
/***** RegistryQueryResult Methods ******/
/*****************************************************************************/
/**
* VOC_RESGETCOUNT -- Return a count of the number of results records.
*
* @brief Return a count of the number of results records.
* @fn count = voc_resGetCount (RegResult res)
*
* @param res Registry result handle
* @returns number of result records
*/
int
voc_resGetCount (RegResult res)
{
int count = 0;
if (res > 0) {
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (res, "resGetCount", 0);
vocRes_t *result = (vocRes_t *) NULL;
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: resGetCount() failed\n");
} else
count = msg_getIntResult (result, 0);
free ((void *)msg); /* free the pointers */
free ((void *)result);
} else if (!vo->quiet)
fprintf (stderr, "ERROR: Null result record to resGetCount\n");
return (count);
}
/**
* VOC_GETSTR -- Get a string-valued attribute from the result resource
* record. Currently recognized real-valued attributes include:
*
* Title Resource title (long version)
* ShortName Short name of Resource
* ServiceURL Service URL (if appropriate)
* ReferenceURL URL to reference about Resource
* Description Text description of resource
* Identifier Standard ivo identifier of resource
* ServiceType Service Type (Cone, Siap, etc)
* Type Resource Type (catalog, survey, etc)
* CoverageSpatial Spatial coverage (STC)
* CoverageTemporal Temporal coverage of data
* CoverageSpectral Spectral coverage (csv list of bandpasses)
* ContentLevel Content level (research, EPO, etc -- csv list)
*
* Attribute strings are case-insensitive.
*
*
* @brief Get a string-valued attribute from the result resource record
* @fn str = voc_resGetStr (RegResult res, char *attr, int index)
*
* @param res Registry result handle
* @param attr record attribute
* @param index record index
* @returns string-valued attribute
*/
char *
voc_resGetStr (RegResult res, char *attribute, int index)
{
char *val = NULL, *str = NULL;
int len = 0;
if (res > 0) {
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (res, "resGetString", 0);
vocRes_t *result = (vocRes_t *) NULL;
msg_addStringParam (msg, attribute);
msg_addIntParam (msg, index);
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: resGetStr() failed\n");
} else {
val = msg_getStringResult (result, 0);
if (*val && strncmp (val, "null", 4) != 0) {
char *ip = val;
len = strlen(val);
str = calloc (1, len+1);
/* Trim string left and right (right side first).
*/
for (ip=(val+len-1); *ip && (ip > val); ip--) {
if (ip && (*ip == ' ' || *ip == '\t' || *ip == '\n'))
*ip = '\0';
else
break;
}
for (ip=val; ip && (*ip == ' ' || *ip == '\t' || *ip == '\n'); )
ip++;
strncpy (str, ip, strlen(ip));
}
}
free ((void *)msg); /* free the pointers */
free ((void *)result);
if (val)
free ((void *)val);
}
return (str);
}
/**
* VOC_GETFLOAT -- Get a real-valued attribute from the result resource
* record. Currently recognized real-valued attributes include:
*
* MaxSR maximum search radius
*
* Attribute string are case-insensitive.
*
* @brief Get a real-valued attribute from the result resource record
* @fn dval = voc_resGetFloat (RegResult res, char *attr, int index)
*
* @param res Registry result handle
* @param attr record attribute
* @param index record index
* @returns string-valued attribute
*/
double
voc_resGetFloat (RegResult res, char *attribute, int index)
{
double dval = 0;
if (res > 0) {
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (res, "resGetFloat", 0);
vocRes_t *result = (vocRes_t *) NULL;
msg_addStringParam (msg, attribute);
msg_addIntParam (msg, index);
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: resGetInt() failed\n");
} else
dval = msg_getFloatResult (result, 0);
free ((void *)msg); /* free the pointers */
free ((void *)result);
} else if (!vo->quiet)
fprintf (stderr, "ERROR: Null result record to resGetFloat\n");
return (dval);
}
/**
* VOC_GETINT -- Get a integer-valued attribute from the result resource
* record. Currently recognized real-valued attributes include:
*
* MaxRecords maximum records returned by the service
*
* Attribute string are case-insensitive.
*
* @brief Get an int-valued attribute from the result resource record
* @fn ival = voc_resGetInt (RegResult res, char *attr, int index)
*
* @param res Registry result handle
* @param attr record attribute
* @param index record index
* @returns string-valued attribute
*/
int
voc_resGetInt (RegResult res, char *attribute, int index)
{
int ival = 0;
if (res > 0) {
vocMsg_t *msg = (vocMsg_t *) msg_newCallMsg (res, "resGetInt", 0);
vocRes_t *result = (vocRes_t *) NULL;
msg_addStringParam (msg, attribute);
msg_addIntParam (msg, index);
/* Send message and read result.
*/
if (msg_resultStatus ((result=msg_sendMsg(vo->io_chan,msg))) == ERR) {
if (!vo->quiet)
fprintf (stderr, "ERROR: resGetInt() failed\n");
} else
ival = msg_getIntResult (result, 0);
free ((void *)msg); /* free the pointers */
free ((void *)result);
} else if (!vo->quiet)
fprintf (stderr, "ERROR: Null result record to resGetInt\n");
return (ival);
}
|