Beispiel #1
0
void AGOSEngine_PN::opn_opcode52() {
	int32 mode = varval();
	if (mode == 1) {
		setWindowImage(mode, varval(), true);
	} else {
		setWindowImageEx(mode, varval());
	}

	setScriptReturn(true);
}
Beispiel #2
0
void AGOSEngine_PN::opn_mul() {
	uint8 *str = _workptr;
	int32 sp = varval() * varval();
	_variableArray[12] = sp % 65536;
	_variableArray[13] = sp / 65536;
	if (sp > 65535)
		sp = 65535;
	writeval(str, (int)sp);
	setScriptReturn(true);
}
Beispiel #3
0
void AGOSEngine_PN::opn_div() {
	uint8 *str = _workptr;
	int32 sp = varval();
	int32 sp2 = varval();
	if (sp2 == 0)
		error("opn_div: Division by 0");
	sp = sp / sp2;
	_variableArray[12] = sp % 65536;
	_variableArray[13] = sp / 65536;
	writeval(str, (int)sp);
	setScriptReturn(true);
}
Beispiel #4
0
void AGOSEngine_PN::opn_opcode35() {
	int a;
	uint8 *sav = _workptr;
	varval();
	a = varval();
	if ((a = gvwrd((uint8 *)_wordcp, a)) == -1) {
		setScriptReturn(false);
		return;
	}

	writeval(sav, a);
	setScriptReturn(true);
}
Beispiel #5
0
void AGOSEngine_PN::opn_opcode57() {
	uint16 windowNum = varval();
	uint16 vgaSpriteId = varval();
	int16 x = varval();
	int16 y = varval();
	uint16 palette = varval();

	_videoLockOut |= 0x40;
	animate(windowNum, 0, vgaSpriteId, x, y, palette);
	_videoLockOut &= ~0x40;

	setScriptReturn(true);
}
Beispiel #6
0
/*ARGSUSED*/
void
dochngd(Char **v, struct command *c)
{
    Char *cp;
    struct directory *dp;
    int dflag = skipargs(&v, "plvn", "[-|<dir>]");

    USE(c);
    printd = 0;
    cp = (dflag & DIR_OLD) ? varval(STRowd) : *v;

    if (cp == NULL) {
	if (!cdtohome)
	    stderror(ERR_NAME | ERR_TOOFEW);
	else if ((cp = varval(STRhome)) == STRNULL || *cp == 0)
	    stderror(ERR_NAME | ERR_NOHOMEDIR);
	if (chdir(short2str(cp)) < 0)
	    stderror(ERR_NAME | ERR_CANTCHANGE);
	cp = Strsave(cp);
    }
    else if ((dflag & DIR_OLD) == 0 && v[1] != NULL) {
	stderror(ERR_NAME | ERR_TOOMANY);
	/* NOTREACHED */
	return;
    }
    else if ((dp = dfind(cp)) != 0) {
	char   *tmp;

	printd = 1;
	if (chdir(tmp = short2str(dp->di_name)) < 0)
	    stderror(ERR_SYSTEM, tmp, strerror(errno));
	dcwd->di_prev->di_next = dcwd->di_next;
	dcwd->di_next->di_prev = dcwd->di_prev;
	dfree(dcwd);
	dnewcwd(dp, dflag);
	return;
    }
    else
	if ((cp = dfollow(cp, dflag & DIR_OLD)) == NULL)
	    return;
    dp = xcalloc(sizeof(struct directory), 1);
    dp->di_name = cp;
    dp->di_count = 0;
    dp->di_next = dcwd->di_next;
    dp->di_prev = dcwd->di_prev;
    dp->di_prev->di_next = dp;
    dp->di_next->di_prev = dp;
    dfree(dcwd);
    dnewcwd(dp, dflag);
}
Beispiel #7
0
int AGOSEngine_PN::setposition(int process, int line) {
	uint8 *ourptr;
	int np;
	int ct;

	ourptr = _dataBase + getlong(_quickptr[6] + 3 * process);
	np = *ourptr++;
	for (ct = 0; ct < line; ++ct) {
		ourptr += (127 & *ourptr);
	}

	while (true) {
		_linebase = ourptr;
		_linct = (127 & *ourptr) - 1;
		if (*ourptr++ <= 127)
			break;

		ct = varval();
		if (ct == (int)_variableArray[1])
			break;

		ourptr += _linct - 1;
		line++;
	}

	_linembr = line;
	_procnum = process;
	_variableArray[0] = process;
	_workptr = ourptr;
	return np;
}
Beispiel #8
0
char *fix_path_for_child(void) {

	char *ptr;
	Char *vp;
	char *pathstr;
	char *oldpath;
	long len;

	vp = varval(STRNTlamepathfix);

	if (vp != STRNULL) {

		len = GetEnvironmentVariable("PATH",NULL,0);

		oldpath = heap_alloc(len+1);
		pathstr = heap_alloc(len+1);

		len = GetEnvironmentVariable("PATH",oldpath,len+1);
		memcpy(pathstr,oldpath,len);

		ptr = pathstr;
		while(*ptr) {
			if (*ptr == '/')
				*ptr = '\\';
			ptr++;
		}
		SetEnvironmentVariable("PATH",pathstr);
		heap_free(pathstr);

		return oldpath; //freed in restore_path;
	}
	else
		return NULL;

}
Beispiel #9
0
void AGOSEngine_PN::opn_opcode31() {
	int a, slot = 0;
	Common::String bf;

	if ((a = varval()) > 2) {
		setScriptReturn(false);
		return;
	}

	switch (a) {
		case 0:
			getFilename();
			slot = matchSaveGame(_saveFile, countSaveGames());
			bf = genSaveName(slot);
			break;
		case 1:
			bf = "pn.sav";
			break;
		case 2:
			// NOTE: Is this case ever used?
			error("opn_opcode31: case 2");
			break;
	}

	if (slot == -1) {
		setScriptReturn(false);
	} else {
		a = loadFile(bf);
		if (a)
			setScriptReturn(badload(a));
		else
			setScriptReturn(true);
	}
}
Beispiel #10
0
std::string path::expandvars(const std::string &path) {
    std::string new_path(path);
    if(new_path.find('$') == std::string::npos) {
        return new_path;
    }
    pcrecpp::StringPiece path_re(new_path);
    pcrecpp::RE expandvars_re(".*\\$(\\w+|\\{[^}]*\\})");
    int offset = 0;
    std::string _;
    std::string varname;
    while(expandvars_re.Consume(&path_re, &varname)) {
        int varname_size = varname.size();
        if(varname.find('{') == 0 && varname.find('}') == varname.size() - 1) {
            varname = varname.substr(1, varname.length() - 2);
        }
        char *_varval = getenv(varname.c_str());
        if(_varval != NULL) {
            std::string varval(_varval);
            offset = new_path.size() - path_re.size();
            std::string tail(new_path.substr(offset));
            new_path = new_path.substr(0, offset - varname_size - 1) + varval;
            offset = new_path.size();
            new_path += tail;
        } else {
            offset = new_path.size() - path_re.size();
        }
    }
    return new_path;
}
Beispiel #11
0
char * forward_slash_get_cwd(char * path, int maxlen) {

	char *ptemp;
	Char *vp;
	int rc ;
	
	if ((path == NULL) || (maxlen == 0)) {
		path = &defcwd[0];
		maxlen = MAX_PATH;
	}

	rc = GetCurrentDirectory(maxlen,path);
	if (rc > maxlen) {
		errno = ERANGE;
		return NULL;
	}
	vp = varval(STRNTcaseifypwd);
	if (vp != STRNULL) {
		caseify_pwd(path);
	}
	ptemp=path;

	path_slashify(ptemp);

	return path;
}
Beispiel #12
0
void AGOSEngine_PN::opn_opcode32() {
	Common::String bf;
	int a, slot;

	a = varval();
	if (a > 2) {
		setScriptReturn(true);
		return;
	}

	uint16 curSlot = countSaveGames();
	switch (a) {
		case 0:
			getFilename();
			slot = matchSaveGame(_saveFile, curSlot);
			if (slot != -1)
				bf = genSaveName(slot);
			else
				bf = genSaveName(curSlot);
			break;
		case 1:
			bf = "pn.sav";
			break;
		case 2:
			// NOTE: Is this case ever used?
			error("opn_opcode32: case 2");
			break;
	}

	a = saveFile(bf);
	setScriptReturn(a);
}
Beispiel #13
0
void AGOSEngine_PN::opn_opcode29() {
	popstack(varval());
	// Jump back to the last doline indicated by the top stackframe.
	// The -1 tells it to simply go on with its business.
	_dolineReturnVal = -1;
	_tagOfActiveDoline = _stackbase->tagOfParentDoline;
}
Beispiel #14
0
/*
 * Karl Kleinpaste, 18 Jan 1984.
 * Added period_cmd(), which executes the alias "periodic" every
 * $tperiod minutes.  Useful for occasional checking of msgs and such.
 */
