+ va_list args1, args2;
+ char *buf;
+ int len, ret;
+
+ /* Copy arguments since we need to make two variadic calls. */
+ va_start(args1, format);
+ va_copy(args2, args1);
+
+ /* Get length of buffer required. */
+ len = vsnprintf(NULL, 0, format, args1);
+ va_end(args1);
+
+ /* Allocate buffer and write out command. */
+ buf = g_malloc(len + 1);
+ vsprintf(buf, format, args2);
+ va_end(args2);
+
+ /* Send command. */
+ ret = scpi->send(scpi->priv, buf);
+
+ /* Free command buffer. */
+ g_free(buf);
+
+ return ret;