[5267] | 1 | //listenpty.c: |
---|
| 2 | |
---|
| 3 | /* |
---|
[5381] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2012 |
---|
[5267] | 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 | |
---|
[5343] | 29 | static int init (struct roar_dl_librarypara * para) { |
---|
[5267] | 30 | int serverfh = posix_openpt(O_RDWR|O_NOCTTY); |
---|
| 31 | struct termios termios; |
---|
| 32 | |
---|
[5343] | 33 | (void)para; |
---|
| 34 | |
---|
[5267] | 35 | if ( serverfh == -1 ) { |
---|
| 36 | ROAR_WARN("Can not open PTY Master: %s", strerror(errno)); |
---|
| 37 | return 0; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | tcgetattr(serverfh, &termios); |
---|
| 41 | cfmakeraw(&termios); |
---|
| 42 | tcsetattr(serverfh, TCSANOW, &termios); |
---|
| 43 | |
---|
| 44 | grantpt(serverfh); |
---|
| 45 | unlockpt(serverfh); |
---|
| 46 | |
---|
| 47 | if ( clients_new_from_fh(serverfh, ROAR_PROTO_ROARAUDIO, ROAR_BYTEORDER_NETWORK, 0) == -1 ) { |
---|
| 48 | close(serverfh); |
---|
| 49 | return 0; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | ROAR_WARN("PTY Slave: %s", ptsname(serverfh)); |
---|
| 53 | return 0; |
---|
| 54 | } |
---|
| 55 | |
---|
[5343] | 56 | static struct roar_dl_appsched sched = { |
---|
| 57 | .init = init, |
---|
| 58 | .free = NULL, |
---|
| 59 | .update = NULL, |
---|
| 60 | .tick = NULL, |
---|
| 61 | .wait = NULL |
---|
[5267] | 62 | }; |
---|
| 63 | |
---|
[5434] | 64 | ROAR_DL_PLUGIN_START(listenpty) { |
---|
[5275] | 65 | ROARD_DL_CHECK_VERSIONS(); |
---|
| 66 | |
---|
[5434] | 67 | ROAR_DL_PLUGIN_META_PRODUCT_NIV("listenpty", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO); |
---|
[5340] | 68 | ROAR_DL_PLUGIN_META_VERSION(ROAR_VERSION_STRING); |
---|
| 69 | ROAR_DL_PLUGIN_META_LICENSE_TAG(GPLv3_0); |
---|
| 70 | ROAR_DL_PLUGIN_META_CONTACT_FLNE("Philipp", "Schafft", "ph3-der-loewe", "lion@lion.leolix.org"); |
---|
| 71 | ROAR_DL_PLUGIN_META_DESC("This implements a listen socket using a PTY"); |
---|
[5275] | 72 | |
---|
[5343] | 73 | ROAR_DL_PLUGIN_REG_APPSCHED(&sched); |
---|
[5267] | 74 | } ROAR_DL_PLUGIN_END |
---|
| 75 | |
---|
| 76 | //ll |
---|