Remote and RPC.
[wrappi.git] / lib / internal.h
index b9cc57c..69128e9 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <string.h>
 #include <errno.h>
+#include <rpc/types.h>
+#include <rpc/xdr.h>
 
 #define STREQ(a,b) (strcmp((a),(b)) == 0)
 #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
@@ -51,11 +53,16 @@ struct wrap_h {
    * on the local side of a connection.
    */
 
-  /* Connection URL.  If scheme = NULL, it means we're using the local
-   * code.
+  uint32_t serial;              /* Serial number used in protocol. */
+
+  FILE *rfp, *wfp;              /* Connection to remote. */
+  pid_t pid;                    /* Child process if using remote, eg ssh */
+
+  /* Connection URL.  If scheme == LOCAL, it means we're using the
+   * local code.
    */
-  const char *scheme;
-  const char *hostname;
+  wrap_scheme_enum scheme;
+  char *hostname;
 };
 
 /* Declare an error, setting the error field in the handle. */
@@ -64,7 +71,26 @@ struct wrap_h {
 #define set_error_errno(fs...) \
   wrap_int_set_error_errno ((struct wrap_internal_h *)w, (errno), __func__, fs)
 
+extern void wrap_int_connect_ssh (wrap_h *w);
+extern void wrap_int_make_request (wrap_h *w, int proc_nr, const void *args, void *ret);
+extern void wrap_int_make_request_xdr (wrap_h *w, int proc_nr, const void *args, void *ret);
 extern void wrap_int_set_error (struct wrap_internal_h *w, const char *func, const char *fs, ...);
 extern void wrap_int_set_error_errno (struct wrap_internal_h *w, int errnum, const char *func, const char *fs, ...);
 
+/* See lib/internal-procs.c for the static contents of this table.
+ * The table is indexed by wrap_int_<name>_num.  These are defined in
+ * lib/internal-procs.h.
+ */
+struct proc_table {
+  const char *name;             /* The name of this entry point. */
+
+  /* XDR encode/decode functions for serializing the args and ret. */
+  xdrproc_t xdr_args;
+  xdrproc_t xdr_ret;
+};
+
+extern const struct proc_table wrap_int_proc_table[];
+
+#include "internal-procs.h"
+
 #endif /* WRAPPI_INTERNAL_H_ */