diff options
author | daniel <danieruru@gmail.com> | 2013-01-25 22:39:58 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-25 22:39:58 +0900 |
commit | 008d5f4b9f3cad2d5fe350fa525b8a2135b97785 (patch) | |
tree | 567cd9e4b973c48494f94947107cb89cae48f477 /libvxi11client/libvxi11client.c | |
parent | 8e631ffb02708f3f9492fa4031c65fee34c12174 (diff) |
String termination fix try 2
Diffstat (limited to 'libvxi11client/libvxi11client.c')
-rw-r--r-- | libvxi11client/libvxi11client.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c index 66bb020..f504def 100644 --- a/libvxi11client/libvxi11client.c +++ b/libvxi11client/libvxi11client.c @@ -234,7 +234,8 @@ int vxi11_read(VXI11Context* context, char* buffer, unsigned int bufferlen, bool * call docmd with the specified command */ -int vxi11_docmd(VXI11Context* context, unsigned long cmd, bool waitforlock) { +int vxi11_docmd(VXI11Context* context, char* datain, int datainlen, char* dataout, int outbufferlen, int* dataoutlen, + unsigned long cmd, bool waitforlock) { if (context->clnt == NULL) return 0; @@ -242,12 +243,17 @@ int vxi11_docmd(VXI11Context* context, unsigned long cmd, bool waitforlock) { .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; + params.data_in.data_in_len = datainlen; + params.data_in.data_in_val = datain; Device_DocmdResp* resp = device_docmd_1(¶ms, context->clnt); - if (resp != NULL && resp->error == 0) + if (resp != NULL && resp->error == 0) { + if (dataout != NULL) + strncpy(dataout, resp->data_out.data_out_val, + (resp->data_out.data_out_len > outbufferlen ? outbufferlen : resp->data_out.data_out_len)); + *dataoutlen = resp->data_out.data_out_len; return 1; + } else if (resp == NULL) return 0; else |