home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / vms / 17853 < prev    next >
Encoding:
Text File  |  1992-11-07  |  1.4 KB  |  66 lines

  1. Xref: sparky comp.os.vms:17853 comp.lang.c:16399
  2. Newsgroups: comp.os.vms,comp.lang.c
  3. Path: sparky!uunet!stanford.edu!rock!concert!rti!jbs
  4. From: jbs@rti.rti.org
  5. Subject: Re: Getting terminal width from VAX-C ?
  6. Message-ID: <1992Nov12.152852.3935@rti.rti.org>
  7. Keywords: terminal_width
  8. Organization: Research Triangle Institute, RTP, NC
  9. References: <1992Nov11.101009.87@front.se>
  10. Date: Thu, 12 Nov 92 15:28:52 GMT
  11. Lines: 53
  12.  
  13. In article <1992Nov11.101009.87@front.se> samuel@front.se writes:
  14. >
  15. >Does anybody out there know how to get the TERMINAL WIDTH from VAX-C ?
  16. >
  17. >How do I implement the function "terminal_width()" ?
  18.  
  19.  
  20. #include <stdio.h>
  21. #include <ttdef.h>
  22. #include <descrip.h>
  23. #include <iodef.h>
  24. #include <ssdef.h>
  25.  
  26. /* I/O status block information. */
  27. struct {
  28.     short iosb_cond, iosb_count;
  29.     int iosb_dev;
  30.        } iosb;
  31.  
  32. short chan;
  33.  
  34. int status, i;
  35.  
  36. /* characteristics buffer */
  37. struct {
  38.     unsigned char class, type;
  39.     short page_width;
  40.     int rest;
  41.        } termchars;
  42.  
  43. $DESCRIPTOR(terminal,"TT:");
  44.  
  45.  
  46. int terminal_width()
  47. {
  48.     if(((status = SYS$QIOW(0,chan,IO$_SENSEMODE,&iosb,0,0,&termchars,
  49.                    8,0,0,0,0))&1)!=1)
  50.         LIB$STOP(status);
  51.     if ((iosb.iosb_cond &1)!=1)
  52.         LIB$STOP(status);
  53.     return(termchars.page_width);
  54. }
  55.  
  56.  
  57. main()
  58. {
  59.     /* Assign a channel to the terminal */
  60.     if (((status = SYS$ASSIGN(&terminal,&chan,0,0))&1)!=1)
  61.         LIB$STOP(status);
  62.  
  63.     printf("Current terminal page width = %d\n",terminal_width());
  64. }
  65.  
  66.