//listenpty.c: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011 * * This file is part of roard a part of RoarAudio, * a cross-platform sound system for both, home and professional use. * See README for details. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation. * * RoarAudio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; see the file COPYING. If not, write to * the Free Software Foundation, 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #include #include static int init(void) { int serverfh = posix_openpt(O_RDWR|O_NOCTTY); struct termios termios; if ( serverfh == -1 ) { ROAR_WARN("Can not open PTY Master: %s", strerror(errno)); return 0; } tcgetattr(serverfh, &termios); cfmakeraw(&termios); tcsetattr(serverfh, TCSANOW, &termios); grantpt(serverfh); unlockpt(serverfh); if ( clients_new_from_fh(serverfh, ROAR_PROTO_ROARAUDIO, ROAR_BYTEORDER_NETWORK, 0) == -1 ) { close(serverfh); return 0; } ROAR_WARN("PTY Slave: %s", ptsname(serverfh)); return 0; } static struct roard_plugins_sched sched[1] = { {.init = init, .free = NULL, .update = NULL} }; ROARD_DL_REG_SCHED(sched) ROAR_DL_PLUGIN_START(roard_discard_protocol) { ROARD_DL_CHECK_VERSIONS(); libname.license = "GPL-3.0"; ROARD_DL_REGFN_SCHED(); } ROAR_DL_PLUGIN_END //ll