Exemple #1
0
CFPropertyListRef Resources::getPropertyList(const char* filename)
{
    CFDataRef xmlCFDataRef;
    CFStringRef error;
    char cerror[10240];
    CFPropertyListRef myCFPropertyListRef = NULL;
    Boolean readOK;
    char  filePathBuf[PATH_MAX];
    CFStringRef filePath = this->getResourcePath(filename);
    CFStringGetCString(filePath, filePathBuf, sizeof(filePathBuf), kCFStringEncodingUTF8);
    CFURLRef fileURL = CFURLCreateFromFileSystemRepresentation (kCFAllocatorDefault, (const unsigned char*)filePathBuf, strlen (filePathBuf), false);
    if (fileURL!=NULL)  {
        readOK = CFURLCreateDataAndPropertiesFromResource( kCFAllocatorDefault, fileURL, &xmlCFDataRef, NULL, NULL, NULL);
        if (readOK)
        {
            myCFPropertyListRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, xmlCFDataRef, kCFPropertyListImmutable, &error);
            if (error != NULL){
                CFStringGetCString(error, cerror, sizeof(cerror), kCFStringEncodingUTF8);
                scprintf("getPropertyList error: %s\n", cerror);
            }
            CFRelease(xmlCFDataRef);
        }
        else{
            scprintf("Couldn't read Plist File %s\n", filePathBuf);
        }
    }
    return myCFPropertyListRef;
}
Exemple #2
0
void UnloadBundle(CFBundleRef theBundle)
{
	/*get bundle resource and convert from xml to propertylist struct so we can look for revdontunload attribute and not unload- necessary for external
	that interface with Cocoa*/
	Boolean dontunload = False;
	CFPropertyListRef tCFPropertyListRef = NULL;
	short resrefnum = CFBundleOpenBundleResourceMap (theBundle );
	CFURLRef resFileCFURLRef = CFBundleCopyResourceURL(theBundle,CFSTR("revinfo"),CFSTR("plist"),NULL);
	CFDataRef resCFDataRef;
	if (resFileCFURLRef && CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault,resFileCFURLRef,&resCFDataRef,nil,nil,nil))
	{
		if (resCFDataRef)
		{
			CFStringRef errorString;
			tCFPropertyListRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault,resCFDataRef,kCFPropertyListImmutable,&errorString);
			CFRelease(resCFDataRef);
		}
	}
	if (tCFPropertyListRef)
	{
		if (CFDictionaryGetValueIfPresent((CFDictionaryRef)tCFPropertyListRef,CFSTR("revdontunload"),NULL))
			dontunload = True;
	}
	if (resFileCFURLRef)
		CFRelease(resFileCFURLRef);
	CFBundleCloseBundleResourceMap (theBundle,resrefnum);
	if (theBundle && !dontunload)
	{
		CFBundleUnloadExecutable(theBundle);
		CFRelease(theBundle);
	}
}
bool LegacyWebArchive::init(SharedBuffer* data)
{
    ASSERT(data);
    if (!data)
        return false;
        
    RetainPtr<CFDataRef> cfData(AdoptCF, data->createCFData());
    if (!cfData)
        return false;
        
    CFStringRef errorString = 0;
    
    RetainPtr<CFDictionaryRef> plist(AdoptCF, static_cast<CFDictionaryRef>(CFPropertyListCreateFromXMLData(0, cfData.get(), kCFPropertyListImmutable, &errorString)));
    if (!plist) {
#ifndef NDEBUG
        const char* cError = errorString ? CFStringGetCStringPtr(errorString, kCFStringEncodingUTF8) : "unknown error";
        LOG(Archives, "LegacyWebArchive - Error parsing PropertyList from archive data - %s", cError);
#endif
        if (errorString)
            CFRelease(errorString);
        return false;
    }
    
    if (CFGetTypeID(plist.get()) != CFDictionaryGetTypeID()) {
        LOG(Archives, "LegacyWebArchive - Archive property list is not the expected CFDictionary, aborting invalid WebArchive");
        return false;
    }
    
    return extract(plist.get());
}
static CFPropertyListRef getPropertyList()
{
  CFDataRef       xmlData;
  CFStringRef error;
  CFPropertyListRef propertyList;
  CFBundleRef appBundle;
  CFURLRef myRef;

  // locate the starter's bundle:
  appBundle = CFBundleGetMainBundle();
  
  // get a URL for the named resource
  myRef = CFBundleCopyResourceURL(appBundle, CFSTR(RSRCNAME), 
				  NULL, NULL);
  if (myRef == NULL) {
    return NULL;
  }
  
  // Load the XML data using its URL.
  CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, myRef, 
					   &xmlData, NULL, NULL, NULL);

  // convert to a Property List
  propertyList = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, xmlData, 
						 kCFPropertyListImmutable, 
						 &error);
  if (error != NULL) {
    return NULL;
  }

  return propertyList;
}
Exemple #5
0
extern pascal OSStatus CFQPropertyListCreateFromXMLCFURL(CFURLRef xmlFile, CFPropertyListMutabilityOptions options, CFPropertyListRef *result)
	// See comment in header.
{
	OSStatus  err;
	CFDataRef xmlData;
	
	assert(xmlFile != NULL);
	assert( result != NULL);
	assert(*result == NULL);

	xmlData = NULL;

	err = noErr;
	if ( ! CFURLCreateDataAndPropertiesFromResource(NULL, xmlFile, &xmlData, NULL, NULL, &err) && (err == noErr) ) {
		err = coreFoundationUnknownErr;
	}
	
	if (err == noErr) {
		*result = CFPropertyListCreateFromXMLData(NULL, xmlData, options, NULL);
		if (*result == NULL) {
			err = coreFoundationUnknownErr;
		}
	}

	CFQRelease(xmlData);

	assert( (err == noErr) == (*result != NULL) );
	
	return err;
}
Exemple #6
0
/* ------------------------------------------------------------------
 *	read_user_settings ()
 */
static CFPropertyListRef read_user_settings ( const char *in_file, CFPropertyListMutabilityOptions in_opts )
{
	CFPropertyListRef	cf_prop_list	= NULL;

	CFURLRef cf_url = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8 *)in_file, strlen(in_file), FALSE);
	if ( !cf_url ) {
		msg_error( "aod: could not create URL from %s", in_file);
		return( NULL );
	}

	SInt32 err;
	CFDataRef cf_data = NULL;
	if ( !CFURLCreateDataAndPropertiesFromResource(NULL, cf_url, &cf_data, NULL, NULL, &err) ) {
		if ( msg_verbose )
			msg_info("aod: no local user settings (%s), using defaults", in_file);
		CFRelease(cf_url);
		return( NULL );
	}

	CFStringRef cf_str_err = NULL;
	if ( cf_data ) {
		cf_prop_list = CFPropertyListCreateFromXMLData( kCFAllocatorDefault, cf_data, in_opts, &cf_str_err);
		if ( cf_prop_list )
			CFRetain(cf_prop_list);
	} else
		msg_error("aod: enable to create CFData ref for %s", in_file);

	CFRelease(cf_url);
	if ( cf_str_err )
		CFRelease( cf_str_err );
	if ( cf_data )
		CFRelease( cf_data );

	return( cf_prop_list );
} /* read_user_settings */
Exemple #7
0
/* @overload read_plist(path)
 *
 * Reads from the specified path and de-serializes the property list.
 *
 * @note This does not yet support all possible types that can exist in a valid property list.
 *
 * @note This currently only assumes to be given an Xcode project document.
 *       This means that it only accepts dictionaries, arrays, and strings in
 *       the document.
 *
 * @param [String] path  The path to the property list file.
 * @return [Hash]        The dictionary contents of the document.
 */
