/* The following source has been taken from the pty-redir package which is itself GPL, like Linuxconf. pty-redir is made of a single file */ /* Copyright (c) 1997 Magosányi Árpád This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Ez a program szabad szoftver; szbadon másolható és/vagy módosítható a GNU General Public Licence feltételei alapján, ahogyan azt a Szabad Szoftver Alapítvány közreadta; akár a 2-es, akár bármely későbbi verzió alapján. Ezt a programot abban a reményben terjesztem, hogy használható lesz, de BÁRMILYEN GARANCIA NÉLKÜL; beleértve a használhatóságra vagy egy adott célra való megfelelésre vonatkozó garanciát is. Lásd a GNU General Public Licence-t a részletekért. Ezt a programot kísérnie kell a GNU General Public Licence egy másolatának. Ha ezt hiányolná, írjon a Free Software Foundation, Inc., 675 Mass Ave, Cambridge, Ma 02139, USA címére. Ha bármi problémád, észrevételed, ötleted, patched van, írj a mag@tas.vein.hu, vagy az ssa@tohotom.vein.hu címre (az utóbbi a Magyar Szabad Szoftver Alapítvány levelezőlistája.) */ #include #include #include #include #include #include #define PTY00 "/dev/ptyXX" #define PTY10 "pqrs" #define PTY01 "0123456789abcdef" static int getPtyMaster(char *tty10, char *tty01) { char *p10; char *p01; static char dev[] = PTY00; int fd; for (p10 = PTY10; *p10 != '\0'; p10++) { dev[8] = *p10; for (p01 = PTY01; *p01 != '\0'; p01++) { dev[9] = *p01; fd = open(dev, O_RDWR); if (fd >= 0) { *tty10 = *p10; *tty01 = *p01; return fd; } } } fprintf(stderr,"Ran out of pty.\n"); exit(1); return fd; } int main(int argc,char *argv[]) { int fd; char a,b; char **args; char *envs[]={NULL}; int i; fd=getPtyMaster(&a,&b); fprintf(stdout,"/dev/tty%c%c",a,b); fflush(stdout); if(NULL==(args=malloc((argc)*sizeof(char *)))) { fprintf(stderr,"Virtual memory exhausted\n"); exit(1); } for(i=1;i