Debian Codegraph @

xpa/doc/client.html

raw symbols SCIP
1 <!-- =defdoc xpaclient xpaclient 3 -->
2 <HTML>
3 <HEAD>
4 <TITLE>XPA Client API</TITLE>
5 </HEAD>
6 <BODY>
7
8 <!-- =section xpaclient NAME -->
9 <H2><A NAME="xpaclient">XPAClient: The XPA Client-side Programming Interface</A></H2>
10
11 <!-- =section xpaclient SYNOPSIS -->
12 <H2>Summary</H2>
13 A description of the XPA client-side programming interface.
14
15 <!-- =section xpaclient DESCRIPTION -->
16 <H2><A NAME="intro">Introduction to XPA Client Programming</H2></A>
17 <P>
18 Sending/receiving data to/from an XPA access point is easy: you
19 generally only need to call the XPAGet() or XPASet() subroutines.
20 <PRE>
21 #include &lt;xpa.h&gt;
22
23 int <A HREF="./client.html#xpaget">XPAGet</A>(XPA xpa,
24 char *template, char *paramlist, char *mode,
25 char **bufs, size_t *lens, char **names, char **messages, int n);
26
27 int <A HREF="./client.html#xpaset">XPASet</A>(XPA xpa,
28 char *template, char *paramlist, char *mode,
29 char *buf, size_t len, char **names, char **messages, int n);
30
31 int <A HREF="./client.html#xpainfo">XPAInfo</A>(XPA xpa,
32 char *template, char *paramlist, char *mode,
33 char **names, char **messages, int n);
34
35 int <A HREF="./client.html#xpaaccess">XPAAccess</A>(XPA xpa,
36 char *template, char *paramlist, char *mode,
37 char **names, char **messages, int n);
38
39 int <A HREF="./client.html#xpagetfd">XPAGetFd</A>(XPA xpa,
40 char *template, char *paramlist, char *mode,
41 int *fds, char **names, char **messages, int n);
42
43 int <A HREF="./client.html#xpasetfd">XPASetFd</A>(XPA xpa,
44 char *template, char *paramlist, char *mode,
45 int fd, char **names, char **messages, int n);
46
47 XPA <A HREF="./client.html#xpaopen">XPAOpen</A>(char *mode);
48
49 void <A HREF="./client.html#xpaclose">XPAClose</A>(XPA xpa);
50
51 int <A HREF="./client.html#xpanslookup">XPANSLookup</A>(XPA xpa,
52 char *template, char *type,
53 char ***classes, char ***names, char ***methods, char ***infos);
54 </PRE>
55
56 <H2>Introduction</H2>
57
58 To use the XPA application programming interface, a software developer
59 generally will include the xpa.h definitions file:
60 <PRE>
61 #include &lt;xpa.h&gt;
62 </PRE>
63 in the software module that defines or accesses an XPA access point and
64 then will link against the libxpa.a library:
65 <PRE>
66 gcc -o foo foo.c libxpa.a
67 </PRE>
68 XPA has been compiled using both C and C++ compilers.
69 <P>
70 Client communication with XPA public access points generally is
71 accomplished using XPAGet() or XPASet() within a program (or xpaget
72 and xpaset at the command line). Both routines require specification
73 of the name of the access point. If a <A HREF="./template.html">template</A>
74 is used to specify the access point name (e.g., "ds9*"), then
75 communication will take place with all servers matching that template.
76
77 <!-- =defdoc xpaget xpaget 3 -->
78
79 <!-- =section xpaget NAME -->
80 <H2><A NAME="xpaget">XPAGet: retrieve data from one or more XPA servers</A></H2>
81
82 <!-- =section xpaget SYNOPSIS -->
83 <B>
84 <PRE>
85 #include &lt;xpa.h&gt;
86
87 int XPAGet(XPA xpa,
88 char *template, char *paramlist, char *mode,
89 char **bufs, size_t *lens, char **names, char **messages,
90 int n);
91 </PRE>
92 </B>
93
94 <!-- =section xpaget DESCRIPTION -->
95 <P>
96 Retrieve data from one or more XPA servers whose class:name identifier
97 matches the specified template.
98
99 <P>
100 A
101 <A HREF="./template.html">template</A>
102 of the form "class1:name1" is sent to the
103 XPA name server, which returns a list of at most n matching XPA
104 servers. A connection is established with each of these servers and
105 the paramlist string is passed to the server as the data transfer
106 request is initiated. If an XPA struct is passed to the call, then the
107 persistent connections are updated as described above. Otherwise,
108 temporary connections are made to the servers (which will be closed
109 when the call completes).
110
111 <P>
112 The XPAGet() routine then retrieves data from at most n XPA servers,
113 places these data into n allocated buffers and places the buffer
114 pointers in the bufs array. The length of each buffer is stored in the
115 lens array. A string containing the class:name and ip:port is stored
116 in the name array. If a given server returned an error or the server
117 callback sends a message back to the client, then the message will be
118 stored in the associated element of the messages array. NB: if
119 specified, the name and messages arrays must be of size n or greater.
120
121 <p>
122 The returned message string will be of the form:
123 <PRE>
124 XPA$ERROR error-message (class:name ip:port)
125 </PRE>
126 or
127 <PRE>
128 XPA$MESSAGE message (class:name ip:port)
129 </PRE>
130 <P>
131 Note that when there is an error stored in an messages entry, the
132 corresponding bufs and lens entry may or may not be NULL and 0
133 (respectively), depending on the particularities of the server.
134
135 <P>
136 The return value will contain the actual number of servers that were
137 processed. This value thus will hold the number of valid entries in
138 the bufs, lens, names, and messages arrays, and can be used to loop
139 through these arrays. In names and/or messages is NULL, no information is
140 passed back in that array.
141
142 <P>
143 The bufs, names, and messages arrays should be freed upon completion (if
144 they are not NULL);
145
146 <P>
147 The mode string is of the form: "key1=value1,key2=value2,..."
148 The following keywords are recognized:
149 <PRE>
150 key value default explanation
151 ------ -------- -------- -----------
152 ack true/false true if false, don't wait for ack from server (after callback completes)
153 doxpa true/false true client processes xpa requests
154 </PRE>
155 <P>
156 The ack keyword is not very useful, since the server completes the callback
157 in order to return the data anyway. It is here for completion (and perhaps
158 for future usefulness).
159
160 <p>
161 Normally, an XPA client will process incoming XPA server requests
162 while awaiting the completion of the client request. Setting this
163 variable to "false" will prevent XPA server requests from being
164 processed by the client.
165
166 <P>
167 <B>Example:</B>
168 <PRE>
169 #include &lt;xpa.h&gt;
170
171 #define NXPA 10
172 int i, got;
173 size_t lens[NXPA];
174 char *bufs[NXPA];
175 char *names[NXPA];
176 char *messages[NXPA];
177 got = XPAGet(NULL, "ds9", "file", NULL, bufs, lens, names, messages,
178 NXPA);
179 for(i=0; i&lt;got; i++){
180 if( messages[i] == NULL ){
181 /* process buf contents */
182 ProcessImage(bufs[i], ...);
183 free(bufs[i]);
184 }
185 else{
186 /* error processing */
187 fprintf(stderr, "ERROR: %s (%s)\n", messages[i], names[i]);
188 }
189 if( names[i] )
190 free(names[i]);
191 if( messages[i] )
192 free(messages[i]);
193 }
194 </PRE>
195
196 <!-- =defdoc xpaset xpaset 3 -->
197
198 <!-- =section xpaset NAME -->
199 <H2><A NAME="xpaset">XPASet: send data to one or more XPA servers</A></H2>
200
201 <!-- =section xpaset SYNOPSIS -->
202 <B>
203 <PRE>
204 #include &lt;xpa.h&gt;
205
206 int XPASet(XPA xpa,
207 char *template, char *paramlist, char *mode,
208 char *buf, size_t len, char **names, char **messages,
209 int n);
210 </PRE>
211 </B>
212
213 <!-- =section xpaset DESCRIPTION -->
214 <P>
215 Send data to one or more XPA servers whose class:name identifier
216 matches the specified template.
217
218 <P>
219 A
220 <A HREF="./template.html">template</A>
221 of the form "class1:name1" is sent to the
222 XPA name server, which returns a list of at most n matching XPA
223 servers. A connection is established with each of these servers and
224 the paramlist string is passed to the server as the data transfer
225 request is initiated. If an XPA struct is passed to the call, the
226 persistent connections are updated as described above. Otherwise,
227 temporary connections are made to the servers (which will be closed
228 when the call completes).
229
230 <P>
231 The XPASet() routine transfers data from buf to the XPA servers.
232 The length of buf (in bytes) should be placed in the len variable.
233
234 <P>
235 A string containing the class:name and ip:port of each of these server
236 is returned in the name array. If a given server returned an error or
237 the server callback sends a message back to the client, then the
238 message will be stored in the associated element of the messages
239 array. NB: if specified, the name and messages arrays must be of size
240 n or greater.
241
242 <p>
243 The returned message string will be of the form:
244
245 <PRE>
246 XPA$ERROR [error] (class:name ip:port)
247 </PRE>
248 or
249 <PRE>
250 XPA$MESSAGE [message] (class:name ip:port)
251 </PRE>
252 <P>
253 The return value will contain the actual number of servers that were
254 processed. This value thus will hold the number of valid entries in
255 the names and messages arrays, and can be used to loop through these
256 arrays. In names and/or messages is NULL, no information is passed back
257 in that particular array.
258
259 <P>
260 The mode string is of the form: "key1=value1,key2=value2,..."
261 The following keywords are recognized:
262 <PRE>
263 key value default explanation
264 ------ -------- -------- -----------
265 ack true/false true if false, don't wait for ack from server (after callback completes)
266 verify true/false false send buf from XPASet[Fd] to stdout
267 doxpa true/false true client processes xpa requests
268 </PRE>
269 <P>
270 The ack keyword is useful in cases where one does not want to wait for
271 the server to complete, e.g. if a lot of processing needs to be done
272 by the server on the passed data or when the success of the server
273 operation is not relevant to the client.
274
275 <p>
276 Normally, an XPA client will process incoming XPA server requests
277 while awaiting the completion of the client request. Setting this
278 variable to "false" will prevent XPA server requests from being
279 processed by the client.
280
281 <P>
282 <B>Example:</B>
283 <PRE>
284 #include &lt;xpa.h&gt;
285
286 #define NXPA 10
287 int i, got;
288 size_t len;
289 char *buf;
290 char *names[NXPA];
291 char *messages[NXPA];
292 ...
293 [fill buf with data and set len to the length, in bytes, of the data]
294 ...
295 /* send data to all access points */
296 got = XPASet(NULL, "ds9", "fits", NULL, buf, len, names, messages, NXPA);
297 /* error processing */
298 for(i=0; i&lt;got; i++){
299 if( messages[i] ){
300 fprintf(stderr, "ERROR: %s (%s)\n", messages[i], names[i]);
301 }
302 if( names[i] ) free(names[i]);
303 if( messages[i] ) free(messages[i]);
304 }
305 </PRE>
306
307 <!-- =defdoc xpainfo xpainfo 3 -->
308
309 <!-- =section xpainfo NAME -->
310 <H2><A NAME="xpainfo">XPAInfo: send short message to one or more XPA servers</A></H2>
311
312 <!-- =section xpainfo SYNOPSIS -->
313 <B>
314 <PRE>
315 #include &lt;xpa.h&gt;
316
317 int XPAInfo(XPA xpa,
318 char *template, char *paramlist, char *mode,
319 char **names, char **messages, int n);
320 </PRE>
321 </B>
322
323 <!-- =section xpainfo DESCRIPTION -->
324 <P>
325 Send a short paramlist message to one or more XPA servers whose
326 class:name identifier matches the specified
327 <A HREF="./template.html">template</A>.
328
329 <P>
330 A
331 <A HREF="./template.html">template</A>
332 of the form "class1:name1" is sent to the
333 XPA name server, which returns a list of at most n matching XPA
334 servers. A connection is established with each of these servers and
335 the paramlist string is passed to the server as the data transfer
336 request is initiated. If an XPA struct is passed to the call, then the
337 persistent connections are updated as described above. Otherwise,
338 temporary connections are made to the servers (which will be closed
339 when the call completes).
340
341 <P>
342 The XPAInfo() routine does not send data from a buf to the XPA
343 servers. Only the paramlist is sent. The semantics of the paramlist
344 is not formalized, but at a minimum is should tell the server how to
345 get more information. For example, it might contain the class:name
346 of the XPA access point from which the server (acting as a client)
347 can obtain more info using XPAGet.
348
349 <P>
350 A string containing the class:name and ip:port of each server is
351 returned in the name array. If a given server returned an error or
352 the server callback sends a message back to the client, then the
353 message will be stored in the associated element of the messages
354 array. The returned message string will be of the form:
355 <PRE>
356 XPA$ERROR error-message (class:name ip:port)
357 </PRE>
358 or
359 <PRE>
360 XPA$MESSAGE message (class:name ip:port)
361 </PRE>
362 <P>
363 The return value will contain the actual number of servers that were
364 processed. This value thus will hold the number of valid entries in
365 the names and messages arrays, and can be used to loop through these
366 arrays. In names and/or messages is NULL, no information is passed back
367 in that array.
368
369 <P>
370 The following keywords are recognized:
371 <PRE>
372 key value default explanation
373 ------ -------- -------- -----------
374 ack true/false true if false, don't wait for ack from server
375 </PRE>
376 <P>
377 When ack is false, XPAInfo() will not wait for an error return from the XPA
378 server. This means, in effect, that XPAInfo will send its paramlist string
379 to the XPA server and then exit: no information will be sent from the server
380 to the client. This UDP-like behavior is essential to avoid race
381 conditions in cases where XPA servers are sending info messages to
382 other servers. If two servers try to send each other an info message
383 at the same time and then wait for an ack, a race condition will result and
384 one or both will time out.
385
386 <P>
387 <B>Example:</B>
388 <PRE>
389 (void)XPAInfo(NULL, "IMAGE", "ds9 image", NULL, NULL, NULL, 0);
390 </PRE>
391
392 <!-- =defdoc xpagetfd xpagetfd 3 -->
393
394 <!-- =section xpagetfd NAME -->
395 <H2><A NAME="xpagetfd">XPAGetFd: retrieve data from one or more XPA servers and write to files</A></H2>
396
397 <!-- =section xpagetfd SYNOPSIS -->
398 <B>
399 <PRE>
400 #include &lt;xpa.h&gt;
401
402 int XPAGetFd(XPA xpa,
403 char *template, char *paramlist, char *mode,
404 int *fds, char **names, char **messages, int n);
405 </PRE>
406 </B>
407
408 <!-- =section xpagetfd DESCRIPTION -->
409 <P>
410 Retrieve data from one or more XPA servers whose class:name identifier
411 matches the specified
412 <A HREF="./template.html">template</A>
413 and write it to files associated with
414 one or more standard I/O fds (i.e, handles returned by open()).
415
416 <P>
417 A
418 <A HREF="./template.html">template</A>
419 of the form "class1:name1" is sent to the
420 XPA name server, which returns a list of at most ABS(n) matching XPA
421 servers. A connection is established with each of these servers and
422 the paramlist string is passed to the server as the data transfer
423 request is initiated. If an XPA struct is passed to the call, then the
424 persistent connections are updated as described above. Otherwise,
425 temporary connections are made to the servers (which will be closed
426 when the call completes).
427
428 <P>
429 The XPAGetFd() routine then retrieves data from the XPA servers,
430 and write these data to the fds associated with one or more fds
431 (i.e., results from open). Is n is positive, then there will be n fds
432 and the data from each server will be sent to a separate fd. If n is
433 negative, then there is only 1 fd and all data is sent to this single
434 fd. (The latter is how xpaget is implemented.)
435
436 <P>
437 A string containing the class:name and ip:port is stored in the name
438 array. If a given server returned an error or the server callback
439 sends a message back to the client, then the message will be stored in
440 the associated element of the messages array. NB: if specified, the
441 name and messages arrays must be of size n or greater.
442
443 <P>
444 The returned message string will be of the form:
445 <PRE>
446 XPA$ERROR error-message (class:name ip:port)
447 </PRE>
448 or
449 <PRE>
450 XPA$MESSAGE message (class:name ip:port)
451 </PRE>
452 <P>
453 Note that when there is an error stored in an messages entry, the
454 corresponding bufs and lens entry may or may not be NULL and 0
455 (respectively), depending on the particularities of the server.
456
457 <P>
458 The return value will contain the actual number of servers that were
459 processed. This value thus will hold the number of valid entries in
460 the bufs, lens, names, and messages arrays, and can be used to loop
461 through these arrays. In names and/or messages is NULL, no information is
462 passed back in that array.
463
464 <P>
465 The mode string is of the form: "key1=value1,key2=value2,..."
466 The following keywords are recognized:
467 <PRE>
468 key value default explanation
469 ------ -------- -------- -----------
470 ack true/false true if false, don't wait for ack from server (after callback completes)
471 </PRE>
472 <P>
473 The ack keyword is not very useful, since the server completes the callback
474 in order to return the data anyway. It is here for completion (and perhaps
475 for future usefulness).
476
477 <P>
478 <B>Example:</B>
479 <PRE>
480 #include &lt;xpa.h&gt;
481 #define NXPA 10
482 int i, got;
483 int fds[NXPA];
484 char *names[NXPA];
485 char *messages[NXPA];
486 for(i=0; i&lt;NXPA; i++)
487 fds[i] = open(...);
488 got = XPAGetFd(NULL, "ds9", "file", NULL, fds, names, messages, NXPA);
489 for(i=0; i&lt;got; i++){
490 if( messages[i] != NULL ){
491 /* error processing */
492 fprintf(stderr, "ERROR: %s (%s)\n", messages[i], names[i]);
493 }
494 if( names[i] )
495 free(names[i]);
496 if( messages[i] )
497 free(messages[i]);
498 }
499 </PRE>
500
501 <!-- =defdoc xpasetfd xpasetfd 3 -->
502
503 <!-- =section xpasetfd NAME -->
504 <H2><A NAME="xpasetfd">XPASetFd: send data from stdin to one or more XPA servers</A></H2>
505
506 <!-- =section xpasetfd SYNOPSIS -->
507 </B>
508 <PRE>
509 #include &lt;xpa.h&gt;
510
511 int XPASetFd(XPA xpa,
512 char *template, char *paramlist, char *mode,
513 int fd, char **names, char **messages, int n)
514 </PRE>
515 </B>
516
517 <!-- =section xpasetfd DESCRIPTION -->
518 <P>
519 Read data from a standard I/O fd and send it to one or more XPA
520 servers whose class:name identifier matches the specified
521 <A HREF="./template.html">template.
522
523 <P>
524 A
525 <A HREF="./template.html">template</A>
526 of the form "class1:name1" is sent to the
527 XPA name server, which returns a list of at most n matching XPA
528 servers. A connection is established with each of these servers and
529 the paramlist string is passed to the server as the data transfer
530 request is initiated. If an XPA struct is passed to the call, then the
531 persistent connections are updated as described above. Otherwise,
532 temporary connections are made to the servers (which will be closed
533 when the call completes).
534
535 <P>
536 The XPASetFd() routine then reads bytes from the specified fd
537 until EOF and sends these bytes to the XPA servers.
538 The final parameter n specifies the maximum number of servers to contact.
539 A string containing the class:name and ip:port of each server is returned in
540 the name array. If a given server returned an error, then the error
541 message will be stored in the associated element of the messages array.
542 NB: if specified, the name and messages arrays must be of size n or greater.
543
544 <P>
545 The return value will contain the actual number of servers that were
546 processed. This value thus will hold the number of valid entries in
547 the names and messages arrays, and can be used to loop through these
548 arrays. In names and/or messages is NULL, no information is passed back
549 in that array.
550
551 <P>
552 The mode string is of the form: "key1=value1,key2=value2,..."
553 The following keywords are recognized:
554 <PRE>
555 key value default explanation
556 ------ -------- -------- -----------
557 ack true/false true if false, don't wait for ack from server (after callback completes)
558 verify true/false false send buf from XPASet[Fd] to stdout
559 </PRE>
560 <P>
561 The ack keyword is useful in cases where one does not want to wait for
562 the server to complete, e.g. is a lot of processing needs to be done
563 on the passed data or when the success of the server operation is not
564 relevant to the client.
565
566 <P>
567 <B>Example:</B>
568 <PRE>
569 #include &lt;xpa.h&gt;
570
571 #define NXPA 10
572 int i, got;
573 int fd;
574 char *names[NXPA];
575 char *messages[NXPA];
576 fd = open(...);
577 got = XPASetFd(NULL, "ds9", "fits", NULL, fd, names, messages, NXPA);
578 for(i=0; i&lt;got; i++){
579 if( messages[i] != NULL ){
580 /* error processing */
581 fprintf(stderr, "ERROR: %s (%s)\n", messages[i], names[i]);
582 }
583 if( names[i] )
584 free(names[i]);
585 if( messages[i] )
586 free(messages[i]);
587 }
588 </PRE>
589
590 <!-- =defdoc xpaopen xpaopen 3 -->
591
592 <!-- =section xpaopen NAME -->
593 <H2><A NAME="xpaopen">XPAOpen: allocate a persistent client handle</A></H2>
594
595 <!-- =section xpaopen SYNOPSIS -->
596 <B>
597 <PRE>
598 #include &lt;xpa.h&gt;
599
600 XPA XPAOpen(char *mode);
601 </PRE>
602 </B>
603
604 <!-- =section xpaopen DESCRIPTION -->
605 <P>
606 XPAOpen() allocates a persistent XPA struct that can be used with
607 calls to XPAGet(), XPASet(), XPAInfo(), XPAGetFd(), and
608 XPASetFd(). Persistence means that a connection to an XPA server is
609 not closed when one of the above calls is completed but will be
610 re-used on successive calls. Using XPAOpen() therefore saves the time
611 it takes to connect to a server, which could be significant with slow
612 connections or if there will be a large number of exchanges with a
613 given access point. The mode argument currently is ignored ("reserved
614 for future use").
615
616 <P>
617 An XPA struct is returned if XPAOpen() was successful; otherwise NULL
618 is returned. This returned struct can be passed as the first argument
619 to XPAGet(), etc. Those calls will update the list of active XPA
620 connections. Already connected servers (from a previous call) are
621 left connected and new servers also will be connected. Old servers
622 (from a previous call) that are no longer needed are disconnected.
623 The connected servers will remain connected when the next call to
624 XPAGet() is made and connections are once again updated.
625
626 <P>
627 <B>Example:</B>
628 <PRE>
629 #include &lt;xpa.h&gt;
630
631 XPA xpa;
632 xpa = XPAOpen(NULL);
633 </PRE>
634
635 <!-- =defdoc xpaclose xpaclose 3 -->
636
637 <!-- =section xpaclose NAME -->
638 <H2><A NAME="xpaclose">XPAClose: close a persistent XPA client handle</A></H2>
639
640 <!-- =section xpaclose SYNOPSIS -->
641 <B>
642 <PRE>
643 #include &lt;xpa.h&gt;
644
645 void XPAClose(XPA xpa);
646 </PRE>
647 </B>
648
649 <!-- =section xpaclose DESCRIPTION -->
650 <P>
651 XPAClose closes the persistent connections associated with this XPA struct
652 and frees all allocated space. It also closes the open sockets connections
653 to all XPA servers that were opened using this handle.
654
655 <P>
656 <B>Example:</B>
657 <PRE>
658 #include &lt;xpa.h&gt;
659
660 XPA xpa;
661 XPAClose(xpa);
662 </PRE>
663
664 <!-- =defdoc xpanslookup xpanslookup 3 -->
665
666 <!-- =section xpanslookup NAME -->
667 <H2><A NAME="xpanslookup">XPANSLookup: lookup registered XPA access points</A></H2>
668
669 <!-- =section xpanslookup SYNOPSIS -->
670 <B>
671 <PRE>
672 #include &lt;xpa.h&gt;
673
674 int XPANSLookup(XPA xpa,
675 char *template, char type,
676 char ***classes, char ***names,
677 char ***methods, char ***infos)
678 </PRE>
679 </B>
680
681 <!-- =section xpanslookup DESCRIPTION -->
682 <P>
683 XPA routines act on a class:name identifier in such a way
684 that all access points that match the identifier are processed. It is
685 sometimes desirable to choose specific access points from the
686 candidates that match the
687 <A HREF="./template.html">template</A>. In order to do this, the
688 XPANSLookup routine can be called to return a list of matches, so that
689 specific class:name instances can then be fed to XPAGet(), XPASet(), etc.
690
691 <P> The first argument is an optional XPA struct. If non-NULL, the
692 existing name server connection associated with the specified xpa is
693 used to query the xpans name server for matching templates. Otherwise,
694 a new (temporary) connection is established with the name server.
695
696 <P>
697 The second argument to XPANSLookup is the class:name
698 <A HREF="./template.html">template</A>
699 to match.
700
701 <P>
702 The third argument for XPANSLookup() is the type of access and can be
703 any combination of:
704 <PRE>
705 type explanation
706 ------ -----------
707 g xpaget calls can be made on this access point
708 s xpaset calls can be made on this access point
709 i xpainfo calls can be made on this access point
710 </PRE>
711 <P>
712 The call typically specifies only one of these at a time.
713
714 <P>
715 The final arguments are pointers to arrays that will be filled
716 in and returned by the name server. The name server will allocate and
717 return arrays filled with the classes, names, and methods of all XPA
718 access points that match the <A HREF="./template.html">template</A>
719 and have the specified type. Also returned are info strings, which
720 generally are used internally by the client routines. These can be
721 ignored (but the strings must be freed). The function returns the
722 number of matches. The returned value can be used to loop through the
723 matches:
724
725 <B>Example:</B>
726 <PRE>
727 #include &lt;xpa.h&gt;
728
729 char **classes;
730 char **names;
731 char **methods;
732 char **infos;
733 int i, n;
734 n = XPANSLookup(NULL, "foo*", "g", &classes, &names, &methods, &infos);
735 for(i=0; i&lt;n; i++){
736 [more specific checks on possibilities ...]
737 [perhaps a call to XPAGet for those that pass, etc. ...]
738 /* don't forget to free alloc'ed strings when done */
739 free(classes[i]);
740 free(names[i]);
741 free(methods[i]);
742 free(infos[i]);
743 }
744 /* free up arrays alloc'ed by names server */
745 if( n > 0 ){
746 free(classes);
747 free(names);
748 free(methods);
749 free(infos);
750 }
751 </PRE>
752 <P>
753 The specified
754 <A HREF="./template.html">template</A>
755 also can be a host:port specification, for example:
756 <PRE>
757 myhost:12345
758 </PRE>
759 <P>
760 In this case, no connection is made to the name server. Instead, the
761 call will return one entry such that the ip array contains the ip for
762 the specified host and the port array contains the port. The class
763 and name entries are set to the character "?", since the class and
764 name of the access point are not known.
765
766 <!-- =defdoc xpaaccess xpaaccess 3 -->
767
768 <!-- =section xpaaccess NAME -->
769 <H2><A NAME="xpaaccess">XPAAccess: return XPA access points matching
770 template (XPA 2.1 and above)</A></H2>
771
772 <!-- =section xpaaccess SYNOPSIS -->
773 <B>
774 <PRE>
775 #include &lt;xpa.h&gt;
776
777 int XPAAccess(XPA xpa,
778 char *template, char *paramlist, char *mode,
779 char **names, char **messages, int n);
780 </PRE>
781 </B>
782
783 <!-- =section xpaaccess DESCRIPTION -->
784 <P>
785 The XPAAccess routine returns the public access points that match the
786 specified second argument <A HREF="./template.html">template</A> and
787 have the specified access type.
788
789 <P>
790 A
791 <A HREF="./template.html">template</A>
792 of the form "class1:name1" is sent to the
793 XPA name server, which returns a list of at most n matching XPA
794 servers. A connection is established with each of these servers and
795 the paramlist string is passed to the server as the data transfer
796 request is initiated. If an XPA struct is passed to the call, then the
797 persistent connections are updated as described above. Otherwise,
798 temporary connections are made to the servers (which will be closed
799 when the call completes).
800
801 <P>
802 The XPAAccess() routine retrieves names from at most n XPA servers
803 that match the specified template and that were checked for access
804 using the specified mode. The return string contains both the
805 class:name and ip:port. If a given server returned an error or the
806 server callback sends a message back to the client, then the message
807 will be stored in the associated element of the messages array.
808 NB: if specified, the name and messages arrays must be of size n or greater.
809
810 <P>
811 The returned message string will be of the form:
812 <PRE>
813 XPA$ERROR error-message (class:name ip:port)
814 </PRE>
815 <P>
816 Note that names of matching registered access points are always
817 returned but may not be valid; it is not sufficient to assume that the
818 returned number of access points is the number of valid access points.
819 Rather, it is essential to check the messages array for error
820 messages. Any string in the messages array is an error message and
821 indicated that the associated access point is not available.
822
823 <P>
824 For example, assume that a server registers a number of access points
825 but delays entering its event loop. If a call to XPAAccess() is made
826 before the event loop is entered, the call will timeout (after waiting
827 for the long timeout period) and return an error of the form:
828 <PRE>
829 XPA$ERROR: timeout waiting for server authentication (XPA:xpa1)
830 </PRE>
831 The error means that the XPA access point has been registered but is
832 not yet available (because events are not being processed). When the
833 server finally enters its event loop, subsequent calls to XPAAccess()
834 will return successfully.
835
836 <P>
837 NB: This routine only works with XPA servers built with XPA 2.1.x and later.
838 Servers with older versions of XPA will return the error message:
839
840 XPA$ERROR invalid xpa command in initialization string
841
842 If you get this error message, then the old server actually is ready
843 for access, since it got to the point of fielding the query! The
844 xpaaccess program, for example, ignores this message in order to work
845 properly with older servers.
846
847 <P>
848 The third argument for XPAAccess() is the type of access and can be
849 any combination of:
850 <PRE>
851 type explanation
852 ------ -----------
853 g xpaget calls can be made on this access point
854 s xpaset calls can be made on this access point
855 i xpainfo calls can be made on this access point
856 </PRE>
857 <P>
858 The mode string argument is of the form: "key1=value1,key2=value2,..."
859 The following keywords are recognized:
860 <PRE>
861 key value default explanation
862 ------ -------- -------- -----------
863 ack true/false true if false, don't wait for ack from server (after callback completes)
864 </PRE>
865 <P>
866 The ack keyword is not very useful, since the server completes the callback
867 in order to return the data anyway. It is here for completion (and perhaps
868 for future usefulness).
869
870 <!-- =section xpaclient SEE ALSO -->
871 <!-- =text See xpa(n) for a list of XPA help pages -->
872 <!-- =section xpaget SEE ALSO -->
873 <!-- =text See xpa(n) for a list of XPA help pages -->
874 <!-- =section xpaset SEE ALSO -->
875 <!-- =text See xpa(n) for a list of XPA help pages -->
876 <!-- =section xpainfo SEE ALSO -->
877 <!-- =text See xpa(n) for a list of XPA help pages -->
878 <!-- =section xpagetfd SEE ALSO -->
879 <!-- =text See xpa(n) for a list of XPA help pages -->
880 <!-- =section xpasetfd SEE ALSO -->
881 <!-- =text See xpa(n) for a list of XPA help pages -->
882 <!-- =section xpaopen SEE ALSO -->
883 <!-- =text See xpa(n) for a list of XPA help pages -->
884 <!-- =section xpaclose SEE ALSO -->
885 <!-- =text See xpa(n) for a list of XPA help pages -->
886 <!-- =section xpanslookup SEE ALSO -->
887 <!-- =text See xpa(n) for a list of XPA help pages -->
888 <!-- =section xpaaccess SEE ALSO -->
889 <!-- =text See xpa(n) for a list of XPA help pages -->
890 <!-- =stop -->
891
892 <P>
893 <A HREF="./help.html">Go to XPA Help Index</A>
894
895 <H5>Last updated: March 10, 2007</H5>
896
897 </BODY>
898 </HTML>