static VALUE
read_plist(VALUE self, VALUE path) {
  CFPropertyListRef dict;
  CFStringRef       errorString;
  CFDataRef         resourceData;
  SInt32            errorCode;

  CFURLRef fileURL = str_to_url(path);
  if (CFURLCreateDataAndPropertiesFromResource(NULL, fileURL, &resourceData, NULL, NULL, &errorCode)) {
    CFRelease(fileURL);
  }
  if (!resourceData) {
    rb_raise(rb_eArgError, "Unable to read data from `%s'", RSTRING_PTR(rb_inspect(path)));
  }

  dict = CFPropertyListCreateFromXMLData(NULL, resourceData, kCFPropertyListImmutable, &errorString);
  if (!dict) {
    rb_raise(rb_eArgError, "Unable to read plist data from `%s': %s", RSTRING_PTR(rb_inspect(path)), RSTRING_PTR(cfstr_to_str(errorString)));
  }
  CFRelease(resourceData);

  register VALUE hash = rb_hash_new();
  CFDictionaryApplyFunction(dict, hash_set, (void *)hash);
  CFRelease(dict);

  return hash;
}
static WTF::RetainPtr<CFDictionaryRef> readPListFile(CFStringRef fileName, bool createFile, CFBundleRef bundle)
{
    if (createFile) {
        BP_CreatePluginMIMETypesPreferencesFuncPtr funcPtr =
            (BP_CreatePluginMIMETypesPreferencesFuncPtr)CFBundleGetFunctionPointerForName(bundle, CFSTR("BP_CreatePluginMIMETypesPreferences"));
        if (funcPtr)
            funcPtr();
    }

    WTF::RetainPtr<CFDictionaryRef> map;
    WTF::RetainPtr<CFURLRef> url =
        CFURLCreateWithFileSystemPath(kCFAllocatorDefault, fileName, kCFURLPOSIXPathStyle, false);

    CFDataRef resource = 0;
    SInt32 code;
    if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, url.get(), &resource, 0, 0, &code))
        return map;

    WTF::RetainPtr<CFPropertyListRef> propertyList =
            CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resource, kCFPropertyListImmutable, 0);

    CFRelease(resource);

    if (!propertyList)
        return map;

    if (CFGetTypeID(propertyList.get()) != CFDictionaryGetTypeID())
        return map;

    map = static_cast<CFDictionaryRef>(static_cast<CFPropertyListRef>(propertyList.get()));
    return map;
}
Exemple #9
0
bool QConfFileSettingsPrivate::readPlistFile(const QString &fileName, ParsedSettingsMap *map) const
{
    QCFType<CFDataRef> resource;
    SInt32 code;
    if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, urlFromFileName(fileName),
            &resource, 0, 0, &code))
        return false;

    QCFString errorStr;
    QCFType<CFPropertyListRef> propertyList =
        CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resource, kCFPropertyListImmutable,
                                        &errorStr);

    if (!propertyList)
        return true;
    if (CFGetTypeID(propertyList) != CFDictionaryGetTypeID())
        return false;

    CFDictionaryRef cfdict =
        static_cast<CFDictionaryRef>(static_cast<CFPropertyListRef>(propertyList));
    int size = (int)CFDictionaryGetCount(cfdict);
    QVarLengthArray<CFPropertyListRef> keys(size);
    QVarLengthArray<CFPropertyListRef> values(size);
    CFDictionaryGetKeysAndValues(cfdict, keys.data(), values.data());

    for (int i = 0; i < size; ++i) {
        QString key = qtKey(static_cast<CFStringRef>(keys[i]));
        map->insert(QSettingsKey(key, Qt::CaseSensitive), qtValue(values[i]));
    }
    return true;
}
// ---------------------------------
// Load the element strings from the given resource (XML) file into a CFPropertyListRef
static CFPropertyListRef xml_load(const CFStringRef pResourceName,const CFStringRef pResourceExtension)
{
	CFPropertyListRef tCFPropertyListRef = NULL;
	CFURLRef resFileCFURLRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), pResourceName, pResourceExtension, NULL);

	if (NULL != resFileCFURLRef)
	{
		CFDataRef resCFDataRef;

		if (CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, resFileCFURLRef, &resCFDataRef, nil, nil, nil))
		{
			if (NULL != resCFDataRef)
			{
				CFStringRef errorString;

				tCFPropertyListRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resCFDataRef, kCFPropertyListImmutable, &errorString);
				if (NULL == tCFPropertyListRef)
					CFShow(errorString);
				CFRelease(resCFDataRef);
			}
		}
		CFRelease(resFileCFURLRef);
	}
	return tCFPropertyListRef;
}
void writePropertyListToFile (CFDataRef data) {
    CFStringRef errorString;

    CFPropertyListRef propertyList = CFPropertyListCreateFromXMLData (NULL, data, kCFPropertyListMutableContainersAndLeaves, &errorString);

    if (errorString == NULL) {
        CFStringRef urlString = CFStringCreateWithCString (NULL, kFilename, CFStringGetSystemEncoding ());

        CFURLRef fileURL = CFURLCreateWithFileSystemPath (NULL, urlString, kCFURLPOSIXPathStyle, FALSE);

        CFWriteStreamRef stream = CFWriteStreamCreateWithFile (NULL, fileURL);

        Boolean isOpen = CFWriteStreamOpen (stream);

        CFShow (CFSTR ("Property list (as written to file):"));
        CFShow (propertyList);
  
        CFIndex bytesWritten = CFPropertyListWriteToStream (propertyList, stream, kCFPropertyListXMLFormat_v1_0, NULL);

        CFWriteStreamClose (stream);
    }
    else {
        CFShow (errorString);
        CFRelease (errorString);
    }

    CFRelease (propertyList);
}
static void SecSystemAnchorSourceInit(void) {
	SecSystemAnchorSourceRef result = (SecSystemAnchorSourceRef)
		malloc(sizeof(*result));
	result->base.copyParents = SecSystemAnchorSourceCopyParents;
	result->base.contains = SecSystemAnchorSourceContains;

	CFDataRef xmlData = SecFrameworkCopyResourceContents(
		CFSTR("SystemAnchors"), CFSTR("plist"), NULL);
	CFPropertyListRef plist = CFPropertyListCreateFromXMLData(
		kCFAllocatorDefault, xmlData, kCFPropertyListImmutable, NULL);
	if (plist) {
		if (CFGetTypeID(plist) == CFDictionaryGetTypeID()) {
			result->digests = (CFSetRef)plist;
		} else {
			secwarning("SystemAnchors plist is wrong type.");
			CFRelease(plist);
		}
	}

	if (!result->digests) {
		result->digests = CFSetCreate(kCFAllocatorDefault, NULL, 0,
			&kCFTypeSetCallBacks);
	}

	kSecSystemAnchorSource = (SecCertificateSourceRef)result;
}
// Assumes the domain has already been locked
static void _loadXMLDomainIfStale(CFURLRef url, _CFXMLPreferencesDomain *domain) {
    CFAllocatorRef alloc = __CFPreferencesAllocator();
    int idx;
    if (domain->_domainDict) {
        CFDateRef modDate;
        CFAbsoluteTime modTime;
    	CFURLRef testURL = url;

        if (CFDictionaryGetCount(domain->_domainDict) == 0) {
            // domain never existed; check the parent directory, not the child
            testURL = CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR(".."), kCFURLPOSIXPathStyle, true, url);
        }

        modDate = (CFDateRef )CFURLCreatePropertyFromResource(alloc, testURL, kCFURLFileLastModificationTime, NULL);
        modTime = modDate ? CFDateGetAbsoluteTime(modDate) : 0.0;

        // free before possible return. we can test non-NULL of modDate but don't depend on contents after this.
        if (testURL != url) CFRelease(testURL);
        if (modDate) CFRelease(modDate);
        
        if (modDate != NULL && modTime < domain->_lastReadTime) {            // We're up-to-date
            return;
        }
    }

	
    // We're out-of-date; destroy domainDict and reload
    if (domain->_domainDict) {
        CFRelease(domain->_domainDict);
        domain->_domainDict = NULL;
    }

    // We no longer lock on read; instead, we assume parse failures are because someone else is writing the file, and just try to parse again.  If we fail 3 times in a row, we assume the file is corrupted.  REW, 7/13/99

    for (idx = 0; idx < 3; idx ++) {
        CFDataRef data;
        if (!CFURLCreateDataAndPropertiesFromResource(alloc, url, &data, NULL, NULL, NULL) || !data) {
            // Either a file system error (so we can't read the file), or an empty (or perhaps non-existant) file
            domain->_domainDict = CFDictionaryCreateMutable(alloc, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
            break;
        } else {
            CFTypeRef pList = CFPropertyListCreateFromXMLData(alloc, data, kCFPropertyListImmutable, NULL);
            CFRelease(data);
            if (pList && CFGetTypeID(pList) == CFDictionaryGetTypeID()) {
                domain->_domainDict = CFDictionaryCreateMutableCopy(alloc, 0, (CFDictionaryRef)pList);
                CFRelease(pList);
                break;
            } else if (pList) {
                CFRelease(pList);
            }
            // Assume the file is being written; sleep for a short time (to allow the write to complete) then re-read
            __CFMilliSleep(150);
        }
    }
    if (!domain->_domainDict) {
        // Failed to ever load
        domain->_domainDict = CFDictionaryCreateMutable(alloc, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    }
    domain->_lastReadTime = CFAbsoluteTimeGetCurrent();
}
Exemple #14
0
/* ------------------------------------------------------------------
 *	get_mail_attribute_values ()
 */
static CFMutableDictionaryRef get_mail_attribute_values ( const char *in_mail_attribute,
															struct od_user_opts *in_out_opts )
{
	CFMutableDictionaryRef cf_mut_dict_ref = NULL;
	unsigned long ul_size = strlen( in_mail_attribute );
	CFDataRef cf_data_ref = CFDataCreate( NULL, (const UInt8 *)in_mail_attribute, ul_size );
	if ( !cf_data_ref )
		return( NULL );

	CFPropertyListRef cf_plist_ref = CFPropertyListCreateFromXMLData( kCFAllocatorDefault,
										cf_data_ref, kCFPropertyListImmutable, NULL );
	if ( cf_plist_ref ) {
		if ( CFDictionaryGetTypeID() == CFGetTypeID( cf_plist_ref ) ) {
			cf_mut_dict_ref = CFDictionaryCreateMutable( kCFAllocatorDefault,
														0, &kCFCopyStringDictionaryKeyCallBacks,
														&kCFTypeDictionaryValueCallBacks);
			CFRetain(cf_mut_dict_ref);
			CFDictionaryAddValue( cf_mut_dict_ref, CFSTR(kXMLKeyAttrVersion), CFSTR(kXMLValueVersion2) );

			CFDictionaryRef cf_dict_ref = (CFDictionaryRef)cf_plist_ref;
			get_acct_state( cf_dict_ref, cf_mut_dict_ref, in_out_opts );
			get_alt_loc( cf_dict_ref, cf_mut_dict_ref );
			get_mail_quota( cf_dict_ref, cf_mut_dict_ref );
		}
	}
	CFRelease( cf_data_ref );

	return(cf_mut_dict_ref);
} /* get_mail_attribute_values */
CFArrayRef copyTrustedAppListFromBundle(CFStringRef bundlePath, CFStringRef trustedAppListFileName)
{
	CFStringRef errorString = nil;
    CFURLRef bundleURL,trustedAppsURL = NULL;
    CFBundleRef secBundle = NULL;
	CFPropertyListRef trustedAppsPlist = NULL;
	CFDataRef xmlDataRef = NULL;
	SInt32 errorCode;
    CFArrayRef trustedAppList = NULL;
	CFMutableStringRef trustedAppListFileNameWithoutExtension = NULL;

    // Make a CFURLRef from the CFString representation of the bundleÕs path.
    bundleURL = CFURLCreateWithFileSystemPath(
        kCFAllocatorDefault,bundlePath,kCFURLPOSIXPathStyle,true);

	CFRange wholeStrRange;

	if (!bundleURL)
        goto xit;

    // Make a bundle instance using the URLRef.
    secBundle = CFBundleCreate(kCFAllocatorDefault,bundleURL);
    if (!secBundle)
        goto xit;

	trustedAppListFileNameWithoutExtension =
		CFStringCreateMutableCopy(NULL,CFStringGetLength(trustedAppListFileName),trustedAppListFileName);
	wholeStrRange = CFStringFind(trustedAppListFileName,CFSTR(".plist"),0);

	CFStringDelete(trustedAppListFileNameWithoutExtension,wholeStrRange);

    // Look for a resource in the bundle by name and type
    trustedAppsURL = CFBundleCopyResourceURL(secBundle,trustedAppListFileNameWithoutExtension,CFSTR("plist"),NULL);
    if (!trustedAppsURL)
        goto xit;

    if ( trustedAppListFileNameWithoutExtension )
		CFRelease(trustedAppListFileNameWithoutExtension);

	if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault,trustedAppsURL,&xmlDataRef,NULL,NULL,&errorCode))
        goto xit;

	trustedAppsPlist = CFPropertyListCreateFromXMLData(kCFAllocatorDefault,xmlDataRef,kCFPropertyListImmutable,&errorString);
    trustedAppList = (CFArrayRef)trustedAppsPlist;

