#include "serialport.h"
-static struct sp_port *sp_port_new(const char *portname)
+struct sp_port *sp_get_port_by_name(const char *portname)
{
struct sp_port *port;
int len;
+ if (!portname)
+ return NULL;
+
if (!(port = malloc(sizeof(struct sp_port))))
return NULL;
if (!(tmp = realloc(list, sizeof(struct sp_port *) * (count + 2))))
goto fail;
list = tmp;
- if (!(list[count] = sp_port_new(portname)))
+ if (!(list[count] = sp_get_port_by_name(portname)))
goto fail;
list[count + 1] = NULL;
return list;
SP_FLOW_SOFTWARE = 2
};
+struct sp_port *sp_get_port_by_name(const char *portname);
struct sp_port **sp_list_ports(void);
void sp_free_port_list(struct sp_port **ports);
int sp_open(struct sp_port *port, int flags);