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
/*------------------------------------------------------*/
void		LoadFromPc(char *p)
			{
			void	InProg(void);
			int		ReadPar(char *);

			char	q[LINK_LEN],*r,*s,*ss[16];
			int		i,j,k;
			long	y,z;
			lib		*l;
			command	*c,**cp;

			switch(*p)
			{
			case 'd':
				Lr=scanLLA(Lr,++p,null);
				if(!Lr)
				{
					j=0;
					switch(strscan(p,ss,',',16))
					{
					case 2:
						j=atoi(ss[1]);
					case 1:
						if(l=FindLib(LinkAddrStr(ss[0])))
						{
							copylib(l,Lr=makelib());
							if(j)
								for(Lr->xc=Lr->x; --j && Lr->xc->next;)
									Lr->xc=Lr->xc->next;
							else
								Lr->x=Lr->xc=freecoord(Lr->x);
							Ungetch(REFRESH,0);
						}
						else
							puts_pc("!NOT_FOUND\r\n");
						break;
					default:
						puts_pc("!SYNTAX\r\n");
						break;
					}
				}
				break;

				case 'l':	if(i=LinkAddrStr(++p)) 
							{
								freelib(Lc);
								Lc=makelib();
								Lc->ltype=LinkAddrType(i);
								Lc->n=LinkAddrN(i);
								}
							else
								InsertLib(&Lc);
							break;

				case 'M':	if(sscanf(++p," %d,%04X,%04X,%s",&k,&i,&j,q)==4) {
                                if(Mscan)
/* znak, da je editor odprt ! */   	if(Mscan->c->maxopt) {
/* vrstica in obseg aktivna ? */		if(k)
											if(--k <= Mscan->c->maxopt) {
												Mscan->active = k;
        	       		                    	Refresh();
            	           		            	}
                                   		break;
                                    	}
                                r=strchr(q,',');
                                *r++=0;
                                cp=NULL;
                                if(!strcmp(q,"message"))
                                	cp=&CP;
                               	if(!strcmp(q,"gun"))
                               		cp=&GUN;
								if(!strcmp(q,"meteo"))
                                	cp=&METEO;
                                if(!cp)
                                	break;
/*......................................................................................*/
	                            if(!*cp)
                                	new_command(cp);
                                else{
	                               	c=*cp;
									do
										if(c->chk == j)
											*cp=c;
										else
											c=c->next;
									while(c != *cp);
									if((*cp)->chk != j)
										new_command(cp);
            						}
								(*cp)->chk=j;
                                c=*cp;
                                s=(char *)c;
								i = sizeof(command) - sizeof(command *) - sizeof(int);
								while(i--) {
					 				sscanf(r,"%02X",&j);
                                    *s++ = j;
									++r;++r;
									}
                                c->chk *= -1;
								if(cp == &CP)
									Ungetch(GXM_MESSAGE_ID,0);
								if(cp == &GUN)
									Ungetch(GXM_GUN_ID,0);
								}
							break;
				case 'r':   if(crest && (sscanf(++p," %ld %ld",&y,&z) == 2)) {
								add_coord(crest,0,y,z);
								crest->xc->refp=null;
								}
							else
								DeleteTask(DMRtimeout,RTC_task);
							break;

				case 'c':   i=j=0;
							if(Lc)
								Lc=scanLLA(Lc,++p,eof);
							break;
				case 'g':	if(Lc && (sscanf(++p," %s %d %d",q,&j,&k) == 3)) {
							for(i=0; Guns[i].name; ++i)
								if(!strcmp(Guns[i].name,q)) {
									Lc->gun=i;
									Lc->refd=j;
									Lc->powder=k;
									}
								}
							break;
				case 'a':	if(Lc && (sscanf(++p,"%s %d",q,&j) == 2)) {
								for(i=0; Guns[Lc->gun].ammo[i]; ++i)
									if(!strcmp(Guns[Lc->gun].ammo[i],q)) {
										Lc->ammpcs[i]=j;
										r=strchr(p,'+');
										s=strrchr(p,'+');
										if(r)
											do	Lc->ammpcs[i] += 0x1000;
													while(r++ != s);
										r=strchr(p,'-');
										s=strrchr(p,'-');
										if(r)
											do	Lc->ammpcs[i] -= 0x1000;
													while(r++ != s);
										}
								}
							break;
				case 'p':	if(sscanf(++p,"%d,%d",&i,&j) == 2)
								if(i<12 && j<4) {
									xyLCD(i,j);
									Ungetch(GXM_CURSOR_POS,0);
									}
							break;

				case 'm':	LoadHexRec(p,'m',_MenuCode);
							break;
				case 'h':	LoadHexRec(p,'h',_MenuHead);
							break;
				case 't':	if(Lc)
							{
								++p;
								++p;
								Lc->txt=addtxt(Lc,p);
							}
							else
								LoadHexRec(p,'t',_TextCode);
							break;

				case 'T':	if(sscanf(++p," %x %x",&i,&j)==2)
							{
							sprintf(q,"%04X\r\n",readTEMP(i,j));
							puts_pc(q);
							}
							break;

				case 'f':   if(ReadPar(++p))
								break;
							i=strscan(p,ss,' ',16);
							if(i>=2)
							{
								sscanf(ss[0],"%lx",&eebott);
								sscanf(ss[1],"%lx",&eetop);
								if(eebott < (long)FLASHTOP)
								{
									puts_pc("!ILL_ADDRESS\r\n");
									break;
								}
								if(eetop > (long)FLASHTOP+0x80000L)
								{
									puts_pc("!ILL_ADDRESS\r\n");
									break;
								}
								if(i==3)
								{
									ss[2][8]=0;
									sprintf(pass,"%-8s",ss[2]);
								}
								if(CheckPass(&syspass))
								{
									puts_pc("!NOT_ALLOWED\r\n");
									break;
								}
								puts_pc("\7\r\nFLASH programming !!!\r\n");
								wait(50);
								InProg();
								puts_pc("Done\r\n");
							}
							else
								puts_pc("!SYNTAX\r\n");
							break;
				case 'b':	k=sscanf(++p," %d %d",&i,&j);
							if(k)
								if(Baud(CHPC,i)) {
									if(k==2)
										Xonoff(j);
									break;
									}
							puts_pc("!SYNTAX\r\n");
							break;

				case 'z':	EnterZone(++p);
							break;

				case 'G':	DeleteTask(ReadPc,RTC_task);
							Guns=ReadGunData(0,0,0,0,NULL);
							SetTask(ReadPc,0,RTC_task);
							break;
				default:	puts_pc("!SYNTAX\r\n");
							break;
				}
			}