xit:
    if (bundleURL)
        CFRelease(bundleURL);
    if (secBundle)
        CFRelease(secBundle);
    if (trustedAppsURL)
        CFRelease(trustedAppsURL);
    if (xmlDataRef)
        CFRelease(xmlDataRef);
    if (errorString)
        CFRelease(errorString);

    return trustedAppList;
}
Exemple #16
0
/**
 * Import the #plist_t structure from XML format.
 *
 * @param plist_xml a pointer to the xml buffer.
 * @param length length of the buffer to read.
 * @param plist a pointer to the imported plist.
 */
void plist_from_xml(const char *plist_xml, uint32_t length, plist_t * plist)
{
	*plist = NULL;
	
	CFDataRef data = CFDataCreate(kCFAllocatorDefault, (UInt8 *)plist_xml, length);
	if (data) {
		*plist = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, data, kCFPropertyListMutableContainers, NULL);
		CFRelease(data);
	}
}
Exemple #17
0
extern CFPropertyListRef INXCreateDictionaryWithString(CFStringRef s) {
	if (s == NULL)
		return NULL;
	CFDataRef data = CFStringCreateExternalRepresentation(NULL, s, kCFStringEncodingUTF8, 0);
	if (data == NULL)
		return NULL;
	CFPropertyListRef retval = CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListImmutable, NULL);
	CFRelease(data);
	return retval;
}
Exemple #18
0
CFDictionaryRef makeCFDictionaryFrom(CFDataRef data)
{
	if (data) {
		CFPropertyListRef plist = CFPropertyListCreateFromXMLData(NULL, data,
			kCFPropertyListImmutable, NULL);
		if (plist && CFGetTypeID(plist) != CFDictionaryGetTypeID())
			CFError::throwMe();
		return CFDictionaryRef(plist);
	} else
		return NULL;
	
}
Exemple #19
0
RemoteVSTClient::RemoteVSTClient(CFBundleRef bundle, audioMasterCallback theMaster, AEffect *theEffect, bool showGUI) :
    RemotePluginClient(theMaster, theEffect)
{
	m_bundle = bundle;
	m_audioMaster = theMaster;
	pid_t child;

	SInt32 errorCode;
	CFDataRef data;
	CFURLRef configUrl = CFBundleCopyResourceURL(bundle, CFSTR("config"), CFSTR("plist"), NULL);
	if (configUrl == 0) {
		return;
	}
	CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, configUrl, &data, NULL, NULL, &errorCode);
	m_props = (CFDictionaryRef) CFPropertyListCreateFromXMLData( kCFAllocatorDefault, data, kCFPropertyListImmutable, NULL);

	std::string dllName(CFStringGetCStringPtr(get_path_prop(CFSTR("plugin-name")), NULL));
    std::string arg = dllName + "," + getFileIdentifiers();
    if (showGUI) arg = "-g " + arg;
	const char *argStr = arg.c_str();

	CFURLRef server_url = CFBundleCopyResourceURL(m_bundle, CFSTR("dssi-vst-server.exe"), CFSTR("so"), NULL);
	if (server_url != NULL) {
		CFStringRef server_path = CFURLCopyFileSystemPath(server_url, kCFURLPOSIXPathStyle);
		if (server_path != NULL) {
			const char *c_server_path = CFStringGetCStringPtr(server_path, NULL);
			CFStringRef wine_path =  (CFStringRef) CFDictionaryGetValue(m_props, CFSTR("wine-path"));
			if (wine_path != NULL) {
				const char *c_wine_path = CFStringGetCStringPtr(wine_path, NULL);	
				std::cerr << "RemoteVSTClient: executing " << c_server_path << "\n";
				// if no dispaly environment guess...
				// setenv("DISPLAY", ":0", 0);
				setenv("DYLD_FALLBACK_LIBRARY_PATH", "/usr/X11/lib:/usr/lib", 0);
				if ((child = fork()) < 0) {
					cleanup();
					throw((std::string)"Fork failed");
				} else if (child == 0) { // child process
					if (execlp(c_wine_path, "wine", c_server_path, argStr, NULL)) {
						perror("Exec failed");
						exit(1);
					}
				}
				syncStartup();
				return;
			}
		}
	}
	cleanup();
	throw((std::string)"Failed to find dssi-vst-server executable");
	return;
 }
extern OSStatus MySyncPaneFromTicket (
    MyCustomContext context, 
    PMPrintSession session
)

{
    OSStatus result = noErr;
    PMTicketRef ticket = NULL;

    result = MyGetTicket (session, kPDE_PMPrintSettingsRef, &ticket);
    if (result == noErr)
    {
        CFDataRef xmlData = NULL;
        CFDictionaryRef dict = NULL;

        result = PMTicketGetCFData (
            ticket, 
            kPMTopLevel, 
            kPMTopLevel, 
            kAppPrintDialogPDEOnlyKey, 
            &xmlData
        );
        if (result == noErr)
        {
            dict = CFPropertyListCreateFromXMLData (
                        kCFAllocatorDefault,
                        xmlData,
                        kCFPropertyListImmutable,
                        NULL
                        );
            if (dict)
            {
                InternSettings(dict, &context->settings);
                CFRelease(dict);
            }
            else
                result = kPMKeyNotFound;    // bad XML?
        }
        if (result == kPMKeyNotFound)
        {
            InitSettings(&context->settings);
            result = noErr;
        }
    }

    if (result == noErr)
        SyncPaneFromSettings(context);
    
    MyDebugMessage("MySyncPane", result);
    return result;
}
const void *
macosx_parse_plist(const char *path)
{
  CFPropertyListRef plist = NULL;
  const char url_header[] = "file://";
  char *url_text = NULL;
  CFURLRef url = NULL;
  CFAllocatorRef cf_alloc = kCFAllocatorDefault;
  size_t url_text_len = ((sizeof(url_header) - 1UL) + strlen(path) + 1UL);
  url_text = (char *)xmalloc(url_text_len);

  /* Create URL text for the Info.plist file: */
  strcpy(url_text, url_header);
  strcat(url_text, path);

  /* Generate a CoreFoundation URL from the URL text: */
  url = CFURLCreateWithBytes(cf_alloc, (const UInt8 *)url_text,
			     url_text_len, kCFStringEncodingUTF8, NULL);
  if (url)
    {
      /* Extract the contents of the file into a CoreFoundation data
	 buffer.  */
      CFDataRef data = NULL;
      if (CFURLCreateDataAndPropertiesFromResource(cf_alloc, url, &data,
						   NULL, NULL, NULL)
          && (data != NULL))
	{
	  /* Create the property list from XML data or from the binary
	     plist data.  */
	  plist = CFPropertyListCreateFromXMLData(cf_alloc, data,
						  kCFPropertyListImmutable,
						  NULL);
	  CFRelease(data);
	  if (plist != NULL)
	    {
	      /* Make sure the property list was a CFDictionary, free it
               * and NULL the pointer if it was not as such: */
	      if (CFGetTypeID(plist) != CFDictionaryGetTypeID())
		{
		  CFRelease(plist);
		  plist = NULL;
		}
	    }
	}
      CFRelease(url);
    }

  xfree(url_text);
  return plist;
}
Exemple #22
0
CFDictionaryRef CreateDictionaryFromPlist(CFStringRef stringPlist, SInt32 *errorCode)
{
    CFDataRef dataRef;
    CFStringRef errorStringRef;
    
    CFURLRef fileURLRef = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,stringPlist,kCFURLPOSIXPathStyle,false);
    Boolean status = CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault,fileURLRef,&dataRef,NULL,NULL,errorCode);
    if (!status) {
        //error
    }
    CFDictionaryRef dictRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault,dataRef,
                                                              kCFPropertyListMutableContainersAndLeaves,&errorStringRef);
    CFRelease(fileURLRef);
    CFRelease(dataRef);
    return dictRef;
}
CFPropertyListRef	 ReadPresetFromPresetFile (char* filePath)
{	
	if (!filePath)
		return NULL;
	
	FSRef ref;
	if (FSPathMakeRef((UInt8 *)filePath, &ref, NULL))
		return NULL;
		
	CFDataRef			resourceData = NULL;
	CFPropertyListRef   theData = NULL;
	CFStringRef			errString = NULL;
	CFURLRef			fileURL = CFURLCreateFromFSRef (kCFAllocatorDefault, &ref);
		if (fileURL == NULL) {
			goto home;
		}
		
	SInt32				result;
    
   // Read the XML file.
   Boolean status; status = CFURLCreateDataAndPropertiesFromResource (kCFAllocatorDefault, fileURL,
                                                                &resourceData,	// place to put file data
                                                                NULL, NULL, &result);
        if (status == false || result) {
            goto home;
        }
    
	theData = CFPropertyListCreateFromXMLData (kCFAllocatorDefault, resourceData,  
													kCFPropertyListImmutable, &errString);
        if (theData == NULL || errString) {
            if (theData)
				CFRelease (theData);
			theData = NULL;
			goto home;
       }
	
home:
	if (fileURL)
		CFRelease (fileURL);
	if (resourceData)
		CFRelease (resourceData);
    if (errString)
		CFRelease (errString);
		
	return theData;
}
Exemple #24
0
// Translates an iPod binary Property-list into a text property list.
//
// Returns:
//		true	on success
//		false	on failure
//
bool CiPoTApi::TranslatePLIST(char *originalFile, char *newFile)
{
	CFPropertyListRef propertyList;
	CFURLRef fileURL;
	CFStringRef inputFile, errorString;
	CFDataRef resourceData;
	Boolean status;
	SInt32 errorCode;
	bool ok = false;

	// Create a URL that specifies the file we will create to hold the XML data.
	inputFile = CFStringCreateWithCString(kCFAllocatorDefault, originalFile, kStrEncoding);
	fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, inputFile, kPathStyle, false);
	if (!fileURL)
		return false;
	// Read the XML file.
	status = CFURLCreateDataAndPropertiesFromResource(
		kCFAllocatorDefault, fileURL, &resourceData, NULL, NULL, &errorCode);
	if (resourceData) {
		// Reconstitute the dictionary using the XML data.
		propertyList = CFPropertyListCreateFromXMLData(
			kCFAllocatorDefault, resourceData,kCFPropertyListImmutable, &errorString);
		if (propertyList != NULL) {
			CFStringRef outputFile;
			CFDataRef xmlData;
			Boolean status;
			SInt32 errorCode;
			
			CFRelease(fileURL);
			outputFile = CFStringCreateWithCString(kCFAllocatorDefault, newFile, kStrEncoding);
			fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, outputFile, kPathStyle, false);
			// Convert the property list into XML data.
			xmlData = CFPropertyListCreateXMLData(kCFAllocatorDefault, propertyList);
			// Write the XML data to the file.
			status = CFURLWriteDataAndPropertiesToResource(fileURL, xmlData, NULL, &errorCode);
			ok = status ? true : false;
			CFRelease(xmlData);
			CFRelease(outputFile);
			CFRelease(propertyList);
		}
	}
	CFRelease(inputFile);
	CFRelease(fileURL);
	return ok;
}
SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags *responseFlags) {
    CHECK_FOR_FORK();
    SInt32 retval = ERR_SUCCESS;
#if DEPLOYMENT_TARGET_MACOSX
    mach_msg_timeout_t msgtime = (timeout > 0.0 && 1000.0 * timeout < INT_MAX) ? (mach_msg_timeout_t)(1000.0 * timeout) : 0;
    mach_msg_base_t *msg = NULL;
    CFIndex size = MAX_STRING_COUNT * MAX_STRING_LENGTH;
    CFDataRef responseData;
    
    if (userNotification && MACH_PORT_NULL != userNotification->_replyPort) {
        msg = (mach_msg_base_t *)CFAllocatorAllocate(kCFAllocatorSystemDefault, size, 0);
	if (__CFOASafe) __CFSetLastAllocationEventName(msg, "CFUserNotification (temp)");
        if (msg) {
            memset(msg, 0, size);
            msg->header.msgh_size = size;
            if (msgtime > 0) {
                retval = mach_msg((mach_msg_header_t *)msg, MACH_RCV_MSG|MACH_RCV_TIMEOUT, 0, size, userNotification->_replyPort, msgtime, MACH_PORT_NULL);
            } else {
                retval = mach_msg((mach_msg_header_t *)msg, MACH_RCV_MSG, 0, size, userNotification->_replyPort, 0, MACH_PORT_NULL);
            }
            if (ERR_SUCCESS == retval) {
                if (responseFlags) *responseFlags = msg->header.msgh_id;
                if (msg->header.msgh_size > sizeof(mach_msg_base_t)) {
                    responseData = CFDataCreate(kCFAllocatorSystemDefault, (uint8_t *)msg + sizeof(mach_msg_base_t), msg->header.msgh_size - sizeof(mach_msg_base_t));
                    if (responseData) {
                        userNotification->_responseDictionary = CFPropertyListCreateFromXMLData(kCFAllocatorSystemDefault, responseData, kCFPropertyListImmutable, NULL);
                        CFRelease(responseData);
                    }
                }
                if (userNotification->_machPort) {
                    CFMachPortInvalidate(userNotification->_machPort);
                    CFRelease(userNotification->_machPort);
                    userNotification->_machPort = NULL;
                }
                mach_port_destroy(mach_task_self(), userNotification->_replyPort);
                userNotification->_replyPort = MACH_PORT_NULL;
            }
            CFAllocatorDeallocate(kCFAllocatorSystemDefault, msg);
        } else {
            retval = unix_err(ENOMEM);
        }
    }
#endif
    return retval;
}
Exemple #26
0
static void _CFUserNotificationMachPortCallBack(CFMachPortRef port, void *m, CFIndex size, void *info) {
    CFUserNotificationRef userNotification = (CFUserNotificationRef)info;
    mach_msg_base_t *msg = (mach_msg_base_t *)m;
    CFOptionFlags responseFlags = msg->header.msgh_id;
    if (msg->header.msgh_size > sizeof(mach_msg_base_t)) {
        CFDataRef responseData = CFDataCreate(kCFAllocatorSystemDefault, (uint8_t *)msg + sizeof(mach_msg_base_t), msg->header.msgh_size - sizeof(mach_msg_base_t));
        if (responseData) {
            userNotification->_responseDictionary = CFPropertyListCreateFromXMLData(kCFAllocatorSystemDefault, responseData, kCFPropertyListImmutable, NULL);
            CFRelease(responseData);
        }
    }
    CFMachPortInvalidate(userNotification->_machPort);
    CFRelease(userNotification->_machPort);
    userNotification->_machPort = NULL;
    mach_port_destroy(mach_task_self(), userNotification->_replyPort);
    userNotification->_replyPort = MACH_PORT_NULL;
    userNotification->_callout(userNotification, responseFlags);
}
static CFDictionaryRef _CFCopyVersionDictionary(CFStringRef path) {
    CFPropertyListRef plist = NULL;
    CFDataRef data;
    CFURLRef url;

    url = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, path, kCFURLPOSIXPathStyle, false);
    if (url && CFURLCreateDataAndPropertiesFromResource(kCFAllocatorSystemDefault, url, &data, NULL, NULL, NULL)) {
	plist = CFPropertyListCreateFromXMLData(kCFAllocatorSystemDefault, data, kCFPropertyListMutableContainers, NULL);
	CFRelease(data);
    }
    if (url) CFRelease(url);
    
    if (plist) {
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
	CFBundleRef locBundle = NULL;
	CFStringRef fullVersion, vers, versExtra, build;
	CFStringRef versionString = _CFCopyLocalizedVersionKey(&locBundle, _kCFSystemVersionProductVersionStringKey);
	CFStringRef buildString = _CFCopyLocalizedVersionKey(&locBundle, _kCFSystemVersionBuildStringKey);
	CFStringRef fullVersionString = _CFCopyLocalizedVersionKey(&locBundle, CFSTR("FullVersionString"));
	if (locBundle) CFRelease(locBundle);

        // Now build the full version string
        if (CFEqual(fullVersionString, CFSTR("FullVersionString"))) {
            CFRelease(fullVersionString);
            fullVersionString = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("%@ %%@ (%@ %%@)"), versionString, buildString);
        }
        vers = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)plist, _kCFSystemVersionProductVersionKey);
        versExtra = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)plist, _kCFSystemVersionProductVersionExtraKey);
        if (vers && versExtra) vers = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, CFSTR("%@ %@"), vers, versExtra);
        build = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)plist, _kCFSystemVersionBuildVersionKey);
        fullVersion = CFStringCreateWithFormat(kCFAllocatorSystemDefault, NULL, fullVersionString, (vers ? vers : CFSTR("?")), build ? build : CFSTR("?"));
        if (vers && versExtra) CFRelease(vers);
        
	CFDictionarySetValue((CFMutableDictionaryRef)plist, _kCFSystemVersionProductVersionStringKey, versionString);
	CFDictionarySetValue((CFMutableDictionaryRef)plist, _kCFSystemVersionBuildStringKey, buildString);
	CFDictionarySetValue((CFMutableDictionaryRef)plist, CFSTR("FullVersionString"), fullVersion);
 	CFRelease(versionString);
	CFRelease(buildString);
	CFRelease(fullVersionString);
        CFRelease(fullVersion);
#endif
    }    
    return (CFDictionaryRef)plist;
}
Exemple #28
0
static CFMutableDictionaryRef copyInfoDict(CFBundleRef bundle)
{
    CFMutableDictionaryRef infoDict = NULL;
    CFURLRef		   infoDictURL;
    CFDataRef		   data;

    infoDictURL = _CFBundleCopyInfoPlistURL(bundle);
    if (infoDictURL)
    {
	if (CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, infoDictURL, &data,
		    NULL, NULL, NULL))
	{
	    infoDict = (CFMutableDictionaryRef) CFPropertyListCreateFromXMLData(kCFAllocatorDefault,
						data, kCFPropertyListMutableContainers, NULL);
	}
	CFRelease(infoDictURL);
    }
    return( infoDict );
}
Exemple #29
0
/*************************************************************************
 *
 * hu_LoadFromXMLFile( inCFURLRef )
 *
 * Purpose: load a property list from an XML file
 *
 * Inputs: inCFURLRef			- URL for the file
 *
 * Returns: CFPropertyListRef - the data
 */
static CFPropertyListRef hu_LoadFromXMLFile(CFURLRef inCFURLRef) {
	CFDataRef xmlCFDataRef;
	CFPropertyListRef myCFPropertyListRef = NULL;
	
	// Read the XML file.
	SInt32 error;
	if ( CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, inCFURLRef, &xmlCFDataRef, NULL, NULL, &error) ) {
		CFStringRef errorString;
		// Reconstitute the dictionary using the XML data.
		myCFPropertyListRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault,
		                                                      xmlCFDataRef,
		                                                      kCFPropertyListImmutable,
		                                                      &errorString);
		// Release the XML data
		CFRelease(xmlCFDataRef);
	}
	
	return (myCFPropertyListRef);
}   // hu_LoadFromXMLFile
static CFPropertyListRef CreateMyPropertyListFromFile(const char *posixfile)
{
	CFPropertyListRef propertyList;
	CFStringRef       errorString;
	CFDataRef         resourceData;
	SInt32            errorCode;
	CFURLRef          fileURL;

	fileURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, posixfile, strlen(posixfile), false);
	if (!fileURL)
		fprintf(stderr, "%s: CFURLCreateFromFileSystemRepresentation(%s) failed\n", argv0, posixfile);
	if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, fileURL, &resourceData, NULL, NULL, &errorCode))
		fprintf(stderr, "%s: CFURLCreateDataAndPropertiesFromResource(%s) failed: %d\n", argv0, posixfile, (int)errorCode);
	propertyList = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resourceData, kCFPropertyListImmutable, &errorString);
	if (!propertyList)
		fprintf(stderr, "%s: propertyList is NULL\n", argv0);
	CFRelease(resourceData);

	return propertyList;
}