This file is indexed.

/usr/share/doc/libxpa-dev/client.html is in libxpa-dev 2.1.18-1+b1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
<!-- =defdoc xpaclient xpaclient 3 -->
<HTML>
<HEAD>
<TITLE>XPA Client API</TITLE>
</HEAD>
<BODY>

<!-- =section xpaclient NAME -->
<H2><A NAME="xpaclient">XPAClient: The XPA Client-side Programming Interface</A></H2>

<!-- =section xpaclient SYNOPSIS -->
<H2>Summary</H2>
A description of the XPA client-side programming interface.

<!-- =section xpaclient DESCRIPTION -->
<H2><A NAME="intro">Introduction to XPA Client Programming</H2></A>
<P>
Sending/receiving data to/from an XPA access point is easy: you
generally only need to call the XPAGet() or XPASet() subroutines.
<PRE>
  #include &lt;xpa.h&gt;

  int <A HREF="./client.html#xpaget">XPAGet</A>(XPA xpa,
      char *template, char *paramlist, char *mode,
      char **bufs, size_t *lens, char **names, char **messages, int n);

  int <A HREF="./client.html#xpaset">XPASet</A>(XPA xpa,
      char *template, char *paramlist, char *mode,
      char *buf, size_t len, char **names, char **messages, int n);

  int <A HREF="./client.html#xpainfo">XPAInfo</A>(XPA xpa,
      char *template, char *paramlist, char *mode,
      char **names, char **messages, int n);

  int <A HREF="./client.html#xpaaccess">XPAAccess</A>(XPA xpa,
      char *template, char *paramlist, char *mode,
      char **names, char **messages, int n);

  int <A HREF="./client.html#xpagetfd">XPAGetFd</A>(XPA xpa,
      char *template, char *paramlist, char *mode,
      int *fds, char **names, char **messages, int n);

  int <A HREF="./client.html#xpasetfd">XPASetFd</A>(XPA xpa,
      char *template, char *paramlist, char *mode,
      int fd, char **names, char **messages, int n);

  XPA <A HREF="./client.html#xpaopen">XPAOpen</A>(char *mode);

  void <A HREF="./client.html#xpaclose">XPAClose</A>(XPA xpa);

  int <A HREF="./client.html#xpanslookup">XPANSLookup</A>(XPA xpa,
      char *template, char *type,
      char ***classes, char ***names, char ***methods, char ***infos);
</PRE>

<H2>Introduction</H2>

To use the XPA application programming interface, a software developer
generally will include the xpa.h definitions file:
<PRE>
  #include &lt;xpa.h&gt;
</PRE>
in the software module that defines or accesses an XPA access point and
then will link against the libxpa.a library:
<PRE>
  gcc -o foo foo.c libxpa.a
</PRE>
XPA has been compiled using both C and C++ compilers.
<P>
Client communication with XPA public access points generally is
accomplished using XPAGet() or XPASet() within a program (or xpaget
and xpaset at the command line).  Both routines require specification
of the name of the access point.  If a <A HREF="./template.html">template</A>
is used to specify the access point name (e.g., "ds9*"), then
communication will take place with all servers matching that template.

<!-- =defdoc xpaget xpaget 3 -->

<!-- =section xpaget NAME -->
<H2><A NAME="xpaget">XPAGet: retrieve data from one or more XPA servers</A></H2>

<!-- =section xpaget SYNOPSIS -->
<B>
<PRE>
  #include &lt;xpa.h&gt;

  int XPAGet(XPA xpa,
             char *template, char *paramlist, char *mode,
             char **bufs, size_t *lens, char **names, char **messages,
	     int n);
</PRE>
</B>

<!-- =section xpaget DESCRIPTION -->
<P>
Retrieve data from one or more XPA servers whose class:name identifier
matches the specified template.

<P>
A 
<A HREF="./template.html">template</A>
of the form "class1:name1" is sent to the
XPA name server, which returns a list of at most n matching XPA
servers.  A connection is established with each of these servers and
the paramlist string is passed to the server as the data transfer
request is initiated. If an XPA struct is passed to the call, then the
persistent connections are updated as described above. Otherwise,
temporary connections are made to the servers (which will be closed
when the call completes).

