aboutsummaryrefslogtreecommitdiff
path: root/include/libtio
diff options
context:
space:
mode:
authorThomas Touhey <thomas@touhey.fr>2019-04-29 12:23:01 +0200
committerThomas Touhey <thomas@touhey.fr>2019-04-29 12:23:01 +0200
commit751f742fc8b8be0746b54d45822b9351f8079a64 (patch)
tree09ba321b956b27aef6a18a232154fba5cd38f824 /include/libtio
parentec1f2954f478f0c0efa2fb614a05d3899ba3a835 (diff)
There seems to be a problem with UNIX-related utilities and their enabling macro…
Diffstat (limited to 'include/libtio')
-rw-r--r--include/libtio/cdefs.h6
-rw-r--r--include/libtio/error.h6
-rw-r--r--include/libtio/io/serial.h12
-rw-r--r--include/libtio/native.h10
4 files changed, 26 insertions, 8 deletions
diff --git a/include/libtio/cdefs.h b/include/libtio/cdefs.h
index bcd4509..b896fa7 100644
--- a/include/libtio/cdefs.h
+++ b/include/libtio/cdefs.h
@@ -16,6 +16,9 @@
#ifndef LIBTIO_CDEFS_H
# define LIBTIO_CDEFS_H 20180710
# include "config.h"
+
+# define _POSIX_C_SOURCE 200809L
+
# include <stddef.h>
# include <time.h>
@@ -71,6 +74,9 @@
static TYPE
# define TIO_HOOK(TYPE) \
static TYPE
+
+# define TIO_EXTERN_TYPE(TYPE) \
+ TYPE
# define TIO_HOOK_TYPE(TYPE) \
TYPE
diff --git a/include/libtio/error.h b/include/libtio/error.h
index 6d6a63d..f2a7b9e 100644
--- a/include/libtio/error.h
+++ b/include/libtio/error.h
@@ -20,13 +20,17 @@ typedef int tio_error_t;
* `alloc`: a memory allocation has failed.
* `op`: unsupported operation.
* `arg`: an argument was invalid.
- * `iter`: no more elements in the iterator. */
+ * `iter`: no more elements in the iterator.
+ * `notfound`: error not found.
+ * `access`: access denied. */
# define tio_error_unknown 0x01
# define tio_error_alloc 0x02
# define tio_error_op 0x03
# define tio_error_arg 0x04
# define tio_error_iter 0x05
+# define tio_error_notfound 0x06
+# define tio_error_access 0x07
/* Stream errors.
* `stream`: invalid stream or stream in erroneous state (parent, …).
diff --git a/include/libtio/io/serial.h b/include/libtio/io/serial.h
index d04a7a7..12242f2 100644
--- a/include/libtio/io/serial.h
+++ b/include/libtio/io/serial.h
@@ -101,13 +101,11 @@ struct tio_serial_attrs {
# define TIO_DTRDIS 0x0000
# define TIO_DTRENB 0x0008
-# define TIO_DTRNOHAND 0x0000
-# define TIO_DTRHAND 0x0010
+# define TIO_DTRHAND 0x0018
# define TIO_RTSDIS 0x0000
# define TIO_RTSENB 0x0020
-# define TIO_RTSNOHAND 0x0000
-# define TIO_RTSHAND 0x0040
+# define TIO_RTSHAND 0x0060
/* The XON/XOFF software control settings.
*
@@ -182,8 +180,10 @@ TIO_EXTERN(int) tio_make_serial_speed_in_bauds
OF((unsigned long *tio__bauds, unsigned long tio__speed));
/* List the available serial ports.
- * TODO: platform-agnostic serial port listing function.
- * the iterator yields strings (`char const *`). */
+ * The iterator yields strings (`char const *`) representing the path. */
+
+TIO_EXTERN(int) tio_list_serial_ports
+ OF((tio_iter_t **tio__iterp));
# define tio_next_serial_port(ITER, PTRP) \
(tio_next((ITER), (void **)(char const **)(PTRP)))
diff --git a/include/libtio/native.h b/include/libtio/native.h
index 083a36a..f5600bc 100644
--- a/include/libtio/native.h
+++ b/include/libtio/native.h
@@ -63,8 +63,13 @@ TIO_EXTERN(int) tio_open_stdin
# ifndef LIBTIO_DISABLED_UNIX
-TIO_EXTERN(int) tio_open_unix_fd
+TIO_EXTERN(int) tio_open_unix_file
OF((tio_stream_t **tio__streamp, int tio__fd, int tio__close));
+TIO_EXTERN(int) tio_open_unix_serial
+ OF((tio_stream_t **tio__streamp, int tio__fd, int tio__close));
+
+TIO_EXTERN(int) tio_open_unix_serial_port
+ OF((tio_stream_t **tio__streamp, char const *tio__path));
/* These might not work, but we can try them on UNIX variants as they
* require the unistd.h functions at compile time. */
@@ -88,6 +93,9 @@ TIO_EXTERN(int) tio_open_windows_serial_handle
OF((tio_stream_t **tio__streamp, HANDLE tio__handle,
int tio__cl));
+TIO_EXTERN(int) tio_open_windows_serial_port
+ OF((tio_stream_t **tio__streamp, char const *tio__path));
+
TIO_EXTERN(int) tio_list_windows_serial_ports
OF((tio_iter_t **tio__iterp));