Example #1
0
FUNCTION static CODE inlevel1 
(
    struct CONTXT	*pctx,		/* in/out: proc context w/ tab to update.	*/
    struct SFILE	*hf,		/* in/out: help file control block	*/
    TEXT		subcmd[]	/* in: subcommand qualifier to search	*/

 )
    {
    IMPORT  struct  VARIABLE *char_gbl;		/* system characteristics 	*/

    TEXT		dirctv[STRINGSIZ+1];
    TEXT		field[STRINGSIZ+1];
    TEXT		scope[STRINGSIZ+1];
    TEXT		prmname[SUBCMDSIZ+1];
    TEXT		proc[FSPECSIZ+1];
    TEXT		subname[SUBCMDSIZ+1];
    struct SYNBLK	sb;
    struct VARIABLE	*v;
    struct SUBCMD	*s;
    struct TUTEXT	*t;
    TEXT		str[STRINGSIZ+1];
    CODE		code, code1;
    struct DIRBLK	db;			/* directive block for d_ pkg	*/
    TEXT		libe[FLIBRSIZ+1];
    struct CONTXT	*ctx;

    if (!tutctx.h1exist  ||  tutctx.h1done)
	return(TUT_H1DONE);
    f_setpos(hf, &tutctx.lasth1pos);	/* restore last lev 1 help position	*/
    for (ctx = pctx; (s_equal((*ctx).pdf.libr,"/LOCAL/")); ctx = (*ctx).backlink);
    s_copy ((*ctx).pdf.libr, libe);	/* make sure we have a libe good for internal procs */
    d_init(&db, hf, libe,
	(TEXT **) (*char_gbl).v_cvp, (*char_gbl).v_count);	/* init directive block	*/
    while (FOREVER)
	{
	if ((code = d_dirctv(&db, dirctv, field)) != SUCCESS) goto read_err;	/* input next directive line*/
	f_movpos(&(*hf).posctx, &tutctx.lasth1pos);
	if (!s_lseq(".VAR", dirctv)  &&  !s_equal(".SUBCMD", dirctv))
	    {
	    tutctx.h1done = TRUE;
	    return(TUT_H1DONE);
	    }
	if (tutctx.subtut  &&  s_equal(".SUBCMD", dirctv))
	    break;
	if (!tutctx.subtut  &&  s_lseq(".VAR", dirctv))	
	    break;
	}
    initok(&sb, field);			/* init sb for syntax pkg		*/
    code = gettok(&sb, prmname);
    if (code != S_ALPHA && (!tutctx.subtut || code != '-')) goto name_err;
    if (tutctx.subtut)
	{
	if (code == '-')
	    prmname[0] = EOS;
	else
	    prmname[SUBCMDSIZ] = EOS;	
	if ((s = subex((*pctx).subptr, prmname)) == NULL) goto nsubc_err;
	t = &(*s).ext;
	}
    else
	{
	prmname[NAMESIZ] = EOS;
	proc[0] = EOS;
	subname[0] = EOS;
	s_copy(sb.curchr, scope);
	if (!NULLSTR(scope))
	    cmd_parse(&sb, scope, NULL, proc, subname);
	if (!NULLSTR(proc) && !s_equal((*pctx).pdf.name, proc)) goto nparm_err;
	if (!s_equal(subcmd, subname)) goto nparm_err;
	if ((v = lookex(&(*pctx).parmst, prmname)) == NULL) goto nparm_err;
	if ((*v).v_tp == NULL)
	    if (((*v).v_tp = (struct TUTEXT *) tae_alloc(1, sizeof(struct TUTEXT))) == NULL)
		goto over_err;
	t = (*v).v_tp;
	}
    if ((*t).l1hexist) goto name_err;
    (*t).l1hexist = TRUE;
    code1 = SUCCESS;				/* in case we get out at once */
    while ((code = txtread(&db, str, &tutctx.lasth1pos)) == SUCCESS)
	{
	if ((code1 = addtxt(&(*t).l1help, str)) != SUCCESS) break;
	}
    d_incclose(&db);				/* close .include file, if any	*/
    if (code != D_EOT) goto read_err;
    if (code1 != SUCCESS) goto over_err;
    if (tutctx.screen)
	if ((brktxt(&(*t).l1help, TUTHL1SIZ)) != SUCCESS) goto over_err;	/* break text up for descr field width*/
    return(SUCCESS);

read_err:
    tutmsg(msg_hrde, key_hrde, (uintptr_t) (*pctx).pdf.name, 0, 0, 0, 0);	/* tutor mode help file read error	*/
    tutctx.h1done = TRUE;
    return(TUT_H1DONE);

nsubc_err:
nparm_err:
name_err:
    f_read(hf, str);
    f_movpos(&(*hf).posctx, &tutctx.lasth1pos);
    return(SUCCESS);

over_err:
    tutmsg(msg_mmov, key_mmov, 0, 0, 0, 0, 0);			/* dyn mem overflow		*/
    return(FAIL);
    }
Example #2
0
int main(void){
	binwrite();
	binread();
	txtwrite();
	txtread();
}