<P>
The XPAGet() routine then retrieves data from at most n XPA servers,
places these data into n allocated buffers and places the buffer
pointers in the bufs array. The length of each buffer is stored in the
lens array. A string containing the class:name and ip:port is stored
in the name array.  If a given server returned an error or the server
callback sends a message back to the client, then the message will be
stored in the associated element of the messages array.  NB: if
specified, the name and messages arrays must be of size n or greater.

<p>
The returned message string will be of the form:
<PRE>
  XPA$ERROR error-message (class:name ip:port)
</PRE>
or
<PRE>
  XPA$MESSAGE message (class:name ip:port)
</PRE>
<P>
Note that when there is an error stored in an messages entry, the
corresponding bufs and lens entry may or may not be NULL and 0
(respectively), depending on the particularities of the server.

<P>
The return value will contain the actual number of servers that were
processed.  This value thus will hold the number of valid entries in
the bufs, lens, names, and messages arrays, and can be used to loop
through these arrays.  In names and/or messages is NULL, no information is
passed back in that array.

<P>
The bufs, names, and messages arrays should be freed upon completion (if
they are not NULL);

<P>
The mode string is of the form: "key1=value1,key2=value2,..."
The following keywords are recognized:
<PRE>
  key   	value		default		explanation
  ------	--------	--------	-----------
  ack		true/false	true		if false, don't wait for ack from server (after callback completes)
  doxpa		true/false	true		client processes xpa requests
</PRE>
<P>
The ack keyword is not very useful, since the server completes the callback
in order to return the data anyway.  It is here for completion (and perhaps
for future usefulness).

<p>
Normally, an XPA client will process incoming XPA server requests
while awaiting the completion of the client request.  Setting this
variable to "false" will prevent XPA server requests from being
processed by the client.
					   
<P>
<B>Example:</B>
<PRE>
  #include &lt;xpa.h&gt;

  #define NXPA 10
  int  i, got;
  size_t  lens[NXPA];
  char *bufs[NXPA];
  char *names[NXPA];
  char *messages[NXPA];
  got = XPAGet(NULL, "ds9", "file", NULL, bufs, lens, names, messages,
  NXPA);
  for(i=0; i&lt;got; i++){
    if( messages[i] == NULL ){
      /* process buf contents */
      ProcessImage(bufs[i], ...);
      free(bufs[i]);
    }
    else{
      /* error processing */
      fprintf(stderr, "ERROR: %s (%s)\n", messages[i], names[i]);
    }
    if( names[i] )
      free(names[i]);
    if( messages[i] )
      free(messages[i]);
  }
</PRE>

<!-- =defdoc xpaset xpaset 3 -->

<!-- =section xpaset NAME -->
<H2><A NAME="xpaset">XPASet: send data to one or more XPA servers</A></H2>

<!-- =section xpaset SYNOPSIS -->
<B>
<PRE>
  #include &lt;xpa.h&gt;

  int XPASet(XPA xpa,
             char *template, char *paramlist, char *mode,
             char *buf, size_t len, char **names, char **messages,
             int n);
</PRE>
</B>

<!-- =section xpaset DESCRIPTION -->
<P>
Send data to one or more XPA servers whose class:name identifier
matches the specified template.

<P>
A 
<A HREF="./template.html">template</A>
of the form "class1:name1" is sent to the
XPA name server, which returns a list of at most n matching XPA
servers.  A connection is established with each of these servers and
the paramlist string is passed to the server as the data transfer
request is initiated. If an XPA struct is passed to the call, the
persistent connections are updated as described above. Otherwise,
temporary connections are made to the servers (which will be closed
when the call completes).

<P>
The XPASet() routine transfers data from buf to the XPA servers.
The length of buf (in bytes) should be placed in the len variable.

<P>
A string containing the class:name and ip:port of each of these server
is returned in the name array.  If a given server returned an error or
the server callback sends a message back to the client, then the
message will be stored in the associated element of the messages
array. NB: if specified, the name and messages arrays must be of size
n or greater.

<p>
The returned message string will be of the form:

<PRE>
  XPA$ERROR   [error] (class:name ip:port)
</PRE>
or
<PRE>
  XPA$MESSAGE [message] (class:name ip:port)
