Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!think!nike!ucbcad!ucbvax!ULKYVX.BITNET!RDROYA01 From: RDROYA01@ULKYVX.BITNET (Robert Royar) Newsgroups: net.micro.atari16 Subject: Scribble-->Proff (v.2) part 1 of 3 Message-ID: <8610140240.AA04231@ucbvax.Berkeley.EDU> Date: Mon, 13-Oct-86 21:10:00 EDT Article-I.D.: ucbvax.8610140240.AA04231 Posted: Mon Oct 13 21:10:00 1986 Date-Received: Tue, 14-Oct-86 07:12:58 EDT Sender: daemon@ucbvax.BERKELEY.EDU Organization: University of Louisville Lines: 378 # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # readme # scribe.h # scribe.c # scribe.mac # This archive created: Mon Oct 13 21:03:36 1986 sed 's/^x//' << \SHAR_EOF > readme xScribe-->Proff v. 2 x xThis is an update of my preliminary posting and includes a number of xenhancements. The program now supports "devices" via the @device() command. xThere is an array of structures in device.c that can be edited to add more xdevices (only Brother/Diablo daisy wheel printers are fully supported). The xfile var.c includes the dynamic memory allocator, lookup, and installation xfor the string, value, and index commands. The chapter and section commands xalso use the variable table maintained by the routines in var.c. x xTwo new commands in device.c allow you to modify the pitch and line height xon your printer, assuming it has minimum horizontal and vertical movement xstrings. They take integers as arguments in the style of WordStar (i.e. x@pitch(10) sets your printer to 12 pitch, and @height(8) sets the line xheight to 6 lines per inch. The @sub(text) command creates a subscript out xof 'text' and @super(text) superscripts the text. If your printer is xdefined as a DEVPLN (see scribe.h) these commands turn into null strings. xIf, on the other hand, you have a DEVFNCY, the program will insert the xcontrol codes that you have defined for your printer for the commands (and xthe @u() @b() commands). x xCaveats: x xSince device.c has the actual ASCII printer codes in it, you may need xto device.c to repair any mailer changes. x xUsing the @u() and @b() commands changes your line length in such a way that xproff can no longer justify the line fully. That's why this program forces xproff to default to .nj rather than .ju. x xCurrently the index command simply writes the indexed word to a file with xthe name infilename.NDX and does nothing more. This is as far as the xpreprocessor can go because it doesn't know about proff's final page xnumbers. x xThe @enumerate() command does not always format the enumerated environment xas desired; it indents the paragraph by one character. x xWhile the @need() command always gets through, proff disregards it at times. x xThe size of a single environment is limited to 32K simply because I was too xlazy to figure out a dynamic allocation function for lines. It just uses a xgiant static array, much larger than most should need. But forgetting to xclose an environment can lead to overwriting a buffer if your file is large xenough (probably about 30K or so). I've used it on 50K texts without xproblem, but I'm rather religious about fences since GNU_EMACS understands x@environment{} names. x xChapter, section, and string variable values are stored in static arrays xinside a circularly linked list of variable structures. Values are limited xto 255 characters, but no checking is done. Labels are limited to 31 xcharacters. x xThis is a one pass preprocessor. Environments can be nested, but string xvariables cannot contain references to other variables. Example x@string(name="Neil") @string(atarirep=name) "The Atari rep is x@value(atarirep)" will not work as expected. x xThe @include(file) command does not really include the file; it just tells xproff to do so. If the included file also contains directives for this xprogram, it will need to be processed before proff includes it. x xThe argv parser creates an outfilename based on the infilename. Example if xoutfile == FILE.MSS, the program will write out a file FILE.PRF to the same xdrive and directory. If the @index() commands shows up, the file FILE.NDX xwill be created. The program only uses four files because it frees up the xstandard I/O files to use putchar(), getchar(), etc. for I/O. x xIt also looks into the STREAM structure, so if you have a braindamaged xcompiler that doesn't let you find stdout->ptr you'll have to repair xlastchar in envir.c. x xComing attractions: x x@case{atarirep, x xNeil, "Write this out to the file." x xJohn, "But don't write this." x xNULL, "[]". x xelse, "Got no name for atarirep."} x x@style(linewidth 39 pica) Style commands aren't too useful if you can't use xpicas, micas, and ems. x x@time(GMT) (i.e. insert time using GMT standard. This assumes you've set xthe default time and the formatter time flag with the @style(time EST).) x x@note(Make this a fottnote, endnote, or inline note) Endnote and inline are xeasy, but footnote is real hard. x xI hope someone finds this program useful. x xRobert Royar x xrdroya01@ulkyvx.bitnet x SHAR_EOF sed 's/^x//' << \SHAR_EOF > scribe.h x/* Header for scribe modules */ x#include x x#define MAXTEXT 32768 /* an array to hold environment for text */ x#define DEFLFT 0 /* default left margin */ x#define DEFRHT 65 /* default right margin */ x#define DEFSPC 1 /* default line spacing */ x#define DEFPRN "plain" /* default printer name */ x#define DEFFIL ".nj\n.ap" /* default fill parameters */ x#define DEFPGL 66 /* default page length */ x#define DEVPLN 1 /* our output device is plain */ x#define DEVFNCY 0 /* our output device is fancy */ x#define VARNUM 2 /* the variable is a number */ x#define VARSTR 1 /* the variable is a string */ x#define VARNDX 0 /* the variable is indexed */ x#define NVARTBL 128 /* static arrays for variables */ x xextern int pglen; /* current page length */ xextern int rghmrg; /* current right margin */ xextern int lftmrg; /* current left margin */ xextern int lspcng; /* current line spacing */ xextern int pmrg; /* current paragraph margin (.ti) */ x x/* variables mostly assigned in var.c */ x xextern char curvlbl[32]; /* current variable label */ xextern char cursval[256]; /* value of string or index variable */ xextern int curnval; /* current int variable */ xextern int pagenum; /* useless page number var for later */ xextern int chapnum; /* chapter variable for @chapter() */ xextern int sectnum; xextern char title[256]; xextern char chaptitle[256]; xextern char secttitle[256]; x xextern char text[MAXTEXT]; xextern int fence; xextern char command[15]; xextern unsigned int txtind; xextern int ndxfile; xextern FILE *ndxfp; xextern char ofname[80]; xextern char ifname[80]; xextern char *strcat(), *strcpy(), *rindex(); xextern FILE *fopen(), *freopen(); x x/* printer strings assigned in device.c */ x xextern char prnname[15]; xextern char bdon[15]; xextern char bdoff[15]; xextern char ulon[15]; xextern char uloff[15]; xextern char pinit[15]; xextern char preset[15]; xextern char ptch[15]; xextern char lhght[15]; xextern int devflag; /* type of current output device */ x x/* structure used by var.c functions to create and maintain a variables' x * list. x */ x xtypedef struct VARTBL { x struct VARTBL *v_fp; x struct VARTBL *v_bp; x char label[32]; x char svalue[256]; x int nvalue; x int type; x} VARTBL; x xextern VARTBL *valloc(), *getvar(); SHAR_EOF sed 's/^x//' << \SHAR_EOF > scribe.c x/* scribe.c preprocessor for proff to convert scribble files to proff */ x x#include "scribe.h" x#include x xint pglen = DEFPGL; /* current page length */ xint rghmrg = DEFRHT; /* current right margin */ xint lftmrg = DEFLFT; /* current left margin */ xint lspcng = DEFSPC; /* current line spacing */ xint pmrg = DEFLFT; /* current paragraph margin (.ti) */ x xchar command[15]; /* current command name */ xint fence; /* expected terminating fence for current env. */ xunsigned int txtind; /* index to current place in text array */ xchar text[MAXTEXT]; /* an array to hold all the text you want */ xchar ofname[80]; xchar ifname[80]; x xmain(argc,argv) xint argc; xchar *argv[]; x{ x x register int c; x x fprintf(stderr,"Scribble --> Proff %c 1986\n\n",0xbd); x if (argc < 2) { x fprintf(stderr,"usage: SCRIBE infile\n"); x exit(1); x } x makename(argv[1]); x if (freopen(ifname,"r",stdin) != stdin) { x fprintf(stderr,"SCRIBE cannot read from file %s\n",ifname); x exit(1); x } x if (freopen(ofname,"w",stdout) != stdout) { x fprintf(stderr,"SCRIBE cannot write to file %s\n",ofname); x exit(1); x } x initdef(); x initvar(); x fprintf(stderr,"Formatting: %s\nOutput : %s\nDevice: %s\n", x ifname,ofname,prnname); x while ((c=getchar())!=EOF) { x if (c == '@') { x fence = getcmd(TRUE); x execute(TRUE); x } x else x putchar(c); x } x if (ndxfile == YES) x fclose(ndxfp); x exit(0); x} x xmakename(name) xchar name[]; x{ x char *ptr; x x strcpy(ifname,name); x strcpy(ofname,name); x if ((ptr = rindex(ofname, '.')) != NULL) x ptr[0] = '\0'; x strcat(ofname,".PRF"); x return; x} x xinitdef() x{ x printf(".po %d\n.rm %d\n.ls %d\n.pl %d\n",lftmrg,rghmrg,lspcng,pglen); x puts(DEFFIL); x strcpy(prnname,DEFPRN); x setdvc(TRUE); x return; x} x xgetcmd(f) xint f; x{ x register int c; x register int i; x i = 0; x x switch (f) x { x case TRUE: { x while ((c=getchar())!=EOF) x if (isalpha(c)){ x command[i++] = c; x } x else x break; x command[i] = '\0'; x break; x } x case FALSE: { x while ((c=text[++txtind])) x if (isalpha(c)){ x command[i++] = c; x } x else { x ++txtind; x break; x } x command[i] = '\0'; x break; x } x default: c = -1; break; /* basic error */ x } x /* return closing fence */ x if (c == (int)'[') x return((int)']'); x else if (c == (int)'(') x return((int)')'); x else if (c == (int)'{') x return((int)'}'); x else if (c == (int)'<') x return((int)'>'); x else x return(-1); /* error */ x} x xgettext() x{ x register int c; x x txtind = 0; /* reset index */ x x while ((c=getchar())!=EOF) { x if (c == fence) x break; x text[txtind++] = c; x } x text[txtind] = '\0'; x txtind = 0; /* reset counter for next function */ x return(c); /* c == closing fence */ x} x xerror() x{ x fprintf(stderr,"\nEnvironment not closed : %s\n", command); x return; x} x xfatal() x{ x fprintf(stderr,"Fatal error in style command.\nCannot parse:\n%s",text); x exit(1); x} x SHAR_EOF sed 's/^x//' << \SHAR_EOF > scribe.mac x.! ----------- macros ---------- x.! sect - produce a bold section header and x.! enter a contents line. First parameter x.! is indent level for contents line. x.define sect x.sp x.cl $1 $2 $3 $4 $5 $6 $7 $8 $9 x$2 $3 $4 $5 $6 $7 $8 $9 x.en x.! x.! macros to create a point-form lists. x.!------------ x.define list x.br x.ls 1 x.in +6 x.en x.!------------ x.define item x.br x.ls 1 x.ti -3 x$1 x.en x.!------------ x.define nolist x.in -6 x.ls 2 x.en x.!------------ SHAR_EOF # End of shell archive exit 0 %NONAME-W-NOMSG, Message number 00000000 %SYSTEM-F-NOLOGNAM, no logical name match