#ifdef _WIN32
#include <windows.h>
#include <tchar.h>
-#include <stdio.h>
#else
#include <limits.h>
#include <termios.h>
/* Debug output macros. */
#define DEBUG(fmt, ...) do { if (sp_debug_handler) sp_debug_handler(fmt ".\n", ##__VA_ARGS__); } while (0)
-#define DEBUG_ERROR(err, msg) DEBUG("%s returning " #err ": " msg, __func__)
-#define DEBUG_FAIL(msg) do { \
+#define DEBUG_ERROR(err, fmt, ...) DEBUG("%s returning " #err ": " fmt, __func__, ##__VA_ARGS__)
+#define DEBUG_FAIL(fmt, ...) do { \
char *errmsg = sp_last_error_message(); \
- DEBUG("%s returning SP_ERR_FAIL: " msg ": %s", __func__, errmsg); \
+ DEBUG("%s returning SP_ERR_FAIL: "fmt": %s", __func__,##__VA_ARGS__,errmsg); \
sp_free_error_message(errmsg); \
} while (0);
#define RETURN() do { DEBUG("%s returning", __func__); return; } while(0)
} \
} while (0)
#define RETURN_OK() RETURN_CODE(SP_OK);
-#define RETURN_ERROR(err, msg) do { DEBUG_ERROR(err, msg); return err; } while (0)
-#define RETURN_FAIL(msg) do { DEBUG_FAIL(msg); return SP_ERR_FAIL; } while (0)
+#define RETURN_ERROR(err, ...) do { DEBUG_ERROR(err, __VA_ARGS__); return err; } while (0)
+#define RETURN_FAIL(...) do { DEBUG_FAIL(__VA_ARGS__); return SP_ERR_FAIL; } while (0)
#define RETURN_VALUE(fmt, x) do { \
typeof(x) _x = x; \
DEBUG("%s returning " fmt, __func__, _x); \
#define TRY(x) do { int ret = x; if (ret != SP_OK) RETURN_CODEVAL(ret); } while (0)
/* Helper functions. */
-static struct sp_port **list_append(struct sp_port **list, const char *portname);
static enum sp_return get_config(struct sp_port *port, struct port_data *data,
struct sp_port_config *config);
static enum sp_return set_config(struct sp_port *port, struct port_data *data,
data_len = data_size / sizeof(TCHAR);
data[data_len] = '\0';
#ifdef UNICODE
- name_len = WideCharToMultiByte(CP_ACP, 0, data, -1, NULL, 0, NULL, NULL)
+ name_len = WideCharToMultiByte(CP_ACP, 0, data, -1, NULL, 0, NULL, NULL);
#else
name_len = data_len + 1;
#endif
COMSTAT status;
/* Prefix port name with '\\.\' to work with ports above COM9. */
- if (!(escaped_port_name = malloc(strlen(port->name + 5))))
+ if (!(escaped_port_name = malloc(strlen(port->name) + 5)))
RETURN_ERROR(SP_ERR_MEM, "Escaped port name malloc failed");
sprintf(escaped_port_name, "\\\\.\\%s", port->name);
}
va_end(args);
}
+
+int sp_get_major_package_version(void)
+{
+ return SP_PACKAGE_VERSION_MAJOR;
+}
+
+int sp_get_minor_package_version(void)
+{
+ return SP_PACKAGE_VERSION_MINOR;
+}
+
+int sp_get_micro_package_version(void)
+{
+ return SP_PACKAGE_VERSION_MICRO;
+}
+
+const char *sp_get_package_version_string(void)
+{
+ return SP_PACKAGE_VERSION_STRING;
+}
+
+int sp_get_current_lib_version(void)
+{
+ return SP_LIB_VERSION_CURRENT;
+}
+
+int sp_get_revision_lib_version(void)
+{
+ return SP_LIB_VERSION_REVISION;
+}
+
+int sp_get_age_lib_version(void)
+{
+ return SP_LIB_VERSION_AGE;
+}
+
+const char *sp_get_lib_version_string(void)
+{
+ return SP_LIB_VERSION_STRING;
+}
+
+/** @} */