SYNOPSIS

  #include <xpa.h>

  int XPAGet(XPA xpa,
             char *template, char *paramlist, char *mode,
             char **bufs, size_t *lens, char **names, char **messages,
             int n);

DESCRIPTION

Retrieve data from one or more \s-1XPA\s0 servers whose class:name identifier matches the specified template.

A template of the form \*(L"class1:name1\*(R" is sent to the \s-1XPA\s0 name server, which returns a list of at most n matching \s-1XPA\s0 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 \s-1XPA\s0 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).

The XPAGet() routine then retrieves data from at most n \s-1XPA\s0 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. \s-1NB:\s0 if specified, the name and messages arrays must be of size n or greater.

The returned message string will be of the form:

XPA$ERROR error\-message (class:name ip:port)

or

XPA$MESSAGE message (class:name ip:port)

Note that when there is an error stored in an messages entry, the corresponding bufs and lens entry may or may not be \s-1NULL\s0 and 0 (respectively), depending on the particularities of the server.

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 \s-1NULL\s0, no information is passed back in that array.

The bufs, names, and messages arrays should be freed upon completion (if they are not \s-1NULL\s0);

The mode string is of the form: \*(L"key1=value1,key2=value2,...\*(R" The following keywords are recognized:

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

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).

Normally, an \s-1XPA\s0 client will process incoming \s-1XPA\s0 server requests while awaiting the completion of the client request. Setting this variable to \*(L"false\*(R" will prevent \s-1XPA\s0 server requests from being processed by the client.

Example -

#include <xpa.h>

#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<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]); }

RELATED TO xpaget…

See xpa(7) for a list of \s-1XPA\s0 help pages