1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#ifndef TIO_NATIVE_H
# define TIO_NATIVE_H 20180710
# include "cdefs.h"
# include "stream.h"
TIO_BEGIN_NAMESPACE
TIO_BEGIN_DECLS
/* ---
* Native support macros defining.
* --- */
/* Macros defined (or not) in the config.h header (included by cdefs.h):
*
* - `LIBTIO_DISABLED_FILE`: disable stdio's FILE support.
* - `LIBTIO_DISABLED_LIBUSB`: disable libusb support.
*
* Macros defined hereafter:
*
* - `LIBTIO_DISABLED_UNIX`: disable POSIX (unistd.h) support.
* - `LIBTIO_DISABLED_WINDOWS`: disable Windows API support.
* - `LIBTIO_DISABLED_MACOS`: disable MacOS (OS X) support. */
# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L
# else
# define LIBTIO_DISABLED_UNIX 1
# endif
# if defined(_WIN16) || defined(_WIN32) || defined(_WIN64) \
|| defined(__WINDOWS__)
# else
# define LIBTIO_DISABLED_WINDOWS 1
# endif
# if defined(__APPLE__)
# else
# define LIBTIO_DISABLED_MACOS 1
# endif
/* ---
* Native stream opening functions.
* --- */
/* FILE streams. */
# ifndef LIBTIO_DISABLED_FILE
# include <stdio.h>
TIO_EXTERN(int) tio_open_std
OF((tio_stream_t **tio__stream,
FILE *tio__fl, int tio__close));
TIO_EXTERN(int) tio_open_stdout
OF((tio_stream_t **tio__stream));
TIO_EXTERN(int) tio_open_stderr
OF((tio_stream_t **tio__stream));
TIO_EXTERN(int) tio_open_stdin
OF((tio_stream_t **tio__stream));
# endif
/* UNIX-specific streams and listings. */
# ifndef LIBTIO_DISABLED_UNIX
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. */
TIO_EXTERN(int) tio_list_unix_serial_ports_using_dev_serial
OF((tio_iter_t **tio__iterp));
TIO_EXTERN(int) tio_list_unix_serial_ports_using_cu_devices
OF((tio_iter_t **tio__iterp));
# endif
/* MS-Windows specific streams and port/device listing. */
# ifndef LIBTIO_DISABLED_WINDOWS
# include <windows.h>
TIO_EXTERN(int) tio_open_windows_file_handle
OF((tio_stream_t **tio__streamp, HANDLE tio__handle,
int tio__cl));
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));
# endif
/* libusb stream. */
# ifndef LIBTIO_DISABLED_LIBUSB
# include <libusb.h>
TIO_EXTERN(int) tio_open_libusb
OF((tio_stream_t **streamp, int bus, int addr));
TIO_EXTERN(int) tio_open_libusb_device
OF((tio_stream_t **streamp, libusb_device_handle *handle));
# endif
TIO_END_DECLS
TIO_END_NAMESPACE
#endif /* TIO_NATIVE_H */
|