1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-19 01:17:36 +00:00
Interlisp.maiko/src/tstsout.c
Nick Briggs 3d9f090e70
Cleanup of includes and related changes based on include-what-you-use diagnostics (#436)
Remove unused #define PERCENT_OF_SCREEN in MyWindow.h
Move structures for dir.c to dirdefs.h where they are used
Resolve S_CHAR vs S_CHARACTER in favor of S_CHARACTER and cleanup #defines
Fix  = vs == bug in FSDEBUG code in dir.c
Eliminate duplicate/unused constant definitions in gcr.c
Declare static internal function bytecmp in mkatom.c
Update many source and include files to include headers for what they use
2022-08-10 11:07:57 -07:00

97 lines
2.5 KiB
C

/* $Id: tstsout.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
/*
* tstsout.c
*/
/************************************************************************/
/* */
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"
#include <fcntl.h> // for open
#include <stdio.h> // for printf, perror, fprintf, sprintf, SEEK_SET
#include <stdlib.h> // for exit
#include <string.h> // for strncmp
#include <fcntl.h> // for O_RDONLY
#include <unistd.h> // for close, lseek, read
#include "byteswapdefs.h" // for word_swap_page
#include "ifpage.h" // for IFPAGE
#define IFPAGE_ADDRESS 512
#define MBYTE 0x100000 /* 1 Mbyte */
void check_sysout(char *sysout_file_name, int verbose);
void usage(char *prog);
void check_sysout(char *sysout_file_name, int verbose) {
int sysout; /* SysoutFile descriptor */
IFPAGE ifpage; /* IFPAGE */
char errmsg[255];
/*
* first read the IFPAGE(InterfacePage)
*/
/* open SysoutFile */
sysout = open(sysout_file_name, O_RDONLY);
if (sysout == -1) {
sprintf(errmsg, "sysout_loader: can't open sysout file: %s", sysout_file_name);
perror(errmsg);
exit(-1);
}
/* seek to IFPAGE */
if (lseek(sysout, IFPAGE_ADDRESS, SEEK_SET) == -1) {
perror("sysout_loader: can't seek to IFPAGE");
exit(-1);
}
/* reads IFPAGE into scratch_page */
if (read(sysout, &ifpage, sizeof(IFPAGE)) == -1) {
perror("sysout_loader: can't read IFPAGE");
exit(-1);
}
#ifdef BYTESWAP
word_swap_page((unsigned short *)&ifpage, (3 + sizeof(IFPAGE)) / 4);
#endif
close(sysout);
if (verbose) {
printf("ifpage.minbversion %d\n", ifpage.minbversion);
printf("ifpage.process_size %d\n", ifpage.process_size);
printf("ifpage.storagefullstate %d\n", ifpage.storagefullstate);
printf("ifpage.nactivepages %d\n", ifpage.nactivepages);
} else {
printf("%d", ifpage.minbversion);
}
}
void usage(char *prog) {
fprintf(stderr, "Usage: %s [-v] sysout-filename\n", prog);
exit(-1);
}
int main(int argc, char **argv) {
switch (argc) {
case 2:
check_sysout(argv[1], 0);
break;
case 3:
if (0 == strncmp(argv[1], "-v", 2)) {
check_sysout(argv[2], 1);
} else {
usage(argv[0]);
}
break;
default:
usage(argv[0]);
}
exit(0);
}