1xpagetfd(3)                   SAORD Documentation                  xpagetfd(3)
2
3
4

NAME

6       XPAGetFd: retrieve data from one or more XPA servers and write to files
7

SYNOPSIS

9         #include <xpa.h>
10
11         int XPAGetFd(XPA xpa,
12                      char *template, char *paramlist, char *mode,
13                      int *fds, char **names, char **messages, int n);
14

DESCRIPTION

16       Retrieve data from one or more XPA servers whose class:name identifier
17       matches the specified template and write it to files associated with
18       one or more standard I/O fds (i.e, handles returned by open()).
19
20       A template of the form "class1:name1" is sent to the XPA name server,
21       which returns a list of at most ABS(n) matching XPA servers.  A
22       connection is established with each of these servers and the paramlist
23       string is passed to the server as the data transfer request is
24       initiated. If an XPA struct is passed to the call, then the persistent
25       connections are updated as described above. Otherwise, temporary
26       connections are made to the servers (which will be closed when the call
27       completes).
28
29       The XPAGetFd() routine then retrieves data from the XPA servers, and
30       write these data to the fds associated with one or more fds (i.e.,
31       results from open). Is n is positive, then there will be n fds and the
32       data from each server will be sent to a separate fd. If n is negative,
33       then there is only 1 fd and all data is sent to this single fd. (The
34       latter is how xpaget is implemented.)
35
36       A string containing the class:name and ip:port is stored in the name
37       array.  If a given server returned an error or the server callback
38       sends a message back to the client, then the message will be stored in
39       the associated element of the messages array.  NB: if specified, the
40       name and messages arrays must be of size n or greater.
41
42       The returned message string will be of the form:
43
44         XPA$ERROR   error-message (class:name ip:port)
45
46       or
47
48         XPA$MESSAGE message     (class:name ip:port)
49
50       Note that when there is an error stored in an messages entry, the
51       corresponding bufs and lens entry may or may not be NULL and 0
52       (respectively), depending on the particularities of the server.
53
54       The return value will contain the actual number of servers that were
55       processed.  This value thus will hold the number of valid entries in
56       the bufs, lens, names, and messages arrays, and can be used to loop
57       through these arrays.  In names and/or messages is NULL, no information
58       is passed back in that array.
59
60       The mode string is of the form: "key1=value1,key2=value2,..."  The
61       following keywords are recognized:
62
63         key           value           default         explanation
64         ------        --------        --------        -----------
65         ack           true/false      true            if false, don't wait for ack from server (after callback completes)
66
67       The ack keyword is not very useful, since the server completes the
68       callback in order to return the data anyway.  It is here for completion
69       (and perhaps for future usefulness).
70
71       Example:
72
73         #include <xpa.h>
74         #define NXPA 10
75         int  i, got;
76         int fds[NXPA];
77         char *names[NXPA];
78         char *messages[NXPA];
79         for(i=0; i<NXPA; i++)
80           fds[i] = open(...);
81         got = XPAGetFd(NULL, "ds9", "file", NULL, fds, names, messages, NXPA);
82         for(i=0; i<got; i++){
83           if( messages[i] != NULL ){
84             /* error processing */
85             fprintf(stderr, "ERROR: %s (%s)\n", messages[i], names[i]);
86           }
87           if( names[i] )
88             free(names[i]);
89           if( messages[i] )
90             free(messages[i]);
91         }
92

SEE ALSO

94       See xpa(n) for a list of XPA help pages
95
96
97
98version 2.1.15                   July 23, 2013                     xpagetfd(3)
Impressum