Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
awgs.c
|
|
|
|
|
|
|
|
Main loop driver code and awgs wordproc file read routines
|
|
|
|
|
1999-01-15 15:46:08 +00:00
|
|
|
$Id: aroff.c,v 1.4 1999/01/15 15:46:08 gdr-ftp Exp $
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <gsos.h>
|
|
|
|
#include <shell.h>
|
1999-01-15 15:45:04 +00:00
|
|
|
#include <orca.h>
|
|
|
|
#include <gno/gno.h>
|
|
|
|
#include "aroff.h"
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
|
1999-01-15 15:45:04 +00:00
|
|
|
int noboldflag = 0;
|
|
|
|
saveArray *docSaveArray;
|
|
|
|
Ruler *docRulers;
|
|
|
|
textBlock **docTextBlocks; /* an array of textBlockPtrs */
|
|
|
|
word docSACount, numRulers, numBlocks;
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
|
|
|
|
void fileError(char *s)
|
|
|
|
{
|
1999-01-15 08:36:31 +00:00
|
|
|
int err;
|
|
|
|
int cl[2];
|
|
|
|
|
|
|
|
if (err = toolerror()) {
|
|
|
|
fprintf(stderr,"%s\n",s);
|
|
|
|
ERROR(&err);
|
|
|
|
cl[0] = 1;
|
|
|
|
cl[1] = 0;
|
|
|
|
CloseGS(cl);
|
|
|
|
exit(1);
|
|
|
|
}
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void readAWGS(char *file)
|
|
|
|
{
|
1999-01-15 08:36:31 +00:00
|
|
|
int ref,err,z; /* refnum, err temp, and loop variable */
|
|
|
|
long recBlockSize; /* size of the upcoming text block */
|
|
|
|
int cl[2]; /* pBlock for GS/OS CloseGS call */
|
1999-01-15 15:45:04 +00:00
|
|
|
static GSString255 f; /* converted cstring(file) -> GSString */
|
|
|
|
static OpenRecGS o; /* pBlock for GS/OS Open call */
|
|
|
|
static SetPositionRecGS p;
|
|
|
|
static IORecGS i;
|
1999-01-15 08:36:31 +00:00
|
|
|
|
|
|
|
f.length = strlen(file);
|
|
|
|
strcpy(f.text,file);
|
|
|
|
o.pCount = 7;
|
|
|
|
o.pathname = &f;
|
|
|
|
o.requestAccess = readEnable;
|
|
|
|
o.resourceNumber = 0;
|
|
|
|
OpenGS(&o);
|
|
|
|
if (err = toolerror()) {
|
|
|
|
fprintf(stderr,"aroff: could not open AWGS file %s\n",file);
|
|
|
|
ERROR(&err);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
ref = o.refNum;
|
|
|
|
if ((o.fileType != 0x50) || (o.auxType != 0x8010l)) {
|
|
|
|
cl[0] = 1;
|
|
|
|
cl[1] = ref;
|
|
|
|
CloseGS(cl);
|
|
|
|
fprintf(stderr,"aroff: file (%s) is not an AWGS file\n",file);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
p.pCount = 3;
|
|
|
|
p.refNum = ref;
|
|
|
|
p.base = startPlus;
|
|
|
|
p.displacement = 668l;
|
|
|
|
SetMarkGS(&p);
|
|
|
|
fileError("SetMarkGS");
|
|
|
|
|
|
|
|
i.pCount = 4;
|
|
|
|
i.refNum = ref;
|
|
|
|
i.dataBuffer = (void *) &docSACount;
|
|
|
|
i.requestCount = 2l;
|
|
|
|
ReadGS(&i);
|
|
|
|
fileError("ReadGS (docSACount)");
|
|
|
|
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
#ifdef DEBUG
|
1999-01-15 08:36:31 +00:00
|
|
|
fprintf(stderr,"Number of SaveArray entries: %d\n",docSACount);
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
#endif
|
|
|
|
|
1999-01-15 08:36:31 +00:00
|
|
|
docSaveArray = calloc((size_t) docSACount, sizeof(saveArray));
|
|
|
|
i.dataBuffer = (void *) docSaveArray;
|
|
|
|
i.requestCount = sizeof(saveArray) * docSACount;
|
|
|
|
ReadGS(&i);
|
|
|
|
fileError("ReadGS (docSaveArray)");
|
|
|
|
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
#ifdef DEBUG
|
1999-01-15 08:36:31 +00:00
|
|
|
fprintf(stderr," saNum textBlock rulerNum\n");
|
|
|
|
fprintf(stderr," ----- --------- --------\n");
|
|
|
|
for (z = 0; z < docSACount; z++) {
|
|
|
|
fprintf(stderr," [%3d] %5d %5d\n",
|
|
|
|
z+1, docSaveArray[z].textBlock,docSaveArray[z].rulerNum);
|
|
|
|
}
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
#endif
|
|
|
|
|
1999-01-15 08:36:31 +00:00
|
|
|
numRulers = numBlocks = 0;
|
|
|
|
for (z = 0; z < docSACount; z++) {
|
|
|
|
if (docSaveArray[z].rulerNum+1 > numRulers) {
|
|
|
|
numRulers = docSaveArray[z].rulerNum+1;
|
|
|
|
}
|
|
|
|
if (docSaveArray[z].textBlock+1 > numBlocks) {
|
|
|
|
numBlocks = docSaveArray[z].textBlock+1;
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
}
|
1999-01-15 08:36:31 +00:00
|
|
|
}
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
#ifdef DEBUG
|
1999-01-15 08:36:31 +00:00
|
|
|
fprintf(stderr,"Number of Rulers: %d\n",numRulers);
|
|
|
|
fprintf(stderr,"Number of Blocks: %d\n",numBlocks);
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
#endif
|
|
|
|
|
1999-01-15 08:36:31 +00:00
|
|
|
docRulers = calloc((size_t) numRulers, sizeof(Ruler));
|
|
|
|
i.dataBuffer = (void *) docRulers;
|
|
|
|
i.requestCount = sizeof(Ruler) * numRulers;
|
|
|
|
ReadGS(&i);
|
|
|
|
fileError("ReadGS (docRulers)");
|
|
|
|
|
|
|
|
docTextBlocks = calloc((size_t) numBlocks, sizeof(textBlockPtr));
|
|
|
|
for (z = 0; z < numBlocks; z++) {
|
|
|
|
i.requestCount = 4l;
|
|
|
|
i.dataBuffer = (void *) &recBlockSize;
|
|
|
|
ReadGS(&i);
|
|
|
|
fileError("ReadGS (recBlockSize)");
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-01-15 08:36:31 +00:00
|
|
|
fprintf(stderr,"block %d size %8ld : ",z,recBlockSize);
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
#endif
|
1999-01-15 08:36:31 +00:00
|
|
|
docTextBlocks[z] = malloc(recBlockSize);
|
|
|
|
i.requestCount = recBlockSize;
|
|
|
|
i.dataBuffer = (void *) docTextBlocks[z];
|
|
|
|
ReadGS(&i);
|
|
|
|
fileError("ReadGS (textBlock)");
|
|
|
|
}
|
|
|
|
|
|
|
|
cl[0] = 1;
|
|
|
|
cl[1] = ref;
|
|
|
|
CloseGS(cl);
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void usage(void)
|
|
|
|
{
|
1999-01-15 08:36:31 +00:00
|
|
|
fprintf(stderr,"aroff [-b] file1 [file ...]\n"
|
|
|
|
"-b don't do any boldfacing (useful for GNO Ref. Manuals)\n");
|
|
|
|
exit(1);
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
1999-01-15 08:36:31 +00:00
|
|
|
int i,z;
|
|
|
|
extern void printAWGS(void);
|
1999-01-15 15:45:04 +00:00
|
|
|
|
|
|
|
__REPORT_STACK(); /* show stack usage on exit if __CHECK_STACK__ defined */
|
1999-01-15 08:36:31 +00:00
|
|
|
if (argc == 1) {
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
if (*argv[i] == '-') {
|
|
|
|
if (argv[i][1] == 'b') {
|
|
|
|
noboldflag = 1;
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
readAWGS(argv[i]);
|
|
|
|
printAWGS();
|
|
|
|
free(docSaveArray);
|
|
|
|
free(docRulers);
|
|
|
|
for (z = 0; z < numBlocks; z++) {
|
|
|
|
free(docTextBlocks[z]);
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
}
|
1999-01-15 08:36:31 +00:00
|
|
|
free(docTextBlocks);
|
|
|
|
}
|
Initial checkin of aroff, binprint, center, less, ls, make, makemake,
passwd, ps, purge, shutdown, stty, upper, and vi. These sources are
for the versions of the utils shipped with GNO v2.0.4.
1998-03-09 08:30:21 +00:00
|
|
|
}
|