"Fossies" - the Fresh Open Source Software Archive

Member "ifhp-3.5.22/src/stty.c" (1 Mar 2009, 27089 Bytes) of package /linux/misc/old/ifhp-3.5.22.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "stty.c" see the Fossies "Dox" file reference documentation.

    1 /**************************************************************************
    2  * LPRng IFHP Filter
    3  * Copyright 1994-1999 Patrick Powell, San Diego, CA <papowell@astart.com>
    4  **************************************************************************/
    5 /**** HEADER *****/
    6  static char *const _id = "$Id: stty.c,v 1.6 2002/04/01 18:01:03 papowell Exp papowell $";
    7 
    8 #include "ifhp.h"
    9 
   10 /**** ENDINCLUDE ****/
   11 
   12 #if USE_STTY == TERMIO
   13 #    include <termio.h>
   14 #    include <sys/termio.h>
   15 #endif
   16 
   17 #if USE_STTY == SGTTYB
   18 # include <sgtty.h>
   19 #endif
   20 
   21 #if USE_STTY == TERMIOS
   22 # include <termios.h>
   23 #endif
   24 
   25 #if defined(HAVE_TTOLD_H)
   26 # include <sys/ttold.h>
   27 #endif
   28 
   29 #if USE_STTY == SGTTYB
   30 
   31 # if !defined(B19200)
   32 #  ifdef EXTA
   33 #   define B19200 EXTA
   34 #  else
   35 #   define B19200 B9600
   36 #  endif  /* !defined(EXTA) */
   37 # endif  /* !defined(B19200) */
   38 
   39 #if !defined(B38400)
   40 #ifdef EXTB
   41 #define B38400 EXTB
   42 #else
   43 #define B38400 B9600
   44 #endif  /* !defined(EXTB) */
   45 #endif  /* !defined(B38400) */
   46 
   47  static struct bauds {
   48     char *string;
   49     int baud;
   50     int speed;
   51 } bauds[] = {
   52 
   53     { "110", 110, B110, },
   54     { "134", 134, B134, },
   55     { "150", 150, B150, },
   56     { "300", 300, B300, },
   57     { "600", 600, B600, },
   58     { "1200", 1200, B1200, },
   59     { "1800", 1800, B1800, },
   60     { "2400", 2400, B2400, },
   61     { "4800", 4800, B4800, },
   62     { "9600", 9600, B9600, },
   63     { "19200", 19200, B19200, },
   64     { "38400", 38400, B38400, },
   65     { (char *) 0, 0, 0 }
   66 };
   67 
   68 /*
   69  * Set terminal modes.
   70  * 
   71  * jmason: I've added support for some combination modes,
   72  *  such as "pass8" and "parity".
   73  */
   74 
   75  struct tchars termctrl;
   76  struct ltchars linectrl;
   77  struct sgttyb mode;
   78 
   79  static struct {
   80     char *string;
   81     int set;
   82     int reset;
   83     int lset;
   84     int lreset;
   85 
   86 } modes[] = {
   87     { "bs0", BS0, BS1, 0, 0 },
   88     { "bs1", BS1, BS1, 0, 0 },
   89     { "cbreak", CBREAK, 0, 0, 0 },
   90     { "-cbreak", 0, CBREAK, 0, 0 },
   91     { "cooked", 0, RAW, 0, 0 },
   92     { "cr0", CR0, CR3, 0, 0 },
   93     { "cr1", CR1, CR3, 0, 0 },
   94     { "cr2", CR2, CR3, 0, 0 },
   95     { "cr3", CR3, CR3, 0, 0 },
   96     { "decctlq", 0, 0, LDECCTQ, 0 },
   97     { "-decctlq", 0, 0, 0, LDECCTQ, },
   98     { "echo", ECHO, 0, 0, 0 },
   99     { "-echo", 0, ECHO, 0, 0 },
  100     { "even", EVENP, 0, 0, 0 },
  101     { "-even", 0, EVENP, 0, 0 },
  102     { "ff0", FF0, FF1, 0, 0 },
  103     { "ff1", FF1, FF1, 0, 0 },
  104     { "lcase", LCASE, 0, 0, 0 },
  105     { "-lcase", 0, LCASE, 0, 0 },
  106     { "litout", 0, 0, LLITOUT, 0 },
  107     { "-litout", 0, 0, 0, LLITOUT, },
  108     { "nl", 0, CRMOD, 0, 0 },
  109     { "-nl", CRMOD, 0, 0, 0 },
  110     { "nl0", NL0, NL3, 0, 0 },
  111     { "nl1", NL1, NL3, 0, 0 },
  112     { "nl2", NL2, NL3, 0, 0 },
  113     { "nl3", NL3, NL3, 0, 0 },
  114     { "noflsh", 0, 0, LNOFLSH, 0 },
  115     { "-noflsh", 0, 0, 0, LNOFLSH, },
  116     { "nohang", 0, 0, LNOHANG, 0 },
  117     { "-nohang", 0, 0, 0, LNOHANG, },
  118     { "odd", ODDP, 0, 0, 0 },
  119     { "-odd", 0, ODDP, 0, 0 },
  120     { "raw", RAW, 0, 0, 0 },
  121     { "-raw", 0, RAW, 0, 0 },
  122     { "tab0", TAB0, XTABS, 0, 0 },
  123     { "tab1", TAB1, XTABS, 0, 0 },
  124     { "tab2", TAB2, XTABS, 0, 0 },
  125     { "tabs", 0, XTABS, 0, 0 },
  126     { "-tabs", XTABS, 0, 0, 0 },
  127     { "tandem", TANDEM, 0, 0, 0 },
  128     { "-tandem", 0, TANDEM, 0, 0 },
  129 #ifndef IS_NEXT
  130     { "tilde", 0, 0, LTILDE, 0 },
  131     { "-tilde", 0, 0, 0, LTILDE, },
  132 #endif
  133     { "tn300", CR1, ALLDELAY, 0, 0 },
  134     { "tty33", CR1, ALLDELAY, 0, 0 },
  135     { "tty37", FF1 + CR2 + TAB1 + NL1, ALLDELAY, 0, 0 },
  136     { "vt05", NL2, ALLDELAY, 0, 0 },
  137 
  138     /* jmason modes and synonyms: */
  139     { "evenp", EVENP, 0, 0, 0 },
  140     { "-evenp", 0, EVENP, 0, 0 },
  141     { "parity", EVENP, 0, 0, 0 },
  142     { "-parity", 0, EVENP|ODDP, 0, 0 },
  143     { "oddp", ODDP, 0, 0, 0 },
  144     { "-oddp", 0, ODDP, 0, 0 },
  145 #ifdef LPASS8
  146     { "pass8", 0, 0, LPASS8, 0 },
  147     { "-pass8", 0, 0, 0, LPASS8, },
  148 #endif
  149     {0}
  150 };
  151 
  152 
  153  static struct special {
  154     char *name;
  155     char *cp;
  156     char def;
  157 } special[] = {
  158 
  159     { "stop", &termctrl.t_stopc, CSTOP },
  160     { "start", &termctrl.t_startc, CSTART },
  161     { 0, 0, 0 }
  162 };
  163 
  164 void Do_stty( int fd, char *Stty_command )
  165 {
  166     int i, localmode, linedisc, argcount;
  167     char *s, *arg, *parm = 0;
  168     OBJ *l = 0;
  169 
  170     l = NEW_OBJ(0,MEMINFO);
  171     l = Split_STR_OBJ( /*p*/l, /*nomod*/1, /*str*/Stty_command,
  172             /*type*/OBJ_T_LIST, /*linesep*/WHITESPACE, /*escape*/0,
  173             /*comment*/ 0, /*trim*/1, /*keysep*/0,/*do_append*/0, /*lc*/0,
  174             /*flagvalues*/ 0, /*value_urlunesc*/0, MEMINFO );
  175 
  176     DEBUG4("Do_stty: using SGTTYB, fd %d", fd );
  177     if( ioctl( fd, TIOCGETP, &mode) < 0
  178         || ioctl( fd, TIOCGETC, &termctrl) < 0
  179         || ioctl( fd, TIOCLGET, &localmode) < 0
  180         || ioctl( fd, TIOCGLTC, &linectrl) < 0 ){
  181         Errorcode = JABORT;
  182         LOGERR_DIE(LOG_INFO) "cannot get tty parameters");
  183     }
  184     DEBUG4("Do_stty: before mode 0x%x, lmode 0x%x, speed 0x%x",
  185              mode.sg_flags, localmode, mode.sg_ispeed);
  186     for( argcount = 0; argcount < LEN_LIST_OBJ(l); ++argcount ){
  187         arg = GET_ENTRY_LIST_OBJ(l,argcount);
  188         for( i = 0; modes[i].string && strcasecmp( modes[i].string, arg); i++);
  189         if( modes[i].string ){
  190             DEBUG4("Do_stty: modes %s, mc 0x%x ms 0x%x lc 0x%x ls 0x%x",
  191                      modes[i].string, modes[i].reset, modes[i].set,
  192                      modes[i].lreset, modes[i].lset);
  193             mode.sg_flags &= ~modes[i].reset;
  194             mode.sg_flags |= modes[i].set;
  195             localmode &= ~modes[i].lreset;
  196             localmode |= modes[i].lset;
  197             continue;
  198         }
  199         for( i = 0; special[i].name && strcasecmp( special[i].name, arg); i++);
  200         if( special[i].name) {
  201             if( ++argcount < LEN_LIST_OBJ(l) ){
  202                 parm = GET_ENTRY_LIST_OBJ(l,argcount);
  203             } else {
  204                 Errorcode = JABORT;
  205                 FATAL(LOG_INFO)  "Do_stty: missing parameter for %s\n", arg);
  206             }
  207             if( parm[0] == '^') {
  208                 if( parm[1] == '?') {
  209                     *special[i].cp = 0177;
  210                 } else {
  211                     *special[i].cp = 037 & parm[1];
  212                 }
  213             } else {
  214                 *special[i].cp = parm[0];
  215             }
  216             DEBUG4("Do_stty: special %s %s", arg, parm);
  217             continue;
  218         }
  219         for( i = 0; bauds[i].string && strcasecmp( bauds[i].string, arg); i++);
  220         if( bauds[i].string) {
  221             DEBUG4("Do_stty: speed %s", arg);
  222             mode.sg_ispeed = mode.sg_ospeed = bauds[i].speed;
  223             continue;
  224         }
  225         if( !strcasecmp( "new", arg)) {
  226             DEBUG4("Do_stty: ldisc %s", arg);
  227             linedisc = NTTYDISC;
  228             if( ioctl( fd, TIOCSETD, &linedisc) < 0){
  229                 Errorcode = JABORT;
  230                 LOGERR_DIE(LOG_INFO) "Do_stty: TIOCSETD ioctl failed");
  231             }
  232             continue;
  233         }
  234         if( !strcasecmp( "old", arg)) {
  235             DEBUG4("Do_stty: ldisc %s", arg);
  236             linedisc = 0;
  237             if( ioctl( fd, TIOCSETD, &linedisc) < 0){
  238                 Errorcode = JABORT;
  239                 LOGERR_DIE(LOG_INFO) "Do_stty: TIOCSETD ioctl failed");
  240             }
  241             continue;
  242         }
  243         LOGMSG(LOG_INFO)"Do_stty: unknown mode: %s", arg);
  244     }
  245     DEBUG4("Do_stty: after mode 0x%x, lmode 0x%x, speed 0x%x",
  246              mode.sg_flags, localmode, mode.sg_ispeed);
  247     if( ioctl( fd, TIOCSETN, &mode) < 0
  248         || ioctl( fd, TIOCSETC, &termctrl) < 0
  249         || ioctl( fd, TIOCSLTC, &linectrl) < 0
  250         || ioctl( fd, TIOCLSET, &localmode) < 0) {
  251         Errorcode = JABORT;
  252         LOGERR_DIE(LOG_INFO) "cannot set tty parameters");
  253     }
  254     Free_line_list( &l );
  255 }
  256 #endif
  257 
  258 #if USE_STTY == TERMIO
  259 
  260 /* the folks who are responsible for include files
  261  * must be the lowest paid/motivated ones in
  262  * OS development... (mj)
  263  */
  264 
  265 #if !defined(TOSTOP) && defined(_TOSTOP)
  266 #define TOSTOP _TOSTOP
  267 #endif
  268 
  269  static struct bauds {
  270     char *string;
  271     int baud;
  272     int speed;
  273 }     bauds[] = {
  274 
  275     { "110", 110, B110, },
  276     { "134", 134, B134, },
  277     { "150", 150, B150, },
  278     { "300", 300, B300, },
  279     { "600", 600, B600, },
  280     { "1200", 1200, B1200, },
  281     { "1800", 1800, B1800, },
  282     { "2400", 2400, B2400, },
  283     { "4800", 4800, B4800, },
  284     { "9600", 9600, B9600, },
  285     { "19200", 19200, B19200, },
  286     { "38400", 38400, B38400, },
  287     { (char *) 0, 0, 0 }
  288 };
  289 
  290  struct termio tio;
  291  static struct {
  292     char *string;
  293     int iset;
  294     int ireset;
  295     int oset;
  296     int oreset;
  297     int cset;
  298     int creset;
  299     int lset;
  300     int lreset;
  301 }      tmodes[] = {
  302 
  303     /* input modes */
  304     { "ignbrk", IGNBRK, 0, 0, 0, 0, 0, 0, 0 },
  305     { "-ignbrk", 0, IGNBRK, 0, 0, 0, 0, 0, 0 },
  306     { "brkint", BRKINT, 0, 0, 0, 0, 0, 0, 0 },
  307     { "-brkint", 0, BRKINT, 0, 0, 0, 0, 0, 0 },
  308     { "ignpar", IGNPAR, 0, 0, 0, 0, 0, 0, 0 },
  309     { "-ignpar", 0, IGNPAR, 0, 0, 0, 0, 0, 0 },
  310     { "parmrk", PARMRK, 0, 0, 0, 0, 0, 0, 0 },
  311     { "-parmrk", 0, PARMRK, 0, 0, 0, 0, 0, 0 },
  312     { "inpck", INPCK, 0, 0, 0, 0, 0, 0, 0 },
  313     { "-inpck", 0, INPCK, 0, 0, 0, 0, 0, 0 },
  314     { "istrip", ISTRIP, 0, 0, 0, 0, 0, 0, 0 },
  315     { "-istrip", 0, ISTRIP, 0, 0, 0, 0, 0, 0 },
  316     { "inlcr", INLCR, 0, 0, 0, 0, 0, 0, 0 },
  317     { "-inlcr", 0, INLCR, 0, 0, 0, 0, 0, 0 },
  318     { "igncr", IGNCR, 0, 0, 0, 0, 0, 0, 0 },
  319     { "-igncr", 0, IGNCR, 0, 0, 0, 0, 0, 0 },
  320     { "icrnl", ICRNL, 0, 0, 0, 0, 0, 0, 0 },
  321     { "-icrnl", 0, ICRNL, 0, 0, 0, 0, 0, 0 },
  322     { "lcase", IUCLC, 0, 0, 0, 0, 0, 0, 0 },
  323     { "iuclc", IUCLC, 0, 0, 0, 0, 0, 0, 0 },
  324     { "-lcase", 0, IUCLC, 0, 0, 0, 0, 0, 0 },
  325     { "-iuclc", 0, IUCLC, 0, 0, 0, 0, 0, 0 },
  326     { "ixon", IXON, 0, 0, 0, 0, 0, 0, 0 },
  327     { "-ixon", 0, IXON, 0, 0, 0, 0, 0, 0 },
  328     { "ixany", IXANY, 0, 0, 0, 0, 0, 0, 0 },
  329     { "-ixany", 0, IXANY, 0, 0, 0, 0, 0, 0 },
  330     { "ixoff", IXOFF, 0, 0, 0, 0, 0, 0, 0 },
  331     { "-ixoff", 0, IXOFF, 0, 0, 0, 0, 0, 0 },
  332     { "decctlq", IXANY, 0, 0, 0, 0, 0, 0, 0 },
  333     { "-decctlq", 0, IXANY, 0, 0, 0, 0, 0, 0 },
  334     { "tandem", IXOFF, 0, 0, 0, 0, 0, 0, 0 },
  335     { "-tandem", 0, IXOFF, 0, 0, 0, 0, 0, 0 },
  336 #ifdef IMAXBEL
  337     { "imaxbel", IMAXBEL, 0, 0, 0, 0, 0, 0, 0 },
  338     { "-maxbel", 0, IMAXBEL, 0, 0, 0, 0, 0, 0 },
  339 #endif
  340     /* output modes */
  341     { "opost", 0, 0, OPOST, 0, 0, 0, 0, 0 },
  342     { "-opost", 0, 0, 0, OPOST, 0, 0, 0, 0 },
  343     { "olcuc", 0, 0, OLCUC, 0, 0, 0, 0, 0 },
  344     { "-olcuc", 0, 0, 0, OLCUC, 0, 0, 0, 0 },
  345     { "onlcr", 0, 0, ONLCR, 0, 0, 0, 0, 0 },
  346     { "-onlcr", 0, 0, 0, ONLCR, 0, 0, 0, 0 },
  347     { "ocrnl", 0, 0, OCRNL, 0, 0, 0, 0, 0 },
  348     { "-ocrnl", 0, 0, 0, OCRNL, 0, 0, 0, 0 },
  349     { "onocr", 0, 0, ONOCR, 0, 0, 0, 0, 0 },
  350     { "-onocr", 0, 0, 0, ONOCR, 0, 0, 0, 0 },
  351     { "onlret", 0, 0, ONLRET, 0, 0, 0, 0, 0 },
  352     { "-onlret", 0, 0, 0, ONLRET, 0, 0, 0, 0 },
  353     { "ofill", 0, 0, OFILL, 0, 0, 0, 0, 0 },
  354     { "-ofill", 0, 0, 0, OFILL, 0, 0, 0, 0 },
  355     { "ofdel", 0, 0, OFDEL, 0, 0, 0, 0, 0 },
  356     { "-ofdel", 0, 0, 0, OFDEL, 0, 0, 0, 0 },
  357     { "nl0", 0, 0, NL0, NLDLY, 0, 0, 0, 0 },
  358     { "nl1", 0, 0, NL1, NLDLY, 0, 0, 0, 0 },
  359     { "cr0", 0, 0, CR1, CRDLY, 0, 0, 0, 0 },
  360     { "cr1", 0, 0, CR1, CRDLY, 0, 0, 0, 0 },
  361     { "cr2", 0, 0, CR2, CRDLY, 0, 0, 0, 0 },
  362     { "cr3", 0, 0, CR3, CRDLY, 0, 0, 0, 0 },
  363     { "tab0", 0, 0, TAB0, TABDLY, 0, 0, 0, 0 },
  364     { "tab1", 0, 0, TAB1, TABDLY, 0, 0, 0, 0 },
  365     { "tab2", 0, 0, TAB2, TABDLY, 0, 0, 0, 0 },
  366     { "tab3", 0, 0, TAB3, TABDLY, 0, 0, 0, 0 },
  367     { "bs0", 0, 0, BS0, BSDLY, 0, 0, 0, 0 },
  368     { "bs1", 0, 0, BS1, BSDLY, 0, 0, 0, 0 },
  369     { "vt0", 0, 0, VT0, VTDLY, 0, 0, 0, 0 },
  370     { "vt1", 0, 0, VT1, VTDLY, 0, 0, 0, 0 },
  371     { "ff0", 0, 0, FF0, FFDLY, 0, 0, 0, 0 },
  372     { "ff1", 0, 0, FF1, FFDLY, 0, 0, 0, 0 },
  373     { "nopost", 0, 0, 0, OPOST, 0, 0, 0, 0 },
  374     { "-nopost", 0, 0, OPOST, 0, 0, 0, 0, 0 },
  375     { "fill", 0, 0, OFILL, OFDEL, 0, 0, 0, 0 },
  376     { "-fill", 0, 0, 0, OFILL | OFDEL, 0, 0, 0, 0 },
  377     { "nul-fill", 0, 0, OFILL, OFDEL, 0, 0, 0, 0 },
  378     { "del-fill", 0, 0, OFILL | OFDEL, 0, 0, 0, 0, 0 },
  379 #ifdef XTABS
  380     { "tabs", 0, 0, 0, XTABS | TABDLY, 0, 0, 0, 0 },
  381     { "-tabs", 0, 0, XTABS, TABDLY, 0, 0, 0, 0 },
  382 #endif
  383     /* control modes */
  384     { "cs5", 0, 0, 0, 0, CS5, CSIZE, 0, 0 },
  385     { "cs6", 0, 0, 0, 0, CS6, CSIZE, 0, 0 },
  386     { "cs7", 0, 0, 0, 0, CS7, CSIZE, 0, 0 },
  387     { "cs8", 0, 0, 0, 0, CS8, CSIZE, 0, 0 },
  388     { "cstopb", 0, 0, 0, 0, CSTOPB, 0, 0, 0 },
  389     { "-cstopb", 0, 0, 0, 0, 0, CSTOPB, 0, 0 },
  390     { "cread", 0, 0, 0, 0, CREAD, 0, 0, 0 },
  391     { "-cread", 0, 0, 0, 0, 0, CREAD, 0, 0 },
  392     { "parenb", 0, 0, 0, 0, PARENB, 0, 0, 0 },
  393     { "-parenb", 0, 0, 0, 0, 0, PARENB, 0, 0 },
  394     { "parodd", 0, 0, 0, 0, PARODD, 0, 0, 0 },
  395     { "-parodd", 0, 0, 0, 0, 0, PARODD, 0, 0 },
  396     { "hupcl", 0, 0, 0, 0, HUPCL, 0, 0, 0 },
  397     { "-hupcl", 0, 0, 0, 0, 0, HUPCL, 0, 0 },
  398     { "clocal", 0, 0, 0, 0, CLOCAL, 0, 0, 0 },
  399     { "-clocal", 0, 0, 0, 0, 0, CLOCAL, 0, 0 },
  400 #ifdef LOBLK
  401     { "loblk", 0, 0, 0, 0, LOBLK, 0, 0, 0 },
  402     { "-loblk", 0, 0, 0, 0, 0, LOBLK, 0, 0 },
  403 #endif
  404     { "parity", 0, 0, 0, 0, PARENB | CS7, PARODD | CSIZE, 0, 0 },
  405     { "-parity", 0, 0, 0, 0, CS8, PARENB | CSIZE, 0, 0 },
  406     { "evenp", 0, 0, 0, 0, PARENB | CS7, PARODD | CSIZE, 0, 0 },
  407     { "-evenp", 0, 0, 0, 0, CS8, PARENB | CSIZE, 0, 0 },
  408     { "oddp", 0, 0, 0, 0, PARENB | PARODD | CS7, CSIZE, 0, 0 },
  409     { "-oddp", 0, 0, 0, 0, CS8, PARENB | PARODD | CSIZE, 0, 0 },
  410     { "stopb", 0, 0, 0, 0, CSTOPB, 0, 0, 0 },
  411     { "-stopb", 0, 0, 0, 0, 0, CSTOPB, 0, 0 },
  412     { "hup", 0, 0, 0, 0, HUPCL, 0, 0, 0 },
  413     { "-hup", 0, 0, 0, 0, 0, HUPCL, 0, 0 },
  414 #ifdef CRTSCTS
  415     { "crtscts", 0, 0, 0, 0, CRTSCTS, 0, 0, 0 },
  416     { "-crtscts", 0, 0, 0, 0, 0, CRTSCTS, 0, 0 },
  417 #endif
  418     /* local modes */
  419     { "isig", 0, 0, 0, 0, 0, 0, ISIG, 0 },
  420     { "-isig", 0, 0, 0, 0, 0, 0, 0, ISIG },
  421     { "noisig", 0, 0, 0, 0, 0, 0, 0, ISIG },
  422     { "-noisig", 0, 0, 0, 0, 0, 0, ISIG, 0 },
  423     { "icanon", 0, 0, 0, 0, 0, 0, ICANON, 0 },
  424     { "-icanon", 0, 0, 0, 0, 0, 0, 0, ICANON },
  425     { "cbreak", 0, 0, 0, 0, 0, 0, ICANON, 0 },
  426     { "-cbreak", 0, 0, 0, 0, 0, 0, 0, ICANON },
  427     { "xcase", 0, 0, 0, 0, 0, 0, XCASE, 0 },
  428     { "-xcase", 0, 0, 0, 0, 0, 0, 0, XCASE },
  429     { "echo", 0, 0, 0, 0, 0, 0, ECHO, 0 },
  430     { "-echo", 0, 0, 0, 0, 0, 0, 0, ECHO },
  431     { "echoe", 0, 0, 0, 0, 0, 0, ECHOE, 0 },
  432     { "-echoe", 0, 0, 0, 0, 0, 0, 0, ECHOE },
  433     { "crterase", 0, 0, 0, 0, 0, 0, ECHOE, 0 },
  434     { "-crterase", 0, 0, 0, 0, 0, 0, 0, ECHOE },
  435     { "echok", 0, 0, 0, 0, 0, 0, ECHOK, 0 },
  436     { "-echok", 0, 0, 0, 0, 0, 0, 0, ECHOK },
  437     { "lfkc", 0, 0, 0, 0, 0, 0, ECHOK, 0 },
  438     { "-lfkc", 0, 0, 0, 0, 0, 0, 0, ECHOK },
  439     { "echonl", 0, 0, 0, 0, 0, 0, ECHONL, 0 },
  440     { "-echonl", 0, 0, 0, 0, 0, 0, 0, ECHONL },
  441     { "noflsh", 0, 0, 0, 0, 0, 0, NOFLSH, 0 },
  442     { "-noflsh", 0, 0, 0, 0, 0, 0, 0, NOFLSH },
  443     { "tostop", 0, 0, 0, 0, 0, 0, TOSTOP, 0 },
  444     { "-tostop", 0, 0, 0, 0, 0, 0, 0, TOSTOP },
  445 #ifdef ECHOCTL
  446     { "echoctl", 0, 0, 0, 0, 0, 0, ECHOCTL, 0 },
  447     { "-echoctl", 0, 0, 0, 0, 0, 0, 0, ECHOCTL },
  448     { "ctlecho", 0, 0, 0, 0, 0, 0, ECHOCTL, 0 },
  449     { "-ctlecho", 0, 0, 0, 0, 0, 0, 0, ECHOCTL },
  450 #endif
  451 #ifdef ECHOPRT
  452     { "echoprt", 0, 0, 0, 0, 0, 0, ECHOPRT, 0 },
  453     { "-echoprt", 0, 0, 0, 0, 0, 0, 0, ECHOPRT },
  454     { "prterase", 0, 0, 0, 0, 0, 0, ECHOPRT, 0 },
  455     { "-prterase", 0, 0, 0, 0, 0, 0, 0, ECHOPRT },
  456 #endif
  457 #ifdef ECHOKE
  458     { "echoke", 0, 0, 0, 0, 0, 0, ECHOKE, 0 },
  459     { "-echoke", 0, 0, 0, 0, 0, 0, 0, ECHOKE },
  460     { "crtkill", 0, 0, 0, 0, 0, 0, ECHOKE, 0 },
  461     { "-crtkill", 0, 0, 0, 0, 0, 0, 0, ECHOKE },
  462 #endif
  463     /* convenience modes */
  464     { "lcase", IUCLC, 0, OLCUC, 0, 0, 0, XCASE, 0 },
  465     { "-lcase", 0, IUCLC, 0, OLCUC, 0, 0, 0, XCASE },
  466     { "nl", 0, ICRNL, 0, ONLCR, 0, 0, 0, 0 },
  467     { "-nl", ICRNL, INLCR | IGNCR, ONLCR, OCRNL | ONLRET, 0, 0, 0, 0 },
  468     { "litout", 0, 0, OPOST, 0, CS8, CSIZE | PARENB, 0, 0 },
  469     { "-litout", 0, 0, 0, OPOST, CS7 | PARENB, CSIZE, 0, 0 },
  470     { "pass8", 0, ISTRIP, 0, 0, CS8, CSIZE | PARENB, 0, 0 },
  471     { "-pass8", ISTRIP, 0, 0, 0, CS7 | PARENB, CSIZE, 0, 0 },
  472     { "raw", 0, -1, 0, OPOST, CS8, CSIZE | PARENB, 0, ISIG | ICANON | XCASE,
  473     },
  474 #ifdef IMAXBEL
  475     { "-raw", BRKINT | IGNPAR | ISTRIP | ICRNL | IXON | IMAXBEL,
  476                 0, OPOST, 0, CS7 | PARENB, CSIZE, ISIG | ICANON, 0 },
  477     { "sane", BRKINT | IGNPAR | ISTRIP | ICRNL | IXON | IMAXBEL,
  478                 IGNBRK | PARMRK | INPCK | INLCR | IGNCR | IUCLC | IXOFF,
  479                 OPOST | ONLCR,
  480                 OLCUC | OCRNL | ONOCR | ONLRET | OFILL | OFDEL | NLDLY | CRDLY|
  481                 TABDLY | BSDLY | VTDLY | FFDLY,
  482                 CS7 | PARENB | CREAD, CSIZE | PARODD | CLOCAL,
  483                 ISIG | ICANON | ECHO | ECHOK, XCASE | ECHOE | ECHONL | NOFLSH},
  484 #endif                          /* IMAXBEL */
  485     { "cooked", BRKINT | IGNPAR | ISTRIP | ICRNL | IXON, 0, OPOST, 0,
  486                 CS7 | PARENB, CSIZE, ISIG | ICANON, 0 },
  487     {0},
  488 };
  489 
  490  void Do_stty( int fd, char *Stty_command )
  491 {
  492     int i, localmode, linedisc, argcount;
  493     char *s, *arg, *parm = 0;
  494     OBJ *l = 0;
  495 
  496     l = NEW_OBJ(0,MEMINFO);
  497     l = Split_STR_OBJ( /*p*/l, /*nomod*/1, /*str*/Stty_command,
  498             /*type*/OBJ_T_LIST, /*linesep*/WHITESPACE, /*escape*/0,
  499             /*comment*/ 0, /*trim*/1, /*keysep*/0,/*do_append*/0, /*lc*/0,
  500             /*flagvalues*/ 0, /*value_urlunesc*/0, MEMINFO );
  501 
  502 
  503     DEBUG4("Do_stty: using TERMIO, fd %d", fd );
  504     if( ioctl( fd, TCGETA, &tio) < 0) {
  505         Errorcode = JABORT;
  506         LOGERR_DIE(LOG_INFO) "cannot get tty parameters");
  507     }
  508     DEBUG4("Do_stty: before imode 0x%x, omode 0x%x, cmode 0x%x, lmode 0x%x",
  509              tio.c_iflag, tio.c_oflag, tio.c_cflag, tio.c_lflag);
  510     for( argcount = 0; argcount < LEN_LIST_OBJ(l); ++argcount ){
  511         arg = GET_ENTRY_LIST_OBJ(l,argcount);
  512         for( i = 0; tmodes[i].string && strcasecmp( tmodes[i].string, arg); i++);
  513 
  514         if( tmodes[i].string) {
  515             DEBUG4("Do_stty: modes %s, ic 0x%x is 0x%x oc 0x%x os 0x%x cc 0x%x cs 0x%x lc 0x%x ls 0x%x",
  516                      tmodes[i].string, tmodes[i].ireset, tmodes[i].iset,
  517                      tmodes[i].oreset, tmodes[i].oset, tmodes[i].creset, tmodes[i].cset,
  518                      tmodes[i].lreset, tmodes[i].lset);
  519 
  520             tio.c_iflag &= ~tmodes[i].ireset;
  521             tio.c_iflag |= tmodes[i].iset;
  522             tio.c_oflag &= ~tmodes[i].oreset;
  523             tio.c_oflag |= tmodes[i].oset;
  524             tio.c_cflag &= ~tmodes[i].creset;
  525             tio.c_cflag |= tmodes[i].cset;
  526             tio.c_lflag &= ~tmodes[i].lreset;
  527             tio.c_lflag |= tmodes[i].lset;
  528             continue;
  529         }
  530         for( i = 0; bauds[i].string && strcasecmp( bauds[i].string, arg); i++);
  531         if( bauds[i].string) {
  532             DEBUG4("Do_stty: speed %s", arg);
  533             tio.c_cflag &= ~CBAUD;
  534             tio.c_cflag |= bauds[i].speed;
  535             continue;
  536         }
  537         LOGMSG(LOG_INFO)"Do_stty: unknown mode: %s", arg);
  538     }
  539 
  540     DEBUG4("Do_stty: before imode 0x%x, omode 0x%x, cmode 0x%x, lmode 0x%x",
  541              tio.c_iflag, tio.c_oflag, tio.c_cflag, tio.c_lflag);
  542     if( ioctl( fd, TCSETA, &tio) < 0) {
  543         Errorcode = JABORT;
  544         LOGERR_DIE(LOG_INFO) "cannot set tty parameters");
  545     }
  546     Free_line_list(&l);
  547 }
  548 #endif
  549 
  550 #if USE_STTY == TERMIOS
  551 
  552 #ifndef HAVE_TCSETATTR
  553 #define tcgetattr(fd,tdat)      (ioctl( (fd), TCGETS, (tdat)))
  554 #define tcsetattr(fd,flags,tdat)    (ioctl( (fd), TCSETS, (tdat)))
  555                     /* ignore the flags arg. */
  556 #endif
  557 
  558  static struct bauds {
  559     char *string;
  560     int baud;
  561     int speed;
  562 }     bauds[] = {
  563 
  564     { "B0", 0, B0, }, { "0", 0, B0, },
  565     { "B50", 50, B50, }, { "50", 50, B50, },
  566     { "B75", 75, B75, }, { "75", 75, B75, },
  567     { "B110", 110, B110, }, { "110", 110, B110, },
  568     { "B134", 134, B134, }, { "134", 134, B134, },
  569     { "B150", 150, B150, }, { "150", 150, B150, },
  570     { "B300", 300, B300, }, { "300", 300, B300, },
  571     { "B600", 600, B600, }, { "600", 600, B600, },
  572     { "B1200", 1200, B1200, }, { "1200", 1200, B1200, },
  573     { "B1800", 1800, B1800, }, { "1800", 1800, B1800, },
  574     { "B2400", 2400, B2400, }, { "2400", 2400, B2400, },
  575     { "B4800", 4800, B4800, }, { "4800", 4800, B4800, },
  576     { "B9600", 9600, B9600, }, { "9600", 9600, B9600, },
  577     { "B19200", 19200, B19200, }, { "19200", 19200, B19200, },
  578     { "B38400", 38400, B38400, }, { "38400", 38400, B38400, },
  579     {"EXTA", EXTA, EXTA},
  580     {"EXTB", EXTB, EXTB},
  581     { (char *) 0, 0, 0 }
  582 };
  583 
  584  struct s_term_dat {
  585     char *name;
  586     uint or_dat;
  587     uint and_dat;
  588 };
  589 
  590 #define FLAGS(X) { #X, X , 0 }, { "-" #X, 0, X }
  591 
  592 /* c_iflag bits */
  593  static struct s_term_dat c_i_dat[] =
  594 {
  595     FLAGS(IGNBRK),
  596     FLAGS(BRKINT),
  597     FLAGS(IGNPAR),
  598     FLAGS(PARMRK),
  599     FLAGS(INPCK),
  600     FLAGS(ISTRIP),
  601     FLAGS(INLCR),
  602     FLAGS(IGNCR),
  603     FLAGS(ICRNL),
  604 #ifdef IUCLC
  605     FLAGS(IUCLC),
  606     {"lcase", IUCLC, 0}, {"-lcase", 0, IUCLC},
  607 #endif
  608     FLAGS(IXON),
  609     FLAGS(IXANY),
  610     FLAGS(IXOFF),
  611 
  612 #ifdef IMAXBEL
  613     FLAGS(IMAXBEL),
  614 #else
  615     /* work out what they do and simulate with IFLAGONE|IFLAGTWO */
  616 #endif
  617 
  618     /* jmason addition: */
  619     {"PASS8", 0, ISTRIP}, {"-PASS8", ISTRIP, 0},
  620     {0, 0, 0}
  621 };
  622 
  623 /* c_oflag bits */
  624  static struct s_term_dat c_o_dat[] =
  625 {
  626     FLAGS(OPOST),
  627 #ifdef OLCUC
  628     FLAGS(OLCUC),
  629 #endif
  630 #ifdef ONLCR
  631     FLAGS(ONLCR),
  632     {"crmod", ONLCR, 0}, {"-crmod", 0, ONLCR},
  633 #endif
  634 #ifdef OCRNL
  635     FLAGS(OCRNL),
  636 #endif
  637 #ifdef ONOCR
  638     FLAGS(ONOCR),
  639 #endif
  640 #ifdef ONLRET
  641     FLAGS(ONLRET),
  642 #endif
  643 #ifdef OFILL
  644     FLAGS(OFILL),
  645 #endif
  646 #ifdef OFDEL
  647     FLAGS(OFDEL),
  648 #endif
  649 #ifdef NLDLY
  650     {"NL0", 0, NLDLY},
  651     {"NL1", NL1, NLDLY},
  652 #endif
  653 #ifdef CRDLY
  654     {"CR0", CR0, CRDLY},
  655     {"CR1", CR1, CRDLY},
  656     {"CR2", CR2, CRDLY},
  657     {"CR3", CR3, CRDLY},
  658 #endif
  659 #ifdef TABDLY
  660     {"TAB0", TAB0, TABDLY},
  661     {"TAB1", TAB1, TABDLY},
  662     {"TAB2", TAB2, TABDLY},
  663     {"TAB3", TAB3, TABDLY},
  664 #endif
  665 #ifdef BSDLY
  666     {"BS0", BS0, BSDLY},
  667     {"BS1", BS1, BSDLY},
  668 #endif
  669 #ifdef VTDLY
  670     {"VT0", VT0, VTDLY},
  671     {"VT1", VT1, VTDLY},
  672 #endif
  673 #ifdef FFDLY
  674     {"FF0", FF0, FFDLY},
  675     {"FF1", FF1, FFDLY},
  676 #endif
  677 
  678     /* jmason addition: */
  679 #ifdef TABDLY
  680     {"TABS", TAB3, TABDLY},
  681 #endif
  682     {0, 0, 0}
  683 };
  684 
  685 /* c_cflag bit meaning */
  686  static struct s_term_dat c_c_dat[] =
  687 {
  688     {"CS5", CS5, CSIZE},
  689     {"CS6", CS6, CSIZE},
  690     {"CS7", CS7, CSIZE},
  691     {"CS8", CS8, CSIZE},
  692     {"CSTOPB", CSTOPB, 0},
  693     {"-CSTOPB", 0, CSTOPB},
  694     {"CREAD", CREAD, 0},
  695     {"-CREAD", 0, CREAD},
  696     {"PARENB", PARENB, 0},
  697     {"-PARENB", 0, PARENB},
  698     {"PARODD", PARODD, 0},
  699     {"-PARODD", 0, PARODD},
  700     {"HUPCL", HUPCL, 0},
  701     {"-HUPCL", 0, HUPCL},
  702     {"CLOCAL", CLOCAL, 0},
  703     {"-CLOCAL", 0, CLOCAL},
  704 
  705 #ifdef CRTSCTS
  706     /* work out what they do and simulate with IFLAGONE|IFLAGTWO */
  707     {"CRTSCTS", CRTSCTS, 0},
  708     {"-CRTSCTS", 0, CRTSCTS},
  709 #endif
  710 
  711     /* jmason additions, from SunOS stty(1v) combination modes: */
  712     /* fixed, papowell Sun Aug 20 06:54:56 PDT 1995 */
  713     {"even", PARENB | CS7, PARODD | CSIZE},
  714     {"-even", CS8, PARENB | CSIZE},
  715     {"EVENP", PARENB | CS7, PARODD | CSIZE},
  716     {"-EVENP", CS8, PARENB | CSIZE},
  717     {"PARITY", PARENB | CS7, PARODD | CSIZE},
  718     {"-PARITY", CS8, PARENB | CSIZE},
  719     {"odd", PARODD| PARENB | CS7, CSIZE},
  720     {"-odd", CS8, PARENB | PARODD | CSIZE},
  721     {"ODDP", PARODD | PARENB | CS7, CSIZE},
  722     {"-ODDP", CS8, PARENB | PARODD | CSIZE},
  723     {"PASS8", CS8, PARENB | CSIZE},
  724     {"-PASS8", PARENB | CS7, CSIZE},
  725     {"LITOUT", CS8, ISTRIP | PARENB | OPOST | CSIZE},
  726     {0, 0, 0}
  727 };
  728 
  729 /* c_lflag bits */
  730  static struct s_term_dat c_l_dat[] =
  731 {
  732     {"ISIG", ISIG, 0},
  733     {"-ISIG", 0, ISIG},
  734     {"cooked", ICANON, 0},
  735     {"-raw", ICANON, 0},
  736     {"cbreak", ICANON, 0},
  737     {"ICANON", ICANON, 0},
  738     {"-ICANON", 0, ICANON},
  739     {"raw", 0, ICANON},
  740     {"-cooked", 0, ICANON},
  741 #ifdef XCASE
  742     {"XCASE", XCASE, 0},
  743     {"-XCASE", 0, XCASE},
  744 #endif
  745     {"ECHO", ECHO, 0},
  746     {"-ECHO", 0, ECHO},
  747     {"ECHOE", ECHOE, 0},
  748     {"-ECHOE", 0, ECHOE},
  749     {"ECHOK", ECHOK, 0},
  750     {"-ECHOK", 0, ECHOK},
  751     {"ECHONL", ECHONL, 0},
  752     {"-ECHONL", 0, ECHONL},
  753     {"NOFLSH", NOFLSH, 0},
  754     {"-NOFLSH", 0, NOFLSH},
  755     {"TOSTOP", TOSTOP, 0},
  756     {"-TOSTOP", 0, TOSTOP},
  757     {"IEXTEN", IEXTEN, 0},
  758     {"-IEXTEN", 0, IEXTEN},
  759 
  760 #ifdef ECHOCTL
  761     {"ECHOCTL", ECHOCTL, 0},
  762     {"-ECHOCTL", 0, ECHOCTL},
  763     {"CTLECHO", ECHOCTL, 0},
  764     {"-CTLECHO", 0, ECHOCTL},
  765 #else
  766     /* work out what they do and simulate with IFLAGONE|IFLAGTWO */
  767 #endif
  768 #ifdef ECHOPRT
  769     {"ECHOPRT", ECHOPRT, 0},
  770     {"-ECHOPRT", 0, ECHOPRT},
  771     {"PRTERASE", ECHOPRT, 0},
  772     {"-PRTERASE", 0, ECHOPRT},
  773     /* ditto etc. -- you get the story */
  774 #endif
  775 #ifdef ECHOKE
  776     {"ECHOKE", ECHOKE, 0},
  777     {"-ECHOKE", 0, ECHOKE},
  778     {"CRTKILL", ECHOKE, 0},
  779     {"-CRTKILL", 0, ECHOKE},
  780 #endif
  781 #ifdef FLUSHO
  782     {"FLUSHO", FLUSHO, 0},
  783     {"-FLUSHO", 0, FLUSHO},
  784 #endif
  785 #ifdef PENDIN
  786     {"PENDIN", PENDIN, 0},
  787     {"-PENDIN", 0, PENDIN},
  788 #endif
  789     { 0 ,0 ,0 }
  790 };
  791 
  792  struct termios t_dat;
  793 
  794  static struct special {
  795     char *name;
  796     char *cp;
  797 }       special[] = {
  798 
  799     { "stop", (char *)&(t_dat.c_cc[VSTOP]) },
  800     { "start", (char *)&(t_dat.c_cc[VSTART]) },
  801     { 0, 0 }
  802 };
  803 
  804  void Do_stty( int fd, char *Stty_command )
  805 {
  806     int i, argcount;
  807     char *arg, *parm = 0;
  808     OBJ *l = 0;
  809 
  810     l = NEW_OBJ(0,MEMINFO);
  811     l = Split_STR_OBJ( /*p*/l, /*nomod*/1, /*str*/Stty_command,
  812             /*type*/OBJ_T_LIST, /*linesep*/WHITESPACE, /*escape*/0,
  813             /*comment*/ 0, /*trim*/1, /*keysep*/0,/*do_append*/0, /*lc*/0,
  814             /*flagvalues*/ 0, /*value_urlunesc*/0, MEMINFO );
  815 
  816     DEBUG4("Do_stty: using TERMIOS, fd %d", fd );
  817     if( tcgetattr( fd, &t_dat) < 0 ){
  818         Errorcode = JABORT;
  819         LOGERR_DIE(LOG_INFO)"cannot get tty parameters");
  820     }
  821     DEBUG4("Do_stty: before iflag 0x%x, oflag 0x%x, cflag 0x%x lflag 0x%x",
  822              t_dat.c_iflag, t_dat.c_oflag, t_dat.c_cflag, t_dat.c_lflag);
  823     for( argcount = 0; argcount < LEN_LIST_OBJ(l); ++argcount ){
  824         arg = GET_ENTRY_LIST_OBJ(l,argcount);
  825         for( i = 0; bauds[i].string && strcasecmp( bauds[i].string, arg); i++);
  826         if( bauds[i].string ){
  827 #ifdef HAVE_CFSETISPEED
  828             DEBUG4("Do_stty: using cfsetispeed/cfsetospeed, speed %s, spd %d",
  829                 arg, bauds[i].speed );
  830             /* POSIX baudrate manipulation */
  831             cfsetispeed( &t_dat, bauds[i].speed);
  832             cfsetospeed( &t_dat, bauds[i].speed);
  833 #else
  834             DEBUG4("Do_stty: setting tdat.c_cflag");
  835             t_dat.c_cflag &= ~CBAUD;
  836             t_dat.c_cflag |= bauds[i].speed;
  837 #endif
  838             continue;
  839         }
  840         for( i = 0; c_i_dat[i].name && strcasecmp( c_i_dat[i].name, arg); i++);
  841         if( c_i_dat[i].name ){
  842             DEBUG4("Do_stty: c_iflag %s, ms 0x%x mc 0x%x",
  843                      c_i_dat[i].name, c_i_dat[i].or_dat, c_i_dat[i].and_dat);
  844             t_dat.c_iflag &= ~(c_i_dat[i].and_dat);
  845             t_dat.c_iflag |= c_i_dat[i].or_dat;
  846             continue;
  847         }
  848         for( i = 0; c_o_dat[i].name && strcasecmp( c_o_dat[i].name, arg); i++);
  849         if( c_o_dat[i].name ){
  850             DEBUG4("Do_stty: c_oflag %s, ms 0x%x mc 0x%x",
  851                      c_o_dat[i].name, c_o_dat[i].or_dat, c_o_dat[i].and_dat);
  852             t_dat.c_oflag &= ~(c_o_dat[i].and_dat);
  853             t_dat.c_oflag |= c_o_dat[i].or_dat;
  854             continue;
  855         }
  856         for( i = 0; c_c_dat[i].name && strcasecmp( c_c_dat[i].name, arg); i++);
  857         if( c_c_dat[i].name ){
  858             DEBUG4("Do_stty: c_cflag %s, ms 0x%x mc 0x%x",
  859                      c_c_dat[i].name, c_c_dat[i].or_dat, c_c_dat[i].and_dat);
  860             t_dat.c_cflag &= ~(c_c_dat[i].and_dat);
  861             t_dat.c_cflag |= c_c_dat[i].or_dat;
  862             continue;
  863         }
  864         for( i = 0; c_l_dat[i].name && strcasecmp( c_l_dat[i].name, arg); i++);
  865         if( c_l_dat[i].name ){
  866             DEBUG4("Do_stty: c_lflag %s, ms 0x%x mc 0x%x",
  867                      c_l_dat[i].name, c_l_dat[i].or_dat, c_l_dat[i].and_dat);
  868             t_dat.c_lflag &= ~(c_l_dat[i].and_dat);
  869             t_dat.c_lflag |= c_l_dat[i].or_dat;
  870             continue;
  871         }
  872         for( i = 0; special[i].name && strcasecmp( special[i].name, arg); i++);
  873         if( special[i].name ){
  874             if( ++argcount < LEN_LIST_OBJ(l) ){
  875                 parm = GET_ENTRY_LIST_OBJ(l,argcount);
  876             } else {
  877                 Errorcode = JABORT;
  878                 FATAL(LOG_INFO)  "Do_stty: missing parameter for %s\n", arg);
  879             }
  880             if( parm[0] == '^') {
  881                 if( parm[1] == '?' ){
  882                     *special[i].cp = 0177;
  883                 } else {
  884                     *special[i].cp = 037 & parm[1];
  885                 }
  886             } else {
  887                 *special[i].cp = parm[0];
  888             }
  889             DEBUG4("Do_stty: special %s %s", arg, parm);
  890             continue;
  891         }
  892         LOGMSG(LOG_INFO)"Do_stty: unknown mode: %s", arg);
  893     }
  894 
  895     if( (t_dat.c_lflag & ICANON) == 0 ){
  896         /* only do this if ICANON is off -- Martin Forssen */
  897         DEBUG4("setting port to read/write with unbuffered reads( MIN=1, TIME=0)");
  898         t_dat.c_cc[VMIN] = 1;
  899         t_dat.c_cc[VTIME] = 0;
  900     }
  901     DEBUG4("Do_stty: after iflag 0x%x, oflag 0x%x, cflag 0x%x lflag 0x%x",
  902              t_dat.c_iflag, t_dat.c_oflag, t_dat.c_cflag, t_dat.c_lflag);
  903 
  904     if( tcsetattr( fd, TCSANOW, &t_dat) < 0 ){
  905         Errorcode = JABORT;
  906         LOGERR_DIE(LOG_INFO) "cannot set tty parameters");
  907     }
  908 }
  909 #endif