]> sigrok.org Git - libserialport.git/blobdiff - serialport.c
Remove sp_ prefix from private port data structure.
[libserialport.git] / serialport.c
index 7f452db3dbefd5325a8562ab64fb4bc5cc903e9e..eed009ab5f8b50d8195c6771f4209ee36a0ef235 100644 (file)
@@ -46,7 +46,7 @@
 
 #include "libserialport.h"
 
-struct sp_port_data {
+struct port_data {
 #ifdef _WIN32
        DCB dcb;
 #else
@@ -91,9 +91,11 @@ const struct std_baudrate std_baudrates[] = {
 #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)
 {
@@ -156,7 +158,7 @@ void sp_free_port(struct sp_port *port)
        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;
@@ -240,7 +242,7 @@ int sp_list_ports(struct sp_port ***list_ptr)
 #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;
@@ -298,7 +300,7 @@ out_done:
                        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);
@@ -357,7 +359,7 @@ out_done:
                        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)
@@ -395,7 +397,7 @@ void sp_free_port_list(struct sp_port **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;
@@ -409,7 +411,7 @@ static int sp_validate_port(struct sp_port *port)
        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)
 {
@@ -442,7 +444,7 @@ 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;
 
@@ -573,7 +575,7 @@ int sp_read(struct sp_port *port, void *buf, size_t count)
 #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;
 
@@ -724,7 +726,7 @@ static int get_config(struct sp_port *port, struct sp_port_data *data, struct sp
        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;
 
@@ -1005,7 +1007,7 @@ static int set_config(struct sp_port *port, struct sp_port_data *data, struct sp
 
 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));
@@ -1015,7 +1017,7 @@ int sp_set_config(struct sp_port *port, struct sp_port_config *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; \
@@ -1035,7 +1037,7 @@ CREATE_SETTER(xon_xoff)
 
 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));