1 | //listenpty.c: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011 |
---|
5 | * |
---|
6 | * This file is part of roard a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * RoarAudio is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
22 | * Boston, MA 02110-1301, USA. |
---|
23 | * |
---|
24 | */ |
---|
25 | |
---|
26 | #include <roard/include/roard.h> |
---|
27 | #include <termios.h> |
---|
28 | |
---|
29 | static int init(void) { |
---|
30 | int serverfh = posix_openpt(O_RDWR|O_NOCTTY); |
---|
31 | struct termios termios; |
---|
32 | |
---|
33 | if ( serverfh == -1 ) { |
---|
34 | ROAR_WARN("Can not open PTY Master: %s", strerror(errno)); |
---|
35 | return 0; |
---|
36 | } |
---|
37 | |
---|
38 | tcgetattr(serverfh, &termios); |
---|
39 | cfmakeraw(&termios); |
---|
40 | tcsetattr(serverfh, TCSANOW, &termios); |
---|
41 | |
---|
42 | grantpt(serverfh); |
---|
43 | unlockpt(serverfh); |
---|
44 | |
---|
45 | if ( clients_new_from_fh(serverfh, ROAR_PROTO_ROARAUDIO, ROAR_BYTEORDER_NETWORK, 0) == -1 ) { |
---|
46 | close(serverfh); |
---|
47 | return 0; |
---|
48 | } |
---|
49 | |
---|
50 | ROAR_WARN("PTY Slave: %s", ptsname(serverfh)); |
---|
51 | return 0; |
---|
52 | } |
---|
53 | |
---|
54 | static struct roard_plugins_sched sched[1] = { |
---|
55 | {.init = init, .free = NULL, .update = NULL} |
---|
56 | }; |
---|
57 | |
---|
58 | ROARD_DL_REG_SCHED(sched) |
---|
59 | |
---|
60 | ROAR_DL_PLUGIN_START(roard_discard_protocol) { |
---|
61 | ROARD_DL_CHECK_VERSIONS(); |
---|
62 | |
---|
63 | libname.license = "GPL-3.0"; |
---|
64 | |
---|
65 | ROARD_DL_REGFN_SCHED(); |
---|
66 | } ROAR_DL_PLUGIN_END |
---|
67 | |
---|
68 | //ll |
---|