vxi11 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3bc860034b8caa8482d52f3ffb2a56b8c664e56
4
- data.tar.gz: 5e4a1ccb9593b13d24493ca67e73de274d8e6847
3
+ metadata.gz: daa95fbd4479a8446ae30a103293b9817b4746db
4
+ data.tar.gz: 3bee939b3df8209081fa19f31669af1a88fd6ea1
5
5
  SHA512:
6
- metadata.gz: c64e49fb613f43e5c5bf56443eb4da0eec218d3c95460d0e1066e1b8f572076ec776eaae306241a071adf92da0082dfe91c9154a0ebf456f13b6120afb44f0be
7
- data.tar.gz: 95927ab88465a16ac8ea802e37c50a1f54574191bbbdc49af1600645d8bafdc1eb131e9f1cb8fdd90f094e872c1d7ca43c6f0f322e36859c20af987cfd08eb18
6
+ metadata.gz: d97dc54aae9ae3ddd8c890fdb6223e50b98b3f85008c8c9673b27f553efe9b86623d780cef0b1bd3286bc361b7e8c70c5d71115e4b244edc59431a19beaa1a94
7
+ data.tar.gz: ee7b9036e4dd4899b71870b03be1747192e26baee7e905704db45614651fe484af2ae1b5a5f5d6387abf4235293bd06eaaa311f84f96ccce23a6b52785811135
@@ -1,4 +1,4 @@
1
- require 'mkmf-rice'
1
+ require 'mkmf'
2
2
 
3
3
  ENV['ARCHFLAGS']= "-Wno-error=unused-command-line-argument-hard-error-in-future"
4
4
 