</PRE>
<P>
The return value will contain the actual number of servers that were
processed.  This value thus will hold the number of valid entries in
the names and messages arrays, and can be used to loop through these
arrays.  In names and/or messages is NULL, no information is passed back
in that particular array.

<P>
The mode string is of the form: "key1=value1,key2=value2,..."
The following keywords are recognized:
<PRE>
  key   	value		default		explanation
  ------	--------	--------	-----------
  ack		true/false	true		if false, don't wait for ack from server (after callback completes)
  verify	true/false	false		send buf from XPASet[Fd] to stdout
  doxpa		true/false	true		client processes xpa requests
</PRE>
<P>
The ack keyword is useful in cases where one does not want to wait for
the server to complete, e.g. if a lot of processing needs to be done
by the server on the passed data or when the success of the server
operation is not relevant to the client.

<p>
Normally, an XPA client will process incoming XPA server requests
while awaiting the completion of the client request.  Setting this
variable to "false" will prevent XPA server requests from being
processed by the client.
					   
<P>
<B>Example:</B>
<PRE>
  #include &lt;xpa.h&gt;

  #define NXPA 10
  int  i, got;
  size_t  len;
  char *buf;
  char *names[NXPA];
  char *messages[NXPA];
  ...
  [fill buf with data and set len to the length, in bytes, of the data]
  ...
  /* send data to all access points */
  got = XPASet(NULL, "ds9", "fits", NULL, buf, len, names, messages, NXPA);
  /* error processing */
  for(i=0; i&lt;got; i++){
    if( messages[i] ){
      fprintf(stderr, "ERROR: %s (%s)\n", messages[i], names[i]);
    }
    if( names[i] )    free(names[i]);
    if( messages[i] ) free(messages[i]);
  }
</PRE>
					   
<!-- =defdoc xpainfo xpainfo 3 -->

<!-- =section xpainfo NAME -->
<H2><A NAME="xpainfo">XPAInfo: send short message to one or more XPA servers</A></H2>

<!-- =section xpainfo SYNOPSIS -->
<B>
<PRE>
  #include &lt;xpa.h&gt;

  int XPAInfo(XPA xpa,
              char *template, char *paramlist, char *mode,
	      char **names, char **messages, int n);
</PRE>
</B>

<!-- =section xpainfo DESCRIPTION -->
<P>
Send a short paramlist message to one or more XPA servers whose
class:name identifier matches the specified
<A HREF="./template.html">template</A>.

<P>
A
<A HREF="./template.html">template</A>
of the form "class1:name1" is sent to the
XPA name server, which returns a list of at most n matching XPA
servers.  A connection is established with each of these servers and
the paramlist string is passed to the server as the data transfer
request is initiated. If an XPA struct is passed to the call, then the
persistent connections are updated as described above. Otherwise,
temporary connections are made to the servers (which will be closed
when the call completes).

<P>
The XPAInfo() routine does not send data from a buf to the XPA
servers. Only the paramlist is sent.  The semantics of the paramlist
is not formalized, but at a minimum is should tell the server how to
get more information.  For example, it might contain the class:name
of the XPA access point from which the server (acting as a client)
can obtain more info using XPAGet.

<P>
A string containing the class:name and ip:port of each server is
returned in the name array.  If a given server returned an error or
the server callback sends a message back to the client, then the
message will be stored in the associated element of the messages
array.  The returned message string will be of the form:
<PRE>
  XPA$ERROR   error-message (class:name ip:port)
</PRE>
or
<PRE>
  XPA$MESSAGE message 	  (class:name ip:port)
</PRE>
<P>
The return value will contain the actual number of servers that were
processed.  This value thus will hold the number of valid entries in
the names and messages arrays, and can be used to loop through these
arrays.  In names and/or messages is NULL, no information is passed back
in that array.

<P>
The following keywords are recognized:
<PRE>
  key   	value		default		explanation
  ------	--------	--------	-----------
  ack		true/false	true		if false, don't wait for ack from server
</PRE>
<P>
When ack is false, XPAInfo() will not wait for an error return from the XPA
server. This means, in effect, that XPAInfo will send its paramlist string
to the XPA server and then exit: no information will be sent from the server
to the client. This UDP-like behavior is essential to avoid race
conditions in cases where XPA servers are sending info messages to
other servers. If two servers try to send each other an info message
at the same time and then wait for an ack, a race condition will result and
one or both will time out.

