home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1557 / cleanup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  1.3 KB  |  48 lines

  1.  
  2. /*
  3.  * Copyright (C) 1990 by Jay Konigsberg. mail: jak@sactoh0
  4.  *
  5.  * Permission to use, copy, modify, and distribute this  software  and  its
  6.  * documentation is hereby  granted,  provided  that  the  above  copyright
  7.  * notice appear in all copies  and that  both  the  copyright  notice  and
  8.  * this permission notice appear in supporting documentation. This software
  9.  * is provided "as is" without express or implied  warranty.  However,  the
  10.  * author retains all Copyright priviliges and rights  to  renumeration  if
  11.  * this software is sold.
  12.  */
  13.  
  14. /*
  15.  * cleanup - resets port settings to what they were before entering
  16.  * raw mode.
  17.  */
  18.  
  19. #include "simped.h"
  20.  
  21. /* Global for interrupt routine: cleanup() */
  22. extern    struct      termio  ttyset;    /* terminal settings */
  23. extern    unsigned  short   c_lflag_hold;    /* hold original values for reset */
  24. extern    unsigned  char    VEOF_hold;    /* hold original value for reset */
  25.  
  26. int cleanup(sig_caught) /* Signal trap for SIGINT */
  27. int    sig_caught;
  28. {
  29. void    exit();
  30.  
  31. int    ioctl(),
  32.     fprintf();
  33.  
  34. /* reset terminal charastics */
  35. ttyset.c_lflag = c_lflag_hold;
  36. ttyset.c_cc[4] = VEOF_hold;
  37. if ( ioctl(0, TCSETAW, &ttyset) == -1) {
  38.     fprintf(stderr, "ioctl: error=%d\n", errno);
  39.     exit(2);
  40. }
  41. if (sig_caught)
  42.     {
  43.     fprintf(stderr,"\nMessage aborted.\n");
  44.     }
  45. exit(2);
  46. return(0);
  47. }
  48.