@@ -0,0 +1,183 @@
1
+ #include <ruby.h>
2
+ #include "vxi11_user.h"
3
+ #include "clnt_find_services.h"
4
+ #include <rpc/pmap_clnt.h>
5
+ #include <arpa/inet.h>
6
+
7
+
8
+ void Init_vxi11();
9
+ VALUE rb_vxi11_connect(VALUE name,VALUE ip);
10
+ VALUE rb_vxi11_send_and_receive(int argc, VALUE *argv, VALUE self);
11
+ VALUE rb_vxi11_find_devices();
12
+
13
+ static VALUE c_vxi11;
14
+
15
+ #define BUFFER_SIZE 1000000
16
+
17
+ static CLINK _clink;
18
+ VALUE found_devs;
19
+ int connected = 0;
20
+
21
+ bool_t who_responded(struct sockaddr_in *addr);
22
+ /*
23
+ class VXI11
24
+ {
25
+ public:
26
+ VXI11(std::string ip="");
27
+ void connect(std::string ip);
28
+ void send(std::string cmd);
29
+ std::string receive(std::string cmd,int timeout);
30
+ std::string send_and_receive(std::string cmd, int timeout=1000);
31
+ Hash find_devices();
32
+ static int who_responded_s(struct sockaddr_in *addr);
33
+
34
+ private:
35
+ bool_t who_responded(struct sockaddr_in *addr);
36
+ CLINK _clink;
37
+ class Ports {
38
+ public:
39
+ Ports(int tcp = 0, int udp = 0) : tcp_port(tcp), udp_port(udp) {}
40
+ int tcp_port;
41
+ int udp_port;
42
+ };
43
+
44
+ typedef std::map<std::string, Ports> AddrMap;
45
+ AddrMap gfFoundDevs;
46
+ };
47
+
48
+ int VXI11::who_responded_s( struct sockaddr_in *addr) {
49
+ VXI11 * mySelf = (VXI11*) pt2Object;
50
+ return mySelf->who_responded(addr);
51
+ }
52
+
53
+ VXI11::VXI11(std::string ip)
54
+ {
55
+ if (ip!="") {
56
+ connect(ip);
57
+ }
58
+ }
59
+ */
60
+ VALUE rb_vxi11_find_devices() {
61
+ if (!connected) {
62
+ rb_raise(rb_eException, "No connected");
63
+ }
64
+ enum clnt_stat clnt_stat;
65
+ const size_t MAXSIZE = 100;
66
+ //char rcv[MAXSIZE];
67
+ struct timeval t;
68
+ t.tv_sec = 1;
69
+ t.tv_usec = 0;
70
+
71
+ found_devs = rb_ary_new();
72
+ // Why 6 for the protocol for the VXI-11 devices? Not sure, but the devices
73
+ // will otherwise not respond.
74
+ clnt_stat = clnt_find_services(DEVICE_CORE, DEVICE_CORE_VERSION, 6, &t, who_responded);
75
+
76
+ return found_devs;
77
+ }
78
+
79
+ bool_t who_responded(struct sockaddr_in *addr)
80
+ {
81
+ VALUE h = rb_hash_new();
82
+ char str[INET_ADDRSTRLEN];
83
+ const char* an_addr = inet_ntop(AF_INET, &(addr->sin_addr), str, INET_ADDRSTRLEN);
84
+
85
+ char * buf = (char*) malloc(BUFFER_SIZE);
86
+ int found = vxi11_send_and_receive(&_clink, "*IDN?", buf, BUFFER_SIZE, 1000);
87
+ if (found > 0) buf[found] = '\0';
88
+
89
+ rb_hash_aset(h, rb_str_new2(an_addr), rb_str_new2(buf));
90
+
91
+ rb_ary_push(found_devs,h);
92
+ free(buf);
93
+
94
+ return 0;
95
+ }
96
+
97
+ VALUE rb_vxi11_send_and_receive(int argc, VALUE *argv, VALUE self)
98
+ {
99
+ if (argc < 1 || argc > 2) {
100
+ rb_raise(rb_eArgError, "wrong number of arguments");
101
+ }
102
+ if (!connected) {
103
+ rb_raise(rb_eException, "No connected");
104
+ }
105
+
106
+ VALUE timeout;
107
+
108
+ if (argc == 1) {
109
+ timeout = INT2FIX(1000);
110
+ } else {
111
+ timeout = argv[1];
112
+ }
113
+ char * buf = (char*) malloc(BUFFER_SIZE);
114
+ int found = vxi11_send_and_receive(&_clink, StringValueCStr(argv[0]), buf, BUFFER_SIZE, NUM2INT(timeout));
115
+ if (found > 0) buf[found] = '\0';
116
+ VALUE str = rb_str_new2(buf);
117
+ free(buf);
118
+ return str;
119
+ }
120
+
121
+ VALUE rb_vxi11_receive(int argc, VALUE *argv, VALUE self)
122
+ {
123
+ if (argc > 1 ) {
124
+ rb_raise(rb_eArgError, "wrong number of arguments");
125
+ }
126
+ if (!connected) {
127
+ rb_raise(rb_eException, "No connected");
128
+ }
129
+
130
+ VALUE timeout;
131
+
132
+ if (argc == 0) {
133
+ timeout = INT2FIX(1000);
134
+ } else {
135
+ timeout = argv[0];
136
+ }
137
+ char * buf = (char*) malloc(BUFFER_SIZE);
138
+ int found = vxi11_receive_timeout(&_clink, buf, BUFFER_SIZE, NUM2INT(timeout));
139
+ if (found > 0) buf[found] = '\0';
140
+ VALUE str = rb_str_new2(buf);
141
+ free(buf);
142
+ return str;
143
+ }
144
+
145
+ VALUE rb_vxi11_init(int argc, VALUE *argv, VALUE self) {
146
+ if (argc > 1) {
147
+ rb_raise(rb_eArgError, "wrong number of arguments");
148
+ }
149
+
150
+ if (argc == 1){
151
+ rb_vxi11_connect(self,argv[0]);
152
+ }
153
+
154
+ return self;
155
+ }
156
+
157
+ VALUE rb_vxi11_send(VALUE name, VALUE cmd)
158
+ {
159
+ if (!connected) {
160
+ rb_raise(rb_eException, "No connected");
161
+ }
162
+ vxi11_send(&_clink, StringValueCStr(cmd));
163
+ return Qnil;
164
+ }
165
+
166
+
167
+ VALUE rb_vxi11_connect(VALUE name,VALUE ip)
168
+ {
169
+ vxi11_open(StringValueCStr(ip), &_clink);
170
+ connected = 1;
171
+ return Qnil;
172
+ }
173
+
174
+ void Init_vxi11()
175
+ {
176
+ c_vxi11 = rb_define_class("VXI11",rb_cObject);
177
+ rb_define_method(c_vxi11,"connect", rb_vxi11_connect,1);
178
+ rb_define_method(c_vxi11,"send_and_receive", rb_vxi11_send_and_receive,-1);
179
+ rb_define_method(c_vxi11,"receive", rb_vxi11_receive,-1);
180
+ rb_define_method(c_vxi11,"send", rb_vxi11_send,1);
181
+ rb_define_method(c_vxi11,"find_devices", rb_vxi11_find_devices,0);
182
+ rb_define_method(c_vxi11,"initialize", rb_vxi11_init,-1);
183
+ }
@@ -1,234 +1,5 @@
1
- /*
2
- * Please do not edit this file.
3
- * It was generated using rpcgen.
4
- */
5
-
6
- #include "vxi11.h"
7
- #include <string.h>
8
- #undef clnt_call
9
- #define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \
10
- ((*(rh)->cl_ops->cl_call)(rh, proc, (xdrproc_t)xargs, argsp, (xdrproc_t)xres, resp, secs))
11
-
12
- /* Default timeout can be changed using clnt_control() */
13
- static struct timeval TIMEOUT = { 25, 0 };
14
-
15
- Device_Error *
16
- device_abort_1(argp, clnt)
17
- Device_Link *argp;
18
- CLIENT *clnt;
19
- {
20
- static Device_Error clnt_res;
21
-
22
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
23
- if (clnt_call(clnt, device_abort, xdr_Device_Link, argp, xdr_Device_Error, &clnt_res, TIMEOUT) != RPC_SUCCESS)
24
- return (NULL);
25
- return (&clnt_res);
26
- }
27
-
28
- Create_LinkResp *
29
- create_link_1(argp, clnt)
30
- Create_LinkParms *argp;
31
- CLIENT *clnt;
32
- {
33
- static Create_LinkResp clnt_res;
34
-
35
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
36
- if (clnt_call(clnt, create_link, xdr_Create_LinkParms, argp, xdr_Create_LinkResp, &clnt_res, TIMEOUT) != RPC_SUCCESS)
37
- return (NULL);
38
- return (&clnt_res);
39
- }
40
-
41
- Device_WriteResp *
42
- device_write_1(argp, clnt)
43
- Device_WriteParms *argp;
44
- CLIENT *clnt;
45
- {
46
- static Device_WriteResp clnt_res;
47
-
48
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
49
- if (clnt_call(clnt, device_write, xdr_Device_WriteParms, argp, xdr_Device_WriteResp, &clnt_res, TIMEOUT) != RPC_SUCCESS)
50
- return (NULL);
51
- return (&clnt_res);
52
- }
53
-
54
- Device_ReadResp *
55
- device_read_1(argp, clnt)
56
- Device_ReadParms *argp;
57
- CLIENT *clnt;
58
- {
59
- static Device_ReadResp clnt_res;
60
-
61
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
62
- if (clnt_call(clnt, device_read, xdr_Device_ReadParms, argp, xdr_Device_ReadResp, &clnt_res, TIMEOUT) != RPC_SUCCESS)
63
- return (NULL);
64
- return (&clnt_res);
65
- }
66
-
67
- Device_ReadStbResp *
68
- device_readstb_1(argp, clnt)
69
- Device_GenericParms *argp;
70
- CLIENT *clnt;
71
- {
72
- static Device_ReadStbResp clnt_res;
73
-
74
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
75
- if (clnt_call(clnt, device_readstb, xdr_Device_GenericParms, argp, xdr_Device_ReadStbResp, &clnt_res, TIMEOUT) != RPC_SUCCESS)
76
- return (NULL);
77
- return (&clnt_res);
78
- }
79
-
80
- Device_Error *
81
- device_trigger_1(argp, clnt)
82
- Device_GenericParms *argp;
83
- CLIENT *clnt;
84
- {
85
- static Device_Error clnt_res;
86
-
87
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
88
- if (clnt_call(clnt, device_trigger, xdr_Device_GenericParms, argp, xdr_Device_Error, &clnt_res, TIMEOUT) != RPC_SUCCESS)
89
- return (NULL);
90
- return (&clnt_res);
91
- }
92
-
93
- Device_Error *
94
- device_clear_1(argp, clnt)
95
- Device_GenericParms *argp;
96
- CLIENT *clnt;
97
- {
98
- static Device_Error clnt_res;
99
-
100
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
101
- if (clnt_call(clnt, device_clear, xdr_Device_GenericParms, argp, xdr_Device_Error, &clnt_res, TIMEOUT) != RPC_SUCCESS)
102
- return (NULL);
103
- return (&clnt_res);
104
- }
105
-
106
- Device_Error *
107
- device_remote_1(argp, clnt)
108
- Device_GenericParms *argp;
109
- CLIENT *clnt;
110
- {
111
- static Device_Error clnt_res;
112
-
113
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
114
- if (clnt_call(clnt, device_remote, xdr_Device_GenericParms, argp, xdr_Device_Error, &clnt_res, TIMEOUT) != RPC_SUCCESS)
115
- return (NULL);
116
- return (&clnt_res);
117
- }
118
-
119
- Device_Error *
120
- device_local_1(argp, clnt)
121
- Device_GenericParms *argp;
122
- CLIENT *clnt;
123
- {
124
- static Device_Error clnt_res;
125
-
126
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
127
- if (clnt_call(clnt, device_local, xdr_Device_GenericParms, argp, xdr_Device_Error, &clnt_res, TIMEOUT) != RPC_SUCCESS)
128
- return (NULL);
129
- return (&clnt_res);
130
- }
131
-
132
- Device_Error *
133
- device_lock_1(argp, clnt)
134
- Device_LockParms *argp;
135
- CLIENT *clnt;
136
- {
137
- static Device_Error clnt_res;
138
-
139
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
140
- if (clnt_call(clnt, device_lock, xdr_Device_LockParms, argp, xdr_Device_Error, &clnt_res, TIMEOUT) != RPC_SUCCESS)
141
- return (NULL);
142
- return (&clnt_res);
143
- }
144
-
145
- Device_Error *
146
- device_unlock_1(argp, clnt)
147
- Device_Link *argp;
148
- CLIENT *clnt;
149
- {
150
- static Device_Error clnt_res;
151
-
152
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
153
- if (clnt_call(clnt, device_unlock, xdr_Device_Link, argp, xdr_Device_Error, &clnt_res, TIMEOUT) != RPC_SUCCESS)
154
- return (NULL);
155
- return (&clnt_res);
156
- }
157
-
158
- Device_Error *
159
- device_enable_srq_1(argp, clnt)
160
- Device_EnableSrqParms *argp;
161
- CLIENT *clnt;
162
- {
163
- static Device_Error clnt_res;
164
-
165
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
166
- if (clnt_call(clnt, device_enable_srq, xdr_Device_EnableSrqParms, argp, xdr_Device_Error, &clnt_res, TIMEOUT) != RPC_SUCCESS)
167
- return (NULL);
168
- return (&clnt_res);
169
- }
170
-
171
- Device_DocmdResp *
172
- device_docmd_1(argp, clnt)
173
- Device_DocmdParms *argp;
174
- CLIENT *clnt;
175
- {
176
- static Device_DocmdResp clnt_res;
177
-
178
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
179
- if (clnt_call(clnt, device_docmd, xdr_Device_DocmdParms, argp, xdr_Device_DocmdResp, &clnt_res, TIMEOUT) != RPC_SUCCESS)
180
- return (NULL);
181
- return (&clnt_res);
182
- }
183
-
184
- Device_Error *
185
- destroy_link_1(argp, clnt)
186
- Device_Link *argp;
187
- CLIENT *clnt;
188
- {
189
- static Device_Error clnt_res;
190
-
191
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
192
- if (clnt_call(clnt, destroy_link, xdr_Device_Link, argp, xdr_Device_Error, &clnt_res, TIMEOUT) != RPC_SUCCESS)
193
- return (NULL);
194
- return (&clnt_res);
195
- }
196
-
197
- Device_Error *
198
- create_intr_chan_1(argp, clnt)
199
- Device_RemoteFunc *argp;
200
- CLIENT *clnt;
201
- {
202
- static Device_Error clnt_res;
203
-
204
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
205
- if (clnt_call(clnt, create_intr_chan, xdr_Device_RemoteFunc, argp, xdr_Device_Error, &clnt_res, TIMEOUT) != RPC_SUCCESS)
206
- return (NULL);
207
- return (&clnt_res);
208
- }
209
-
210
- Device_Error *
211
- destroy_intr_chan_1(argp, clnt)
212
- void *argp;
213
- CLIENT *clnt;
214
- {
215
- static Device_Error clnt_res;
216
-
217
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
218
- if (clnt_call(clnt, destroy_intr_chan, xdr_void, argp, xdr_Device_Error, &clnt_res, TIMEOUT) != RPC_SUCCESS)
219
- return (NULL);
220
- return (&clnt_res);
221
- }
222
-
223
- void *
224
- device_intr_srq_1(argp, clnt)
225
- Device_SrqParms *argp;
226
- CLIENT *clnt;
227
- {
228
- static char clnt_res;
229
-
230
- memset((char *)&clnt_res, 0, sizeof(clnt_res));
231
- if (clnt_call(clnt, device_intr_srq, xdr_Device_SrqParms, argp, xdr_void, &clnt_res, TIMEOUT) != RPC_SUCCESS)
232
- return (NULL);
233
- return ((void *)&clnt_res);
234
- }
1
+ #ifdef __APPLE__
2
+ #include "vxi11_clnt_darwin.inc"
3
+ #else
4
+ #include "vxi11_clnt_linux.inc"
5
+ #endif
@@ -123,7 +123,7 @@ int device_no=-1;
123
123
  * must be link number 1. Keep track of how many devices we've
