/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <descrip.h>
#include <iodef.h>
#include <ssdef.h>
#include <starlet.h>

int main()
{
   short int chan,iosb[4];
   int h,w;
   char inq[]="\x1B[\"v";
   char buf[80];
   char *p1,*p2,*p3;
   $DESCRIPTOR(ttdesc,"TT:");
   sys$assign(&ttdesc,&chan,0,0);
   sys$qiow(0,chan,IO$_WRITEVBLK,0,0,0,inq,strlen(inq),0,0,0,0);
   sys$qiow(0,chan,IO$_READVBLK|IO$M_NOECHO|IO$M_TIMED,iosb,0,0,
              &buf,sizeof(buf),2,0,0,0);
   sys$qiow(0,chan,IO$_READVBLK|IO$M_NOECHO|IO$M_TIMED,iosb,0,0,
              &buf,sizeof(buf),2,0,0,0);
   buf[iosb[1]]='\0';
   sys$dassgn(chan);
   p1=buf;
   while(!isdigit(*p1)) p1++;
   p2=strchr(buf,';');
   p3=strchr(p1+1,';');
   *p2='\0';
   *p3='\0';
   h=atoi(p1);
   w=atoi(p2+1);
   printf("Terminal display %d x %d\n",h,w);
   return SS$_NORMAL;
}