<P>
<B>Example:</B>
<PRE>
  (void)XPAInfo(NULL, "IMAGE", "ds9 image", NULL, NULL, NULL, 0);
</PRE>
					   
<!-- =defdoc xpagetfd xpagetfd 3 -->

<!-- =section xpagetfd NAME -->
<H2><A NAME="xpagetfd">XPAGetFd: retrieve data from one or more XPA servers and write to files</A></H2>

<!-- =section xpagetfd SYNOPSIS -->
<B>
<PRE>
  #include &lt;xpa.h&gt;

  int XPAGetFd(XPA xpa,
               char *template, char *paramlist, char *mode,
	       int *fds, char **names, char **messages, int n);
</PRE>
</B>

<!-- =section xpagetfd DESCRIPTION -->
<P>
Retrieve data from one or more XPA servers whose class:name identifier
matches the specified
<A HREF="./template.html">template</A>
and write it to files associated with
one or more standard I/O fds (i.e, handles returned by open()).

<P>
A 
<A HREF="./template.html">template</A>
of the form "class1:name1" is sent to the
XPA name server, which returns a list of at most ABS(n) matching XPA
servers.  A connection is established with each of these servers and
the paramlist string is passed to the server as the data transfer
request is initiated. If an XPA struct is passed to the call, then the
persistent connections are updated as described above. Otherwise,
temporary connections are made to the servers (which will be closed
when the call completes).

<P>
The XPAGetFd() routine then retrieves data from the XPA servers,
and write these data to the fds associated with one or more fds
(i.e., results from open). Is n is positive, then there will be n fds
and the data from each server will be sent to a separate fd. If n is
negative, then there is only 1 fd and all data is sent to this single
fd. (The latter is how xpaget is implemented.)

<P>
A string containing the class:name and ip:port is stored in the name
array.  If a given server returned an error or the server callback
sends a message back to the client, then the message will be stored in
the associated element of the messages array.  NB: if specified, the
name and messages arrays must be of size n or greater.

<P>
The returned message string will be of the form:
<PRE>
  XPA$ERROR   error-message (class:name ip:port)
</PRE>
or
<PRE>
  XPA$MESSAGE message 	  (class:name ip:port)
</PRE>
<P>
Note that when there is an error stored in an messages entry, the
corresponding bufs and lens entry may or may not be NULL and 0
(respectively), depending on the particularities of the server.

<P>
The return value will contain the actual number of servers that were
processed.  This value thus will hold the number of valid entries in
the bufs, lens, names, and messages arrays, and can be used to loop
through these arrays.  In names and/or messages is NULL, no information is
passed back in that array.

<P>
The mode string is of the form: "key1=value1,key2=value2,..."
The following keywords are recognized:
<PRE>
  key   	value		default		explanation
  ------	--------	--------	-----------
  ack		true/false	true		if false, don't wait for ack from server (after callback completes)
</PRE>
<P>
The ack keyword is not very useful, since the server completes the callback
in order to return the data anyway.  It is here for completion (and perhaps
for future usefulness).
					   
<P>
<B>Example:</B>
<PRE>
  #include &lt;xpa.h&gt;
  #define NXPA 10
  int  i, got;
  int fds[NXPA];
  char *names[NXPA];
  char *messages[NXPA];
  for(i=0; i&lt;NXPA; i++)
    fds[i] = open(...);
  got = XPAGetFd(NULL, "ds9", "file", NULL, fds, names, messages, NXPA);
  for(i=0; i&lt;got; i++){
    if( messages[i] != NULL ){
      /* error processing */
      fprintf(stderr, "ERROR: %s (%s)\n", messages[i], names[i]);
    }
    if( names[i] )
      free(names[i]);
    if( messages[i] )
      free(messages[i]);
  }
</PRE>

<!-- =defdoc xpasetfd xpasetfd 3 -->

<!-- =section xpasetfd NAME -->
<H2><A NAME="xpasetfd">XPASetFd: send data from stdin to one or more XPA servers</A></H2>

<!-- =section xpasetfd SYNOPSIS -->
</B>
<PRE>
  #include &lt;xpa.h&gt;

  int XPASetFd(XPA xpa,
               char *template, char *paramlist, char *mode,
	       int fd, char **names, char **messages, int n)
