Add sp_get_port_by_name() function.
This commit is contained in:
parent
5919c9134a
commit
d4babed247
|
@ -45,11 +45,14 @@
|
|||
|
||||
#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;
|
||||
|
||||
|
@ -74,7 +77,7 @@ static struct sp_port **sp_list_append(struct sp_port **list, const char *portna
|
|||
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;
|
||||
|
|
|
@ -79,6 +79,7 @@ enum {
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue