Пример #1
0
static
void KpRegisterIcon (initializedGlobals_p iGblP)
{
	KpOsType_t	wintype;
	KpInt32_t	version, ret;
	DWORD		disposition, bufSize, bufType;
	KpInt8_t	buffer[MAX_PATH], readBuf[MAX_PATH];
	HKEY		hkey;
	KpBool_t	exists;
	char		*fPtr;

	/*  This section disabled to prevent creation of
		HKEY_CLASSES_ROOT registry entries */
	if ( FALSE ){

	/* get the Windows OS type */
	KpGetSystemInfo (&wintype, &version);

	/* register the PT file only if not Win32s */
	if (wintype != KPOSTYPE_WIN32S)	{
		/* create/open the ".pt" registry key */
		ret = RegCreateKeyEx (HKEY_CLASSES_ROOT, PTFILEEXT, 0, NULL,
								REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
								NULL, &hkey, &disposition);
		if (ret != ERROR_SUCCESS) {
				return;
		}

		/* if this is a new created key, write out to the registry */
		if (disposition == REG_CREATED_NEW_KEY) {
			RegSetValueEx (hkey, NULL, 0, REG_SZ, (BYTE *)PTKEYNAME, strlen(PTKEYNAME)+1);
		}
		else {
			/* make sure the data exists */
			bufSize = MAX_PATH;
			bufType = REG_SZ;
			ret = RegQueryValueEx (hkey, NULL, NULL, &bufType,
								(BYTE *)readBuf, (DWORD *)&bufSize);
			if (ret != ERROR_SUCCESS) {
				/* data didn't exists, write it out */
				RegSetValueEx (hkey, NULL, 0, REG_SZ, (BYTE *)PTKEYNAME, strlen(PTKEYNAME)+1);
			}
		}

		/* close the registry key */
		RegCloseKey(hkey);

		/* create/open the "ptfile" registry key, this creates the file type */
		ret = RegCreateKeyEx (HKEY_CLASSES_ROOT, PTKEYNAME, 0, NULL,
								REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
								NULL, &hkey, &disposition);
		if (ret != ERROR_SUCCESS) {
			return;
		}

		/* if this is a new created key, write out to the registry the file type */
		if (disposition == REG_CREATED_NEW_KEY) {
			RegSetValueEx (hkey, NULL, 0, REG_SZ, (BYTE *)PTFILETYPE, strlen(PTFILETYPE)+1);
		}
		else {
			/* make sure the data exists */
			bufSize = MAX_PATH;
			bufType = REG_SZ;
			ret = RegQueryValueEx (hkey, NULL, NULL, &bufType,
								(BYTE *)readBuf, (DWORD *)&bufSize);
			if (ret != ERROR_SUCCESS) {
				/* data didn't exists, write it out */
				RegSetValueEx (hkey, NULL, 0, REG_SZ, (BYTE *)PTFILETYPE, strlen(PTFILETYPE)+1);
			}
		}

		/* close the registry key */
		RegCloseKey(hkey);

		/* create/open the "ptfile\defaultIcon" registry key */
		ret = RegCreateKeyEx (HKEY_CLASSES_ROOT, PTKEYDEF, 0, NULL,
								REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
								NULL, &hkey, &disposition);
		if (ret != ERROR_SUCCESS) {
			return;
		}

		/* get the path of the Color Processor dll */
		ret = GetModuleFileName (iGblP->moduleId, buffer, MAX_PATH);
		if (ret != 0) {
			/* if this is a new created key, write out to the registry */
			if (disposition == REG_CREATED_NEW_KEY) {
				strcat (buffer, ",0");
				RegSetValueEx (hkey, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer)+1);
			}
			else {
				/* test if the Color Processor dll exists at the give path */
				bufSize = MAX_PATH;
				bufType = REG_SZ;
				ret = RegQueryValueEx (hkey, NULL, NULL, &bufType,
								(BYTE *)readBuf, (DWORD *)&bufSize);
				if (ret == ERROR_SUCCESS) {
					/* strip off the index at the end of the path */
					fPtr = strrchr (readBuf, ',');
					if (fPtr != NULL) {
						*fPtr = '\0';
					}

					KpFileExists (readBuf, NULL, &exists);
					if (exists == KPFALSE) {
						strcat (buffer, ",0");
						RegSetValueEx (hkey, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer)+1);
					}
				}
			}
		}

		/* close the registry key */
		RegCloseKey(hkey);
	}
	} /* if (FALSE ) */	
}
Пример #2
0
/*--------------------------------------------------------------------
 * DESCRIPTION	(Public)
 *	Return the default directory name(s) where the profiles
 *	were loaded.  The argument Entries points to the first element in
 *	an array of SpDataBaseEntry structures.  The number of entries in
 *	the array is specified in the location pointed to by numEntries.
 *	The size of the dirName field in each entry in the array is specified 
 *	in the location pointed to by entrySize.  If the dirName field is not
 *	large enough to hold the default directory names the size required 
 *	is returned in the location pointed to by entrySize. 
 *
 * AUTHOR
 * 	Marleen_Clark & doro & M. Biamonte
 *
 * DATE CREATED
 *	October 16, 1995
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI SpProfileGetDefaultDB(
				KpInt32_t		numEntries,
				KpInt32_t		FileNameSize,
				SpDataBaseEntry_p	Entries)
{
KpInt32_t	numDBs;
SpStatus_t 	spStat = SpStatSuccess;
KpInt32_t	count;
#if defined (KPSGI) || defined(KPSGIALL) || defined (KPSUN)
KpBool_t	DoesExist;
dirStatus	Dstat;
#endif

#if defined (KPMAC)
long		gestaltResponse;
OSErr       theErr;
long        theDirID;
short       theVRefNum;
char		fname[MAX_PATH];
CInfoPBRec	parm; /* parameters for call to ROM */
HFileInfo	*fParm = (HFileInfo *)&parm;
DirInfo		*dParm = (DirInfo *)&parm;
Boolean		async=false, ColorSyncAvailable=false;
short       folderID[3] = {kLocalDomain, kSystemDomain, kUserDomain};
KpInt32_t	i;
#endif
long	macOSVersion = 0;