</PRE>
</B>

<!-- =section xpasetfd DESCRIPTION -->
<P>
Read data from a standard I/O fd and send it to one or more XPA
servers whose class:name identifier matches the specified
<A HREF="./template.html">template.

<P>
A
<A HREF="./template.html">template</A>
of the form "class1:name1" is sent to the
XPA name server, which returns a list of at most n matching XPA
servers.  A connection is established with each of these servers and
the paramlist string is passed to the server as the data transfer
request is initiated. If an XPA struct is passed to the call, then the
persistent connections are updated as described above. Otherwise,
temporary connections are made to the servers (which will be closed
when the call completes).

<P>
The XPASetFd() routine then reads bytes from the specified fd
until EOF and sends these bytes to the XPA servers.  
The final parameter n specifies the maximum number of servers to contact.
A string containing the class:name and ip:port of each server is returned in
the name array.  If a given server returned an error, then the error
message will be stored in the associated element of the messages array.
NB: if specified, the name and messages arrays must be of size n or greater.

<P>
The return value will contain the actual number of servers that were
processed.  This value thus will hold the number of valid entries in
the names and messages arrays, and can be used to loop through these
arrays.  In names and/or messages is NULL, no information is passed back
in that array.

<P>
The mode string is of the form: "key1=value1,key2=value2,..."
The following keywords are recognized:
<PRE>
  key   	value		default		explanation
  ------	--------	--------	-----------
  ack		true/false	true		if false, don't wait for ack from server (after callback completes)
  verify	true/false	false		send buf from XPASet[Fd] to stdout
</PRE>
<P>
The ack keyword is useful in cases where one does not want to wait for
the server to complete, e.g. is a lot of processing needs to be done
on the passed data or when the success of the server operation is not
relevant to the client.

<P>
<B>Example:</B>
<PRE>
  #include &lt;xpa.h&gt;

  #define NXPA 10
  int  i, got;
  int fd;
  char *names[NXPA];
  char *messages[NXPA];
  fd = open(...);
  got = XPASetFd(NULL, "ds9", "fits", NULL, fd, names, messages, NXPA);
  for(i=0; i&lt;got; i++){
    if( messages[i] != NULL ){
      /* error processing */
      fprintf(stderr, "ERROR: %s (%s)\n", messages[i], names[i]);
    }
    if( names[i] )
      free(names[i]);
    if( messages[i] )
      free(messages[i]);
  }
</PRE>

<!-- =defdoc xpaopen xpaopen 3 -->

<!-- =section xpaopen NAME -->
<H2><A NAME="xpaopen">XPAOpen: allocate a persistent client handle</A></H2>

<!-- =section xpaopen SYNOPSIS -->
<B>
<PRE>
  #include &lt;xpa.h&gt;

  XPA XPAOpen(char *mode);
</PRE>
</B>

