/* 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 <stdlib.h>
#include <stdint.h>

#include <ssdef.h>
#include <iodef.h>
#include <descrip.h>
#include <starlet.h>
#include <lib$routines.h>

int main()
{
    $DESCRIPTOR(ttdesc, "TT:");
    int8_t c;
    int16_t chan, iosb[4];
    int32_t stat;
    stat = sys$assign(&ttdesc, &chan, 0, 0, 0);
    if(stat != SS$_NORMAL) lib$signal(stat);
    stat = sys$qiow(0, chan, IO$_READVBLK|IO$M_NOECHO, iosb, 0, 0, &c, 1, 0, 0, 0, 0);
    if(stat != SS$_NORMAL) lib$signal(stat);
    if(iosb[0] != SS$_NORMAL) lib$signal(iosb[0]);
    printf("You entered: %c\n", c);
    stat = sys$dassgn(chan);
    if(stat != SS$_NORMAL) lib$signal(stat);
    return 0;
}
