Article View: net.micro.atari16
Article #2301Scribble-->Proff (v.2) part 3 of 3
From: Robert Royar
Date: Tue, 14 Oct 1986 01:16
Date: Tue, 14 Oct 1986 01:16
367 lines
10982 bytes
10982 bytes
# 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:
# keytab.c
# var.c
# lnk.
# This archive created: Mon Oct 13 21:06:08 1986
sed 's/^x//' << \SHAR_EOF > keytab.c
x/* keytab.c main key table for environment command lookup. Edit this file
x * to add or delete recognized command names. All table lookup is based
x * on D. G. Conroy's original MicroEmacs execute() function.
x */
x
x#include "scribe.h"
x
xtypedef struct {
x char name[15];
x int (*keyfunc)();
x}ENVTAB;
x
xextern int enumer;
xextern int quote;
xextern int vrbate;
xextern int itemz;
xextern int ux;
xextern int u;
xextern int bold;
xextern int sp;
xextern int newpage;
xextern int he;
xextern int fo;
xextern int style;
xextern int head;
xextern int subh;
xextern int chapter;
xextern int include;
xextern int need;
xextern int comment;
xextern int undent;
xextern int super;
xextern int sub;
xextern int reset;
xextern int ndex;
xextern int string;
xextern int value;
xextern int section;
x
xENVTAB envtab[] = {
x "enumerate", &enumer,
x "quotation", "e,
x "verbatim", &vrbate,
x "itemize", &itemz,
x "ux", &ux,
x "u", &u,
x "i", &u,
x "b", &bold,
x "blankspace", &sp,
x "newpage", &newpage,
x "pageheading", &he,
x "pagefooting", &fo,
x "style", &style,
x "heading", &head,
x "subheading", &subh,
x "chapter", &chapter,
x "include", &include,
x "need", &need,
x "undent", &undent,
x "device", &device,
x "pitch", &pitch,
x "height", &height,
x "super", &super,
x "sub", &sub,
x "reset", &reset,
x "index", &ndex,
x "string", &string,
x "value", &value,
x "section", §ion,
x "comment", &comment
x};
x
x#define NENVTAB (sizeof(envtab)/sizeof(envtab[0]))
x
xexecute(f)
xint f;
x{
x register ENVTAB *etp;
x int status;
x
x etp = &envtab[0];
x while (etp < &envtab[NENVTAB]) {
x if (strcmp(etp->name,command)==0) {
x status = (*etp->keyfunc)(f);
x return(status);
x }
x ++etp;
x }
x fprintf(stderr,"no code table for: %s\n",command);
x return(unbound(f)); /* just set it up as a proff command */
x}
SHAR_EOF
sed 's/^x//' << \SHAR_EOF > var.c
x/* var.c functions to assign and retrieve variables in text. Also the index
x * function is in this section.
x */
x
x#include "scribe.h"
x#include <ctype.h>
x
x#define NBLOCK 16
x
xint ndxfile = NO; /* we don't yet have an index filed opened */
xchar curvlbl[32]; /* current variable label */
xchar cursval[256]; /* value of string or index variable */
xint curnval; /* current int variable value */
xint pagenum=1; /* useless page number var for later */
xint chapnum=1; /* chapter variable for @chapter() */
xint sectnum=1; /* section variable for @section() */
xchar title[256];
xchar chaptitle[256];
xchar secttitle[256];
xextern FILE *fopen();
xFILE *ndxfp;
xextern char *malloc();
xVARTBL *vheadp; /* variable table header pointer */
xVARTBL *curvp; /* current variable table pointer */
x
x/* start up the variables table at the root */
x
xinitvar(f)
xint f;
x{
x strcpy(&curvlbl[0],"ROOTNODE");
x strcpy(&cursval[0],"");
x vheadp = valloc(0);
x vheadp->v_fp = vheadp;
x vheadp->v_bp = NULL;
x strcpy(vheadp->label,&curvlbl[0]);
x strcpy(vheadp->svalue,&cursval[0]);
x vheadp->type=VARSTR;
x curvp = vheadp;
x return(f);
x}
x
x/* put a, possibly preallocated, variable into the table */
x
xputvar(f)
xint f; /* f == type of variable */
x{
x register VARTBL *vtp;
x
x /* perhaps we've already defined this variable */
x if ((vtp=getvar(FALSE))==(VARTBL *)NULL) {
x vtp = valloc(); /* no, then allocate space */
x if (curvp == vheadp) { /* special case first time after init */
x vtp->v_fp = vheadp;
x vtp->v_bp = vheadp;
x vheadp->v_fp = vtp;
x }
x else {
x vtp->v_fp = vheadp;
x vtp->v_bp = curvp;
x curvp->v_fp = vtp;
x }
x curvp = vtp;
x }
x if (f == VARSTR) {
x strcpy(vtp->label,curvlbl);
x strcpy(vtp->svalue,cursval);
x vtp->type=VARSTR;
x }
x else if (f == VARNUM) {
x strcpy(vtp->label,curvlbl);
x vtp->nvalue=curnval;
x vtp->type=VARNUM;
x }
x else if (f == VARNDX) {
x strcpy(vtp->label,curvlbl);
x strcpy(vtp->svalue,cursval);
x vtp->type=VARNDX;
x }
x else {
x fprintf(stderr,"Bad argument to putvar(): %d\n",f);
x return(FALSE);
x }
x return(TRUE);
x}
x
xVARTBL *
xgetvar(f)
xint f; /* f==TRUE really get var; f==FALSE just return pointer */
x{
x VARTBL *vtp;
x
x vtp = curvp;
x
x while (vtp->v_bp != NULL) {
x if (strcmp(vtp->label,curvlbl)==0) {
x if (f == FALSE)
x return(vtp);
x if (vtp->type == VARSTR) {
x strcpy(cursval,vtp->svalue);
x return(vtp);
x }
x else if (vtp->type == VARNUM) {
x curnval = vtp->nvalue;
x return(vtp);
x }
x else if (vtp->type == VARNDX)
x return(vtp);
x else {
x fprintf(stderr,"Bad argument to getvar(): %d\n",
f);
x return((VARTBL *)NULL);
x }
x }
x vtp = vtp->v_bp;
x }
x return((VARTBL *) NULL);
x}
x
xVARTBL
x*valloc()
x{
x register VARTBL *vp;
x register int size;
x
x size = (NBLOCK-1) & ~(NBLOCK-1);
x if (size == 0)
x size = NBLOCK;
x if ((vp=(VARTBL *)malloc(sizeof(VARTBL)+size)) == NULL) {
x fprintf(stderr,"Fatal Error: out of space in variable table\n")
;
x exit(1);
x }
x return (vp);
x}
x
xndex(f) /* not index() because that name is taken */
xint f;
x{
x register int i;
x register int c;
x int myfence;
x i = 0;
x
x if (ndxfile == NO)
x mkndxf();
x myfence = (f == TRUE ? '\0' : fence);
x
x if (f == TRUE)
x if (gettext() != fence)
x error();
x while ((c=text[txtind]) != myfence)
x cursval[i++] = text[txtind++];
x cursval[i] = '\0';
x ++txtind;
x strcpy(curvlbl,"NDXVAR");
x putvar(VARNDX);
x fputs(cursval,ndxfp);
x fputc('\n',ndxfp);
x return(TRUE);
x}
x
xmkndxf()
x{
x char *ptr;
x char ndxname[80];
x
x strcpy(ndxname,ifname);
x if ((ptr = rindex(ndxname, '.')) != NULL)
x ptr[0] = '\0';
x strcat(ndxname,".NDX");
x if ((ndxfp=fopen(ndxname, "w")) == NULL) {
x fprintf(stderr,"Fatal Error: scribe cannot open %s for writing\n
");
x exit(1);
x }
x ndxfile = YES;
x return;
x}
x
xstring(f)
xint f;
x{
x register int i;
x register int c;
x int myfence;
x
x i = 0;
x
x myfence = (f == TRUE ? '\0' : fence);
x
x if (f == TRUE)
x if (gettext() != fence)
x error();
x while ((c=text[txtind]) != '=') {
x if (isspace(c)) {
x txtind++;
x continue; /* skip blanks */
x }
x else if (c == myfence) {
x fprintf(stderr,"Improper assignment to string\n");
x return(FALSE);
x }
x else
x curvlbl[i++] = text[txtind++];
x }
x curvlbl[i] = '\0';
x i = 0;
x txtind++;
x while (text[txtind] != myfence)
x cursval[i++] = text[txtind++];
x cursval[i] = '\0';
x ++txtind;
x putvar(VARSTR);
x return(TRUE);
x}
x
xvalue(f)
xint f;
x{
x register int i;
x register int c;
x int myfence;
x
x i = 0;
x
x myfence = (f == TRUE ? '\0' : fence);
x
x if (f == TRUE)
x if (gettext() != fence)
x error();
x while ((c=text[txtind]) != myfence) {
x if (isspace(c)) {
x txtind++;
x continue; /* skip blanks */
x }
x else
x curvlbl[i++] = text[txtind++];
x }
x curvlbl[i] = '\0';
x ++txtind;
x if (getvar(TRUE)!= (VARTBL *)NULL) {
x i = 0;
x while (c=cursval[i++])
x if (c != '\"')
x putchar(c);
x }
x else {
x fprintf(stderr,"@VALUE: variable not found '%s'\n",curvlbl);
x return(FALSE);
x }
x return(TRUE);
x}
x
SHAR_EOF
sed 's/^x//' << \SHAR_EOF > lnk.
xscribe.68k=gemstart,scribe,keytab,var,device,envir,gemlib[in[_nofloat]]
x
SHAR_EOF
# End of shell archive
exit 0
%NONAME-W-NOMSG, Message number 00000000
Technical Details
Message-ID:
<8610140413.AA05794@ucbvax.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!think!nike!ucbcad!ucbvax!ULKYVX.BITNET!RDROYA01Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!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 3 of 3 Message-ID: <8610140413.AA05794@ucbvax.Berkeley.EDU> Date: Mon, 13-Oct-86 21:16:00 EDT Article-I.D.: ucbvax.8610140413.AA05794 Posted: Mon Oct 13 21:16:00 1986 Date-Received: Tue, 14-Oct-86 07:17:36 EDT Sender: daemon@ucbvax.BERKELEY.EDU Organization: University of Louisville Lines: 367