Ejemplo n.º 1
0
boolean filegetdefaultpath ( ptrfilespec fs ) {

	//
	// 2006-06-25 creedon: for Mac, FSRef-ized
	//
	
	#ifdef MACVERSION
	
		*fs = fsdefault;
		
		return ( true );

	#endif

	#ifdef WIN95VERSION
	
		DWORD sz;

		sz = GetCurrentDirectory (257, stringbaseaddress (fsname (fs)));
		
		if (sz == 0) {
			
			oserror (GetLastError ());
			
			return (false);
			}
		
		strcat (stringbaseaddress (fsname (fs)), "\\");

		setstringlength(fsname (fs), sz + 1);
		
		return (true);
		
	#endif		
	} /*filegetdefaultpath*/
Ejemplo n.º 2
0
boolean debugnewtexthandle (char * filename, unsigned long linenumber, unsigned long threadid, const bigstring bs, Handle *htext) {

    /*
    create a new handle to hold the text of the string.

    if the string is "\pABC" -- you get a handle of size 3.
    */

    register long len = stringlength (bs);
    register Handle h;

    h = debuggetnewhandle (filename, linenumber, threadid, len, false);

    if (h == nil) {

        memoryerror ();

        return (false);
    }

    if (len > 0)
        moveleft ((ptrstring) stringbaseaddress (bs), *h, len);

    *htext = h; /*pass handle back to caller*/

    return (true);
} /*newtexthandle*/
Ejemplo n.º 3
0
boolean filesetdefaultpath ( const ptrfilespec fs ) {

	//
	// 2006-06-18 creedon: for Mac, FSRef-ized
	//
	
	#ifdef MACVERSION

		setfserrorparam ( fs );
		
		fsdefault = *fs;
		
		return (true);
		
	#endif

	#ifdef WIN95VERSION
	
		if (isemptystring (fsname (fs)))
			return (true);
		
		if (!SetCurrentDirectory (stringbaseaddress(fsname (fs)))) {
			
			oserror (GetLastError ());
			
			return (false);
			}

		return (true);
		
	#endif
	
	} // filesetdefaultpath
Ejemplo n.º 4
0
static boolean winregpullhkeyfromtext (Handle htext, HKEY *hkey) {

	/*
	7.0.2b1 Radio PBS: get the base key from the text string. Remove
	it from the text string.

	If a string is HKCU/foo/bar/, then htext becomes foo\bar\, and *hkey
	becomes HKEY_CLASSES_USER.
	*/

	short ixslash;
	bigstring bsbase;
	boolean fl = false;
	
	ixslash = textpatternmatch (*htext, gethandlesize (htext), BIGSTRING ("\x01\\"), true);

	if (ixslash == -1) /*didn't find?*/
		return (false);

	pullfromhandle (htext, 0, ixslash, stringbaseaddress (bsbase));

	pullfromhandle (htext, 0, 1, nil); /*remove leading /*/

	setstringlength (bsbase, ixslash);

	allupper (bsbase); /*case insensitive*/

	if ((equalstrings (bsbase, STR_P_HKCU_SHORT)) || (equalstrings (bsbase, STR_P_HKCU_LONG))) {
		*hkey = HKEY_CURRENT_USER;
		fl = true;
		}

	if ((equalstrings (bsbase, STR_P_HKLM_SHORT)) || (equalstrings (bsbase, STR_P_HKLM_LONG))) {
		*hkey = HKEY_LOCAL_MACHINE;
		fl = true;
		}

	if ((equalstrings (bsbase, STR_P_HKCR_SHORT)) || (equalstrings (bsbase, STR_P_HKCR_LONG))) {
		*hkey = HKEY_CLASSES_ROOT;
		fl = true;
		}

	if ((equalstrings (bsbase, STR_P_HKU_SHORT)) || (equalstrings (bsbase, STR_P_HKU_LONG))) {
		*hkey = HKEY_USERS;
		fl = true;
		}

	if ((equalstrings (bsbase, STR_P_HKCC_SHORT)) || (equalstrings (bsbase, STR_P_HCC_LONG))) {
		*hkey = HKEY_CURRENT_CONFIG;
		fl = true;
		}
	
	return (fl);
	} /*winregpullhkeyfromtext*/
