Debian Codegraph @

netax25/ttyutils.h

raw
1 /* LIBAX25 - Library for AX.25 programs
2 * Copyright (C) 1997-1999 Jonathan Naylor, Tomi Manninen, Jean-Paul Roubelat
3 * and Alan Cox.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20 /*
21 * Generic serial port handling functions.
22 */
23
24 #ifndef _TTYUTILS_H
25 #define _TTYUTILS_H
26
27 #ifndef TRUE
28 #define TRUE 1
29 #endif
30
31 #ifndef FALSE
32 #define FALSE 0
33 #endif
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /*
40 * Put a given file descriptor into raw mode, if the hwflag is set to TRUE
41 * then hardware handshaking is enabled. Returns TRUE if successful.
42 */
43 extern int tty_raw(int fd, int hwflag);
44
45 /*
46 * Set the speed of the given file descriptor. Returns TRUE is it was
47 * successful.
48 */
49 extern int tty_speed(int fd, int speed);
50
51 /*
52 * Determines whether a given tty is already open by another process. Returns
53 * TRUE if is already locked, or FALSE if it is free.
54 */
55 extern int tty_is_locked(char *tty);
56
57 /*
58 * Creates a lock file for the given tty. It writes the process ID to the
59 * file so take care if doing a fork. Returns TRUE if everything was OK.
60 */
61 extern int tty_lock(char *tty);
62
63 /*
64 * Removes the lock file for a given tty. Returns TRUE if successful.
65 */
66 extern int tty_unlock(char *tty);
67
68 #ifdef __cplusplus
69 }
70 #endif
71
72 #endif