/*-=-=-=-=-=-=-=-=-=-=-=- RCCL/RCI Notice of Copyright -=-=-=-=-=-=-=-=-=-=-*
 *									    *
 *	Copyright (C) 1987, 1991 by Mike Parker.			    *
 *									    *
 *	Information on copyright permissions, as well as a complete	    *
 *	disclaimer of warranty, is given in the file COPYRIGHT.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#include <stdio.h>

#include <sys/file.h>

#include "../sys/rciext/kaioctl.h"
#include "../sys/rciext/kamsgs.h"

main()
{
 struct blkdesc d;
 static char dmsg[5] = { MSG_DEBUG, 5, 0, 0, 0 };
 static char ackmsg[6];
 int fd;

 fd = open("/dev/ka1",O_RDWR,0);
 if (fd < 0)
  { perror("/dev/ka1");
    exit(1);
  }
 d.size = sizeof(dmsg);
 d.addr = dmsg;
 if (ioctl(fd,KAIOC_WMSGBUF,&d) < 0)
  { perror("KAIOC_WMSGBUF ioctl");
    exit(1);
  }
 d.size = sizeof(ackmsg);
 d.addr = ackmsg;
 if (ioctl(fd,KAIOC_RMSGBUF,&d) < 0)
  { perror("KAIOC_RMSGBUF ioctl");
    exit(1);
  }
 if (ackmsg[0] != MSG_ACK)
  { fprintf(stderr,"Non-ack reply (type %d)\n",0xff&(int)ackmsg[0]);
  }
 else if (*(int *)&ackmsg[1] != 6)
  { fprintf(stderr,"Bad size (%d) ack reply\n",*(int *)&ackmsg[1]);
  }
 else if (ackmsg[5] != MSG_DEBUG)
  { fprintf(stderr,"Wrong type (%d) ack\n",0xff&(int)ackmsg[5]);
  }
 exit(0);
}
