home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / most423.zip / sysdep.c < prev    next >
C/C++ Source or Header  |  1997-03-07  |  18KB  |  726 lines

  1. /*
  2.  * HISTORY
  3.  * {1}  19-Mar-91  Henk D. Davids <hdavids@mswe.dnet.ms.philips.nl>
  4.  *      History started. Added default input file name so you do not
  5.  *      have to specify name or type if you want it to be *.
  6.  *      Changes indicated by "-hdd" in comment.
  7.  *
  8.  *  2.  4/4/91  John E. Davis
  9.  *      I added code to read the teminal size for unix systems-- at least it
  10.  *      works on a sun4 (BSD ?).  In addition I have also recently added file
  11.  *      deletion code for both unix and vms.
  12.  */
  13. #ifdef VMS
  14. #include <ssdef.h>
  15. #include <rmsdef.h>
  16. #include <dvidef.h>
  17. #include <jpidef.h>
  18. /* #include <libdef.h> */
  19. #include <descrip.h>
  20. #include <iodef.h>
  21. #include <ttdef.h>
  22. #include <stdlib.h>
  23. /* #include <unixlib.h> */
  24. #endif
  25.  
  26.  
  27.  
  28. #ifdef unix
  29. # include <signal.h>
  30. # ifdef SYSV
  31. #  include <sys/types.h>
  32. #  include <fcntl.h>
  33. # endif
  34. # include <sys/file.h>
  35. #endif
  36.  
  37. #include "externs.h"
  38. #include "sysdep.h"
  39. #include "display.h"
  40. #include "window.h"
  41.  
  42. #ifdef VMS
  43. typedef struct {                /* I/O status block     */
  44.         short i_cond;           /* Condition value      */
  45.         short i_xfer;           /* Transfer count     */
  46.         long  i_info;           /* Device information     */
  47. } iosb;
  48.  
  49. typedef struct {                /* Terminal characteristics   */
  50.         char  t_class;          /* Terminal class     */
  51.         char  t_type;           /* Terminal type      */
  52.         short t_width;          /* Terminal width in characters   */
  53.         long  t_mandl;          /* Terminal's mode and length   */
  54.         long  t_extend;         /* Extended terminal characteristics  */
  55. }  termchar;
  56.  
  57. short TTY_CHANNEL_GLOBAL;
  58. static int zero = 0;
  59.  
  60. #else
  61. int TTY_DESCR;
  62. #endif /* VMS */
  63.  
  64. /*
  65.  *
  66.  *
  67.  *                          SHELL COMMANDS
  68.  *
  69.  */
  70.  
  71. #ifdef VMS
  72.  
  73. /* these two from emacs source */
  74. void define_logical_name (char *varname, char *string)
  75. {
  76.   static char sstring[200], svarname[200];
  77.  
  78.    struct dsc$descriptor_s strdsc =
  79.      {strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, sstring};
  80.    struct dsc$descriptor_s envdsc =
  81.      {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, svarname};
  82.    struct dsc$descriptor_s lnmdsc =
  83.      {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"};
  84.  
  85.    strcpy(sstring, string); strcpy(svarname, varname);
  86.  
  87.    LIB$SET_LOGICAL (&envdsc, &strdsc, &lnmdsc, 0, 0);
  88. }
  89.  
  90. void delete_logical_name (char *varname)
  91. {
  92.     struct dsc$descriptor_s envdsc =
  93.       {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname};
  94.     struct dsc$descriptor_s lnmdsc =
  95.       {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"};
  96.  
  97.     LIB$DELETE_LOGICAL (&envdsc, &lnmdsc);
  98. }
  99.  
  100.  
  101. int do_emacs_command()
  102. {
  103.     unsigned long pid;
  104.     char *pidstr;
  105.  
  106.     if((pidstr = getenv("EMACS_PID")) != NULL)
  107.       {
  108.           (void) sscanf(pidstr,"%X",&pid);
  109.           if (lib$attach(&pid) == SS$_NORMAL) /* we attach to emacs */
  110.             return(1);
  111.           else
  112.             return(0);
  113.           /*        printf("Can't attach to pid %X\n",pid); */
  114.       }
  115.     else return(0);
  116. }
  117.  
  118. unsigned long SHELL_PID = 0;
  119.  
  120. /* returns 0 on success */
  121. int do_shell_command()
  122. {
  123.     /* here we try to attach to the parent otherwise just spawn a new one */
  124.     unsigned long parent_pid;
  125.     unsigned long status = 0;
  126.     char str[80];
  127.  
  128.     $DESCRIPTOR(MOST_$_descr, "MOST > ");
  129.  
  130.     parent_pid = getppid();
  131.  
  132.     if (parent_pid && parent_pid != 0xffffffff)
  133.       /* we attach to parent */
  134.       status = lib$attach(&parent_pid);
  135.  
  136.     else if (SHELL_PID && SHELL_PID != 0xffffffff)
  137.       /* try to attach to previous shell */
  138.       status = lib$attach (&SHELL_PID);
  139.  
  140.     if (status != SS$_NORMAL)           /* others fail so spawn a new shell */
  141.       {
  142.           status = 0;
  143.           send_string_to_term("Spawning MOST DCL SUBPROCESS (Logout when finished)...");
  144.           lib$spawn(0,0,0,0,0,&SHELL_PID,&status,0,0,0,&MOST_$_descr);
  145.           /* if we attach back, status may come back unchanged */
  146.           if ((status != 0) && (status != SS$_NORMAL))
  147.             {
  148.                 sprintf(str,"Unable to spawn subprocess. Error = %X", status);
  149.                 message(str,1);
  150.                 return(0);
  151.             }
  152.       }
  153.    message(" ",0);  /* make sure message window is restored */
  154.     return(1);
  155. }
  156.  
  157. #endif /* VMS */
  158.  
  159. /*
  160.  *                            FILE IO
  161.  *
  162.  */
  163.  
  164. #ifdef VMS
  165. int expand_file_name(char *file,char *expanded_file)
  166. {
  167.     unsigned long status;
  168.     static int context = 0, len = 0;
  169.     static char inputname[255] = "";
  170.     $DESCRIPTOR(file_desc,inputname);
  171.     $DESCRIPTOR(default_dsc,"SYS$DISK:[]*.*;");
  172.     static struct dsc$descriptor_s  result =
  173.             {0, DSC$K_DTYPE_T, DSC$K_CLASS_D, NULL};
  174.  
  175.     if (strcmp(inputname, file))
  176.       {
  177.           if (context)
  178.             {
  179.                 lib$find_file_end(&context);
  180.             }
  181.           context = 0;
  182.           strcpy(inputname, file);
  183.          len = strlen(inputname);
  184.       }
  185.    file_desc.dsc$w_length = len;
  186.  
  187.     if (RMS$_NORMAL == lib$find_file(&file_desc,&result,&context,
  188.                                      &default_dsc,0,0,&zero))
  189.       {
  190.           memcpy(expanded_file, result.dsc$a_pointer, result.dsc$w_length);
  191.           expanded_file[result.dsc$w_length] = '\0';
  192.           return (1);
  193.       }
  194.     else
  195.       {
  196.           expanded_file[0] = '\0';       /* so file comes back as zero width */
  197.           return(0);
  198.       }
  199. }
  200. #endif /* VMS */
  201.  
  202. /*
  203.  *
  204.  *
  205.  *         Terminal IO
  206.  *
  207.  */
  208.  
  209. #ifdef VMS
  210. /*
  211.  *      Exit Handler Control Block
  212.  */
  213. static struct argument_block
  214.     {
  215.     int forward_link;
  216.     int (*exit_routine)();
  217.     int arg_count;
  218.     int *status_address;
  219.     int exit_status;
  220.     } exit_block
  221.       = {
  222.         0,
  223.         NULL,
  224.         1,
  225.         &exit_block.exit_status,
  226.         0
  227.       };
  228.  
  229. /*
  230. ** For deciding whether to request a terminal channel.
  231. */
  232. static int first_request_for_MostTT_chan   = 1;
  233.  
  234. #endif
  235.  
  236. #ifdef unix
  237.  
  238. #ifndef sequent
  239. # include <stdlib.h>
  240. #endif
  241. #include <sys/time.h>
  242. #include <sys/ioctl.h>
  243. #ifndef apollo
  244. # include <unistd.h>
  245. #endif
  246. #if HAS_TERMIOS
  247. # include <termios.h>
  248. #endif
  249. #ifdef __EMX__
  250. # include <termio.h>
  251. #endif
  252. #ifdef SYSV
  253. # include <sys/termio.h>
  254. # include <sys/stream.h>
  255. # include <sys/ptem.h>
  256. # include <sys/tty.h>
  257. #endif
  258. #include <sys/types.h>
  259. #include <sys/stat.h>
  260. #include <errno.h>
  261.  
  262. #if !HAS_TERMIOS
  263. struct ttystuff
  264.   {
  265.       struct tchars t;
  266.       struct ltchars lt;
  267.       struct sgttyb s;
  268.   };
  269. struct ttystuff OLDTTY;
  270. #else
  271. struct termios OLDTTY;
  272. #endif
  273.  
  274.      /* this next works on ultrix for setting termios */
  275. #ifdef TCGETS
  276. #define GET_TERMIOS(fd, x) ioctl(fd, TCGETS, x)
  277. #define SET_TERMIOS(fd, x) ioctl(fd, TCSETS, x)
  278. #else
  279. # if !HAS_TERMIOS
  280. #  define X(x,m)  &(((struct ttystuff*)(x))->m)
  281. #  define GET_TERMIOS(fd, x)    \
  282.         if(ioctl(fd, TIOCGETC, X(x,t))<0 || \
  283.         ioctl(fd, TIOCGLTC, X(x,lt))<0 || \
  284.         ioctl(fd, TIOCGETP, X(x,s))<0)exit_error("Can't get terminal info")
  285. #  define SET_TERMIOS(fd, x)    \
  286.         if(ioctl(fd, TIOCSETC, X(x,t))<0 || \
  287.         ioctl(fd, TIOCSLTC, X(x,lt))<0 || \
  288.         ioctl(fd, TIOCSETP, X(x,s))<0)exit_error("Can't set terminal info")
  289. # else
  290. #  define GET_TERMIOS(fd, x) tcgetattr(fd, x)
  291. #  define SET_TERMIOS(fd, x) tcsetattr(fd, TCSANOW, x)
  292. # endif
  293. #endif
  294. #endif
  295.  
  296. #ifdef unix
  297. static void open_term()
  298. {
  299.    if ((TTY_DESCR = open("/dev/tty",O_RDONLY)) < 0)
  300.      {
  301.         exit_error("Unable to open tty.");
  302.      }
  303. }
  304. #endif
  305.  
  306.  
  307. void init_tty()
  308. {
  309. #ifdef VMS
  310.     $DESCRIPTOR ( Term, "SYS$ERROR");
  311.    if (first_request_for_MostTT_chan)
  312.      {
  313.         if (sys$assign ( &Term, &TTY_CHANNEL_GLOBAL, 0, 0 )
  314.             != SS$_NORMAL)
  315.           {
  316.              fprintf(stderr,"Unable to assign input channel\n");
  317.              exit(0);
  318.           }
  319.         if (NULL == exit_block.exit_routine)
  320.           {
  321.              reset_tty();
  322.              exit_block.exit_routine = reset_tty;
  323.              SYS$DCLEXH(&exit_block);
  324.           }
  325.         first_request_for_MostTT_chan = 0;
  326.      }
  327. #else
  328.    /* unix */
  329.  
  330. #if !HAS_TERMIOS
  331.     struct ttystuff newtty;
  332. #else
  333.     struct termios newtty;
  334. #endif
  335.    enable_cursor_keys();
  336.    open_term();
  337.    GET_TERMIOS(TTY_DESCR, &OLDTTY);
  338.    GET_TERMIOS(TTY_DESCR, &newtty);
  339. #if !HAS_TERMIOS
  340.    newtty.s.sg_flags &= ~(ECHO);
  341.    newtty.s.sg_flags &= ~(CRMOD);
  342.    newtty.t.t_eofc = 1;
  343.    newtty.t.t_intrc = 255;      /* */
  344.    newtty.t.t_quitc = 255;
  345.    newtty.lt.t_suspc = 255;   /* to ignore ^Z */
  346.    newtty.lt.t_lnextc = 255;
  347.    newtty.s.sg_flags |= CBREAK;         /* do I want cbreak or raw????? */
  348. #else
  349.  
  350.    newtty.c_iflag &= ~(ECHO | INLCR | ICRNL);
  351.    newtty.c_oflag |= ONLCR;            /* map newline to cr/newline on out */
  352.    newtty.c_oflag &= ~OCRNL;
  353.    newtty.c_cc[VMIN] = 1;
  354.    newtty.c_cc[VTIME] = 0;
  355.    newtty.c_cc[VEOF] = 1;
  356.    newtty.c_lflag = ISIG | NOFLSH;
  357.    newtty.c_cc[VINTR] = 255;   /* ^G */
  358.    newtty.c_cc[VQUIT] = 255;
  359.    newtty.c_cc[VSUSP] = 255;   /* to ignore ^Z */
  360. #ifdef VSWTCH
  361.    newtty.c_cc[VSWTCH] = 255;   /* to ignore who knows what */
  362. #endif
  363. #endif /* HAS_TERMIOS */
  364.    SET_TERMIOS(TTY_DESCR, &newtty);
  365. /* VMS */
  366. #endif
  367. }
  368.  
  369. int reset_tty()
  370. {
  371. #ifdef unix
  372.    SET_TERMIOS(TTY_DESCR, &OLDTTY);
  373.    close(TTY_DESCR);
  374. #endif
  375.    return(0);
  376. }
  377.  
  378. int INPUT_BUFFER_LEN = 0;
  379. char INPUT_BUFFER[80];
  380.  
  381. char sys_getkey()
  382. {
  383.     char c;
  384.  
  385. #ifndef VMS
  386.     if (read(TTY_DESCR, &c, 1) < 0)
  387.       {
  388.           fprintf(stderr,"getkey():  read failed.\n");
  389.           reset_tty();
  390.           exit(0);
  391.       }
  392. #else
  393.     /* VMS */
  394.     /* see Guide to Programming VAX/VMS */
  395.     int status;
  396.     static int trmmsk [2] = { 0, 0 };
  397.     short iosb [4];
  398.  
  399.     status = sys$qiow ( 0, TTY_CHANNEL_GLOBAL,
  400.                        IO$_READVBLK | IO$M_NOECHO | IO$_TTYREADALL,
  401.                        iosb, 0, 0,
  402.                        &c, 1, 0, trmmsk, 0, 0 );
  403.  
  404. #endif  /* VMS */
  405.  
  406.     return(c);
  407. }
  408.  
  409. char getkey()
  410. {
  411.    int i;
  412.    int ch;
  413.    if (!INPUT_BUFFER_LEN)
  414.      {
  415.         ch = sys_getkey();
  416.  
  417.         ch &= 0x7F;
  418.         return(ch);
  419.      }
  420.  
  421.     ch = INPUT_BUFFER[0];
  422.     INPUT_BUFFER_LEN--;
  423.     for (i = 0; i < INPUT_BUFFER_LEN; i++)
  424.       {
  425.           INPUT_BUFFER[i] = INPUT_BUFFER[i + 1];
  426.       }
  427.     return(ch);
  428. }
  429.  
  430. void ungetkey(char ch)
  431. {
  432.     int i;
  433.     for (i = 0; i < INPUT_BUFFER_LEN; i++)
  434.       {
  435.           INPUT_BUFFER[i+1] = INPUT_BUFFER[i];
  436.       }
  437.     INPUT_BUFFER[0] = ch;
  438.     INPUT_BUFFER_LEN++;
  439. }
  440.  
  441.  
  442. /*
  443.  *
  444.  *      Misc Termial stuff
  445.  *
  446.  *
  447.  */
  448.  
  449.  
  450. /*  This is to get the size of the terminal  */
  451. void get_term_dimensions(int *cols, int *rows)
  452. {
  453. #ifdef VMS
  454.     int status;
  455.     iosb iostatus;
  456.     $DESCRIPTOR(devnam, "SYS$ERROR");
  457.     struct
  458.         {
  459.         short row_buflen;
  460.         short row_itmcod;
  461.         int *row_bufadr;
  462.         short *row_retlen;
  463.         short col_buflen;
  464.         short col_itmcod;
  465.         int *col_bufadr;
  466.         short *col_retlen;
  467.         int listend;
  468.         } itmlst =
  469.         {
  470.         sizeof(*rows), DVI$_TT_PAGE, rows, 0,
  471.         sizeof(*cols), DVI$_DEVBUFSIZ, cols, 0,
  472.         0
  473.         };
  474.  
  475.     /* Get current terminal characteristics */
  476.     status = sys$getdviw(0,           /* Wait on event flag zero  */
  477.                          0,           /* Channel to input terminal  */
  478.                          &devnam,     /* device name */
  479.                          &itmlst,         /* Item descriptor List */
  480.                          &iostatus,   /* Status after operation */
  481.                          0, 0,        /* No AST service   */
  482.                          0);          /* nullarg */
  483.     if (status&1)
  484.         status = iostatus.i_cond;
  485.     /* Jump out if bad status */
  486.     if ((status & 1) == 0)
  487.       exit(status);
  488. #else    /* this may need work on other unix-- works for sun4 */
  489. #ifdef TIOCGWINSZ
  490.    struct winsize wind_struct;
  491.  
  492.    ioctl(TTY_DESCR,TIOCGWINSZ,&wind_struct);
  493.    *cols = (int) wind_struct.ws_col;
  494.    *rows = (int) wind_struct.ws_row;
  495. #ifdef __EMX__
  496.    if (*rows <= 0) *rows = 25;
  497. #else
  498.    if (*rows <= 0) *rows = 24;
  499. #endif
  500.    if (*cols <= 0) *cols = 80;
  501. #else
  502. #ifdef __EMX__
  503.    {
  504.      int scrsize[2];
  505.      _scrsize(scrsize);
  506.      *cols = scrsize[0];
  507.      *rows = scrsize[1];
  508.    }
  509.    if (*rows <= 0) *rows = 25;
  510.    if (*cols <= 0) *cols = 80;
  511. #else
  512.    *rows = 24;
  513.    *cols = 80;
  514. #endif
  515. #endif
  516. #endif /* VMS */
  517. }
  518.  
  519. /* returns 0 on failure, 1 on sucess */
  520. int sys_delete_file(char *filename)
  521. {
  522. #ifdef VMS
  523.     return (1 + delete(filename));   /* 0: sucess; -1 failure */
  524. #else  /* unix not ready yet */
  525.     return(1 + unlink(filename));
  526. #endif
  527. }
  528.  
  529.  
  530. /* This routine converts unix type names to vms names */
  531. #ifdef VMS
  532. int locate(char ch, char *string)
  533. {
  534.     int i;
  535.     char c;
  536.  
  537.     i = 0;
  538.     while (c = string[i++], (c != ch) && (c != '\0'));
  539.     if (c == ch) return(i); else return (0);
  540. }
  541.  
  542. char *unix2vms(char *file)
  543. {
  544.     int i,device,j,first,last;
  545.     static char vms_name[80];
  546.     char ch;
  547.  
  548.     if (locate('[',file)) return(file); /* vms_name syntax */
  549.     if (!locate('/',file)) return(file); /* vms_name syntax */
  550.  
  551.     /* search for the ':' which means a device is present */
  552.     device = locate(':',file);
  553.  
  554.     i = 0;
  555.     if (device)
  556.       {
  557.           while (ch = file[i], i < device) vms_name[i++] = ch;
  558.       }
  559.     j = i;
  560.  
  561.     /* go from the  end looking for a '/' and mark it */
  562.     i = strlen(file) - 1;
  563.     while(ch = file[i], ch != '/' && i-- >= 0);
  564.     if (ch == '/')
  565.       {
  566.           file[i] = ']';
  567.           last = 0;
  568.       }
  569.     else last = 1;
  570.  
  571.     i = j;
  572.     vms_name[j++] = '[';
  573.     vms_name[j++] = '.';
  574.     first = 0;
  575.     while(ch = file[i++], ch != '\0')
  576.       {
  577.           switch (ch)
  578.             {
  579.               case '.':
  580.                 if (last) vms_name[j++] = '.';
  581.                 if (last) break;
  582.                 ch = file[i++];
  583.                 if (ch == '.')
  584.                   {
  585.                       if (!first) j--;  /* overwrite the dot */
  586.                       vms_name[j++] = '-';
  587.                   }
  588.                 else if (ch == '/'); /*  './' combinations-- do nothing */
  589.                 else if (ch == ']')
  590.                   {
  591.                       last = 1;
  592.                       if (vms_name[j-1] == '.') j--;
  593.                       vms_name[j++] = ']';
  594.                   }
  595.  
  596.                 else vms_name[j++] = '.';
  597.                 break;
  598.               case '/':
  599.                 if (first)
  600.                   {
  601.                       vms_name[j++] = '.';
  602.                   }
  603.                 else
  604.                   {
  605.                       first = 1;
  606.                       /* if '/' is first char or follows a colon do nothing */
  607.                       if ((i!=1) && (file[i-2] != ':'))
  608.                         {
  609.                             vms_name[j++] = '.';
  610.                         }
  611.                       else j--; /* overwrite the '.' following '[' */
  612.                   }
  613.                 break;
  614.               case ']':
  615.                 last = 1;
  616.                 if (vms_name[j-1] == '.') j--;
  617.                 vms_name[j++] = ']';
  618.                 break;
  619.               default:
  620.                 vms_name[j++] = ch;
  621.             }
  622.       }
  623.     return (vms_name);
  624. }
  625.  
  626. /*
  627. main(int argc, char **argv)
  628. {
  629.     puts(unix2vms(argv[1]));
  630. }
  631. */
  632.  
  633. #endif /* VMS */
  634.  
  635. #include <time.h>
  636.  
  637. char *get_time()
  638. {
  639.     time_t clock;
  640.     char *the_time;
  641.  
  642.    clock = time((time_t *) 0);
  643.    the_time = (char *) ctime(&clock);
  644.    /* returns the form Sun Sep 16 01:03:52 1985\n\0 */
  645.     the_time[24] = '\0';
  646.     return(the_time);
  647. }
  648.  
  649. extern int SCREEN_WIDTH;
  650.  
  651. void set_width(int width, int redraw)
  652. {
  653. #ifdef VMS
  654.     short fd;
  655.     int status;
  656.     iosb iostatus;
  657.     static termchar tc; /* Terminal characteristics   */
  658.     $DESCRIPTOR( devnam, "SYS$ERROR");
  659. #else
  660. #ifdef TIOCSWINSZ
  661.     struct winsize wind_struct;
  662. #endif
  663. #endif
  664.  
  665.     /* Switching physical terminal to narrow/wide mode.*/
  666.  
  667.     if(width<=80)
  668.       {
  669.           width = 80;
  670.           narrow_width();
  671.       }
  672.     else
  673.       {
  674.           width = 132;
  675.           wide_width();
  676.       }
  677.     SCREEN_WIDTH = width;
  678.  
  679. #ifdef VMS
  680.     /* Assign input to a channel */
  681.     status = sys$assign(&devnam, &fd, 0, 0);
  682.     if ((status & 1) == 0)
  683.       exit(status);
  684.     /* Get current terminal characteristics */
  685.     status = sys$qiow(          /* Queue and wait   */
  686.                       0,        /* Wait on event flag zero  */
  687.                       fd,       /* Channel to input terminal  */
  688.                       IO$_SENSEMODE, /* Get current characteristic */
  689.                       &iostatus, /* Status after operation */
  690.                       0, 0,     /* No AST service   */
  691.                       &tc,      /* Terminal characteristics buf */
  692.                       sizeof(tc), /* Size of the buffer   */
  693.                       0, 0, 0, 0); /* P3-P6 unused     */
  694.  
  695.     /*set terminal characteristics */
  696.     tc.t_width=width;
  697.     status = sys$qiow(           /* Queue and wait   */
  698.                       0,           /* Wait on event flag zero  */
  699.                       fd,           /* Channel to input terminal  */
  700.                       IO$_SETMODE,   /* Get current characteristic */
  701.                       &iostatus,       /* Status after operation */
  702.                       0, 0,            /* No AST service   */
  703.                       &tc,             /* Terminal characteristics buf */
  704.                       sizeof(tc),      /* Size of the buffer   */
  705.                       0, 0, 0, 0);     /* P3-P6 unused     */
  706.  
  707.     if( (sys$dassgn(fd)  & 1)==0)
  708.       exit(status);
  709.  
  710.     /* here we redraw the screen, on unix, we assume that the terminal
  711.        driver sends the appropriate signal that most catches to redraw so we
  712.        do not redraw because it is likely that screen will be redrawn twice */
  713.  
  714.     if (redraw) redraw_display();
  715. #else
  716. #ifdef TIOCSWINSZ
  717.     /* this may need work on other unix-- works for sun4 */
  718.     ioctl(TTY_DESCR,TIOCGWINSZ,&wind_struct);
  719.     wind_struct.ws_col = width;
  720.     ioctl(TTY_DESCR,TIOCSWINSZ,&wind_struct);
  721. #endif
  722. #endif /* VMS */
  723. }
  724.  
  725.  
  726.