#if defined (KPWIN32)
KpInt32_t		retVal;
#endif

	numDBs = GetDefaultDBCount();

#if defined (KPMAC)
	Gestalt(gestaltSystemVersion, &macOSVersion);
#endif

	if (macOSVersion >= 0x1000) {	/* Only will be non-zero on Mac */
		if (numEntries <=0)
      		return SpStatBufferTooSmall;
      	count = numDBs;	/* keep number of DBs we know about */
    }
    else {
      	if (numEntries < numDBs)
     		return SpStatBufferTooSmall;
    }

   numDBs = 0;

#if defined (KPSUN)
   if (FileNameSize < 40)  /* Testing against the longer 
                                   of the following two 
                                   directory paths */
      return SpStatBufferTooSmall;

   strcpy(Entries[numDBs].dirName, 
         "/usr/openwin/share/etc/devdata/profiles");
   Dstat = KpFileExists(Entries[numDBs].dirName,
                        &Entries[numDBs].fileProps,
                        &DoesExist);
   if (DoesExist == KPTRUE)
      numDBs++;

   strcpy(Entries[numDBs].dirName,
         "/etc/openwin/devdata/profiles");
   Dstat = KpFileExists(Entries[numDBs].dirName,
                        &Entries[numDBs].fileProps,
                        &DoesExist);
   if (DoesExist == KPTRUE)
      numDBs++;
      
     /* Set filenames of unused DBs to NULL */
   while (numDBs < numEntries)
   	 Entries[numDBs++].dirName[0] = '\0';

#else

