
/*
 *  QTEST.C
 */

#include <typedefs.h>
#include <stdio.h>

typedef struct Library LIB;

LIB *DMiscSupportBase;
long QHan;
long Count;
long EnErr;
long Error;

extern LIB *OpenLibrary();
extern TASK *FindTask();

handler(arg)
{
    printf("ARG: %ld ************\n", arg);
}

main()
{
    int i;

    DMiscSupportBase = OpenLibrary("dmiscsup.library", 0);
    if (!DMiscSupportBase) {
	puts("Unable to open library");
	exit(1);
    }
    puts("Q-TEST");
    QHan = OpenQInts();
    if (!QHan) {
	puts("Unable to alloc. q ints");
	CloseLibrary(DMiscSupportBase);
	exit(1);
    }
    printf("QHAn=  %08lx\n", QHan);
    puts("UnSetting NULL vector");
    SetQVector(QHan, NULL, SIGBREAKB_CTRL_E, 0, 0);
    puts("Setting ^D vector");
    SetQVector(QHan, handler, SIGBREAKB_CTRL_D, 30, -20);
    puts("UnSetting NULL vector");
    SetQVector(QHan, NULL, SIGBREAKB_CTRL_E, 0, 0);
    puts("Loop");
    for (i = 0; i < 100; ++i) {
	char oldpri = SetQPri(QHan, 127);
	EnErr = 1;
	printf("%ld  cnt = %ld  error = %ld (old=%ld) %08lx %08lx\n", i, Count, Error, oldpri,
	    SetSignal(0,0), FindTask(NULL)->tc_SigExcept
	);
	EnErr = 0;
	SetQPri(QHan, oldpri);
    }
    puts("UnSetting NULL vector");
    SetQVector(QHan, NULL, SIGBREAKB_CTRL_E, 0, 0);
    printf("%ld  cnt = %ld  error = %ld\n", i, Count, Error);
    puts("closing");
    CloseQInts(QHan);
    puts("closelib");
    RemLibrary(DMiscSupportBase);
    CloseLibrary(DMiscSupportBase);
}


