DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦645d2bc66⟧ TextFile

    Length: 2074 (0x81a)
    Types: TextFile
    Notes: UNIX file
    Names: »parslin.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »unimenu/src/menu/parslin.c« 

TextFile

static char SCCSid[] = "@(#)parslin.c	1.1 15:35:12 4/6/85";
/*
 *		Copyright 1984
 *
 *		LANTECH Systems, Incoroporated
 *
 *		Portions Copyright 1985 
 *
 *		Five Paces Software
 *
 *		All rights reserved
 */
/*
 * function:	parslin(cp)
 *
 * argh:	a pointer to a character array
 *		to be parsed.
 *
 * returns:	a pointer to a line stuctre.  This structure has been
 *		"calloc"ed.
 *
 * diagnostics:	returns NULL on fatal error, l_type == LERROR
 *		on non-fatal errors.
 *
 * History:	Original coding July 84 by Robert Adams.
 *		Modifications for windows Mar 95 Dan Mitchell
 *		Porting to Xenix Apr. 85 Dan Mitchell
 */

# include "defs.h"


static struct option    options[] =
{
	{ "Help",	LHELP,	3 },
	{ "Exec",	LEXEC,	3 },
	{ "Prompt",	LPRMPT,	3 },
	{ "Bad",	LBAD,	3 },
	{ "Columns",	LCOL,	3 },
	{ "Text",	LTEXT,	3 },
	{ "Expl",	LEXPL,	3 },
	{ "Top",	LTOP,	3 },
	{ "Lhcol",	LHCOL,	3 },
	{ "Pwd",	LPWD,	3 },
	{ NULL,		LOTHR,	0 }
};

struct line_f  *parslin (cp)
char   *cp;
{
struct line_f  *lp;
struct option  *optp;
char   *malloc(), *calloc();
char   *strchr(), *strcpy();

	/* 
	 * Steal some memory for the line structure.
	 */
	if ( (lp = (struct line_f *) calloc(1, sizeof(struct line_f))) == NULL)
		x (1, "parslin: calloc: lp");

	/* 
	 * Steal some memory for the char array
	 */
	if ( (lp->l_key = malloc (strlen (cp) + 1)) == NULL)
		x (1, "parslin: malloc l_key");

	strcpy (lp->l_key, cp);

	/* 
	 * Is the line valid, anyway?
	 */
	if ((lp->l_val = strchr (lp->l_key, ':')) == NULL)
	{
		lp -> l_type = LERROR;
		return (lp);
	}
	/* 
	 * since it is, lets set up the value
	 */
	*(lp->l_val) = EOS;			/* zap the colon */
	lp->l_val++;				/* and move past it */

	/*
	 * eat white space so it doesn't screw my window stuff
	 * drm
	 */
	while ( *(lp->l_val) == ' ' || *(lp->l_val) == '\t' )
		lp->l_val++;

	/* 
	 * Decide which choice he made.
	 */
	for (optp = &options[0]; optp->o_text != NULL; optp++)
	{
		if (ncmp (optp->o_text, cp, optp->o_size) == SAME)
			break;
	}

	lp->l_type = optp->o_type;
	/* 
	 * all together, now
	 */
	return (lp);
}