#if defined (KPSGI) || defined(KPSGIALL)

   if (FileNameSize < 18)   /* Testing against the string size */
      return SpStatBufferTooSmall;

   strcpy(Entries[0].dirName,
         "/var/cms/profiles");

   Dstat = KpFileExists(Entries[numDBs].dirName, 
                        &Entries[numDBs].fileProps,
                        &DoesExist);
   if (DoesExist == KPTRUE)
      numDBs++;

     /* Set filenames of unused DBs to NULL */
   while (numDBs < numEntries)
   	 Entries[numDBs++].dirName[0] = '\0';

#elif defined (KPMAC)

#if defined (KPMACPPC)
	ColorSyncAvailable =
		((Gestalt(gestaltColorMatchingAttr, &gestaltResponse) == noErr)
			&& (gestaltResponse & (1<<gestaltColorMatchingLibLoaded)));
#else defined (KPMAC68K)
	if (Gestalt(gestaltColorMatchingVersion, &version) == noErr) {
		if (version >= gestaltColorSync20) {
			ColorSyncAvailable = true;
		}
	}
#endif

	if (macOSVersion < 0x1000)
	{
		if (ColorSyncAvailable == true) {
			theErr = CMGetColorSyncFolderSpec ( kOnSystemDisk, kDontCreateFolder,
   										&theVRefNum, &theDirID);
   		} else {
   			theErr = colorSyncNotInstalled;
   		}

		if (theErr == noErr) {
			strcpy(Entries[0].dirName, "");
			Entries[0].fileProps.dirID   = theDirID;
			Entries[0].fileProps.vRefNum = theVRefNum;
			numDBs++;
		} else {
			theErr = FindFolder(kOnSystemDisk, kPreferencesFolderType,
                       				kDontCreateFolder, &theVRefNum, &theDirID);


			if (theErr == noErr) {
				/* Get the folder name */
				GetIndString((StringPtr)fname, COLORSYNCSTR, 1);
				if (fname[0] == 0) { /* test for empty pascal string */
					return SpStatFileNotFound;
				}
				if (fname[0] > (unsigned long)FileNameSize) {
					return SpStatBufferTooSmall;
				}
				fParm->ioCompletion = nil;
				fParm->ioVRefNum    = theVRefNum;
				fParm->ioDirID      = theDirID;
				fParm->ioFDirIndex  = 0;
				fParm->ioNamePtr    = (StringPtr)fname;
				theErr = PBGetCatInfo(&parm,async);

				if (theErr == noErr) {
					strcpy(Entries[0].dirName, "");
					Entries[0].fileProps.dirID   = dParm->ioDrDirID;
					Entries[0].fileProps.vRefNum = fParm->ioVRefNum;
					numDBs++;
				} else {
					return SpStatFileNotFound;
				}
			} else {
				return SpStatFileNotFound;
			}
		}
	}
	else
	{	/* OS X Implementation */
		/* First find profiles folder */
			for (i = 0; (i < numEntries) && (i < count); i++)
			{
			
				theErr = FindFolder(folderID[i], kColorSyncProfilesFolderType,
                       				kCreateFolder, &theVRefNum, &theDirID);
				if (theErr == noErr) {
					strcpy(Entries[i].dirName, "");
					Entries[i].fileProps.dirID   = theDirID;
					Entries[i].fileProps.vRefNum = theVRefNum;
					numDBs++;
				} else {
					spStat =  SpStatFileNotFound;
				}
            }
    }
   
     /* Set filenames and Props of unused DBs to NULL */
	while (numDBs < numEntries) {
		Entries[numDBs].dirName[0] = '\0';
		Entries[numDBs].fileProps.dirID   = 0;
		Entries[numDBs++].fileProps.vRefNum = 0;   	
	} 

#elif defined (KPWIN32)

	retVal = GetWinDefaultDB (Entries[0].dirName, FileNameSize);
	if (retVal == SpStatSuccess) {
		numDBs++;
	}
	else {
		return retVal;
	}
	
     /* Set filenames of unused DBs to NULL */
   while (numDBs < numEntries)
   	 Entries[numDBs++].dirName[0] = '\0';
#else

   return SpStatFileNotFound;

#endif

#endif
   return spStat;
}