7 * Revision 1.23 1994/09/22 03:18:05 markc
8 * changes to remove compiler warnings
9 * changed pid passed to RPCprocessCreate
11 * Revision 1.22 1994/08/17 18:23:53 markc
12 * Added new classes: Cstring KeyList, KList
13 * Added new function: RPCgetArg
14 * Changed typedefs in machineType.h to #defines
16 * Revision 1.21 1994/07/28 22:21:26 krisna
17 * changed declaration of xdrIOFunc to conform to prototypes
19 * Revision 1.20 1994/07/19 18:29:59 markc
20 * Made machineName default to zero as last parameter to RPC_make_arg_list.
21 * Added typecast to malloc call in RPC_make_arg_list.
23 * Revision 1.19 1994/07/18 19:09:10 hollings
24 * added extra arg to RPC_make_arg_list.
26 * Revision 1.18 1994/06/02 23:35:15 markc
27 * Modified RPCUser class to support improved error checking for igen.
29 * Revision 1.17 1994/04/21 23:23:44 hollings
30 * removed paradynd name from make args function.
32 * Revision 1.16 1994/04/06 22:45:24 markc
33 * Cleaned up rpcUtil.h. Moved include files to rpcUtil.C where they belonged.
35 * Revision 1.15 1994/03/31 22:59:04 hollings
36 * added well known port as a paramter to xdrRPC constructor.
38 * Revision 1.14 1994/03/25 16:07:31 markc
39 * Added option to specify timeout on readReady.
41 * Revision 1.13 1994/03/20 01:45:23 markc
42 * Changed xdr_Boolean to char rather than int to reflect Boolean change.
44 * Revision 1.12 1994/03/11 21:01:24 hollings
45 * Changed Boolean from int to char to match X11 convention.
52 #include <sys/types.h>
53 #include <sys/socket.h>
54 #include <rpc/types.h>
59 #define xdr_Boolean xdr_char
61 typedef int (*xdrIOFunc)(const void *, char *, int);
65 extern int RPC_readReady (int fd, int timeout=0);
69 // Functions common to server and client side.
73 XDRrpc(char *m, char *u, char *p, xdrIOFunc, xdrIOFunc,
74 char **arg_list=0, int nblock=0, int wellKnownPortFd = 0);
75 XDRrpc(int fd, xdrIOFunc readRoutine, xdrIOFunc writeRoutine, int nblock=0);
76 XDRrpc(int family, int port, int type, char *machine, xdrIOFunc readFunc,
77 xdrIOFunc writeFunc, int nblock=0);
79 inline void setNonBlock() {
81 fcntl (fd, F_SETFL, FNDELAY);
83 inline void closeConnect() {
84 if (fd >= 0) close(fd); fd = -1;
89 inline int readReady(int timeout=0) {
90 return RPC_readReady (fd, timeout);
98 inline void setPid(int to) {
101 inline XDR *getXdrs() {
104 inline setDir(xdr_op d) {__xdrs__->x_op = d;}
108 int pid; // pid of child;
109 static int __wellKnownPortFd__;
113 // common routines that are transport independent.
117 inline RPCBase(int st=0, int v=0) { err_state = st; versionVerifyDone = v;}
119 inline int get_err_state() { return err_state;}
120 inline int clear_err_state() {err_state = 0;}
121 inline int did_error_occur() {return (err_state != 0);}
122 inline int getVersionVerifyDone() { return versionVerifyDone;}
123 inline int setVersionVerifyDone() { versionVerifyDone = 1;}
124 inline void set_err_state(int s) { err_state = s;}
126 int versionVerifyDone;
132 inline THREADrpc(int t) { tid = t; }
134 inline void setTid(int id) { tid = id; }
135 inline int getTid() { return tid;}
137 // see not on requestingThread, the use of this may be unsafe
138 inline unsigned int getRequestingThread() { return requestingThread; }
139 inline void setRequestingThread(int t) { requestingThread = t;}
142 // these are only to be used by implmentors of thread RPCs.
143 // the value is only valid during a thread RPC.
144 unsigned int requestingThread;
147 extern int RPC_setup_socket (int *sfd, // return file descriptor
148 int family, // AF_INET ...
149 int type); // SOCK_STREAM ...
150 extern int xdr_char_PTR (XDR*, char**);
151 extern int RPCprocessCreate(int &pid, const char *hostName, const char *userName,
152 const char *commandLine, char **arg_list = 0,
153 int wellKnownPort = 0);
155 extern char **RPC_make_arg_list (int family, int type,
158 char *machienName = (char*) 0);
161 RPC_undo_arg_list (int argc, char **arg_list, char **machine, int &family,
162 int &type, int &well_known_socket, int &flag);
163 extern int RPC_getConnect (int fd);
165 extern char **RPCgetArg(int &argc, const char *input);