Exemplo n.º 1
0
boolean getfilecomment (FSSpec *pfs, bigstring bscomment) {
	
	DTPBRec dt;
	
	clearbytes (&dt, longsizeof (dt));
	
	setemptystring (bscomment); /*default return*/
	
	if (!hasdesktopmanager ((*pfs).vRefNum))
		return (false);
	
	dt.ioVRefNum = (*pfs).vRefNum;
	
	if (PBDTGetPath (&dt) != noErr)
		return (false);
	
	dt.ioNamePtr = (*pfs).name;
	
	dt.ioDirID = (*pfs).parID;
	
	dt.ioDTBuffer = (Ptr) bscomment + 1;
	
	dt.ioDTReqCount = lenbigstring;
	
	if (PBDTGetCommentSync (&dt) != noErr)
		return (false);
	
	setstringlength (bscomment, dt.ioDTActCount);
	
	return (true);
	} /*getfilecomment*/
Exemplo n.º 2
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*/
Exemplo n.º 3
0
boolean opgetheadstring (hdlheadrecord hnode, bigstring bs) {
	
	if (hnode == nil) 
		setstringlength (bs, 0);
	else
		texthandletostring ((**hnode).headstring, bs);
	
	return (true);
	} /*opgetheadstring*/
Exemplo 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*/
Exemplo n.º 5
0
void texttostring (ptrvoid ptext, long ctchars, bigstring bs) {

    register long len = ctchars;

    if (len > lenbigstring)
        len = lenbigstring;

    setstringlength (bs, len);

    moveleft (ptext, &bs [1], len);
} /*texttostring*/
Exemplo n.º 6
0
static boolean midinsertchar (byte ch, bigstring bs, short ixinsert) {
	
	byte bs1 [4];  /*rab 3/21/97 was 2*/
	
	if (ixinsert > lenbigstring)
		return (false);
	
	if (stringlength (bs) == lenbigstring) /*overflow -- push character off end*/
		
		setstringlength (bs, lenbigstring - 1);
	
	setstringwithchar (ch, bs1);
	
	return (midinsertstring (bs1, bs, ixinsert)); /*should always be true*/
	} /*midinsertchar*/
Exemplo n.º 7
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*/
Exemplo n.º 8
0
static boolean newrecord (void) {
	
	hdlappwindow ha = app.appwindow;
	hdldata hdata = nil;
	bigstring bs;
	boolean fl;
	
	if (!newclearhandle (longsizeof (tydata), (Handle *) &hdata))
		return (false);
	
	setstringlength (bs, 0);
	
	/*
	pushstyle ((**ha).defaultfont, (**ha).defaultsize, (**ha).defaultstyle);
	*/
	
	outlinewindowinfo = ha;
	
	fl = opnewrecord ((**ha).contentrect);
	
	/*
	popstyle ();
	*/
	
	if (!fl)
		goto error;
	
	/*
	(**outlinedata).dirtyroutine = (callback) &madechanges;
	*/
	
	(**hdata).heditrecord = outlinedata;
	
	app.appdata = (Handle) hdata;
	
	setupoutline ();
	return (true);
	
	error:
	
	disposehandle ((Handle) hdata);
	
	return (false);
	} /*newrecord*/
Exemplo n.º 9
0
static void claygetfatsizestring (const tybrowserinfo *browserinfo, bigstring bs) {
	
	setstringlength (bs, 0);
	
	if ((*browserinfo).flvolume) { 
		
		tybrowserspec fs;
		tyfileinfo fileinfo;
		
		if (!claymakespec ((*browserinfo).vnum, 0, "\0", &fs))
			return;
	
		if (!filegetinfo (&fs, &fileinfo))
			return;

		numbertostring (fileinfo.cttotalbytes, bs);
		
		return;				
		}
		
	if ((*browserinfo).flfolder) {
		
		short ctfiles = (*browserinfo).filesize;
		
		numbertostring (ctfiles, bs);
		
		pushstring (BIGSTRING ("\x05" " item"), bs);
		
		if (ctfiles != 1)
			pushstring (BIGSTRING ("\x01" "s"), bs);
	
		return;
		}
		
	numbertostring ((*browserinfo).filesize, bs);
	} /*claygetfatsizestring*/
Exemplo n.º 10
0
land4bytestostring (long bytes, bigstring bs) {
	
	setstringlength (bs, 4);
	
	landmoveleft (&bytes, &bs [1], 4L);
	} /*land4bytestostring*/
Exemplo n.º 11
0
static void claygetfilekindstring (const tybrowserinfo *info, bigstring bs) {
	
//	FSSpec appspec;
	
	if ((*info).flvolume) {
		
		setstringlength (bs, 0);
	
		if ((*info).flejectable)
			pushadjective (BIGSTRING ("\x09" "Removable"), bs);
			
		if ((*info).flhardwarelock)
			pushadjective (BIGSTRING ("\x09" "Read-only"), bs);
			
		if ((*info).flremotevolume)
			pushadjective (BIGSTRING ("\x06" "Shared"), bs);
		
		if (stringlength (bs) > 0)
			pushstring (BIGSTRING ("\x05" " disk"), bs);
		else
			copystring (BIGSTRING ("\x04" "Disk"), bs);
		
		return;
		}
	
	if ((*info).flfolder) {
		
		copystring (BIGSTRING ("\x06" "Folder"), bs);
		
		return;
		}
	
	if ((*info).flalias) {
		
		copystring (BIGSTRING ("\x05" "Alias"), bs);
		
		return;
		}
		
	switch ((*info).filecreator) {
		
		case 'DMGR': case 'ERIK':
			copystring (BIGSTRING ("\x14" "Desktop Manager file"), bs);
		
			return;

		case 'MACS':
			copystring (BIGSTRING ("\x0f" "System Software"), bs);
			
			return;
		} /*switch*/
		
	switch ((*info).filetype) {
		
		case 'APPL':
			copystring (BIGSTRING ("\x13" "Application program"), bs);
		
			return;
			
		case 'cdev':
			copystring (BIGSTRING ("\x0d" "Control Panel"), bs);
		
			return;
			
		case 'INIT': case 'appe': case 'fext': case 'adev':
			copystring (BIGSTRING ("\x10" "System Extension"), bs);
		
			return;
		
		case 'thng': 
			copystring (BIGSTRING ("\x10" "System Component"), bs);
		
			return;
			
		case 'PRER': case 'PRES':
			copystring (BIGSTRING ("\x11" "Chooser Extension"), bs);
		
			return;
			
		case 'FFIL':
			copystring (BIGSTRING ("\x0d" "Font Suitcase"), bs);
			
			return;
			
		case 'dbgr':
			copystring (BIGSTRING ("\x08" "Debugger"), bs);
			
			return;
			
		case 'dfil':
			copystring (BIGSTRING ("\x0e" "Desk Accessory"), bs);
			
			return;
		} /*switch*/
#if 0	
	if (clayfindapp ((*info).filecreator, &appspec, (*info).vnum)) {
		
		if (stringlength (appspec.name) > 0) {
		
			copystring (appspec.name, bs);
	
			pushstring (BIGSTRING ("\x09" " document"), bs);
		
			return;
			}
		}
	else { /*DW 9/14/93 -- add it to the cache -- avoid future delays*/
		
		addapptocache ((*info).filecreator, nil);
		}
#endif
	
	copystring (BIGSTRING ("\x08" "document"), bs);
	} /*claygetfilekindstring*/
Exemplo n.º 12
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*/