Ejemplo n.º 5
0
boolean pushtexthandle (const bigstring bs, Handle htext) {

    /*
    htext is a handle created with newtexthandle.

    increase the size of the handle so we can push the text of bs at
    the end of the handle (not including length byte).
    */

    return (enlargehandle (htext, (long) stringlength (bs), (ptrvoid) stringbaseaddress (bs)));
} /*pushtexthandle*/
Ejemplo n.º 6
0
boolean getRegKeyString (Handle regkey, bigstring subkey, bigstring itemname, bigstring bsval) {
    HKEY hkey;
	char key[256];
	char item[256];
	char * itemptr;
	DWORD regtype;
	long err;
	DWORD len;

	if ((subkey == NULL) || (bsval == NULL))
		return (false);

	if (stringlength (subkey) == 0)
		return (false);

	copyptocstring (subkey, key);

	if (itemname != NULL) {
		itemptr = item;
		copyptocstring (itemname, item);
		}
	else
		itemptr = NULL;

	if (RegOpenKeyEx ((HKEY) regkey, key, 0, KEY_READ, &hkey) == ERROR_SUCCESS) {
		
		len = sizeof(bigstring) - 1;

		err = RegQueryValueEx (hkey, itemptr, NULL, &regtype, stringbaseaddress(bsval), &len);
			
		RegCloseKey (hkey);

		if (err != ERROR_SUCCESS)
			return (false);

		if (regtype != REG_SZ)
			return (false);

		setstringlength (bsval, len - 1);

		return (true);
		}

	return (false);
	} /*getRegKeyString*/
Ejemplo n.º 7
0
boolean opsetactualheadstring (hdlheadrecord hnode, bigstring newstring) {
	
	return (sethandlecontents (stringbaseaddress (newstring), stringlength (newstring), (**hnode).headstring));
	} /*opsetactualheadstring*/
