#if !defined(__COREFOUNDATION_CFPRIV__)
#define __COREFOUNDATION_CFPRIV__ 1
#include <string.h>
#include <CoreFoundation/CFBase.h>
#include <CoreFoundation/CFArray.h>
#include <CoreFoundation/CFString.h>
#include <CoreFoundation/CFURL.h>
#include <CoreFoundation/CFBundlePriv.h>
#if defined(__MACH__)
#include <CoreFoundation/CFMachPort.h>
#endif
#if defined(__MACH__) || defined(__WIN32__)
#include <CoreFoundation/CFRunLoop.h>
#include <CoreFoundation/CFSocket.h>
#endif
#if defined(__MACH__)
#include <CoreFoundation/CFMachPort.h>
#endif
#if 0
#include <shlobj.h>
#endif
CF_EXTERN_C_BEGIN
CF_EXPORT intptr_t _CFDoOperation(intptr_t code, intptr_t subcode1, intptr_t subcode2);
CF_EXPORT void _CFRuntimeSetCFMPresent(void *a);
CF_EXPORT const char *_CFProcessPath(void);
CF_EXPORT const char **_CFGetProcessPath(void);
CF_EXPORT const char **_CFGetProgname(void);
#if defined(__MACH__)
CF_EXPORT CFRunLoopRef CFRunLoopGetMain(void);
CF_EXPORT SInt32 CFRunLoopRunSpecific(CFRunLoopRef rl, CFStringRef modeName, CFTimeInterval seconds, Boolean returnAfterSourceHandled);
CF_EXPORT void _CFRunLoopSetCurrent(CFRunLoopRef rl);
CF_EXPORT Boolean _CFRunLoopModeContainsMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef candidateContainedName);
CF_EXPORT void _CFRunLoopAddModeToMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef toModeName);
CF_EXPORT void _CFRunLoopRemoveModeFromMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef fromModeName);
CF_EXPORT void _CFRunLoopStopMode(CFRunLoopRef rl, CFStringRef modeName);
#if defined(__MACH__)
CF_EXPORT CFIndex CFMachPortGetQueuedMessageCount(CFMachPortRef mp);
#endif
CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url);
CF_EXPORT CFURLRef _CFURLCreateFromPropertyListRepresentation(CFAllocatorRef alloc, CFPropertyListRef pListRepresentation);
#endif
CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url);
CF_EXPORT CFURLRef _CFURLCreateFromPropertyListRepresentation(CFAllocatorRef alloc, CFPropertyListRef pListRepresentation);
CF_EXPORT void CFPreferencesFlushCaches(void);
#if !__LP64__
#if !defined(__WIN32__)
struct FSSpec;
CF_EXPORT
Boolean _CFGetFSSpecFromURL(CFAllocatorRef alloc, CFURLRef url, struct FSSpec *spec);
CF_EXPORT
CFURLRef _CFCreateURLFromFSSpec(CFAllocatorRef alloc, const struct FSSpec *voidspec, Boolean isDirectory);
#endif
#endif
#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
enum {
kCFURLComponentDecompositionNonHierarchical,
kCFURLComponentDecompositionRFC1808,
kCFURLComponentDecompositionRFC2396
};
typedef CFIndex CFURLComponentDecomposition;
typedef struct {
CFStringRef scheme;
CFStringRef schemeSpecific;
} CFURLComponentsNonHierarchical;
typedef struct {
CFStringRef scheme;
CFStringRef user;
CFStringRef password;
CFStringRef host;
CFIndex port;
CFArrayRef pathComponents;
CFStringRef parameterString;
CFStringRef query;
CFStringRef fragment;
CFURLRef baseURL;
} CFURLComponentsRFC1808;
typedef struct {
CFStringRef scheme;
CFStringRef userinfo;
CFStringRef host;
CFIndex port;
CFArrayRef pathComponents;
CFStringRef query;
CFStringRef fragment;
CFURLRef baseURL;
} CFURLComponentsRFC2396;
CF_EXPORT
Boolean _CFURLCopyComponents(CFURLRef url, CFURLComponentDecomposition decompositionType, void *components);
CF_EXPORT
CFURLRef _CFURLCreateFromComponents(CFAllocatorRef alloc, CFURLComponentDecomposition decompositionType, const void *components);
#define CFURLCopyComponents _CFURLCopyComponents
#define CFURLCreateFromComponents _CFURLCreateFromComponents
#endif
CF_EXPORT Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, UInt8 *buffer, CFIndex maxBufLen);
CF_EXPORT CFStringRef _CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean externalFormat, CFAllocatorRef contentsDeallocator);
CF_EXPORT
CFStringRef CFGetUserName(void);
CF_EXPORT
CFURLRef CFCopyHomeDirectoryURLForUser(CFStringRef uName);
CF_EXPORT
const CFStringRef kCFUserNotificationKeyboardTypesKey AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
enum {
kCFApplicationDirectory = 1,
kCFDemoApplicationDirectory,
kCFDeveloperApplicationDirectory,
kCFAdminApplicationDirectory,
kCFLibraryDirectory,
kCFDeveloperDirectory,
kCFUserDirectory,
kCFDocumentationDirectory,
kCFDocumentDirectory,
kCFAllApplicationsDirectory = 100,
kCFAllLibrariesDirectory = 101
};
typedef CFIndex CFSearchPathDirectory;
enum {
kCFUserDomainMask = 1,
kCFLocalDomainMask = 2,
kCFNetworkDomainMask = 4,
kCFSystemDomainMask = 8,
kCFAllDomainsMask = 0x0ffff
};
typedef CFOptionFlags CFSearchPathDomainMask;
CF_EXPORT
CFArrayRef CFCopySearchPathForDirectoriesInDomains(CFSearchPathDirectory directory, CFSearchPathDomainMask domainMask, Boolean expandTilde);
CF_EXPORT const CFStringRef kCFFileURLExists;
CF_EXPORT const CFStringRef kCFFileURLPOSIXMode;
CF_EXPORT const CFStringRef kCFFileURLSize;
CF_EXPORT const CFStringRef kCFFileURLDirectoryContents;
CF_EXPORT const CFStringRef kCFFileURLLastModificationTime;
CF_EXPORT const CFStringRef kCFHTTPURLStatusCode;
CF_EXPORT const CFStringRef kCFHTTPURLStatusLine;
CF_EXPORT CFStringRef CFCopySystemVersionString(void); CF_EXPORT CFDictionaryRef _CFCopySystemVersionDictionary(void);
CF_EXPORT CFDictionaryRef _CFCopyServerVersionDictionary(void);
CF_EXPORT const CFStringRef _kCFSystemVersionProductNameKey;
CF_EXPORT const CFStringRef _kCFSystemVersionProductCopyrightKey;
CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionKey;
CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionExtraKey;
CF_EXPORT const CFStringRef _kCFSystemVersionProductUserVisibleVersionKey; CF_EXPORT const CFStringRef _kCFSystemVersionBuildVersionKey;
CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionStringKey; CF_EXPORT const CFStringRef _kCFSystemVersionBuildStringKey;
CF_EXPORT void CFMergeSortArray(void *list, CFIndex count, CFIndex elementSize, CFComparatorFunction comparator, void *context);
CF_EXPORT void CFQSortArray(void *list, CFIndex count, CFIndex elementSize, CFComparatorFunction comparator, void *context);
enum {
CFSystemVersionCheetah = 0,
CFSystemVersionPuma = 1,
CFSystemVersionJaguar = 2,
CFSystemVersionPanther = 3,
CFSystemVersionPinot = 3,
CFSystemVersionTiger = 4,
CFSystemVersionMerlot = 4,
CFSystemVersionLeopard = 5,
CFSystemVersionChablis = 5,
CFSystemVersionMax
};
typedef CFIndex CFSystemVersion;
CF_EXPORT Boolean _CFExecutableLinkedOnOrAfter(CFSystemVersion version);
enum {
kCFStringGraphemeCluster = 1,
kCFStringComposedCharacterCluster = 2,
kCFStringCursorMovementCluster = 3,
kCFStringBackwardDeletionCluster = 4
};
typedef CFIndex CFStringCharacterClusterType;
CF_EXPORT CFRange CFStringGetRangeOfCharacterClusterAtIndex(CFStringRef string, CFIndex charIndex, CFStringCharacterClusterType type);
enum {
kCFCompareDiacriticsInsensitive = 128,
kCFCompareDiacriticsInsensitiveCompatibilityMask = ((1 << 28)|kCFCompareDiacriticsInsensitive),
};
CF_EXPORT void _CFStringEncodingSetForceASCIICompatibility(Boolean flag);
#if defined(CF_INLINE)
CF_INLINE const UniChar *CFStringGetCharactersPtrFromInlineBuffer(CFStringInlineBuffer *buf, CFRange desiredRange) {
if ((desiredRange.location < 0) || ((desiredRange.location + desiredRange.length) > buf->rangeToBuffer.length)) return NULL;
if (buf->directBuffer) {
return buf->directBuffer + buf->rangeToBuffer.location + desiredRange.location;
} else {
if (desiredRange.length > __kCFStringInlineBufferLength) return NULL;
if (((desiredRange.location + desiredRange.length) > buf->bufferedRangeEnd) || (desiredRange.location < buf->bufferedRangeStart)) {
buf->bufferedRangeStart = desiredRange.location;
buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength;
if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length;
CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer);
}
return buf->buffer + (desiredRange.location - buf->bufferedRangeStart);
}
}
CF_INLINE void CFStringGetCharactersFromInlineBuffer(CFStringInlineBuffer *buf, CFRange desiredRange, UniChar *outBuf) {
if (buf->directBuffer) {
memmove(outBuf, buf->directBuffer + buf->rangeToBuffer.location + desiredRange.location, desiredRange.length * sizeof(UniChar));
} else {
if ((desiredRange.location >= buf->bufferedRangeStart) && (desiredRange.location < buf->bufferedRangeEnd)) {
CFIndex bufLen = desiredRange.length;
if (bufLen > (buf->bufferedRangeEnd - desiredRange.location)) bufLen = (buf->bufferedRangeEnd - desiredRange.location);
memmove(outBuf, buf->buffer + (desiredRange.location - buf->bufferedRangeStart), bufLen * sizeof(UniChar));
outBuf += bufLen; desiredRange.location += bufLen; desiredRange.length -= bufLen;
} else {
CFIndex desiredRangeMax = (desiredRange.location + desiredRange.length);
if ((desiredRangeMax > buf->bufferedRangeStart) && (desiredRangeMax < buf->bufferedRangeEnd)) {
desiredRange.length = (buf->bufferedRangeStart - desiredRange.location);
memmove(outBuf + desiredRange.length, buf->buffer, (desiredRangeMax - buf->bufferedRangeStart) * sizeof(UniChar));
}
}
if (desiredRange.length > 0) CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + desiredRange.location, desiredRange.length), outBuf);
}
}
#else
#define CFStringGetCharactersPtrFromInlineBuffer(buf, desiredRange) ((buf)->directBuffer ? (buf)->directBuffer + (buf)->rangeToBuffer.location + desiredRange.location : NULL)
#define CFStringGetCharactersFromInlineBuffer(buf, desiredRange, outBuf) \
if (buf->directBuffer) memmove(outBuf, (buf)->directBuffer + (buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length * sizeof(UniChar)); \
else CFStringGetCharacters((buf)->theString, CFRangeMake((buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length), outBuf);
#endif
typedef struct {
CFCharacterSetRef cset;
uint32_t flags;
uint32_t rangeStart;
uint32_t rangeLimit;
const uint8_t *bitmap;
} CFCharacterSetInlineBuffer;
enum {
kCFCharacterSetIsCompactBitmap = (1 << 0),
kCFCharacterSetNoBitmapAvailable = (1 << 1),
kCFCharacterSetIsInverted = (1 << 2)
};
CF_EXPORT
void CFCharacterSetInitInlineBuffer(CFCharacterSetRef cset, CFCharacterSetInlineBuffer *buffer);
#if defined(CF_INLINE)
CF_INLINE bool CFCharacterSetInlineBufferIsLongCharacterMember(CFCharacterSetInlineBuffer *buffer, UTF32Char character) {
bool isInverted = ((0 == (buffer->flags & kCFCharacterSetIsInverted)) ? false : true);
if ((character >= buffer->rangeStart) && (character < buffer->rangeLimit)) {
if ((character > 0xFFFF) || (0 != (buffer->flags & kCFCharacterSetNoBitmapAvailable))) return (CFCharacterSetIsLongCharacterMember(buffer->cset, character) != 0);
if (NULL == buffer->bitmap) {
if (0 == (buffer->flags & kCFCharacterSetIsCompactBitmap)) isInverted = !isInverted;
} else if (0 == (buffer->flags & kCFCharacterSetIsCompactBitmap)) {
if (buffer->bitmap[character >> 3] & (1 << (character & 7))) isInverted = !isInverted;
} else {
uint8_t value = buffer->bitmap[character >> 8];
if (value == 0xFF) {
isInverted = !isInverted;
} else if (value > 0) {
const uint8_t *segment = buffer->bitmap + (256 + (32 * (value - 1)));
character &= 0xFF;
if (segment[character >> 3] & (1 << (character % 8))) isInverted = !isInverted;
}
}
}
return isInverted;
}
#else
#define CFCharacterSetInlineBufferIsLongCharacterMember(buffer, character) (CFCharacterSetIsLongCharacterMember(buffer->cset, character))
#endif
#if defined(__MACH__)
#include <CoreFoundation/CFMessagePort.h>
CFMessagePortRef CFMessagePortCreatePerProcessLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo);
CFMessagePortRef CFMessagePortCreatePerProcessRemote(CFAllocatorRef allocator, CFStringRef name, CFIndex pid);
#endif
CF_EXTERN_C_END
#endif