Category : Files from Magazines
Archive   : CUJ9212.ZIP
Filename : 1012107A

 
Output of file : 1012107A contained in archive : CUJ9212.ZIP
/* LISTING 7. DFAFCNS.C */
/* Collection of functions to support the DFA */

#include
#include
#include
#include
#include "dfa.h"

/****************************************************/
/* The first few routines are support routines for */
/* the state machine. */
/* The second set are default target routines */
/* The third set are default action routines */
/****************************************************/

/****************************************************/
/* STATE-MACHINE-SPECIFIC SUPPORT ROUTINES */
/****************************************************/

// Init the state machine object so tokenizer can be
// extracted. Setup a DFA_CLASS to allow tokenizer
// to run without the state machine.
void InitStateMachine(
DFA_CLASS *p, // user class to init
void *statetbl, // user's state table
char *tokenizer, // user-defined tokenizer
FILE *infile, // input file
char *tokelims) // token delimiters
{
// Set the user's state table address
p->tbl = statetbl;

// Set the input file
p->infile = infile;

// Set default, or user's override, as tokenizer
if (tokenizer == NULL) {
p->get_token = get_token;
}
else {
p->get_token = tokenizer;
}

// Set the tokenizer's delimiters
p->delim = tokelims;

// Set the internal working variables
p->movest = move; // state transition fcn
p->ndx = 0; // initial state
p->oflag = 0; // init to clear

memset(p->workbuf, 0, MAXBUFLEN);
p->wp = &(p->workbuf[0]);
p->cp = 0;

return;
}


// Update state table index as the machine moves
// to the next state.
short move(
DFA_CLASS *o, // ptr to current dfa
short value) // GOOD or BAD to next state
{
CURRENT_STATE = value ? GOODSTATE : BADSTATE;
return(CURRENT_STATE);
}

/***************************/
/* DEFAULT TARGET ROUTINES */
/***************************/
// Check if end of buffer (record) has been reached
short isEOF(
char *token)
{
return(token[0] == '\0');
}

// Check if end of buffer (record) has been reached
short isEOR(
char *token)
{
return(token[0] == EOR);
}

// Check if a Field Separator has been found
short isFS(
char *token)
{
return(token[0] == FS);
}

// Check if a Group Separator has been found
short isGS(
char *token)
{
return(token[0] == GS);
}

// Check if a Left Brace has been found
short isLBR(
char *token)
{
return(token[0] == LBR);
}

// Check if a Group Separator has been found
short isRBR(
char *token)
{
return(token[0] == RBR);
}


/***************************/
/* DEFAULT ACTION ROUTINES */
/***************************/

// Print out an error message
short errmsg(
char *token)
{
fprintf(stderr,
"Error in state machine for token '%s'\n",
token);
return(ERR);
}

// Function that does nothing;
// Allows moving to next state
short skip(
char *token)
{
IGNORE(token);
return(1);
}

// Block tokenizer so same token can be reused
short block(
char *token)
{
IGNORE(token);
need_token = NO;
return(1);
}


  3 Responses to “Category : Files from Magazines
Archive   : CUJ9212.ZIP
Filename : 1012107A

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/