From 425b461dfe9f330f7bb35061c6cce4c78fbcc5aa Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 18 Jan 2013 02:40:49 +0900 Subject: add a lazy way to call write --- libvxi11client/libvxi11client.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libvxi11client/libvxi11client.c') diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c index 4b17532..a6a5dd2 100644 --- a/libvxi11client/libvxi11client.c +++ b/libvxi11client/libvxi11client.c @@ -171,16 +171,17 @@ int vxi11_readstatusbyte(VXI11Context* context, bool waitforlock) { } /** - * write to the connected device + * write to the connected device. If len is less than 0 the length will be calculated with strlen + * **only safe for standard terminated strings** */ -int vxi11_write(VXI11Context* context, char* data, unsigned int len, bool waitlock, bool end) { +int vxi11_write(VXI11Context* context, char* data, int len, bool waitlock, bool end) { if (context->clnt == NULL) return 0; Device_WriteParms params = { .lid = context->devicelink, .io_timeout = VXI11_DEFAULT_TIMEOUT, .lock_timeout = VXI11_DEFAULT_TIMEOUT, .flags = vxi11_generateflags(waitlock, end, false) }; - params.data.data_len = len; + params.data.data_len = len < 0 ? (strlen(data) + 1) : len; params.data.data_val = data; Device_WriteResp* resp = device_write_1(¶ms, context->clnt); -- cgit