- /*
- * Override shared value for LPD using system-specific APIs...
- */
-
-#ifdef HAVE_CFPRIV_H /* MacOS X */
- if (shared && *shared)
- {
- CFURLRef prefsurl; /* URL for preferences file */
- CFDataRef xmldata; /* XML data from preferences file */
- CFPropertyListRef plist; /* Property list from XML data */
- CFStringRef queueid; /* CFString of destination name */
- CFArrayRef lprqarray; /* Array of shared "LPR" printers */
- CFBooleanRef serverflag; /* State of the print service */
- static const char printerprefsfile[] =
- "/Library/Preferences/com.apple.printservice.plist";
- /* Preferences file */
-
-
- /*
- * See if we are running on MacOS X Server...
- */
-
- CFDictionaryRef versdict = _CFCopyServerVersionDictionary();
-
- if (versdict)
- {
- /*
- * Yes, use the LPR sharing preference...
- */
-
- CFRelease(versdict);
-
- *shared = 0;
-
- prefsurl = CFURLCreateFromFileSystemRepresentation(
- kCFAllocatorDefault,
- (const UInt8 *)printerprefsfile,
- (CFIndex)strlen(printerprefsfile),
- false);
- if (prefsurl)
- {
- if (CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault,
- prefsurl, &xmldata, NULL,
- NULL, NULL))
- {
- plist = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, xmldata,
- kCFPropertyListImmutable,
- NULL);
- if (plist)
- {
- serverflag = (CFBooleanRef)CFDictionaryGetValue(
- (CFDictionaryRef)plist,
- CFSTR("serviceState"));
-
- if (serverflag && CFBooleanGetValue(serverflag))
- {
- lprqarray = (CFArrayRef)CFDictionaryGetValue(
- (CFDictionaryRef)plist,
- CFSTR("lprSharedQueues"));
-
- if (lprqarray)
- {
- queueid = CFStringCreateWithCString(CFAllocatorGetDefault(),
- dest,
- kCFStringEncodingUTF8);
-
- if (queueid)
- {
- *shared = CFArrayContainsValue(lprqarray,
- CFRangeMake(0,
- CFArrayGetCount(lprqarray)),
- queueid);
-
- CFRelease(queueid);
- }
- }
- }
-
- CFRelease(plist);
- }
-
- CFRelease(xmldata);
- }
-
- CFRelease(prefsurl);
- }
-
- if (!shared)
- syslog(LOG_ERR, "Warning - Print Service sharing disabled for LPD "
- "on queue: %s", name);
- }
- }
-#endif /* HAVE_CFPRIV_H */
-