summaryrefslogtreecommitdiff
path: root/libvxi11client
diff options
context:
space:
mode:
Diffstat (limited to 'libvxi11client')
-rw-r--r--libvxi11client/Makefile37
-rw-r--r--libvxi11client/client.c162
-rw-r--r--libvxi11client/libvxi11client.c487
-rw-r--r--libvxi11client/libvxi11client.h32
-rw-r--r--libvxi11client/perlbits/Makefile.PL39
-rw-r--r--libvxi11client/perlbits/VXI11-Client.t22
-rw-r--r--libvxi11client/perlbits/typemap1
-rw-r--r--libvxi11client/vxi11.h342
-rw-r--r--libvxi11client/vxi11_clnt.c265
-rw-r--r--libvxi11client/vxi11_xdr.c462
10 files changed, 1849 insertions, 0 deletions
diff --git a/libvxi11client/Makefile b/libvxi11client/Makefile
new file mode 100644
index 0000000..b313b63
--- /dev/null
+++ b/libvxi11client/Makefile
@@ -0,0 +1,37 @@
+CFLAGS = -Wall -std=gnu99 `pkg-config --cflags gthread-2.0`
+LFLAGS = `pkg-config --libs gthread-2.0`
+
+all: client
+
+client: libvxi11client.o vxi11_clnt.o vxi11_xdr.o client.o
+ $(CC) -o $@ $^ $(LFLAGS)
+
+client.o: client.c libvxi11client.h
+ $(CC) $(CFLAGS) -c $<
+
+libvxi11client.o: libvxi11client.c libvxi11client.h
+ $(CC) $(CFLAGS) -c $<
+
+vxi11_clnt.o: vxi11_clnt.c
+ $(CC) $(CFLAGS) -c $<
+
+vxi11_xdr.o: vxi11_xdr.c
+ $(CC) $(CFLAGS) -c $^
+
+.PHONY: clean perl
+
+clean:
+ -rm *.o client
+ -rm -rf VXI11-Client
+
+perl:
+ -rm -rf VXI11-Client
+ h2xs -A -M vxi11 -x -n VXI11::Client libvxi11client.h
+ cp vxi11.h libvxi11client.c libvxi11client.h vxi11_clnt.c vxi11_xdr.c VXI11-Client/
+ cp perlbits/Makefile.PL VXI11-Client/
+ cp perlbits/VXI11-Client.t VXI11-Client/t/
+ cp perlbits/typemap VXI11-Client/
+ cd VXI11-Client/ && perl Makefile.PL
+ cd VXI11-Client/ && make
+ cd VXI11-Client/ && make test
+
diff --git a/libvxi11client/client.c b/libvxi11client/client.c
new file mode 100644
index 0000000..04753a8
--- /dev/null
+++ b/libvxi11client/client.c
@@ -0,0 +1,162 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "libvxi11client.h"
+
+#define IDENTIFY "*IDN?"
+
+static char* geterrorstring(int errorcode) {
+ switch (errorcode) {
+ case 0:
+ return "invalid state (not connected) or no response from server";
+ case -4:
+ return "invalid link identifier";
+ case -6:
+ return "channel not established";
+ case -8:
+ return "operation not supported";
+ case -11:
+ return "device locked by another link";
+ case -12:
+ return "no lock held by this link";
+ case -29:
+ return "channel already established";
+ default:
+ return "unknown error code";
+ }
+}
+
+int main(int argc, char *argv[]) {
+
+ printf("VXI-11 test client\n");
+
+ if (argc != 2) {
+ printf("usage; %s <host>\n", argv[0]);
+ exit(1);
+ }
+
+ int err = 0;
+
+ if ((err = vxi11_open(argv[1], NULL)) > 0) {
+
+ /**
+ * Basic tests
+ */
+
+ // write some bytes
+ int byteswritten = vxi11_write(IDENTIFY, sizeof(IDENTIFY), false);
+ if (byteswritten >= 0)
+ printf("Wrote %d bytes\n", byteswritten);
+ else
+ printf("Error writing data\n");
+
+ // read some bytes
+ int bytesread = vxi11_read(NULL, 0, false, false, 0);
+ if (bytesread >= 0)
+ printf("Read %d bytes\n", bytesread);
+ else
+ printf("Error reading data\n");
+
+ // trigger
+ if (vxi11_trigger(false) > 0)
+ printf("triggered\n");
+
+ // clear
+ if (vxi11_clear(false) > 0)
+ printf("cleared\n");
+
+ // abort
+ if ((err = vxi11_abort()) > 0)
+ printf("aborted\n");
+ else
+ printf("abort failed; %s\n", geterrorstring(err));
+
+ // lock
+ if ((err = vxi11_lock(false)) > 0)
+ printf("locked\n");
+
+ // unlock
+ if ((err = vxi11_unlock()) > 0)
+ printf("unlocked\n");
+
+ // remote
+ if ((err = vxi11_remote(false)) > 0)
+ printf("remote'd\n");
+
+ // local
+ if ((err = vxi11_local(false)) > 0)
+ printf("local'd\n");
+
+ // read the status byte
+ int statusbyte = vxi11_readstatusbyte(false);
+ if (statusbyte >= 0)
+ printf("Status byte is 0x%02x\n", statusbyte);
+ else
+ printf("Error reading status byte\n");
+
+ /**
+ * Locking tests
+ */
+
+ // try locking twice
+ printf("-- Locking twice --\n");
+ if ((err = vxi11_lock(false)) > 0) {
+ printf("locked\n");
+ if ((err = vxi11_lock(false)) > 0) {
+ printf("locked again!!\n");
+ exit(1);
+ }
+ else {
+ printf("Second lock failed; %s\n", geterrorstring(err));
+ }
+ }
+ if ((err = vxi11_unlock()) > 0)
+ printf("unlocked\n");
+ else {
+ printf("error unlocking; %s\n", geterrorstring(err));
+ exit(1);
+ }
+
+ printf("\n");
+
+ // try unlocking unlocked device
+ printf("-- Unlocking when unlocked --\n");
+ if ((err = vxi11_unlock()) > 0) {
+ printf("Unlocked!!\n");
+ exit(1);
+ }
+ else
+ printf("error unlocking; %s\n", geterrorstring(err));
+ printf("\n");
+
+ // Interrupt channel tests
+ printf("-- Testing interrupt channel --\n");
+ // create interrupt channel
+ if ((err = vxi11_create_intr_chan()) > 0) {
+ printf("Created interrupt channel\n");
+ sleep(10);
+ // destroy interrupt channel
+ if ((err = vxi11_destroy_intr_chan()) > 0)
+ printf("Destroyed interrupt channel\n");
+ else
+ printf("Error destroying interrupt channel; %s\n", geterrorstring(err));
+ }
+ else
+ printf("Error creating interrupt channel; %s\n", geterrorstring(err));
+ printf("\n");
+
+ // docmd
+ if ((err = vxi11_docmd(0x00, false)) > 0)
+ printf("did command, should fail!\n");
+ else
+ printf("Error calling docmd; %s\n", geterrorstring(err));
+
+ // close
+ if ((err = vxi11_close() > 0))
+ printf("Closed\n");
+ }
+ else {
+ printf("Error opening device; %s\n", geterrorstring(err));
+ exit(1);
+ }
+ return 0;
+}
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c
new file mode 100644
index 0000000..2f36147
--- /dev/null
+++ b/libvxi11client/libvxi11client.c
@@ -0,0 +1,487 @@
+#include <stdbool.h>
+#include <rpc/rpc.h>
+#include <netinet/in.h>
+#include <glib.h>
+#include <poll.h>
+#include "vxi11.h"
+
+#define DEBUG
+
+#ifdef DEBUG
+#include <stdio.h>
+#include <arpa/inet.h>
+#endif
+
+/**
+ * This is a thin wrapper around the rpcgen generated code to give it a simpler interface.
+ * Only one server with a single link is supported.
+ */
+
+#define FLAG_TERMCHRSET (1 << 7)
+#define FLAG_END (1 << 3)
+#define FLAG_WAITLOCK 1
+
+#define VXI11_DEFAULT_TIMEOUT 1000
+
+static CLIENT* clnt = NULL;
+static CLIENT* abortclnt = NULL;
+static Device_Link link;
+static GThread* interruptthread;
+static bool interruptchannelopen = false;
+
+static void killinterruptthreadandwait() {
+ interruptchannelopen = false;
+ g_thread_join(interruptthread);
+ interruptthread = NULL;
+}
+
+void *
+device_intr_srq_1_svc(Device_SrqParms *argp, struct svc_req *rqstp) {
+#ifdef DEBUG
+ printf("device_intr_srq_1_svc()\n");
+#endif
+ static char * result;
+ return (void *) &result;
+}
+
+static void device_intr_1(struct svc_req *rqstp, register SVCXPRT *transp) {
+ union {
+ Device_SrqParms device_intr_srq_1_arg;
+ } argument;
+ char *result;
+ xdrproc_t _xdr_argument, _xdr_result;
+ char *(*local)(char *, struct svc_req *);
+
+ switch (rqstp->rq_proc) {
+ case NULLPROC:
+ (void) svc_sendreply(transp, (xdrproc_t) xdr_void, (char *) NULL);
+ return;
+
+ case device_intr_srq:
+ _xdr_argument = (xdrproc_t) xdr_Device_SrqParms;
+ _xdr_result = (xdrproc_t) xdr_void;
+ local = (char *(*)(char *, struct svc_req *)) device_intr_srq_1_svc;
+ break;
+
+ default:
+ svcerr_noproc(transp);
+ return;
+ }
+ memset((char *) &argument, 0, sizeof(argument));
+ if (!svc_getargs(transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
+ svcerr_decode(transp);
+ return;
+ }
+ result = (*local)((char *) &argument, rqstp);
+ if (result != NULL && !svc_sendreply(transp, (xdrproc_t) _xdr_result, result)) {
+ svcerr_systemerr(transp);
+ }
+ if (!svc_freeargs(transp, (xdrproc_t) _xdr_argument, (caddr_t) &argument)) {
+ fprintf(stderr, "%s", "unable to free arguments");
+ exit(1);
+ }
+ return;
+}
+
+static Device_Flags vxi11_generateflags(bool waitlock, bool end, bool termchrset) {
+ Device_Flags flags = 0;
+ if (waitlock)
+ flags |= FLAG_WAITLOCK;
+ if (end)
+ flags |= FLAG_END;
+ if (termchrset)
+ flags |= FLAG_TERMCHRSET;
+ return flags;
+}
+
+/**
+ * create an RPC client and open a link to the server at $address.
+ * $device is apparently used for VXI-11 -> GPIB gateways.. this is untested.
+ */
+
+int vxi11_open(char* address, char* device) {
+ clnt = clnt_create(address, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp");
+
+ if (clnt == NULL)
+ return 0;
+
+ else {
+ Create_LinkParms link_parms;
+ link_parms.clientId = (long) clnt;
+ link_parms.lockDevice = 0;
+ link_parms.lock_timeout = VXI11_DEFAULT_TIMEOUT;
+ link_parms.device = device != NULL ? device : "device0";
+
+ Create_LinkResp* linkresp = create_link_1(&link_parms, clnt);
+ if (linkresp != NULL && linkresp->error == 0) {
+ link = linkresp->lid;
+
+#ifdef DEBUG
+ printf("Link created, lid is %d, abort channel port %d\n", linkresp->lid, linkresp->abortPort);
+#endif
+
+ struct sockaddr_in serveraddr;
+ if (clnt_control(clnt, CLGET_SERVER_ADDR, (char*) &serveraddr)) {
+#ifdef DEBUG
+ char addressstring[INET_ADDRSTRLEN];
+ inet_ntop(AF_INET, &serveraddr.sin_addr, addressstring, sizeof(addressstring));
+ printf("Remote is %s\n", addressstring);
+#endif
+ serveraddr.sin_port = htons(linkresp->abortPort);
+ int sock = RPC_ANYSOCK;
+ abortclnt = clnttcp_create(&serveraddr, DEVICE_ASYNC, DEVICE_ASYNC_VERSION, &sock, 0, 0);
+ if (abortclnt == NULL)
+ return 0;
+
+ }
+ else
+ // failed!
+ return 0;
+
+ return 1;
+ }
+ else if (linkresp == NULL)
+ return 0;
+ else
+ return -(linkresp->error);
+ }
+}
+
+/**
+ * read the status byte of the connected server
+ */
+
+int vxi11_readstatusbyte(bool waitforlock) {
+ if (clnt == NULL)
+ return 0;
+
+ Device_GenericParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
+ Device_ReadStbResp* resp = device_readstb_1(&params, clnt);
+
+ if (resp != NULL && resp->error == 0)
+ return resp->stb;
+ else if (resp == NULL)
+ return 0;
+ else
+ return -1;
+}
+
+/**
+ * write to the connected device
+ */
+
+int vxi11_write(char* data, unsigned int len, bool waitlock, bool end) {
+ if (clnt == NULL)
+ return 0;
+
+ Device_WriteParms params = { .lid = link, .io_timeout = VXI11_DEFAULT_TIMEOUT,
+ .lock_timeout = VXI11_DEFAULT_TIMEOUT, .flags = vxi11_generateflags(waitlock, end, false) };
+ params.data.data_len = len;
+ params.data.data_val = data;
+
+ Device_WriteResp* resp = device_write_1(&params, clnt);
+ if (resp != NULL && resp->error == 0)
+ return resp->size;
+ else if (resp == NULL)
+ return 0;
+ else
+ return -1;
+}
+
+/**
+ * read from the connected device
+ */
+
+int vxi11_read(char* buffer, unsigned int bufferlen, bool waitlock, bool termchrset, char termchr) {
+ if (clnt == NULL)
+ return 0;
+
+ Device_ReadParms params = { .lid = link, .requestSize = 256, .io_timeout = VXI11_DEFAULT_TIMEOUT, .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT, .flags = vxi11_generateflags(waitlock, false, termchrset), .termChar =
+ termchrset ? termchr : 0 };
+
+ Device_ReadResp* resp = device_read_1(&params, clnt);
+ if (resp != NULL && resp->error == 0)
+ return resp->data.data_len;
+ else if (resp == NULL)
+ return 0;
+ else
+ return -1;
+}
+
+/**
+ *
+ */
+
+int vxi11_docmd(unsigned long cmd, bool waitforlock) {
+ if (clnt == NULL)
+ return 0;
+
+ Device_DocmdParms params =
+ { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .io_timeout = VXI11_DEFAULT_TIMEOUT,
+ .lock_timeout = VXI11_DEFAULT_TIMEOUT, .cmd = cmd, .network_order = 0, .datasize = 0 };
+
+ params.data_in.data_in_len = 0;
+ params.data_in.data_in_val = NULL;
+
+ Device_DocmdResp* resp = device_docmd_1(&params, clnt);
+ if (resp != NULL && resp->error == 0)
+ return 1;
+ else if (resp == NULL)
+ return 0;
+ else
+ return -(resp->error);
+}
+
+/**
+ * trigger the connected device
+ */
+
+int vxi11_trigger(bool waitforlock) {
+ if (clnt == NULL)
+ return 0;
+
+ Device_GenericParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
+ Device_Error* error = device_trigger_1(&params, clnt);
+
+ if (error->error == 0)
+ return 1;
+ else
+ return -(error->error);
+}
+
+/**
+ * clear the connected device
+ */
+
+int vxi11_clear(bool waitforlock) {
+ if (clnt == NULL)
+ return 0;
+ Device_GenericParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
+ Device_Error* error = device_clear_1(&params, clnt);
+ if (error != NULL && error->error == 0)
+ return 1;
+ else if (error == NULL)
+ return 0;
+ else
+ return -(error->error);
+}
+
+/**
+ * remote the connected device
+ */
+
+int vxi11_remote(bool waitforlock) {
+ if (clnt == NULL)
+ return 0;
+ Device_GenericParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
+ Device_Error* error = device_remote_1(&params, clnt);
+ if (error != NULL && error->error == 0)
+ return 1;
+ else if (error == NULL)
+ return 0;
+ else
+ return -(error->error);
+}
+
+/**
+ * local the connected device
+ */
+
+int vxi11_local(bool waitforlock) {
+ if (clnt == NULL)
+ return 0;
+ Device_GenericParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT, .io_timeout = VXI11_DEFAULT_TIMEOUT };
+ Device_Error* error = device_local_1(&params, clnt);
+ if (error != NULL && error->error == 0)
+ return 1;
+ else if (error == NULL)
+ return 0;
+ else
+ return -(error->error);
+}
+
+/**
+ * lock the connected device
+ */
+
+int vxi11_lock(bool waitforlock) {
+ if (clnt == NULL)
+ return 0;
+ Device_LockParms params = { .lid = link, .flags = vxi11_generateflags(waitforlock, false, false), .lock_timeout =
+ VXI11_DEFAULT_TIMEOUT };
+ Device_Error* error = device_lock_1(&params, clnt);
+ if (error != NULL && error->error == 0)
+ return 1;
+ else if (error == NULL)
+ return 0;
+ else
+ return -(error->error);
+}
+
+/**
+ * unlock the connected device
+ */
+
+int vxi11_unlock() {
+ if (clnt == NULL)
+ return 0;
+ Device_Error* error = device_unlock_1(&link, clnt);
+ if (error != NULL && error->error == 0)
+ return 1;
+ else if (error == NULL)
+ return 0;
+ else
+ return -(error->error);
+}
+
+static gpointer interruptthreadfunc(gpointer data) {
+#ifdef DEBUG
+ printf("Interrupt channel thread started\n");
+#endif
+ SVCXPRT *transp;
+ transp = svctcp_create(RPC_ANYSOCK, 0, 0);
+ if (transp == NULL) {
+ fprintf(stderr, "%s", "cannot create tcp service.");
+ return 0;
+ }
+
+#ifdef DEBUG
+ printf("Interrupt channel on port %d tcp\n", transp->xp_port);
+#endif
+
+ if (!svc_register(transp, DEVICE_INTR, DEVICE_INTR_VERSION, device_intr_1, 0)) {
+ fprintf(stderr, "%s", "unable to register (DEVICE_INTR, DEVICE_INTR_VERSION, tcp).\n");
+ return 0;
+ }
+ *((unsigned int*) data) = transp->xp_port;
+
+ int no_of_fds;
+ int i;
+ struct pollfd pollfd_set[1024];
+
+ //svc_run();
+ // stolen from: http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.commtechref%2Fdoc%2Fcommtrf1%2Fsvc_getreq_poll.htm
+ while (interruptchannelopen) {
+ /* initialize the pollfd_set array and
+ get no of file descriptors in "no_of_fds"*/
+
+ /* Keep polling on file descriptors */
+ switch (i = poll(pollfd_set, no_of_fds, -1)) {
+ case -1:
+ case 0:
+ continue;
+ default:
+ /* Handle RPC request on each file descriptor */
+ svc_getreq_poll(pollfd_set, i);
+ }
+ }
+
+#ifdef DEBUG
+ printf("Interrupt channel thread ended\n");
+#endif
+ return NULL;
+}
+
+/**
+ * create an interrupt channel from the connected device
+ */
+int vxi11_create_intr_chan() {
+ if (interruptchannelopen)
+ return 0;
+ else if (clnt == NULL)
+ return 0;
+ else if (interruptthread != NULL)
+ return 0;
+
+ interruptchannelopen = true;
+ unsigned int port = -1;
+ g_thread_init(NULL);
+ interruptthread = g_thread_create(interruptthreadfunc, &port, true, NULL);
+
+ while (port == -1) { // spin
+ };
+
+ struct sockaddr_in myaddress;
+ get_myaddress(&myaddress);
+
+ Device_RemoteFunc remotefunc = { .hostAddr = myaddress.sin_addr.s_addr, .hostPort = port, .progNum = DEVICE_INTR,
+ .progVers = DEVICE_INTR_VERSION, .progFamily = DEVICE_TCP };
+ Device_Error* error = create_intr_chan_1(&remotefunc, clnt);
+ if (error != NULL && error->error == 0)
+ return 1;
+ else if (error == NULL) {
+ killinterruptthreadandwait();
+ return 0;
+ }
+ else {
+ killinterruptthreadandwait();
+ return -(error->error);
+ }
+}
+
+/**
+ * destroy an interrupt channel from the connected device
+ */
+
+int vxi11_destroy_intr_chan() {
+ if (!interruptchannelopen)
+ return 0;
+ else if (clnt == NULL)
+ return 0;
+ else if (interruptthread == NULL)
+ return 0;
+
+ Device_Error* error = destroy_intr_chan_1(NULL, clnt);
+ if (error != NULL && error->error == 0) {
+ killinterruptthreadandwait();
+ return 1;
+ }
+ else if (error == NULL)
+ return 0;
+ else
+ return -(error->error);
+}
+
+/**
+ * send an abort to the connected device
+ */
+
+int vxi11_abort() {
+ if (abortclnt == NULL)
+ return 0;
+ Device_Error* error = device_abort_1(&link, abortclnt);
+ if (error != NULL && error->error == 0)
+ return 1;
+ else if (error == NULL)
+ return 0;
+ else
+ return -(error->error);
+}
+
+/**
+ * close the current link and free the RPC client
+ */
+
+int vxi11_close() {
+ if (clnt == NULL)
+ return 0;
+
+ Device_Error* error = destroy_link_1(&link, clnt);
+ clnt_destroy(clnt);
+ clnt = NULL;
+ clnt_destroy(abortclnt);
+ abortclnt = NULL;
+
+ if (error != NULL && error->error == 0)
+ return 1;
+ else if (error == NULL)
+ return 0;
+ else
+ return -(error->error);
+}
diff --git a/libvxi11client/libvxi11client.h b/libvxi11client/libvxi11client.h
new file mode 100644
index 0000000..c9779e4
--- /dev/null
+++ b/libvxi11client/libvxi11client.h
@@ -0,0 +1,32 @@
+#include <stdbool.h>
+
+#define ERR_SYNTAXERROR -1
+#define ERR_DEVICENOTACCESSIBLE -3
+#define ERR_INVALIDLINKINDENTIFIER -4
+#define ERR_PARAMETERERROR -5
+#define ERR_CHANNELNOTESTABLISHED -6
+#define ERR_OPERATIONNOTSUPPORTED -8
+#define ERR_OUTOFRESOURCES -9
+#define ERR_DEVICELOCKEDBYANOTHERLINK -11
+#define ERR_NOLOCKHELDBYTHISLINK -12
+#define ERR_IOTIMEOUT -15
+#define ERR_IOERROR -17
+#define ERR_INVALIDADDRESS -21
+#define ERR_ABORT -23
+#define ERR_CHANNELALREADYESTABLISHED -29
+
+int vxi11_open(char* address, char* device);
+int vxi11_abort(void);
+int vxi11_trigger(bool waitforlock);
+int vxi11_clear(bool waitforlock);
+int vxi11_write(char* data, unsigned int len, bool end);
+int vxi11_read(char* buffer, unsigned int bufferlen, bool waitlock, bool termchrset, char termchr);
+int vxi11_lock(bool waitforlock);
+int vxi11_unlock(void);
+int vxi11_local(bool waitforlock);
+int vxi11_remote(bool waitforlock);
+int vxi11_readstatusbyte(bool waitforlock);
+int vxi11_create_intr_chan(void);
+int vxi11_destroy_intr_chan(void);
+int vxi11_docmd(unsigned long cmd, bool waitforlock);
+int vxi11_close(void);
diff --git a/libvxi11client/perlbits/Makefile.PL b/libvxi11client/perlbits/Makefile.PL
new file mode 100644
index 0000000..801c91f
--- /dev/null
+++ b/libvxi11client/perlbits/Makefile.PL
@@ -0,0 +1,39 @@
+use 5.014002;
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ NAME => 'VXI11::Client',
+ VERSION_FROM => 'lib/VXI11/Client.pm', # finds $VERSION
+ PREREQ_PM => {}, # e.g., Module::Name => 1.1
+ ($] >= 5.005 ? ## Add these new keywords supported since 5.005
+ (ABSTRACT_FROM => 'lib/VXI11/Client.pm', # retrieve abstract from module
+ AUTHOR => 'daniel <daniel@>') : ()),
+ LIBS => [''], # e.g., '-lm'
+ DEFINE => '', # e.g., '-DHAVE_SOMETHING'
+ INC => '-I.', # e.g., '-I. -I/usr/include/other'
+ OBJECT => '$(O_FILES)', # link all the C files too
+);
+if (eval {require ExtUtils::Constant; 1}) {
+ # If you edit these definitions to change the constants used by this module,
+ # you will need to use the generated const-c.inc and const-xs.inc
+ # files to replace their "fallback" counterparts before distributing your
+ # changes.
+ my @names = (qw());
+ ExtUtils::Constant::WriteConstants(
+ NAME => 'VXI11::Client',
+ NAMES => \@names,
+ DEFAULT_TYPE => 'IV',
+ C_FILE => 'const-c.inc',
+ XS_FILE => 'const-xs.inc',
+ );
+
+}
+else {
+ use File::Copy;
+ use File::Spec;
+ foreach my $file ('const-c.inc', 'const-xs.inc') {
+ my $fallback = File::Spec->catfile('fallback', $file);
+ copy ($fallback, $file) or die "Can't copy $fallback to $file: $!";
+ }
+}
diff --git a/libvxi11client/perlbits/VXI11-Client.t b/libvxi11client/perlbits/VXI11-Client.t
new file mode 100644
index 0000000..de10ecf
--- /dev/null
+++ b/libvxi11client/perlbits/VXI11-Client.t
@@ -0,0 +1,22 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl VXI11-Client.t'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use strict;
+use warnings;
+
+use Test::More tests => 5;
+BEGIN { use_ok('VXI11::Client') };
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+
+is(&VXI11::Client::vxi11_open("roi", 0), 1);
+is(&VXI11::Client::vxi11_lock(0), 1);
+is(&VXI11::Client::vxi11_unlock(), 1);
+is(&VXI11::Client::vxi11_close(), 1);
diff --git a/libvxi11client/perlbits/typemap b/libvxi11client/perlbits/typemap
new file mode 100644
index 0000000..4391935
--- /dev/null
+++ b/libvxi11client/perlbits/typemap
@@ -0,0 +1 @@
+_Bool T_IV
diff --git a/libvxi11client/vxi11.h b/libvxi11client/vxi11.h
new file mode 100644
index 0000000..c21d661
--- /dev/null
+++ b/libvxi11client/vxi11.h
@@ -0,0 +1,342 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#ifndef _VXI11_H_RPCGEN
+#define _VXI11_H_RPCGEN
+
+#include <rpc/rpc.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef long Device_Link;
+
+enum Device_AddrFamily {
+ DEVICE_TCP = 0,
+ DEVICE_UDP = 1,
+};
+typedef enum Device_AddrFamily Device_AddrFamily;
+
+typedef long Device_Flags;
+
+typedef long Device_ErrorCode;
+
+struct Device_Error {
+ Device_ErrorCode error;
+};
+typedef struct Device_Error Device_Error;
+
+struct Create_LinkParms {
+ long clientId;
+ bool_t lockDevice;
+ u_long lock_timeout;
+ char *device;
+};
+typedef struct Create_LinkParms Create_LinkParms;
+
+struct Create_LinkResp {
+ Device_ErrorCode error;
+ Device_Link lid;
+ u_short abortPort;
+ u_long maxRecvSize;
+};
+typedef struct Create_LinkResp Create_LinkResp;
+
+struct Device_WriteParms {
+ Device_Link lid;
+ u_long io_timeout;
+ u_long lock_timeout;
+ Device_Flags flags;
+ struct {
+ u_int data_len;
+ char *data_val;
+ } data;
+};
+typedef struct Device_WriteParms Device_WriteParms;
+
+struct Device_WriteResp {
+ Device_ErrorCode error;
+ u_long size;
+};
+typedef struct Device_WriteResp Device_WriteResp;
+
+struct Device_ReadParms {
+ Device_Link lid;
+ u_long requestSize;
+ u_long io_timeout;
+ u_long lock_timeout;
+ Device_Flags flags;
+ char termChar;
+};
+typedef struct Device_ReadParms Device_ReadParms;
+
+struct Device_ReadResp {
+ Device_ErrorCode error;
+ long reason;
+ struct {
+ u_int data_len;
+ char *data_val;
+ } data;
+};
+typedef struct Device_ReadResp Device_ReadResp;
+
+struct Device_ReadStbResp {
+ Device_ErrorCode error;
+ u_char stb;
+};
+typedef struct Device_ReadStbResp Device_ReadStbResp;
+
+struct Device_GenericParms {
+ Device_Link lid;
+ Device_Flags flags;
+ u_long lock_timeout;
+ u_long io_timeout;
+};
+typedef struct Device_GenericParms Device_GenericParms;
+
+struct Device_RemoteFunc {
+ u_long hostAddr;
+ u_long hostPort;
+ u_long progNum;
+ u_long progVers;
+ Device_AddrFamily progFamily;
+};
+typedef struct Device_RemoteFunc Device_RemoteFunc;
+
+struct Device_EnableSrqParms {
+ Device_Link lid;
+ bool_t enable;
+ struct {
+ u_int handle_len;
+ char *handle_val;
+ } handle;
+};
+typedef struct Device_EnableSrqParms Device_EnableSrqParms;
+
+struct Device_LockParms {
+ Device_Link lid;
+ Device_Flags flags;
+ u_long lock_timeout;
+};
+typedef struct Device_LockParms Device_LockParms;
+
+struct Device_DocmdParms {
+ Device_Link lid;
+ Device_Flags flags;
+ u_long io_timeout;
+ u_long lock_timeout;
+ long cmd;
+ bool_t network_order;
+ long datasize;
+ struct {
+ u_int data_in_len;
+ char *data_in_val;
+ } data_in;
+};
+typedef struct Device_DocmdParms Device_DocmdParms;
+
+struct Device_DocmdResp {
+ Device_ErrorCode error;
+ struct {
+ u_int data_out_len;
+ char *data_out_val;
+ } data_out;
+};
+typedef struct Device_DocmdResp Device_DocmdResp;
+
+struct Device_SrqParms {
+ struct {
+ u_int handle_len;
+ char *handle_val;
+ } handle;
+};
+typedef struct Device_SrqParms Device_SrqParms;
+
+#define DEVICE_ASYNC 0x0607B0
+#define DEVICE_ASYNC_VERSION 1
+
+#if defined(__STDC__) || defined(__cplusplus)
+#define device_abort 1
+extern Device_Error * device_abort_1(Device_Link *, CLIENT *);
+extern Device_Error * device_abort_1_svc(Device_Link *, struct svc_req *);
+extern int device_async_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
+
+#else /* K&R C */
+#define device_abort 1
+extern Device_Error * device_abort_1();
+extern Device_Error * device_abort_1_svc();
+extern int device_async_1_freeresult ();
+#endif /* K&R C */
+
+#define DEVICE_CORE 0x0607AF
+#define DEVICE_CORE_VERSION 1
+
+#if defined(__STDC__) || defined(__cplusplus)
+#define create_link 10
+extern Create_LinkResp * create_link_1(Create_LinkParms *, CLIENT *);
+extern Create_LinkResp * create_link_1_svc(Create_LinkParms *, struct svc_req *);
+#define device_write 11
+extern Device_WriteResp * device_write_1(Device_WriteParms *, CLIENT *);
+extern Device_WriteResp * device_write_1_svc(Device_WriteParms *, struct svc_req *);
+#define device_read 12
+extern Device_ReadResp * device_read_1(Device_ReadParms *, CLIENT *);
+extern Device_ReadResp * device_read_1_svc(Device_ReadParms *, struct svc_req *);
+#define device_readstb 13
+extern Device_ReadStbResp * device_readstb_1(Device_GenericParms *, CLIENT *);
+extern Device_ReadStbResp * device_readstb_1_svc(Device_GenericParms *, struct svc_req *);
+#define device_trigger 14
+extern Device_Error * device_trigger_1(Device_GenericParms *, CLIENT *);
+extern Device_Error * device_trigger_1_svc(Device_GenericParms *, struct svc_req *);
+#define device_clear 15
+extern Device_Error * device_clear_1(Device_GenericParms *, CLIENT *);
+extern Device_Error * device_clear_1_svc(Device_GenericParms *, struct svc_req *);
+#define device_remote 16
+extern Device_Error * device_remote_1(Device_GenericParms *, CLIENT *);
+extern Device_Error * device_remote_1_svc(Device_GenericParms *, struct svc_req *);
+#define device_local 17
+extern Device_Error * device_local_1(Device_GenericParms *, CLIENT *);
+extern Device_Error * device_local_1_svc(Device_GenericParms *, struct svc_req *);
+#define device_lock 18
+extern Device_Error * device_lock_1(Device_LockParms *, CLIENT *);
+extern Device_Error * device_lock_1_svc(Device_LockParms *, struct svc_req *);
+#define device_unlock 19
+extern Device_Error * device_unlock_1(Device_Link *, CLIENT *);
+extern Device_Error * device_unlock_1_svc(Device_Link *, struct svc_req *);
+#define device_enable_srq 20
+extern Device_Error * device_enable_srq_1(Device_EnableSrqParms *, CLIENT *);
+extern Device_Error * device_enable_srq_1_svc(Device_EnableSrqParms *, struct svc_req *);
+#define device_docmd 22
+extern Device_DocmdResp * device_docmd_1(Device_DocmdParms *, CLIENT *);
+extern Device_DocmdResp * device_docmd_1_svc(Device_DocmdParms *, struct svc_req *);
+#define destroy_link 23
+extern Device_Error * destroy_link_1(Device_Link *, CLIENT *);
+extern Device_Error * destroy_link_1_svc(Device_Link *, struct svc_req *);
+#define create_intr_chan 25
+extern Device_Error * create_intr_chan_1(Device_RemoteFunc *, CLIENT *);
+extern Device_Error * create_intr_chan_1_svc(Device_RemoteFunc *, struct svc_req *);
+#define destroy_intr_chan 26
+extern Device_Error * destroy_intr_chan_1(void *, CLIENT *);
+extern Device_Error * destroy_intr_chan_1_svc(void *, struct svc_req *);
+extern int device_core_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
+
+#else /* K&R C */
+#define create_link 10
+extern Create_LinkResp * create_link_1();
+extern Create_LinkResp * create_link_1_svc();
+#define device_write 11
+extern Device_WriteResp * device_write_1();
+extern Device_WriteResp * device_write_1_svc();
+#define device_read 12
+extern Device_ReadResp * device_read_1();
+extern Device_ReadResp * device_read_1_svc();
+#define device_readstb 13
+extern Device_ReadStbResp * device_readstb_1();
+extern Device_ReadStbResp * device_readstb_1_svc();
+#define device_trigger 14
+extern Device_Error * device_trigger_1();
+extern Device_Error * device_trigger_1_svc();
+#define device_clear 15
+extern Device_Error * device_clear_1();
+extern Device_Error * device_clear_1_svc();
+#define device_remote 16
+extern Device_Error * device_remote_1();
+extern Device_Error * device_remote_1_svc();
+#define device_local 17
+extern Device_Error * device_local_1();
+extern Device_Error * device_local_1_svc();
+#define device_lock 18
+extern Device_Error * device_lock_1();
+extern Device_Error * device_lock_1_svc();
+#define device_unlock 19
+extern Device_Error * device_unlock_1();
+extern Device_Error * device_unlock_1_svc();
+#define device_enable_srq 20
+extern Device_Error * device_enable_srq_1();
+extern Device_Error * device_enable_srq_1_svc();
+#define device_docmd 22
+extern Device_DocmdResp * device_docmd_1();
+extern Device_DocmdResp * device_docmd_1_svc();
+#define destroy_link 23
+extern Device_Error * destroy_link_1();
+extern Device_Error * destroy_link_1_svc();
+#define create_intr_chan 25
+extern Device_Error * create_intr_chan_1();
+extern Device_Error * create_intr_chan_1_svc();
+#define destroy_intr_chan 26
+extern Device_Error * destroy_intr_chan_1();
+extern Device_Error * destroy_intr_chan_1_svc();
+extern int device_core_1_freeresult ();
+#endif /* K&R C */
+
+#define DEVICE_INTR 0x0607B1
+#define DEVICE_INTR_VERSION 1
+
+#if defined(__STDC__) || defined(__cplusplus)
+#define device_intr_srq 30
+extern void * device_intr_srq_1(Device_SrqParms *, CLIENT *);
+extern void * device_intr_srq_1_svc(Device_SrqParms *, struct svc_req *);
+extern int device_intr_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
+
+#else /* K&R C */
+#define device_intr_srq 30
+extern void * device_intr_srq_1();
+extern void * device_intr_srq_1_svc();
+extern int device_intr_1_freeresult ();
+#endif /* K&R C */
+
+/* the xdr functions */
+
+#if defined(__STDC__) || defined(__cplusplus)
+extern bool_t xdr_Device_Link (XDR *, Device_Link*);
+extern bool_t xdr_Device_AddrFamily (XDR *, Device_AddrFamily*);
+extern bool_t xdr_Device_Flags (XDR *, Device_Flags*);
+extern bool_t xdr_Device_ErrorCode (XDR *, Device_ErrorCode*);
+extern bool_t xdr_Device_Error (XDR *, Device_Error*);
+extern bool_t xdr_Create_LinkParms (XDR *, Create_LinkParms*);
+extern bool_t xdr_Create_LinkResp (XDR *, Create_LinkResp*);
+extern bool_t xdr_Device_WriteParms (XDR *, Device_WriteParms*);
+extern bool_t xdr_Device_WriteResp (XDR *, Device_WriteResp*);
+extern bool_t xdr_Device_ReadParms (XDR *, Device_ReadParms*);
+extern bool_t xdr_Device_ReadResp (XDR *, Device_ReadResp*);
+extern bool_t xdr_Device_ReadStbResp (XDR *, Device_ReadStbResp*);
+extern bool_t xdr_Device_GenericParms (XDR *, Device_GenericParms*);
+extern bool_t xdr_Device_RemoteFunc (XDR *, Device_RemoteFunc*);
+extern bool_t xdr_Device_EnableSrqParms (XDR *, Device_EnableSrqParms*);
+extern bool_t xdr_Device_LockParms (XDR *, Device_LockParms*);
+extern bool_t xdr_Device_DocmdParms (XDR *, Device_DocmdParms*);
+extern bool_t xdr_Device_DocmdResp (XDR *, Device_DocmdResp*);
+extern bool_t xdr_Device_SrqParms (XDR *, Device_SrqParms*);
+
+#else /* K&R C */
+extern bool_t xdr_Device_Link ();
+extern bool_t xdr_Device_AddrFamily ();
+extern bool_t xdr_Device_Flags ();
+extern bool_t xdr_Device_ErrorCode ();
+extern bool_t xdr_Device_Error ();
+extern bool_t xdr_Create_LinkParms ();
+extern bool_t xdr_Create_LinkResp ();
+extern bool_t xdr_Device_WriteParms ();
+extern bool_t xdr_Device_WriteResp ();
+extern bool_t xdr_Device_ReadParms ();
+extern bool_t xdr_Device_ReadResp ();
+extern bool_t xdr_Device_ReadStbResp ();
+extern bool_t xdr_Device_GenericParms ();
+extern bool_t xdr_Device_RemoteFunc ();
+extern bool_t xdr_Device_EnableSrqParms ();
+extern bool_t xdr_Device_LockParms ();
+extern bool_t xdr_Device_DocmdParms ();
+extern bool_t xdr_Device_DocmdResp ();
+extern bool_t xdr_Device_SrqParms ();
+
+#endif /* K&R C */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_VXI11_H_RPCGEN */
diff --git a/libvxi11client/vxi11_clnt.c b/libvxi11client/vxi11_clnt.c
new file mode 100644
index 0000000..d8f339a
--- /dev/null
+++ b/libvxi11client/vxi11_clnt.c
@@ -0,0 +1,265 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include <memory.h> /* for memset */
+#include "vxi11.h"
+
+/* Default timeout can be changed using clnt_control() */
+static struct timeval TIMEOUT = { 25, 0 };
+
+Device_Error *
+device_abort_1(Device_Link *argp, CLIENT *clnt)
+{
+ static Device_Error clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_abort,
+ (xdrproc_t) xdr_Device_Link, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Create_LinkResp *
+create_link_1(Create_LinkParms *argp, CLIENT *clnt)
+{
+ static Create_LinkResp clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, create_link,
+ (xdrproc_t) xdr_Create_LinkParms, (caddr_t) argp,
+ (xdrproc_t) xdr_Create_LinkResp, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_WriteResp *
+device_write_1(Device_WriteParms *argp, CLIENT *clnt)
+{
+ static Device_WriteResp clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_write,
+ (xdrproc_t) xdr_Device_WriteParms, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_WriteResp, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_ReadResp *
+device_read_1(Device_ReadParms *argp, CLIENT *clnt)
+{
+ static Device_ReadResp clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_read,
+ (xdrproc_t) xdr_Device_ReadParms, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_ReadResp, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_ReadStbResp *
+device_readstb_1(Device_GenericParms *argp, CLIENT *clnt)
+{
+ static Device_ReadStbResp clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_readstb,
+ (xdrproc_t) xdr_Device_GenericParms, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_ReadStbResp, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_Error *
+device_trigger_1(Device_GenericParms *argp, CLIENT *clnt)
+{
+ static Device_Error clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_trigger,
+ (xdrproc_t) xdr_Device_GenericParms, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_Error *
+device_clear_1(Device_GenericParms *argp, CLIENT *clnt)
+{
+ static Device_Error clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_clear,
+ (xdrproc_t) xdr_Device_GenericParms, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_Error *
+device_remote_1(Device_GenericParms *argp, CLIENT *clnt)
+{
+ static Device_Error clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_remote,
+ (xdrproc_t) xdr_Device_GenericParms, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_Error *
+device_local_1(Device_GenericParms *argp, CLIENT *clnt)
+{
+ static Device_Error clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_local,
+ (xdrproc_t) xdr_Device_GenericParms, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_Error *
+device_lock_1(Device_LockParms *argp, CLIENT *clnt)
+{
+ static Device_Error clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_lock,
+ (xdrproc_t) xdr_Device_LockParms, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_Error *
+device_unlock_1(Device_Link *argp, CLIENT *clnt)
+{
+ static Device_Error clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_unlock,
+ (xdrproc_t) xdr_Device_Link, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_Error *
+device_enable_srq_1(Device_EnableSrqParms *argp, CLIENT *clnt)
+{
+ static Device_Error clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_enable_srq,
+ (xdrproc_t) xdr_Device_EnableSrqParms, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_DocmdResp *
+device_docmd_1(Device_DocmdParms *argp, CLIENT *clnt)
+{
+ static Device_DocmdResp clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_docmd,
+ (xdrproc_t) xdr_Device_DocmdParms, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_DocmdResp, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_Error *
+destroy_link_1(Device_Link *argp, CLIENT *clnt)
+{
+ static Device_Error clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, destroy_link,
+ (xdrproc_t) xdr_Device_Link, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_Error *
+create_intr_chan_1(Device_RemoteFunc *argp, CLIENT *clnt)
+{
+ static Device_Error clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, create_intr_chan,
+ (xdrproc_t) xdr_Device_RemoteFunc, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+Device_Error *
+destroy_intr_chan_1(void *argp, CLIENT *clnt)
+{
+ static Device_Error clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, destroy_intr_chan,
+ (xdrproc_t) xdr_void, (caddr_t) argp,
+ (xdrproc_t) xdr_Device_Error, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&clnt_res);
+}
+
+void *
+device_intr_srq_1(Device_SrqParms *argp, CLIENT *clnt)
+{
+ static char clnt_res;
+
+ memset((char *)&clnt_res, 0, sizeof(clnt_res));
+ if (clnt_call (clnt, device_intr_srq,
+ (xdrproc_t) xdr_Device_SrqParms, (caddr_t) argp,
+ (xdrproc_t) xdr_void, (caddr_t) &clnt_res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return ((void *)&clnt_res);
+}
diff --git a/libvxi11client/vxi11_xdr.c b/libvxi11client/vxi11_xdr.c
new file mode 100644
index 0000000..29d9371
--- /dev/null
+++ b/libvxi11client/vxi11_xdr.c
@@ -0,0 +1,462 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "vxi11.h"
+
+bool_t
+xdr_Device_Link (XDR *xdrs, Device_Link *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_long (xdrs, objp))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_AddrFamily (XDR *xdrs, Device_AddrFamily *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_enum (xdrs, (enum_t *) objp))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_Flags (XDR *xdrs, Device_Flags *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_long (xdrs, objp))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_ErrorCode (XDR *xdrs, Device_ErrorCode *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_long (xdrs, objp))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_Error (XDR *xdrs, Device_Error *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_Device_ErrorCode (xdrs, &objp->error))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Create_LinkParms (XDR *xdrs, Create_LinkParms *objp)
+{
+ register int32_t *buf;
+
+
+ if (xdrs->x_op == XDR_ENCODE) {
+ buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_long (xdrs, &objp->clientId))
+ return FALSE;
+ if (!xdr_bool (xdrs, &objp->lockDevice))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+
+ } else {
+ IXDR_PUT_LONG(buf, objp->clientId);
+ IXDR_PUT_BOOL(buf, objp->lockDevice);
+ IXDR_PUT_U_LONG(buf, objp->lock_timeout);
+ }
+ if (!xdr_string (xdrs, &objp->device, ~0))
+ return FALSE;
+ return TRUE;
+ } else if (xdrs->x_op == XDR_DECODE) {
+ buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_long (xdrs, &objp->clientId))
+ return FALSE;
+ if (!xdr_bool (xdrs, &objp->lockDevice))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+
+ } else {
+ objp->clientId = IXDR_GET_LONG(buf);
+ objp->lockDevice = IXDR_GET_BOOL(buf);
+ objp->lock_timeout = IXDR_GET_U_LONG(buf);
+ }
+ if (!xdr_string (xdrs, &objp->device, ~0))
+ return FALSE;
+ return TRUE;
+ }
+
+ if (!xdr_long (xdrs, &objp->clientId))
+ return FALSE;
+ if (!xdr_bool (xdrs, &objp->lockDevice))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+ if (!xdr_string (xdrs, &objp->device, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Create_LinkResp (XDR *xdrs, Create_LinkResp *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_Device_ErrorCode (xdrs, &objp->error))
+ return FALSE;
+ if (!xdr_Device_Link (xdrs, &objp->lid))
+ return FALSE;
+ if (!xdr_u_short (xdrs, &objp->abortPort))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->maxRecvSize))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_WriteParms (XDR *xdrs, Device_WriteParms *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_Device_Link (xdrs, &objp->lid))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->io_timeout))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+ if (!xdr_Device_Flags (xdrs, &objp->flags))
+ return FALSE;
+ if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_WriteResp (XDR *xdrs, Device_WriteResp *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_Device_ErrorCode (xdrs, &objp->error))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->size))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_ReadParms (XDR *xdrs, Device_ReadParms *objp)
+{
+ register int32_t *buf;
+
+
+ if (xdrs->x_op == XDR_ENCODE) {
+ if (!xdr_Device_Link (xdrs, &objp->lid))
+ return FALSE;
+ buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_u_long (xdrs, &objp->requestSize))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->io_timeout))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+
+ } else {
+ IXDR_PUT_U_LONG(buf, objp->requestSize);
+ IXDR_PUT_U_LONG(buf, objp->io_timeout);
+ IXDR_PUT_U_LONG(buf, objp->lock_timeout);
+ }
+ if (!xdr_Device_Flags (xdrs, &objp->flags))
+ return FALSE;
+ if (!xdr_char (xdrs, &objp->termChar))
+ return FALSE;
+ return TRUE;
+ } else if (xdrs->x_op == XDR_DECODE) {
+ if (!xdr_Device_Link (xdrs, &objp->lid))
+ return FALSE;
+ buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_u_long (xdrs, &objp->requestSize))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->io_timeout))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+
+ } else {
+ objp->requestSize = IXDR_GET_U_LONG(buf);
+ objp->io_timeout = IXDR_GET_U_LONG(buf);
+ objp->lock_timeout = IXDR_GET_U_LONG(buf);
+ }
+ if (!xdr_Device_Flags (xdrs, &objp->flags))
+ return FALSE;
+ if (!xdr_char (xdrs, &objp->termChar))
+ return FALSE;
+ return TRUE;
+ }
+
+ if (!xdr_Device_Link (xdrs, &objp->lid))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->requestSize))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->io_timeout))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+ if (!xdr_Device_Flags (xdrs, &objp->flags))
+ return FALSE;
+ if (!xdr_char (xdrs, &objp->termChar))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_ReadResp (XDR *xdrs, Device_ReadResp *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_Device_ErrorCode (xdrs, &objp->error))
+ return FALSE;
+ if (!xdr_long (xdrs, &objp->reason))
+ return FALSE;
+ if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_ReadStbResp (XDR *xdrs, Device_ReadStbResp *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_Device_ErrorCode (xdrs, &objp->error))
+ return FALSE;
+ if (!xdr_u_char (xdrs, &objp->stb))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_GenericParms (XDR *xdrs, Device_GenericParms *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_Device_Link (xdrs, &objp->lid))
+ return FALSE;
+ if (!xdr_Device_Flags (xdrs, &objp->flags))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->io_timeout))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_RemoteFunc (XDR *xdrs, Device_RemoteFunc *objp)
+{
+ register int32_t *buf;
+
+
+ if (xdrs->x_op == XDR_ENCODE) {
+ buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_u_long (xdrs, &objp->hostAddr))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->hostPort))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->progNum))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->progVers))
+ return FALSE;
+
+ } else {
+ IXDR_PUT_U_LONG(buf, objp->hostAddr);
+ IXDR_PUT_U_LONG(buf, objp->hostPort);
+ IXDR_PUT_U_LONG(buf, objp->progNum);
+ IXDR_PUT_U_LONG(buf, objp->progVers);
+ }
+ if (!xdr_Device_AddrFamily (xdrs, &objp->progFamily))
+ return FALSE;
+ return TRUE;
+ } else if (xdrs->x_op == XDR_DECODE) {
+ buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_u_long (xdrs, &objp->hostAddr))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->hostPort))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->progNum))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->progVers))
+ return FALSE;
+
+ } else {
+ objp->hostAddr = IXDR_GET_U_LONG(buf);
+ objp->hostPort = IXDR_GET_U_LONG(buf);
+ objp->progNum = IXDR_GET_U_LONG(buf);
+ objp->progVers = IXDR_GET_U_LONG(buf);
+ }
+ if (!xdr_Device_AddrFamily (xdrs, &objp->progFamily))
+ return FALSE;
+ return TRUE;
+ }
+
+ if (!xdr_u_long (xdrs, &objp->hostAddr))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->hostPort))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->progNum))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->progVers))
+ return FALSE;
+ if (!xdr_Device_AddrFamily (xdrs, &objp->progFamily))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_EnableSrqParms (XDR *xdrs, Device_EnableSrqParms *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_Device_Link (xdrs, &objp->lid))
+ return FALSE;
+ if (!xdr_bool (xdrs, &objp->enable))
+ return FALSE;
+ if (!xdr_bytes (xdrs, (char **)&objp->handle.handle_val, (u_int *) &objp->handle.handle_len, 40))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_LockParms (XDR *xdrs, Device_LockParms *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_Device_Link (xdrs, &objp->lid))
+ return FALSE;
+ if (!xdr_Device_Flags (xdrs, &objp->flags))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_DocmdParms (XDR *xdrs, Device_DocmdParms *objp)
+{
+ register int32_t *buf;
+
+
+ if (xdrs->x_op == XDR_ENCODE) {
+ if (!xdr_Device_Link (xdrs, &objp->lid))
+ return FALSE;
+ if (!xdr_Device_Flags (xdrs, &objp->flags))
+ return FALSE;
+ buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_u_long (xdrs, &objp->io_timeout))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+ if (!xdr_long (xdrs, &objp->cmd))
+ return FALSE;
+ if (!xdr_bool (xdrs, &objp->network_order))
+ return FALSE;
+ if (!xdr_long (xdrs, &objp->datasize))
+ return FALSE;
+
+ } else {
+ IXDR_PUT_U_LONG(buf, objp->io_timeout);
+ IXDR_PUT_U_LONG(buf, objp->lock_timeout);
+ IXDR_PUT_LONG(buf, objp->cmd);
+ IXDR_PUT_BOOL(buf, objp->network_order);
+ IXDR_PUT_LONG(buf, objp->datasize);
+ }
+ if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0))
+ return FALSE;
+ return TRUE;
+ } else if (xdrs->x_op == XDR_DECODE) {
+ if (!xdr_Device_Link (xdrs, &objp->lid))
+ return FALSE;
+ if (!xdr_Device_Flags (xdrs, &objp->flags))
+ return FALSE;
+ buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_u_long (xdrs, &objp->io_timeout))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+ if (!xdr_long (xdrs, &objp->cmd))
+ return FALSE;
+ if (!xdr_bool (xdrs, &objp->network_order))
+ return FALSE;
+ if (!xdr_long (xdrs, &objp->datasize))
+ return FALSE;
+
+ } else {
+ objp->io_timeout = IXDR_GET_U_LONG(buf);
+ objp->lock_timeout = IXDR_GET_U_LONG(buf);
+ objp->cmd = IXDR_GET_LONG(buf);
+ objp->network_order = IXDR_GET_BOOL(buf);
+ objp->datasize = IXDR_GET_LONG(buf);
+ }
+ if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0))
+ return FALSE;
+ return TRUE;
+ }
+
+ if (!xdr_Device_Link (xdrs, &objp->lid))
+ return FALSE;
+ if (!xdr_Device_Flags (xdrs, &objp->flags))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->io_timeout))
+ return FALSE;
+ if (!xdr_u_long (xdrs, &objp->lock_timeout))
+ return FALSE;
+ if (!xdr_long (xdrs, &objp->cmd))
+ return FALSE;
+ if (!xdr_bool (xdrs, &objp->network_order))
+ return FALSE;
+ if (!xdr_long (xdrs, &objp->datasize))
+ return FALSE;
+ if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_DocmdResp (XDR *xdrs, Device_DocmdResp *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_Device_ErrorCode (xdrs, &objp->error))
+ return FALSE;
+ if (!xdr_bytes (xdrs, (char **)&objp->data_out.data_out_val, (u_int *) &objp->data_out.data_out_len, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_Device_SrqParms (XDR *xdrs, Device_SrqParms *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_bytes (xdrs, (char **)&objp->handle.handle_val, (u_int *) &objp->handle.handle_len, ~0))
+ return FALSE;
+ return TRUE;
+}