<!-- =section xpaopen DESCRIPTION -->
<P>
XPAOpen() allocates a persistent XPA struct that can be used with
calls to XPAGet(), XPASet(), XPAInfo(), XPAGetFd(), and
XPASetFd(). Persistence means that a connection to an XPA server is
not closed when one of the above calls is completed but will be
re-used on successive calls. Using XPAOpen() therefore saves the time
it takes to connect to a server, which could be significant with slow
connections or if there will be a large number of exchanges with a
given access point.  The mode argument currently is ignored ("reserved
for future use").

<P>
An XPA struct is returned if XPAOpen() was successful; otherwise NULL
is returned. This returned struct can be passed as the first argument
to XPAGet(), etc.  Those calls will update the list of active XPA
connections.  Already connected servers (from a previous call) are
left connected and new servers also will be connected.  Old servers
(from a previous call) that are no longer needed are disconnected.
The connected servers will remain connected when the next call to
XPAGet() is made and connections are once again updated.

<P>
<B>Example:</B>
<PRE>
 #include &lt;xpa.h&gt;

  XPA xpa;
  xpa = XPAOpen(NULL);
</PRE>

<!-- =defdoc xpaclose xpaclose 3 -->

<!-- =section xpaclose NAME -->
<H2><A NAME="xpaclose">XPAClose: close a persistent XPA client handle</A></H2>

<!-- =section xpaclose SYNOPSIS -->
<B>
<PRE>
  #include &lt;xpa.h&gt;

  void XPAClose(XPA xpa);
</PRE>
</B>

<!-- =section xpaclose DESCRIPTION -->
<P>
XPAClose closes the persistent connections associated with this XPA struct
and frees all allocated space. It also closes the open sockets connections
to all XPA servers that were opened using this handle.

<P>
<B>Example:</B>
<PRE>
  #include &lt;xpa.h&gt;

  XPA xpa;
  XPAClose(xpa);
</PRE>

<!-- =defdoc xpanslookup xpanslookup 3 -->

<!-- =section xpanslookup NAME -->
<H2><A NAME="xpanslookup">XPANSLookup: lookup registered XPA access points</A></H2>

<!-- =section xpanslookup SYNOPSIS -->
<B>
<PRE>
  #include &lt;xpa.h&gt;

  int XPANSLookup(XPA xpa,
  	          char *template, char type,
	          char ***classes, char ***names,
	          char ***methods, char ***infos)
</PRE>
</B>

<!-- =section xpanslookup DESCRIPTION -->
<P>
XPA routines act on a class:name identifier in such a way
that all access points that match the identifier are processed.  It is
sometimes desirable to choose specific access points from the
candidates that match the
<A HREF="./template.html">template</A>.  In order to do this, the
XPANSLookup routine can be called to return a list of matches, so that
specific class:name instances can then be fed to XPAGet(), XPASet(), etc.

<P> The first argument is an optional XPA struct. If non-NULL, the
existing name server connection associated with the specified xpa is
used to query the xpans name server for matching templates. Otherwise,
a new (temporary) connection is established with the name server.

<P>
The second argument to XPANSLookup is the class:name 
<A HREF="./template.html">template</A>
to match.

<P>
The third argument for XPANSLookup() is the type of access and can be
any combination of:
<PRE>
  type   	explanation
  ------	-----------
  g		xpaget calls can be made on this access point
  s		xpaset calls can be made on this access point
  i		xpainfo calls can be made on this access point
</PRE>
<P>
The call typically specifies only one of these at a time.

<P>
The final arguments are pointers to arrays that will be filled
in and returned by the name server. The name server will allocate and
return arrays filled with the classes, names, and methods of all XPA
access points that match the <A HREF="./template.html">template</A>
and have the specified type. Also returned are info strings, which
generally are used internally by the client routines. These can be
ignored (but the strings must be freed).  The function returns the
number of matches. The returned value can be used to loop through the
matches:

<B>Example:</B>
<PRE>
  #include &lt;xpa.h&gt;

  char **classes;
  char **names;
  char **methods;
  char **infos;
  int i, n;
  n = XPANSLookup(NULL, "foo*", "g", &classes, &names, &methods, &infos);
  for(i=0; i&lt;n; i++){
    [more specific checks on possibilities ...]
    [perhaps a call to XPAGet for those that pass, etc. ...]
    /* don't forget to free alloc'ed strings when done */
    free(classes[i]);
    free(names[i]);
    free(methods[i]);
    free(infos[i]);
  }
  /* free up arrays alloc'ed by names server */
  if( n > 0 ){
    free(classes);
    free(names);
    free(methods);
    free(infos);
  }
</PRE>
<P>
The specified 
<A HREF="./template.html">template</A>
also can be a host:port specification, for example:
<PRE>
  myhost:12345
</PRE>
<P>
In this case, no connection is made to the name server. Instead, the
call will return one entry such that the ip array contains the ip for
the specified host and the port array contains the port.  The class
and name entries are set to the character "?", since the class and
name of the access point are not known. 

<!-- =defdoc xpaaccess xpaaccess 3 -->

<!-- =section xpaaccess NAME -->
<H2><A NAME="xpaaccess">XPAAccess: return XPA access points matching
template (XPA 2.1 and above)</A></H2>

<!-- =section xpaaccess SYNOPSIS -->
<B>
<PRE>
  #include &lt;xpa.h&gt;

  int XPAAccess(XPA xpa,
	        char *template, char *paramlist, char *mode,
	        char **names, char **messages, int n);
</PRE>
</B>

<!-- =section xpaaccess DESCRIPTION -->
<P>
The XPAAccess routine returns the public access points that match the
specified second argument <A HREF="./template.html">template</A> and
have the specified access type.

<P>
A
<A HREF="./template.html">template</A>
of the form "class1:name1" is sent to the
XPA name server, which returns a list of at most n matching XPA
servers.  A connection is established with each of these servers and
the paramlist string is passed to the server as the data transfer
request is initiated. If an XPA struct is passed to the call, then the
persistent connections are updated as described above. Otherwise,
temporary connections are made to the servers (which will be closed
when the call completes).

<P>
The XPAAccess() routine retrieves names from at most n XPA servers
that match the specified template and that were checked for access
using the specified mode.  The return string contains both the
class:name and ip:port.  If a given server returned an error or the
server callback sends a message back to the client, then the message
will be stored in the associated element of the messages array.
NB: if specified, the name and messages arrays must be of size n or greater.

<P>
The returned message string will be of the form:
<PRE>
  XPA$ERROR error-message (class:name ip:port)
</PRE>
<P>
Note that names of matching registered access points are always
returned but may not be valid; it is not sufficient to assume that the
returned number of access points is the number of valid access points.
Rather, it is essential to check the messages array for error
messages.  Any string in the messages array is an error message and
indicated that the associated access point is not available.

<P>
For example, assume that a server registers a number of access points
but delays entering its event loop. If a call to XPAAccess() is made
before the event loop is entered, the call will timeout (after waiting
for the long timeout period) and return an error of the form:
<PRE>
  XPA$ERROR: timeout waiting for server authentication (XPA:xpa1)
</PRE>
The error means that the XPA access point has been registered but is
not yet available (because events are not being processed). When the
server finally enters its event loop, subsequent calls to XPAAccess()
will return successfully.

<P>
NB: This routine only works with XPA servers built with XPA 2.1.x and later.
Servers with older versions of XPA will return the error message:

  XPA$ERROR invalid xpa command in initialization string

If you get this error message, then the old server actually is ready
for access, since it got to the point of fielding the query! The
xpaaccess program, for example, ignores this message in order to work
properly with older servers.

<P>
The third argument for XPAAccess() is the type of access and can be
any combination of:
<PRE>
  type   	explanation
  ------	-----------
  g		xpaget calls can be made on this access point
  s		xpaset calls can be made on this access point
  i		xpainfo calls can be made on this access point
</PRE>
<P>
The mode string argument is of the form: "key1=value1,key2=value2,..."
The following keywords are recognized:
<PRE>
  key   	value		default		explanation
  ------	--------	--------	-----------
  ack		true/false	true		if false, don't wait for ack from server (after callback completes)
</PRE>
<P>
The ack keyword is not very useful, since the server completes the callback
in order to return the data anyway.  It is here for completion (and perhaps
for future usefulness).

<!-- =section xpaclient SEE ALSO -->
<!-- =text See xpa(n) for a list of XPA help pages -->
<!-- =section xpaget SEE ALSO -->
<!-- =text See xpa(n) for a list of XPA help pages -->
<!-- =section xpaset SEE ALSO -->
<!-- =text See xpa(n) for a list of XPA help pages -->
<!-- =section xpainfo SEE ALSO -->
<!-- =text See xpa(n) for a list of XPA help pages -->
<!-- =section xpagetfd SEE ALSO -->
<!-- =text See xpa(n) for a list of XPA help pages -->
<!-- =section xpasetfd SEE ALSO -->
<!-- =text See xpa(n) for a list of XPA help pages -->
<!-- =section xpaopen SEE ALSO -->
<!-- =text See xpa(n) for a list of XPA help pages -->
<!-- =section xpaclose SEE ALSO -->
<!-- =text See xpa(n) for a list of XPA help pages -->
<!-- =section xpanslookup SEE ALSO -->
<!-- =text See xpa(n) for a list of XPA help pages -->
<!-- =section xpaaccess SEE ALSO -->
<!-- =text See xpa(n) for a list of XPA help pages -->
<!-- =stop -->

<P>
<A HREF="./help.html">Go to XPA Help Index</A>

<H5>Last updated: March 10, 2007</H5>

</BODY>
</HTML>