void
period_cmd(void)
{
    Char *vp;
    time_t  t, interval;

    pintr_disabled++;
    cleanup_push(&pintr_disabled, disabled_cleanup);
    if (periodic_active) {	/* an error must have been caught */
	aliasrun(2, STRunalias, STRperiodic);
	xprintf("%s", CGETS(22, 6, "Faulty alias 'periodic' removed.\n"));
	goto leave;
    }
    periodic_active = 1;
    if (!whyles && adrof1(STRperiodic, &aliases)) {
	vp = varval(STRtperiod);
	if (vp == STRNULL) {
	    aliasrun(1, STRperiodic, NULL);
	    goto leave;
	}
	interval = getn(vp);
	(void) time(&t);
	if (t - t_period >= interval * 60) {
	    t_period = t;
	    aliasrun(1, STRperiodic, NULL);
	}
    }
leave:
    periodic_active = 0;
    cleanup_until(&pintr_disabled);
}
Beispiel #15
0
void AGOSEngine_PN::opn_opcode34() {
	uint16 msgNum1, msgNum2;
	varval();
	getResponse((int)_variableArray[166], (int)_variableArray[167], msgNum1, msgNum2);
	_variableArray[168]= msgNum1;
	_variableArray[169]= msgNum2;
	setScriptReturn(true);
}
Beispiel #16
0
void AGOSEngine_PN::opn_opcode22() {
	int pf[8];
	int n = varval();
	funcentry(pf, n);
	funccpy(pf);
	setposition(n, 0);
	setScriptReturn(true);
}
Beispiel #17
0
void AGOSEngine_PN::opn_opcode12() {
	char bf[8];
	int a = 0;
	sprintf(bf,"%d", varval());
	while (bf[a])
		pcf(bf[a++]);
	setScriptReturn(true);
}
Beispiel #18
0
void AGOSEngine_PN::opn_opcode45() {
	uint8 *myptr;
	int x;

	if (_havinit == 0) {
		_seed = (int16)getTime();
		_havinit = 1;
	}
	_seed = 1 + (75 * (_seed + 1) - 1) % 65537;
	myptr = _workptr;
	varval();
	x = varval();
	if (x == 0)
		error("Illegal range specified for RANDOM");
	writeval(myptr, (_seed % x));
	setScriptReturn(true);
}
Beispiel #19
0
void AGOSEngine_PN::opn_opcode38() {
	_noScanFlag = 1;
	clearInputLine();
	writeval(_workptr, _keyPressed.ascii);
	_keyPressed.reset();
	_noScanFlag = 0;
	varval();
	setScriptReturn(true);
}
Beispiel #20
0
void AGOSEngine_PN::opn_opcode15() {
	int32 x = varval();
	if ((x < 0) || (x > 4))
		x = 0;

	pcf((unsigned char)254);
	_curWindow = x;
	_xofs = (8 * _windowArray[_curWindow]->textLength) / 6 + 1;
	setScriptReturn(true);
}
Beispiel #21
0
static void
dset(Char *dp)
{
    /*
     * Don't call set() directly cause if the directory contains ` or
     * other junk characters glob will fail. 
     */
    setcopy(STRowd, varval(STRcwd), VAR_READWRITE|VAR_NOGLOB);
    setcopy(STRcwd, dp, VAR_READWRITE|VAR_NOGLOB);
    tsetenv(STRPWD, dp);
}
Beispiel #22
0
int AGOSEngine_PN::findentry() {
	int stepmt;
	int curObj = 0;
	uint32 ofs = _quickptr[11];
	int c1, c2;

	c1 = varval();
	c2 = varval();
	stepmt = _quickshort[4];

	while (curObj < _quickshort[6]) {
		if (((c1 == 255) || (c1 == getptr(ofs))) &&
			(c2 == getptr(ofs + 2))) {
				_variableArray[23] = curObj;
				return 1;
		}
		curObj++;
		ofs += stepmt;
	}
	return 0;
}
Beispiel #23
0
int AGOSEngine_PN::findset() {
	int curObj = _fnst;
	int c1, c2, c3, c4;
	int stepmt = _quickshort[4];
	uint32 ofs = _quickptr[11] + stepmt * curObj;
	c1 = varval();
	c2 = varval();
	c3 = varval();
	c4 = varval();
	while (curObj < _quickshort[6]) {
		if (((c1 ==255) || (c1 == getptr(ofs))) &&
			((c2 == 255) || (c2 == getptr(ofs + 2))) &&
			((c3 == 255) || (c3 == getptr(ofs + 4))) &&
			((c4 == 255) || (c4 == getptr(ofs + 6)))) {
				_variableArray[23] = curObj;
				_fnst = curObj + 1;
				return 1;
		}
		curObj++;
		ofs += stepmt;
	}
	return 0;
}
Beispiel #24
0
int AGOSEngine_PN::doline(int needsave) {
	assert(!_stackbase == !needsave);

	int x;
	int myTag = ++_tagOfActiveDoline;	// Obtain a unique tag for this doline invocation
	_dolineReturnVal = 0;

	if (_stackbase && needsave)
		_stackbase->tagOfParentDoline = myTag;

	do {
		_linct = ((*_linebase) & 127) - 1;
		_workptr = _linebase + 1;
		if (*_linebase > 127) {
			x = varval();
			if (x != (int)_variableArray[1])
				goto skipln;
		}

		do {
			x = doaction();

			if (_dolineReturnVal != 0) {
				if (_tagOfActiveDoline != myTag)
					return 0;

				x = _dolineReturnVal;
				_dolineReturnVal = 0;

				if (x > 0) {
					if (x != 3)
						dumpstack();
					// Restore the active jmpbuf to its previous value,
					// then return _dolineReturnVal-1 (will be 2-1=1 or 1-1=0).
					_tagOfActiveDoline = myTag - 1;
					return (x - 1);
				}
			}

		} while (x && !shouldQuit());

skipln:
		_linebase += 127 & *_linebase;
		_linembr++;
	} while (!shouldQuit());

	return 0;
}
Beispiel #25
0
void AGOSEngine_PN::opn_opcode63() {
	int a = readfromline();
	switch (a) {
		case 65:
			setScriptReturn(inventoryOn(varval()));
			break;
		case 64:
			setScriptReturn((_videoLockOut & 0x10) != 0);
			break;
		case 63:
			setScriptReturn(inventoryOff());
			break;
		default:
			error("opn_opcode63: unknown code %d", a);
	}
}
Beispiel #26
0
void
loaddirs(Char *fname)
{
    static Char *loaddirs_cmd[] = { STRsource, NULL, NULL };

    bequiet = 1;
    cleanup_push(&bequiet, bequiet_cleanup);
    if (fname)
	loaddirs_cmd[1] = fname;
    else if ((fname = varval(STRdirsfile)) != STRNULL)
	loaddirs_cmd[1] = fname;
    else
	loaddirs_cmd[1] = STRtildotdirs;
    dosource(loaddirs_cmd, NULL);
    cleanup_until(&bequiet);
}
Beispiel #27
0
void AGOSEngine_PN::opn_opcode62() {
	int32 zoneNum = varval();

	_videoLockOut |= 0x80;

	vc29_stopAllSounds();

	_hitCalled = 0;
	_oneClick = 0;

	loadZone(zoneNum);

	setWindowImage(2, 2);

	_copyScnFlag = 0;
	_vgaSpriteChanged = 0;

	_videoLockOut &= ~0x80;

	setScriptReturn(true);
}
Beispiel #28
0
/*ARGSUSED*/
void
dopopd(Char **v, struct command *c)
{
    Char *cp;
    struct directory *dp, *p = NULL;
    int dflag = skipargs(&v, "plvn", " [-|+<n>]");

    USE(c);
    printd = 1;
    cp = (dflag & DIR_OLD) ? varval(STRowd) : *v;

    if (cp == NULL)
	dp = dcwd;
    else if ((dflag & DIR_OLD) == 0 && v[1] != NULL) {
	stderror(ERR_NAME | ERR_TOOMANY);
	/* NOTREACHED */
	return;
    }
    else if ((dp = dfind(cp)) == 0)
	stderror(ERR_NAME | ERR_BADDIR);
    if (dp->di_prev == &dhead && dp->di_next == &dhead)
	stderror(ERR_NAME | ERR_EMPTY);
    if (dp == dcwd) {
	char   *tmp;

	if ((p = dp->di_prev) == &dhead)
	    p = dhead.di_prev;
	if (chdir(tmp = short2str(p->di_name)) < 0)
	    stderror(ERR_SYSTEM, tmp, strerror(errno));
    }
    dp->di_prev->di_next = dp->di_next;
    dp->di_next->di_prev = dp->di_prev;
    dfree(dp);
    if (dp == dcwd) {
        dnewcwd(p, dflag);
    }
    else {
	printdirs(dflag);
    }
}
Beispiel #29
0
/* Returns a newly allocated string, old or NULL */
Char *
globequal(Char *old)
{
    int     dig;
    const Char *dir;
    Char    *b;

    /*
     * kfk - 17 Jan 1984 - stack hack allows user to get at arbitrary dir names
     * in stack. PWP: let =foobar pass through (for X windows)
     */
    if (old[1] == '-' && (old[2] == '\0' || old[2] == '/')) {
	/* =- */
	const Char *olddir = varval (STRowd);

	if (olddir && *olddir &&
	    !dcwd->di_next->di_name && !dcwd->di_prev->di_name)
	    return Strspl(olddir, &old[2]);
	dig = -1;
	b = &old[2];
    }
    else if (Isdigit(old[1])) {
	/* =<number> */
	dig = old[1] - '0';
	for (b = &old[2]; Isdigit(*b); b++)
	    dig = dig * 10 + (*b - '0');
	if (*b != '\0' && *b != '/')
	    /* =<number>foobar */
	    return old;
    }
    else
	/* =foobar */
	return old;

    dir = getstakd(dig);
    if (dir == NULL)
	return NULL;
    return Strspl(dir, b);
}
Beispiel #30
0
static void
update_vars(Char *vp)
{
    if (eq(vp, STRpath)) {
	struct varent *p = adrof(STRpath); 
	if (p == NULL)
	    stderror(ERR_NAME | ERR_UNDVAR);
	else {
	    exportpath(p->vec);
	    dohash(NULL, NULL);
	}
    }
    else if (eq(vp, STRnoclobber)) {
	struct varent *p = adrof(STRnoclobber);
	if (p == NULL)
	    stderror(ERR_NAME | ERR_UNDVAR);
	else
	    no_clobber = set_noclobber(p->vec);
    }
    else if (eq(vp, STRhistchars)) {
	Char *pn = varval(vp);

	HIST = *pn++;
	if (HIST)
	    HISTSUB = *pn;
	else
	    HISTSUB = HIST;
    }
    else if (eq(vp, STRpromptchars)) {
	Char *pn = varval(vp);

	PRCH = *pn++;
	if (PRCH)
	    PRCHROOT = *pn;
	else
	    PRCHROOT = PRCH;
    }
    else if (eq(vp, STRhistlit)) {
	HistLit = 1;
    }
    else if (eq(vp, STRuser)) {
	tsetenv(STRKUSER, varval(vp));
	tsetenv(STRLOGNAME, varval(vp));
    }
    else if (eq(vp, STRgroup)) {
	tsetenv(STRKGROUP, varval(vp));
    }
    else if (eq(vp, STRwordchars)) {
	word_chars = varval(vp);
    }
    else if (eq(vp, STRloginsh)) {
	loginsh = 1;
    }
    else if (eq(vp, STRanyerror)) {
	anyerror = 1;
    }
    else if (eq(vp, STRsymlinks)) {
	Char *pn = varval(vp);

	if (eq(pn, STRignore))
	    symlinks = SYM_IGNORE;
	else if (eq(pn, STRexpand))
	    symlinks = SYM_EXPAND;
	else if (eq(pn, STRchase))
	    symlinks = SYM_CHASE;
	else
	    symlinks = 0;
    }
    else if (eq(vp, STRterm)) {
	Char *cp = varval(vp);
	tsetenv(STRKTERM, cp);
#ifdef DOESNT_WORK_RIGHT
	cp = getenv("TERMCAP");
	if (cp && (*cp != '/'))	/* if TERMCAP and not a path */
	    Unsetenv(STRTERMCAP);
#endif /* DOESNT_WORK_RIGHT */
	GotTermCaps = 0;
	if (noediting && Strcmp(cp, STRnetwork) != 0 &&
	    Strcmp(cp, STRunknown) != 0 && Strcmp(cp, STRdumb) != 0) {
	    editing = 1;
	    noediting = 0;
	    setNS(STRedit);
	}
	ed_Init();		/* reset the editor */
    }
    else if (eq(vp, STRhome)) {
	Char *cp, *canon;

	cp = Strsave(varval(vp));	/* get the old value back */
	cleanup_push(cp, xfree);

	/*
	 * convert to cononical pathname (possibly resolving symlinks)
	 */
	canon = dcanon(cp, cp);
	cleanup_ignore(cp);
	cleanup_until(cp);
	cleanup_push(canon, xfree);

	setcopy(vp, canon, VAR_READWRITE);	/* have to save the new val */

	/* and now mirror home with HOME */
	tsetenv(STRKHOME, canon);
	/* fix directory stack for new tilde home */
	dtilde();
	cleanup_until(canon);
    }
    else if (eq(vp, STRedit)) {
	editing = 1;
	noediting = 0;
	/* PWP: add more stuff in here later */
    }
    else if (eq(vp, STRvimode)) {
	VImode = 1;
	update_wordchars();
    }
    else if (eq(vp, STRshlvl)) {
	tsetenv(STRKSHLVL, varval(vp));
    }
    else if (eq(vp, STRignoreeof)) {
	Char *cp;
	numeof = 0;
    	for ((cp = varval(STRignoreeof)); cp && *cp; cp++) {
	    if (!Isdigit(*cp)) {
		numeof = 0;
		break;
	    }
	    numeof = numeof * 10 + *cp - '0';
	}
	if (numeof <= 0) numeof = 26;	/* Sanity check */
    } 
    else if (eq(vp, STRbackslash_quote)) {
	bslash_quote = 1;
    }
    else if (eq(vp, STRcompat_expr)) {
	compat_expr = 1;
    }
    else if (eq(vp, STRdirstack)) {
	dsetstack();
    }
    else if (eq(vp, STRrecognize_only_executables)) {
	tw_cmd_free();
    }
    else if (eq(vp, STRkillring)) {
	SetKillRing((int)getn(varval(vp)));
    }
    else if (eq(vp, STRhistory)) {
	sethistory((int)getn(varval(vp)));
    }
#ifndef HAVENOUTMP
    else if (eq(vp, STRwatch)) {
	resetwatch();
    }
#endif /* HAVENOUTMP */
    else if (eq(vp, STRimplicitcd)) {
	implicit_cd = ((eq(varval(vp), STRverbose)) ? 2 : 1);
    }
    else if (eq(vp, STRcdtohome)) {
	cdtohome = 1;
    }
#ifdef COLOR_LS_F
    else if (eq(vp, STRcolor)) {
	set_color_context();
    }
#endif /* COLOR_LS_F */
#if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
    else if(eq(vp, CHECK_MBYTEVAR) || eq(vp, STRnokanji)) {
	update_dspmbyte_vars();
    }
#endif
#ifdef NLS_CATALOGS
    else if (eq(vp, STRcatalog)) {
	nlsclose();
	nlsinit();
    }
#if defined(FILEC) && defined(TIOCSTI)
    else if (eq(vp, STRfilec))
	filec = 1;
#endif
#endif /* NLS_CATALOGS */
}