/* slsnif.h * Copyright (C) 2001 Yan "Warrior" Gurtovoy (ymg@azstarnet.com) * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_GETOPT_H #include #endif #ifdef HAVE_SYS_TIMEB_H #include #endif #ifdef HAVE_TIME_H #include #endif #include "common.h" #define OPTSTR "bnhtp:l:s:" /* list of short options for getopt_long() */ #define PORT_OUT "\nHost --> " #define PORT_IN "\nDevice --> " #define DEFPTRNAME "/dev/pty??" #define TOTALBYTES "Total bytes transmitted:" #define MEMFAIL "Memory allocation failed" #define PTYFAIL "Failed to open a pty" #define PORTFAIL "Failed to open port" #define LOGFAIL "Failed to open log file, defaulting to stdout" #define SELFAIL "`Select` failed" #define RPORTFAIL "Error reading from port" #define RPTYFAIL "Error reading from pty" #define CLOSEFAIL "Failed to close file - data loss may occur" #define RAWFAIL "Failed to switch into raw mode" #define SYNCFAIL "Failed to syncronize ttys" #define PIPEFAIL "Failed to create pipe" #define FORKFAIL "Failed to create child process" #define RPIPEFAIL "Error reading from pipe" #define max(x,y) ((x) > (y) ? (x) : (y)) #define BUFFSIZE 32 #define PRFXSIZE 12 #define DEFBAUDRATE B9600 #define WHITE 7 #define PORTNAMELEN 11 static tty_struct tty_data; static pid_t pid = -1; /* baudrates */ typedef struct _spd_struct { speed_t speed; char *spdstr; } spd_struct; static spd_struct baudrates[] = { {B50, "50"}, {B75, "75"}, {B110, "110"}, {B134, "134"}, {B150, "150"}, {B200, "200"}, {B300, "300"}, {B600, "600"}, {B1200, "1200"}, {B1800, "1800"}, {B2400, "2400"}, {B4800, "4800"}, {B9600, "9600"}, {B19200, "19200"}, {B38400, "38400"}, {B57600, "57600"}, {B115200, "115200"}, {0, NULL} }; static clr_struct colors[] = { {"black", "\033[0;30m"}, {"red", "\033[0;31m"}, {"green", "\033[0;32m"}, {"yellow", "\033[0;33m"}, {"blue", "\033[0;34m"}, {"magenta", "\033[0;35m"}, {"cyan", "\033[0;36m"}, {"white", "\033[0;37m"}, {"brightblack", "\033[1;30m"}, {"brightred", "\033[1;31m"}, {"brightgreen", "\033[1;32m"}, {"brightyellow", "\033[1;33m"}, {"brightblue", "\033[1;34m"}, {"brightmagenta", "\033[1;35m"}, {"brightcyan", "\033[1;36m"}, {"brightwhite", "\033[1;37m"}, {NULL, NULL } }; /* function prototypes */ pid_t dev_getlock(char *dev); pid_t dev_setlock(char *dev); int dev_unlock(char *dev); void readRC(tty_struct *ptr);