error.c
-----
#pragma intrinsic GENMESSAGE
#pragma intrinsic FOPEN
#include <stdio.h>
#include <fcntl.h>
#include <mpe.h> /* added because getmsg() doesn't work */
#define ML 80
void usage() {
printf("Usage: ERROR errtype errnumber\n");
printf("Example:\n");
printf(" ERROR FS 0\n");
printf(" ERROR FSERR 42\n\n");
exit(1);
}
/* The following two tables are in corresponding order: set 11 is AC */
char * prefix[12] =
{"AC","CI","CR","FS","JS","LD","LO","PA","PV","SD","UL",""};
int set[12] = { 11, 2, 10, 8, 35, 44, 9, 40, 15, 19,
20, 0};
main(int argc, char * argv[]) {
int i, found, cat, message_number;
char message[ML], key[3];
if (argc != 3) usage();
key[0] = toupper(argv[1][0]);
key[1] = toupper(argv[1][1]);
key[3] = '\0';
message_number = atoi(argv[2]);
found = 0;
i = 0;
while(!found && prefix[i][0]) {
if (strcmp(prefix[i], key) == 0)
found = !found;
else
i++;
}
if (found) {
/* cat = open("CATALOG.PUB.SYS", O_RDONLY); */
/* following replacement because getmsg() doesn't work */
foptions f;
aoptions a;
f.fv = a.av = 0;
f.fs.domain = 3;
f.fs.ascii = 1;
a.as.multirecord = 1;
a.as.no_buf = 1;
cat = FOPEN("CATALOG.PUB.SYS", f.fv, a.av);
/* * * * * * * * * * * * * * * * * * * * * * * * * * */
if (cat <= 0) {
perror("Message catalog not available");
exit(2);
}
GENMESSAGE( cat, set[i], message_number);
/* following code commented out because getmsg() doesn't work */
/* getmsg(cat, set[i], message_number, message, ML);
if (message[0] != '\0')
printf("\n%s\n", message);
else */
if (ccode() != CCE) {
printf("\nThere is no message %s %d\n", key,
message_number);
exit(3);
}
} else {
printf("Error type %s not found\n");
exit(4);
}
return(0);
}
-----
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|