#include "libserialport.h"
-struct sp_port_data {
+struct port_data {
#ifdef _WIN32
DCB dcb;
#else
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#define NUM_STD_BAUDRATES ARRAY_SIZE(std_baudrates)
-/* Helper functions for configuring ports. */
-static int get_config(struct sp_port *port, struct sp_port_data *data, struct sp_port_config *config);
-static int set_config(struct sp_port *port, struct sp_port_data *data, struct sp_port_config *config);
+/* Helper functions. */
+static int validate_port(struct sp_port *port);
+static struct sp_port **list_append(struct sp_port **list, const char *portname);
+static int get_config(struct sp_port *port, struct port_data *data, struct sp_port_config *config);
+static int set_config(struct sp_port *port, struct port_data *data, struct sp_port_config *config);
int sp_get_port_by_name(const char *portname, struct sp_port **port_ptr)
{
free(port);
}
-static struct sp_port **sp_list_append(struct sp_port **list, const char *portname)
+static struct sp_port **list_append(struct sp_port **list, const char *portname)
{
void *tmp;
unsigned int count;
#else
strcpy(name, data);
#endif
- if (type == REG_SZ && !(list = sp_list_append(list, name)))
+ if (type == REG_SZ && !(list = list_append(list, name)))
{
ret = SP_ERR_MEM;
goto out;
result = CFStringGetCString(cf_path,
path, PATH_MAX, kCFStringEncodingASCII);
CFRelease(cf_path);
- if (result && !(list = sp_list_append(list, path)))
+ if (result && !(list = list_append(list, path)))
{
ret = SP_ERR_MEM;
IOObjectRelease(port);
if (serial_info.type == PORT_UNKNOWN)
goto skip;
}
- list = sp_list_append(list, name);
+ list = list_append(list, name);
skip:
udev_device_unref(ud_dev);
if (!list)
free(list);
}
-static int sp_validate_port(struct sp_port *port)
+static int validate_port(struct sp_port *port)
{
if (port == NULL)
return 0;
return 1;
}
-#define CHECK_PORT() do { if (!sp_validate_port(port)) return SP_ERR_ARG; } while (0)
+#define CHECK_PORT() do { if (!validate_port(port)) return SP_ERR_ARG; } while (0)
int sp_open(struct sp_port *port, int flags)
{
return SP_ERR_FAIL;
#else
int flags_local = 0;
- struct sp_port_data data;
+ struct port_data data;
struct sp_port_config config;
int ret;
#endif
}
-static int get_config(struct sp_port *port, struct sp_port_data *data, struct sp_port_config *config)
+static int get_config(struct sp_port *port, struct port_data *data, struct sp_port_config *config)
{
unsigned int i;
return SP_OK;
}
-static int set_config(struct sp_port *port, struct sp_port_data *data, struct sp_port_config *config)
+static int set_config(struct sp_port *port, struct port_data *data, struct sp_port_config *config)
{
unsigned int i;
int sp_set_config(struct sp_port *port, struct sp_port_config *config)
{
- struct sp_port_data data;
+ struct port_data data;
struct sp_port_config prev_config;
TRY(get_config(port, &data, &prev_config));
}
#define CREATE_SETTER(x) int sp_set_##x(struct sp_port *port, int x) { \
- struct sp_port_data data; \
+ struct port_data data; \
struct sp_port_config config; \
TRY(get_config(port, &data, &config)); \
config.x = x; \
int sp_set_flowcontrol(struct sp_port *port, int flowcontrol)
{
- struct sp_port_data data;
+ struct port_data data;
struct sp_port_config config;
TRY(get_config(port, &data, &config));