enum {
/* Operation completed successfully. */
SP_OK = 0,
- /* A system error occured while executing the operation. */
- SP_ERR_FAIL = -1,
/* Invalid arguments were passed to the function. */
- SP_ERR_ARG = -2
+ SP_ERR_ARG = -1,
+ /* A system error occured while executing the operation. */
+ SP_ERR_FAIL = -2,
+ /* A memory allocation failed while executing the operation. */
+ SP_ERR_MEM = -3
};
/* Port access modes. */
SP_FLOW_SOFTWARE = 2
};
-char **sp_list_ports(void);
-void sp_free_port_list(char **ports);
-int sp_open(struct sp_port *port, char *portname, int flags);
+int sp_get_port_by_name(const char *portname, struct sp_port **port_ptr);
+void sp_free_port(struct sp_port *port);
+int sp_list_ports(struct sp_port ***list_ptr);
+void sp_free_port_list(struct sp_port **ports);
+int sp_open(struct sp_port *port, int flags);
int sp_close(struct sp_port *port);
int sp_flush(struct sp_port *port);
int sp_write(struct sp_port *port, const void *buf, size_t count);