124
124
  * opened so we don't run out of storage space. */
125
125
  else {
126
- ret = vxi11_open_device(ip, &(clink->client), &(clink->link), device);
126
+ ret = vxi11_open_device_client(ip, &(clink->client), &(clink->link), device);
127
127
  strncpy(VXI11_IP_ADDRESS[VXI11_DEVICE_NO],ip,20);
128
128
  VXI11_CLIENT_ADDRESS[VXI11_DEVICE_NO] = clink->client;
129
129
  VXI11_LINK_COUNT[VXI11_DEVICE_NO]=1;
@@ -140,7 +140,7 @@ int device_no=-1;
140
140
  /* Copy the client pointer address. Just establish a new link
141
141
  * (not a new client). Add one to the link count */
142
142
  clink->client = VXI11_CLIENT_ADDRESS[device_no];
143
- ret = vxi11_open_link(ip, &(clink->client), &(clink->link), device);
143
+ ret = vxi11_open_link_client(ip, &(clink->client), &(clink->link), device);
144
144
  // printf("Found an ip address, copying client from VXI11_CLIENT_ADDRESS[%d]\n",device_no);
145
145
  VXI11_LINK_COUNT[device_no]++;
146
146
  // printf("Have just incremented VXI11_LINK_COUNT[%d], it's now %d\n",device_no,VXI11_LINK_COUNT[device_no]);
@@ -156,7 +156,7 @@ int device_no=-1;
156
156
  * (devices). In order to differentiate between them, we need to pass a device
157
157
  * name. This gets used in the vxi11_open_link() fn, as the link_parms.device
158
158
  * value. */
159
- int vxi11_open_device(const char *ip, CLINK *clink) {
159
+ int vxi11_open(const char *ip, CLINK *clink) {
160
160
  char device[6];
161
161
  strncpy(device,"inst0",6);
162
162
  return vxi11_open_device(ip, clink, device);
@@ -188,13 +188,13 @@ int device_no = -1;
188
188
  else { /* Found the IP, there's more than one link to that instrument,
189
189
  * so keep track and just close the link */
190
190
  if (VXI11_LINK_COUNT[device_no] > 1 ) {
191
- ret = vxi11_close_link(ip,clink->client, clink->link);
191
+ ret = vxi11_close_link_client(ip,clink->client, clink->link);
192
192
  VXI11_LINK_COUNT[device_no]--;
193
193
  }
194
194
  /* Found the IP, it's the last link, so close the device (link
195
195
  * AND client) */
196
196
  else {
197
- ret = vxi11_close_device(ip, clink->client, clink->link);
197
+ ret = vxi11_close_device_client(ip, clink->client, clink->link);
198
198
  /* Remove the IP address, so that if we re-open the same device
199
199
  * we do it properly */
200
200
  memset(VXI11_IP_ADDRESS[device_no], 0, 20);
@@ -210,13 +210,13 @@ int device_no = -1;
210
210
  /* A _lot_ of the time we are sending text strings, and can safely rely on
211
211
  * strlen(cmd). */
212
212
  int vxi11_send(CLINK *clink, const char *cmd) {
213
- return vxi11_send(clink, cmd, strlen(cmd));
213
+ return vxi11_send_data(clink, cmd, strlen(cmd));
214
214
  }
215
215
 
216
216
  /* We still need the version of the function where the length is set explicitly
217
217
  * though, for when we are sending fixed length data blocks. */
218
- int vxi11_send(CLINK *clink, const char *cmd, unsigned long len) {
219
- return vxi11_send(clink->client, clink->link, cmd, len);
218
+ int vxi11_send_data(CLINK *clink, const char *cmd, unsigned long len) {
219
+ return vxi11_send_data_client(clink->client, clink->link, cmd, len);
220
220
  }
221
221
 
222
222
 
@@ -225,11 +225,11 @@ int vxi11_send(CLINK *clink, const char *cmd, unsigned long len) {
225
225
 
226
226
  /* Lazy wrapper for when I can't be bothered to specify a read timeout */
227
227
  long vxi11_receive(CLINK *clink, char *buffer, unsigned long len) {
228
- return vxi11_receive(clink, buffer, len, VXI11_READ_TIMEOUT);
228
+ return vxi11_receive_timeout(clink, buffer, len, VXI11_READ_TIMEOUT);
229
229
  }
230
230
 
231
- long vxi11_receive(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout) {
232
- return vxi11_receive(clink->client, clink->link, buffer, len, timeout);
231
+ long vxi11_receive_timeout(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout) {
232
+ return vxi11_receive_timeout_client(clink->client, clink->link, buffer, len, timeout);
233
233
  }
234
234
 
235
235
 
@@ -246,11 +246,11 @@ char *out_buffer;
246
246
  int cmd_len=strlen(cmd);
247
247
  int ret;
248
248
 
249
- out_buffer=new char[cmd_len+10+len];
249
+ out_buffer=(char *)malloc(cmd_len+10+len);
250
250
  sprintf(out_buffer,"%s#8%08lu",cmd,len);
251
251
  memcpy(out_buffer+cmd_len+10,buffer,(unsigned long) len);
252
- ret = vxi11_send(clink, out_buffer, (unsigned long) (cmd_len+10+len));
253
- delete[] out_buffer;
252
+ ret = vxi11_send_data(clink, out_buffer, (unsigned long) (cmd_len+10+len));
253
+ free(out_buffer);
254
254
  return ret;
255
255
  }
256
256
 
@@ -279,8 +279,8 @@ unsigned long returned_bytes;
279
279
  int l;
280
280
  char scan_cmd[20];
281
281
  necessary_buffer_size=len+12;
282
- in_buffer=new char[necessary_buffer_size];
283
- ret=vxi11_receive(clink, in_buffer, necessary_buffer_size, timeout);
282
+ in_buffer=(char *)malloc(necessary_buffer_size);
283
+ ret=vxi11_receive_timeout(clink, in_buffer, necessary_buffer_size, timeout);
284
284
  if (ret < 0) return ret;
285
285
  if (in_buffer[0] != '#') {
286
286
  printf("vxi11_user: data block error: data block does not begin with '#'\n");
@@ -300,7 +300,7 @@ char scan_cmd[20];
300
300
  sprintf(scan_cmd,"#%%1d%%%dlu",ndigits);
301
301
  sscanf(in_buffer,scan_cmd,&ndigits,&returned_bytes);
302
302
  memcpy(buffer, in_buffer+(ndigits+2), returned_bytes);
303
- delete[] in_buffer;
303
+ free(in_buffer);
304
304
  return (long) returned_bytes;
305
305
  }
306
306
  else return 0;
@@ -326,7 +326,7 @@ long bytes_returned;
326
326
  else printf("(Info: VXI11_NULL_WRITE_RESP in vxi11_send_and_receive, resending query)\n");
327
327
  }
328
328
 
329
- bytes_returned = vxi11_receive(clink, buf, buf_len, timeout);
329
+ bytes_returned = vxi11_receive_timeout(clink, buf, buf_len, timeout);
330
330
  if (bytes_returned <= 0) {
331
331
  if (bytes_returned >-VXI11_NULL_READ_RESP) {
332
332
  printf("Error: vxi11_send_and_receive: problem reading reply.\n");
@@ -342,7 +342,7 @@ long bytes_returned;
342
342
 
343
343
  /* FUNCTIONS TO RETURN A LONG INTEGER VALUE SENT AS RESPONSE TO A QUERY *
344
344
  * ==================================================================== */
345
- long vxi11_obtain_long_value(CLINK *clink, const char *cmd, unsigned long timeout) {
345
+ long vxi11_obtain_long_value_timeout(CLINK *clink, const char *cmd, unsigned long timeout) {
346
346
  char buf[50]; /* 50=arbitrary length... more than enough for one number in ascii */
347
347
  memset(buf, 0, 50);
348
348
  if (vxi11_send_and_receive(clink, cmd, buf, 50, timeout) != 0) {
@@ -354,13 +354,13 @@ char buf[50]; /* 50=arbitrary length... more than enough for one number in ascii
354
354
 
355
355
  /* Lazy wrapper function with default read timeout */
356
356
  long vxi11_obtain_long_value(CLINK *clink, const char *cmd) {
357
- return vxi11_obtain_long_value(clink, cmd, VXI11_READ_TIMEOUT);
357
+ return vxi11_obtain_long_value_timeout(clink, cmd, VXI11_READ_TIMEOUT);
358
358
  }
359
359
 
360
360
 
361
361
  /* FUNCTIONS TO RETURN A DOUBLE FLOAT VALUE SENT AS RESPONSE TO A QUERY *
362
362
  * ==================================================================== */
363
- double vxi11_obtain_double_value(CLINK *clink, const char *cmd, unsigned long timeout) {
363
+ double vxi11_obtain_double_value_timeout(CLINK *clink, const char *cmd, unsigned long timeout) {
364
364
  char buf[50]; /* 50=arbitrary length... more than enough for one number in ascii */
365
365
  double val;
366
366
  memset(buf, 0, 50);
@@ -374,7 +374,7 @@ double val;
374
374
 
375
375
  /* Lazy wrapper function with default read timeout */
376
376
  double vxi11_obtain_double_value(CLINK *clink, const char *cmd) {
377
- return vxi11_obtain_double_value(clink, cmd, VXI11_READ_TIMEOUT);
377
+ return vxi11_obtain_double_value_timeout(clink, cmd, VXI11_READ_TIMEOUT);
378
378
  }
379
379
 
380
380
 
@@ -385,7 +385,7 @@ double vxi11_obtain_double_value(CLINK *clink, const char *cmd) {
385
385
 
386
386
  /* OPEN FUNCTIONS *
387
387
  * ============== */
388
- int vxi11_open_device(const char *inputip, CLIENT **client, VXI11_LINK **link, char *device) {
388
+ int vxi11_open_device_client(const char *inputip, CLIENT **client, VXI11_LINK **link, char *device) {
389
389
 
390
390
  #ifdef __APPLE__
391
391
  char ip[strlen(inputip)];
@@ -401,10 +401,10 @@ int vxi11_open_device(const char *inputip, CLIENT **client, VXI11_LINK **link, c
401
401
  return -1;
402
402
  }
403
403
 
404
- return vxi11_open_link(ip, client, link, device);
404
+ return vxi11_open_link_client(ip, client, link, device);
405
405
  }
406
406
 
407
- int vxi11_open_link(const char *inputip, CLIENT **client, VXI11_LINK **link, char *device) {
407
+ int vxi11_open_link_client(const char *inputip, CLIENT **client, VXI11_LINK **link, char *device) {
408
408
 
409
409
  Create_LinkParms link_parms;
410
410
  #ifdef __APPLE__
@@ -440,17 +440,17 @@ Create_LinkParms link_parms;
440
440
 
441
441
  /* CLOSE FUNCTIONS *
442
442
  * =============== */
443
- int vxi11_close_device(const char *ip, CLIENT *client, VXI11_LINK *link) {
443
+ int vxi11_close_device_client(const char *ip, CLIENT *client, VXI11_LINK *link) {
444
444
  int ret;
445
445
 
446
- ret = vxi11_close_link(ip, client, link);
446
+ ret = vxi11_close_link_client(ip, client, link);
447
447
 
448
448
  clnt_destroy(client);
449
449
 
450
450
  return ret;
451
451
  }
452
452
 
453
- int vxi11_close_link(const char *inputip, CLIENT *client, VXI11_LINK *link) {
453
+ int vxi11_close_link_client(const char *inputip, CLIENT *client, VXI11_LINK *link) {
454
454
  Device_Error dev_error;
455
455
  #ifdef __APPLE__
456
456
  char ip[strlen(inputip)];
@@ -480,18 +480,18 @@ Device_Error dev_error;
480
480
 
481
481
  /* A _lot_ of the time we are sending text strings, and can safely rely on
482
482
  * strlen(cmd). */
483
- int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd) {
484
- return vxi11_send(client, link, cmd, strlen(cmd));
483
+ int vxi11_send_client(CLIENT *client, VXI11_LINK *link, const char *cmd) {
484
+ return vxi11_send_data_client(client, link, cmd, strlen(cmd));
485
485
  }
486
486
 
487
487
  /* We still need the version of the function where the length is set explicitly
488
488
  * though, for when we are sending fixed length data blocks. */
489
- int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd, unsigned long len) {
489
+ int vxi11_send_data_client(CLIENT *client, VXI11_LINK *link, const char *cmd, unsigned long len) {
490
490
  Device_WriteParms write_parms;
491
491
  unsigned int bytes_left = len;
492
492
  char *send_cmd;
493
493
 
494
- send_cmd = new char[len];
494
+ send_cmd = (char *)malloc(len);
495
495
  memcpy(send_cmd, cmd, len);
496
496
 
497
497
  write_parms.lid = link->lid;
@@ -530,7 +530,7 @@ char *send_cmd;
530
530
  #else
531
531
  if(device_write_1(&write_parms, &write_resp, client) != RPC_SUCCESS) {
532
532
  #endif
533
- delete[] send_cmd;
533
+ free(send_cmd);
534
534
  return -VXI11_NULL_WRITE_RESP; /* The instrument did not acknowledge the write, just completely
535
535
  dropped it. There was no vxi11 comms error as such, the
536
536
  instrument is just being rude. Usually occurs when the instrument
@@ -542,13 +542,13 @@ char *send_cmd;
542
542
  #endif
543
543
  if (write_resp.error != 0) {
544
544
  printf("vxi11_user: write error: %d\n", (int)write_resp.error);
545
- delete[] send_cmd;
545
+ free(send_cmd);
546
546
  return -(write_resp.error);
547
547
  }
548
548
  bytes_left -= write_resp.size;
549
549
  } while (bytes_left > 0);
550
550
 
551
- delete[] send_cmd;
551
+ free(send_cmd);
552
552
  return 0;
553
553
  }
554
554
 
@@ -559,14 +559,16 @@ char *send_cmd;
559
559
  // It appeared that this function wasn't correctly dealing with more data available than specified in len.
560
560
  // This patch attempts to fix this issue. RDP 2007/8/13
561
561
 
562
- /* wrapper, for default timeout */ long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len) { return vxi11_receive(client, link, buffer, len, VXI11_READ_TIMEOUT);
563
- }
562
+ /* wrapper, for default timeout */
563
+ long vxi11_receive_client(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len) {
564
+ return vxi11_receive_timeout_client(client, link, buffer, len, VXI11_READ_TIMEOUT);
565
+ }
564
566
 
565
567
  #define RCV_END_BIT 0x04 // An end indicator has been read
566
568
  #define RCV_CHR_BIT 0x02 // A termchr is set in flags and a character which matches termChar is transferred
567
569
  #define RCV_REQCNT_BIT 0x01 // requestSize bytes have been transferred. This includes a request size of zero.
568
570
 
569
- long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout) {
571
+ long vxi11_receive_timeout_client(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout) {
570
572
  Device_ReadParms read_parms;
571
573
  Device_ReadResp read_resp;
572
574
  unsigned long curr_pos = 0;
@@ -1,465 +1,5 @@
1
- /*
2
- * Please do not edit this file.
3
- * It was generated using rpcgen.
4
- */
5
-
6
- #include "vxi11.h"
7
-
8
- bool_t
9
- xdr_Device_Link(xdrs, objp)
10
- XDR *xdrs;
11
- Device_Link *objp;
12
- {
13
-
14
- if (!xdr_long(xdrs, objp))
15
- return (FALSE);
16
- return (TRUE);
17
- }
18
-
19
- bool_t
20
- xdr_Device_AddrFamily(xdrs, objp)
21
- XDR *xdrs;
22
- Device_AddrFamily *objp;
23
- {
24
-
25
- if (!xdr_enum(xdrs, (enum_t *)objp))
26
- return (FALSE);
27
- return (TRUE);
28
- }
29
-
30
- bool_t
31
- xdr_Device_Flags(xdrs, objp)
32
- XDR *xdrs;
33
- Device_Flags *objp;
34
- {
35
-
36
- if (!xdr_long(xdrs, objp))
37
- return (FALSE);
38
- return (TRUE);
39
- }
40
-
41
- bool_t
42
- xdr_Device_ErrorCode(xdrs, objp)
43
- XDR *xdrs;
44
- Device_ErrorCode *objp;
45
- {
46
-
47
- if (!xdr_long(xdrs, objp))
48
- return (FALSE);
49
- return (TRUE);
50
- }
51
-
52
- bool_t
53
- xdr_Device_Error(xdrs, objp)
54
- XDR *xdrs;
55
- Device_Error *objp;
56
- {
57
-
58
- if (!xdr_Device_ErrorCode(xdrs, &objp->error))
59
- return (FALSE);
60
- return (TRUE);
61
- }
62
-
63
- bool_t
64
- xdr_Create_LinkParms(xdrs, objp)
65
- XDR *xdrs;
66
- Create_LinkParms *objp;
67
- {
68
- int32_t *buf;
69
-
70
- if (xdrs->x_op == XDR_ENCODE) {
71
- buf = (int32_t *)XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT);
72
- if (buf == NULL) {
73
- if (!xdr_long(xdrs, &objp->clientId))
74
- return (FALSE);
75
- if (!xdr_bool(xdrs, &objp->lockDevice))
76
- return (FALSE);
77
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
78
- return (FALSE);
79
- } else {
80
- IXDR_PUT_LONG(buf, objp->clientId);
81
- IXDR_PUT_BOOL(buf, objp->lockDevice);
82
- IXDR_PUT_U_LONG(buf, objp->lock_timeout);
83
- }
84
- if (!xdr_string(xdrs, &objp->device, ~0))
85
- return (FALSE);
86
- } else if (xdrs->x_op == XDR_DECODE) {
87
- buf = (int32_t *)XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT);
88
- if (buf == NULL) {
89
- if (!xdr_long(xdrs, &objp->clientId))
90
- return (FALSE);
91
- if (!xdr_bool(xdrs, &objp->lockDevice))
92
- return (FALSE);
93
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
94
- return (FALSE);
95
- } else {
96
- objp->clientId = IXDR_GET_LONG(buf);
97
- objp->lockDevice = IXDR_GET_BOOL(buf);
98
- objp->lock_timeout = IXDR_GET_U_LONG(buf);
99
- }
100
- if (!xdr_string(xdrs, &objp->device, ~0))
101
- return (FALSE);
102
- } else {
103
- if (!xdr_long(xdrs, &objp->clientId))
104
- return (FALSE);
105
- if (!xdr_bool(xdrs, &objp->lockDevice))
106
- return (FALSE);
107
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
108
- return (FALSE);
109
- if (!xdr_string(xdrs, &objp->device, ~0))
110
- return (FALSE);
111
- }
112
- return (TRUE);
113
- }
114
-
115
- bool_t
116
- xdr_Create_LinkResp(xdrs, objp)
117
- XDR *xdrs;
118
- Create_LinkResp *objp;
119
- {
120
-
121
- if (!xdr_Device_ErrorCode(xdrs, &objp->error))
122
- return (FALSE);
123
- if (!xdr_Device_Link(xdrs, &objp->lid))
124
- return (FALSE);
125
- if (!xdr_u_short(xdrs, &objp->abortPort))
126
- return (FALSE);
127
- if (!xdr_u_long(xdrs, &objp->maxRecvSize))
128
- return (FALSE);
129
- return (TRUE);
130
- }
131
-
132
- bool_t
133
- xdr_Device_WriteParms(xdrs, objp)
134
- XDR *xdrs;
135
- Device_WriteParms *objp;
136
- {
137
-
138
- if (!xdr_Device_Link(xdrs, &objp->lid))
139
- return (FALSE);
140
- if (!xdr_u_long(xdrs, &objp->io_timeout))
141
- return (FALSE);
142
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
143
- return (FALSE);
144
- if (!xdr_Device_Flags(xdrs, &objp->flags))
145
- return (FALSE);
146
- if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, ~0))
147
- return (FALSE);
148
- return (TRUE);
149
- }
150
-
151
- bool_t
152
- xdr_Device_WriteResp(xdrs, objp)
153
- XDR *xdrs;
154
- Device_WriteResp *objp;
155
- {
156
-
157
- if (!xdr_Device_ErrorCode(xdrs, &objp->error))
158
- return (FALSE);
159
- if (!xdr_u_long(xdrs, &objp->size))
160
- return (FALSE);
161
- return (TRUE);
162
- }
163
-
164
- bool_t
165
- xdr_Device_ReadParms(xdrs, objp)
166
- XDR *xdrs;
167
- Device_ReadParms *objp;
168
- {
169
- int32_t *buf;
170
-
171
- if (xdrs->x_op == XDR_ENCODE) {
172
- if (!xdr_Device_Link(xdrs, &objp->lid))
173
- return (FALSE);
174
- buf = (int32_t *)XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT);
175
- if (buf == NULL) {
176
- if (!xdr_u_long(xdrs, &objp->requestSize))
177
- return (FALSE);
178
- if (!xdr_u_long(xdrs, &objp->io_timeout))
179
- return (FALSE);
180
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
181
- return (FALSE);
182
- } else {
183
- IXDR_PUT_U_LONG(buf, objp->requestSize);
184
- IXDR_PUT_U_LONG(buf, objp->io_timeout);
185
- IXDR_PUT_U_LONG(buf, objp->lock_timeout);
186
- }
187
- if (!xdr_Device_Flags(xdrs, &objp->flags))
188
- return (FALSE);
189
- if (!xdr_char(xdrs, &objp->termChar))
190
- return (FALSE);
191
- } else if (xdrs->x_op == XDR_DECODE) {
192
- if (!xdr_Device_Link(xdrs, &objp->lid))
193
- return (FALSE);
194
- buf = (int32_t *)XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT);
195
- if (buf == NULL) {
196
- if (!xdr_u_long(xdrs, &objp->requestSize))
197
- return (FALSE);
198
- if (!xdr_u_long(xdrs, &objp->io_timeout))
199
- return (FALSE);
200
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
201
- return (FALSE);
202
- } else {
203
- objp->requestSize = IXDR_GET_U_LONG(buf);
204
- objp->io_timeout = IXDR_GET_U_LONG(buf);
205
- objp->lock_timeout = IXDR_GET_U_LONG(buf);
206
- }
207
- if (!xdr_Device_Flags(xdrs, &objp->flags))
208
- return (FALSE);
209
- if (!xdr_char(xdrs, &objp->termChar))
210
- return (FALSE);
211
- } else {
212
- if (!xdr_Device_Link(xdrs, &objp->lid))
213
- return (FALSE);
214
- if (!xdr_u_long(xdrs, &objp->requestSize))
215
- return (FALSE);
216
- if (!xdr_u_long(xdrs, &objp->io_timeout))
217
- return (FALSE);
218
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
219
- return (FALSE);
220
- if (!xdr_Device_Flags(xdrs, &objp->flags))
221
- return (FALSE);
222
- if (!xdr_char(xdrs, &objp->termChar))
223
- return (FALSE);
224
- }
225
- return (TRUE);
226
- }
227
-
228
- bool_t
229
- xdr_Device_ReadResp(xdrs, objp)
230
- XDR *xdrs;
231
- Device_ReadResp *objp;
232
- {
233
-
234
- if (!xdr_Device_ErrorCode(xdrs, &objp->error))
235
- return (FALSE);
236
- if (!xdr_long(xdrs, &objp->reason))
237
- return (FALSE);
238
- if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, ~0))
239
- return (FALSE);
240
- return (TRUE);
241
- }
242
-
243
- bool_t
244
- xdr_Device_ReadStbResp(xdrs, objp)
245
- XDR *xdrs;
246
- Device_ReadStbResp *objp;
247
- {
248
-
249
- if (!xdr_Device_ErrorCode(xdrs, &objp->error))
250
- return (FALSE);
251
- if (!xdr_u_char(xdrs, &objp->stb))
252
- return (FALSE);
253
- return (TRUE);
254
- }
255
-
256
- bool_t
257
- xdr_Device_GenericParms(xdrs, objp)
258
- XDR *xdrs;
259
- Device_GenericParms *objp;
260
- {
261
-
262
- if (!xdr_Device_Link(xdrs, &objp->lid))
263
- return (FALSE);
264
- if (!xdr_Device_Flags(xdrs, &objp->flags))
265
- return (FALSE);
266
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
267
- return (FALSE);
268
- if (!xdr_u_long(xdrs, &objp->io_timeout))
269
- return (FALSE);
270
- return (TRUE);
271
- }
272
-
273
- bool_t
274
- xdr_Device_RemoteFunc(xdrs, objp)
275
- XDR *xdrs;
276
- Device_RemoteFunc *objp;
277
- {
278
- int32_t *buf;
279
-
280
- if (xdrs->x_op == XDR_ENCODE) {
281
- buf = (int32_t *)XDR_INLINE(xdrs, 4 * BYTES_PER_XDR_UNIT);
282
- if (buf == NULL) {
283
- if (!xdr_u_long(xdrs, &objp->hostAddr))
284
- return (FALSE);
285
- if (!xdr_u_long(xdrs, &objp->hostPort))
286
- return (FALSE);
287
- if (!xdr_u_long(xdrs, &objp->progNum))
288
- return (FALSE);
289
- if (!xdr_u_long(xdrs, &objp->progVers))
290
- return (FALSE);
291
- } else {
292
- IXDR_PUT_U_LONG(buf, objp->hostAddr);
293
- IXDR_PUT_U_LONG(buf, objp->hostPort);
294
- IXDR_PUT_U_LONG(buf, objp->progNum);
295
- IXDR_PUT_U_LONG(buf, objp->progVers);
296
- }
297
- if (!xdr_Device_AddrFamily(xdrs, &objp->progFamily))
298
- return (FALSE);
299
- } else if (xdrs->x_op == XDR_DECODE) {
300
- buf = (int32_t *)XDR_INLINE(xdrs, 4 * BYTES_PER_XDR_UNIT);
301
- if (buf == NULL) {
302
- if (!xdr_u_long(xdrs, &objp->hostAddr))
303
- return (FALSE);
304
- if (!xdr_u_long(xdrs, &objp->hostPort))
305
- return (FALSE);
306
- if (!xdr_u_long(xdrs, &objp->progNum))
307
- return (FALSE);
308
- if (!xdr_u_long(xdrs, &objp->progVers))
309
- return (FALSE);
310
- } else {
311
- objp->hostAddr = IXDR_GET_U_LONG(buf);
312
- objp->hostPort = IXDR_GET_U_LONG(buf);
313
- objp->progNum = IXDR_GET_U_LONG(buf);
314
- objp->progVers = IXDR_GET_U_LONG(buf);
315
- }
316
- if (!xdr_Device_AddrFamily(xdrs, &objp->progFamily))
317
- return (FALSE);
318
- } else {
319
- if (!xdr_u_long(xdrs, &objp->hostAddr))
320
- return (FALSE);
321
- if (!xdr_u_long(xdrs, &objp->hostPort))
322
- return (FALSE);
323
- if (!xdr_u_long(xdrs, &objp->progNum))
324
- return (FALSE);
325
- if (!xdr_u_long(xdrs, &objp->progVers))
326
- return (FALSE);
327
- if (!xdr_Device_AddrFamily(xdrs, &objp->progFamily))
328
- return (FALSE);
329
- }
330
- return (TRUE);
331
- }
332
-
333
- bool_t
334
- xdr_Device_EnableSrqParms(xdrs, objp)
335
- XDR *xdrs;
336
- Device_EnableSrqParms *objp;
337
- {
338
-
339
- if (!xdr_Device_Link(xdrs, &objp->lid))
340
- return (FALSE);
341
- if (!xdr_bool(xdrs, &objp->enable))
342
- return (FALSE);
343
- if (!xdr_bytes(xdrs, (char **)&objp->handle.handle_val, (u_int *)&objp->handle.handle_len, 40))
344
- return (FALSE);
345
- return (TRUE);
346
- }
347
-
348
- bool_t
349
- xdr_Device_LockParms(xdrs, objp)
350
- XDR *xdrs;
351
- Device_LockParms *objp;
352
- {
353
-
354
- if (!xdr_Device_Link(xdrs, &objp->lid))
355
- return (FALSE);
356
- if (!xdr_Device_Flags(xdrs, &objp->flags))
357
- return (FALSE);
358
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
359
- return (FALSE);
360
- return (TRUE);
361
- }
362
-
363
- bool_t
364
- xdr_Device_DocmdParms(xdrs, objp)
365
- XDR *xdrs;
366
- Device_DocmdParms *objp;
367
- {
368
- int32_t *buf;
369
-
370
- if (xdrs->x_op == XDR_ENCODE) {
371
- if (!xdr_Device_Link(xdrs, &objp->lid))
372
- return (FALSE);
373
- if (!xdr_Device_Flags(xdrs, &objp->flags))
374
- return (FALSE);
375
- buf = (int32_t *)XDR_INLINE(xdrs, 5 * BYTES_PER_XDR_UNIT);
376
- if (buf == NULL) {
377
- if (!xdr_u_long(xdrs, &objp->io_timeout))
378
- return (FALSE);
379
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
380
- return (FALSE);
381
- if (!xdr_long(xdrs, &objp->cmd))
382
- return (FALSE);
383
- if (!xdr_bool(xdrs, &objp->network_order))
384
- return (FALSE);
385
- if (!xdr_long(xdrs, &objp->datasize))
386
- return (FALSE);
387
- } else {
388
- IXDR_PUT_U_LONG(buf, objp->io_timeout);
389
- IXDR_PUT_U_LONG(buf, objp->lock_timeout);
390
- IXDR_PUT_LONG(buf, objp->cmd);
391
- IXDR_PUT_BOOL(buf, objp->network_order);
392
- IXDR_PUT_LONG(buf, objp->datasize);
393
- }
394
- if (!xdr_bytes(xdrs, (char **)&objp->data_in.data_in_val, (u_int *)&objp->data_in.data_in_len, ~0))
395
- return (FALSE);
396
- } else if (xdrs->x_op == XDR_DECODE) {
397
- if (!xdr_Device_Link(xdrs, &objp->lid))
398
- return (FALSE);
399
- if (!xdr_Device_Flags(xdrs, &objp->flags))
400
- return (FALSE);
401
- buf = (int32_t *)XDR_INLINE(xdrs, 5 * BYTES_PER_XDR_UNIT);
402
- if (buf == NULL) {
403
- if (!xdr_u_long(xdrs, &objp->io_timeout))
404
- return (FALSE);
405
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
406
- return (FALSE);
407
- if (!xdr_long(xdrs, &objp->cmd))
408
- return (FALSE);
409
- if (!xdr_bool(xdrs, &objp->network_order))
410
- return (FALSE);
411
- if (!xdr_long(xdrs, &objp->datasize))
412
- return (FALSE);
413
- } else {
414
- objp->io_timeout = IXDR_GET_U_LONG(buf);
415
- objp->lock_timeout = IXDR_GET_U_LONG(buf);
416
- objp->cmd = IXDR_GET_LONG(buf);
417
- objp->network_order = IXDR_GET_BOOL(buf);
418
- objp->datasize = IXDR_GET_LONG(buf);
419
- }
420
- if (!xdr_bytes(xdrs, (char **)&objp->data_in.data_in_val, (u_int *)&objp->data_in.data_in_len, ~0))
421
- return (FALSE);
422
- } else {
423
- if (!xdr_Device_Link(xdrs, &objp->lid))
424
- return (FALSE);
425
- if (!xdr_Device_Flags(xdrs, &objp->flags))
426
- return (FALSE);
427
- if (!xdr_u_long(xdrs, &objp->io_timeout))
428
- return (FALSE);
429
- if (!xdr_u_long(xdrs, &objp->lock_timeout))
430
- return (FALSE);
431
- if (!xdr_long(xdrs, &objp->cmd))
432
- return (FALSE);
433
- if (!xdr_bool(xdrs, &objp->network_order))
434
- return (FALSE);
435
- if (!xdr_long(xdrs, &objp->datasize))
436
- return (FALSE);
437
- if (!xdr_bytes(xdrs, (char **)&objp->data_in.data_in_val, (u_int *)&objp->data_in.data_in_len, ~0))
438
- return (FALSE);
439
- }
440
- return (TRUE);
441
- }
442
-
443
- bool_t
444
- xdr_Device_DocmdResp(xdrs, objp)
445
- XDR *xdrs;
446
- Device_DocmdResp *objp;
447
- {
448
-
449
- if (!xdr_Device_ErrorCode(xdrs, &objp->error))
450
- return (FALSE);
451
- if (!xdr_bytes(xdrs, (char **)&objp->data_out.data_out_val, (u_int *)&objp->data_out.data_out_len, ~0))
452
- return (FALSE);
453
- return (TRUE);
454
- }
455
-
456
- bool_t
457
- xdr_Device_SrqParms(xdrs, objp)
458
- XDR *xdrs;
459
- Device_SrqParms *objp;
460
- {
461
-
462
- if (!xdr_bytes(xdrs, (char **)&objp->handle.handle_val, (u_int *)&objp->handle.handle_len, ~0))
463
- return (FALSE);
464
- return (TRUE);
465
- }
1
+ #ifdef __APPLE__
2
+ #include "vxi11_xdr_darwin.inc"
3
+ #else
4
+ #include "vxi11_xdr_linux.inc"
5
+ #endif
@@ -1,6 +1,6 @@
1
1
  require "vxi11/vxi11"
2
2
 
3
- module VXI11
3
+ class VXI11
4
4
 
5
5
  VERSION = "0.1.0"
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vxi11
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Kallen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-15 00:00:00.000000000 Z
11
+ date: 2014-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -24,32 +24,19 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rice
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  description:
42
- email:
28
+ email: info@erikkallen.nl
43
29
  executables: []
44
30
  extensions:
45
31
  - ext/vxi11/extconf.rb
46
32
  extra_rdoc_files: []
47
33
  files:
48
34
  - ext/vxi11/clnt_find_services.c
35
+ - ext/vxi11/vxi11.c
49
36
  - ext/vxi11/vxi11_clnt.c
37
+ - ext/vxi11/vxi11_user.c
50
38
  - ext/vxi11/vxi11_xdr.c
51
39
  - ext/vxi11/extconf.rb
52
- - ext/vxi11/vxi11_user.cc
53
40
  - lib/vxi11.rb
54
41
  homepage:
55
42
  licenses: []