Ejemplo n.º 8
0
static boolean sysfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
	
	//
	// 2006-06-28 creedon: for Mac, FSRef-ized
	//
	// 5.0b16 dmb: undo that change. it affect performance adversely if many threads do it.
	//
	// 5.0b12 dmb: in systemtaskfunc, set flresting to false to make sure we don't slow down too much
	//
	// 1/18/93 dmb: in systemtaskfunc, don't call processyield directly; use langbackgroundtask
	//
	// 8/11/92 dmb: make apprunningfunc accept a string or an ostype
	//
	// 5/20/92 dmb: do processyield directly on systemtaskfunc
	//
	// 2/12/92 dmb: do partialeventloop on systemtask & bringapptofrontfunc
	//
	
	register tyvaluerecord *v = vreturned;
	
	setbooleanvalue (false, v); /*assume the worst*/
	
	switch (token) { /*these verbs don't need any special globals pushed*/
		
		case systemversionfunc: {
			bigstring bs;
			
			getsystemversionstring (bs, nil);
			
			if (!langcheckparamcount (hparam1, 0))
				return (false);
						
			return (setstringvalue (bs, v));
			}
		
		case systemtaskfunc:
			if (!langcheckparamcount (hparam1, 0)) /*shouldn't have any parameters*/
				return (false);
			
			shellsysverbwaitroutine ();
			
			/*
			if (!processyield ())
				return (false);
			*/
			
			if (!langbackgroundtask (true))
				return (false);
			
			(*v).data.flvalue = true;
			
			return (true);
		
		case browsenetworkfunc:
		
			#ifdef MACVERSION
			
				return (langipcbrowsenetwork (hparam1, v));
				
			#endif
			
			#ifdef WIN95VERSION
			
				#pragma message ("WIN95: browsenetworkfunc - not yet implemented!")
			
				break;
				
			#endif

		case apprunningfunc: {
			OSType appid;
			bigstring bsapp;
			tyvaluerecord val;
			
			flnextparamislast = true;
			
			/*
			if (!getostypevalue (hparam1, 1, &appid))
				return (false);
			
			(*v).data.flvalue = findrunningapplication (&appid, nil);
			*/
			
			if (!getparamvalue (hparam1, 1, &val))
				return (false);
			
			if (val.valuetype == ostypevaluetype) {
				
				setemptystring (bsapp);
				
				appid = val.data.ostypevalue;
				}
			else {
				if (!coercetostring (&val))
					return (false);
				
				pullstringvalue (&val, bsapp);
				
				if (!stringtoostype (bsapp, &appid))
					appid = 0;
				}
			
			(*v).data.flvalue = findrunningapplication (&appid, bsapp, nil);
			
			return (true);
			}
		
		case frontappfunc: {
			bigstring bs;
			
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			if (!getfrontapplication (bs, false))
				return (false);
			
			return (setstringvalue (bs, v));
			}
		
		case bringapptofrontfunc: {
			bigstring bs;
			
			flnextparamislast = true;
			
			if (!getstringvalue (hparam1, 1, bs))
				return (false);
			
			(*v).data.flvalue = activateapplication (bs);
			
			return (true);
			}
		
		case countappsfunc:
			if (!langcheckparamcount (hparam1, 0))
				return (false);
			
			return (setlongvalue (countapplications (), v));
		
		case getnthappfunc: {
			short n;
			bigstring bs;
			
			if (!getintvalue (hparam1, 1, &n))
				return (false);
			
			if (!getnthapplication (n, bs))
				setemptystring (bs);
			
			return (setstringvalue (bs, v));
			}
		
		case getapppathfunc: {
			bigstring bs;
			tyfilespec fs;
			
			flnextparamislast = true;
			
			if ( ! getstringvalue ( hparam1, 1, bs ) )
				return ( false );
			
			if ( ! getapplicationfilespec ( bs, &fs ) ) // 2006-02-17 aradke: initializes fs even if it fails
				setemptystring (bs);
				
			return ( setfilespecvalue ( &fs, v ) );
			}
		
		case memavailfunc:
			{
			unsigned long memavail;

			#ifdef WIN95VERSION
				MEMORYSTATUS meminfo;

				meminfo.dwLength = sizeof (MEMORYSTATUS);

				GlobalMemoryStatus (&meminfo);

				memavail = meminfo.dwAvailVirtual;
			#endif

			#ifdef MACVERSION
				memavail = TempFreeMem();
			#endif
			
			if (!langcheckparamcount (hparam1, 0)) /*shouldn't have any parameters*/
				return (false);
			
			return (setlongvalue (memavail, v));
			}
		
		case machinefunc:
			
			#ifdef MACVERSION
				//Code change by Timothy Paustian Friday, June 16, 2000 3:13:09 PM
				//Changed to Opaque call for Carbon
				//Carbon only runs on PPC
				#if TARGET_API_MAC_CARBON
				return (setstringvalue (machinePPC, v));
				#else
				#if GENERATINGPOWERPC
				return (setstringvalue (machinePPC, v));
				#endif
				#if GENERATING68K
				return (setstringvalue (machine68K, v));
				#endif
				#endif

				
			#endif
			
			#ifdef WIN95VERSION
				return (setstringvalue (machinex86, v));
			#endif

			break;

		case osfunc:
			return (sysos (v));
			break;

		#ifdef WIN95VERSION
			case getenvironmentvariablefunc: {
				bigstring bsenvname;
				bigstring buf;
				DWORD res;
				
				flnextparamislast = true;
				
				if (!getstringvalue (hparam1, 1, bsenvname))
					return (false);

				nullterminate(bsenvname);

				res = GetEnvironmentVariable (stringbaseaddress(bsenvname), stringbaseaddress(buf), sizeof(buf)-2);

				if (res > sizeof(buf) - 2) {
					return (setbooleanvalue (false, v));		//safety valve
					}

				setstringlength (buf, res);

				return (setstringvalue (buf, v));
				}
				break;

			case setenvironmentvariablefunc: {
				bigstring bsenvname;
				bigstring bsenvval;
				bigstring bserror, bserror2;
				boolean res;
				
				if (!getstringvalue (hparam1, 1, bsenvname))
					return (false);

				flnextparamislast = true;
				
				if (!getstringvalue (hparam1, 2, bsenvval))
					return (false);

				nullterminate(bsenvname);
				nullterminate(bsenvval);

				res = SetEnvironmentVariable (stringbaseaddress(bsenvname), stringbaseaddress(bsenvval));

				if (res) {
					return (setbooleanvalue (true, v));	
					}

				getsystemerrorstring (GetLastError(), bserror);

				nullterminate(bserror);

				wsprintf (bserror2, "Can't set environment variable \"%s\" to \"%s\" because %s", stringbaseaddress (bsenvname), stringbaseaddress (bsenvval), stringbaseaddress (bserror));

				setstringlength (bserror2, strlen(stringbaseaddress(bserror2)));

				shellerrormessage (bserror2);

				return (setbooleanvalue (false, v));	
				}
				break;
		#endif
		
		#if TARGET_API_MAC_CARBON == 1
		
			case unixshellcommandfunc: { /*7.0b51 PBS: call shell on OS X*/
			
				Handle hcommand, hreturn;
				
				flnextparamislast = true;
				
				if (!getexempttextvalue (hparam1, 1, &hcommand))
					return (false);
				
				newemptyhandle (&hreturn);
										
				if (!unixshellcall (hcommand, hreturn)) {
				
					disposehandle (hreturn);
					
					disposehandle (hcommand);
					
					return (false);
					} /*if*/
				
				disposehandle (hcommand);
					
				return (setheapvalue (hreturn, stringvaluetype, v));
				}
		
		#endif 
		
		#ifdef WIN95VERSION

			case winshellcommandfunc: {
				Handle hcommand;
				Handle houttext = nil;
				Handle herrtext = nil;
				long exitcode = 0;
				tyaddress adrexitcode, adrstderr;
				short ctconsumed = 1;
				short ctpositional = 1;
				boolean flneedexitcode, flneedstderr;
				tyvaluerecord val;
				
				if (!getexempttextvalue (hparam1, 1, &hcommand))
					return (false);
				
				if (!getoptionaladdressparam (hparam1, &ctconsumed, &ctpositional, "\x0b" "adrExitCode", &adrexitcode.ht, adrexitcode.bs))
					return (false);
				
				flnextparamislast = true;
				
				if (!getoptionaladdressparam (hparam1, &ctconsumed, &ctpositional, "\x0b" "adrStdErr", &adrstderr.ht, adrstderr.bs))
					return (false);
				
				flneedexitcode = (adrexitcode.ht != nil) || !isemptystring (adrexitcode.bs);
				
				flneedstderr = (adrstderr.ht != nil) || !isemptystring (adrstderr.bs);

				newemptyhandle (&houttext);

				if (flneedstderr)
					newemptyhandle (&herrtext);
										
				if (!winshellcall (hcommand, houttext, herrtext,
										(flneedexitcode ? &exitcode : nil))) {
				
					disposehandle (houttext);
					
					disposehandle (herrtext);
					
					disposehandle (hcommand);
					
					return (false);
					} /*if*/
				
				disposehandle (hcommand);
				
				if (flneedexitcode) {

					setlongvalue (exitcode, &val);
					
					if (!langsetsymboltableval (adrexitcode.ht, adrexitcode.bs, val))
						return (false);
					}
					
				if (flneedstderr) {

					setheapvalue (herrtext, stringvaluetype, &val);
					
					if (!langsetsymboltableval (adrstderr.ht, adrstderr.bs, val))
						return (false);
					
					exemptfromtmpstack (&val);
					}
					
				return (setheapvalue (houttext, stringvaluetype, v));
				}

		#endif //WIN95VERSION
		
		default:
			break;
		}

	getstringlist (langerrorlist, unimplementedverberror, bserror);

	return (false);
	} /*sysfunctionvalue*/