Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge commit '950fbab1c91f7829852c59276353652310090158' into feature

  • Loading branch information...
commit 1fc93a4ff271543ab5b99b4046007f76ebe737e3 2 parents ac4c61e + 950fbab
@ttilley ttilley authored
View
10 ext/fsevent_watch/Info.plist
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleIdentifier</key>
+ <string>com.teaspoonofinsanity.fsevent_watch</string>
+ <key>CFBundleName</key>
+ <string>fsevent_watch</string>
+</dict>
+</plist>
View
44 ext/fsevent_watch/fsevent_watch.xcodeproj/project.pbxproj
@@ -22,6 +22,7 @@
6A57F6FF13F5E614000BE6A9 /* fsevent_watch */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fsevent_watch; sourceTree = BUILT_PRODUCTS_DIR; };
6A57F70313F5E614000BE6A9 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };
6A57F70613F5E614000BE6A9 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
+ 6A68C5E31440CBDF0040623D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
6A81FCE7143429DE00F83EDD /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
6A81FCEA14342A6300F83EDD /* TSICTString.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = TSICTString.c; sourceTree = "<group>"; };
6A81FCEB14342A6300F83EDD /* TSICTString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSICTString.h; sourceTree = "<group>"; };
@@ -45,6 +46,7 @@
6A57F6F413F5E614000BE6A9 = {
isa = PBXGroup;
children = (
+ 6A68C5E31440CBDF0040623D /* Info.plist */,
6A57F70513F5E614000BE6A9 /* fsevent_watch */,
6A57F70213F5E614000BE6A9 /* Frameworks */,
6A57F70013F5E614000BE6A9 /* Products */,
@@ -150,7 +152,9 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
+ CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = NO;
+ CURRENT_PROJECT_VERSION = 0.1.0;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -165,6 +169,7 @@
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
+ "PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\"",
"DEBUG=1",
"$(inherited)",
);
@@ -186,7 +191,7 @@
LD_NO_PIE = NO;
LLVM_LTO = NO;
"LLVM_LTO[arch=x86_64]" = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = NO;
PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES;
@@ -194,7 +199,18 @@
SDKROOT = "";
STRIP_INSTALLED_PRODUCT = NO;
VALID_ARCHS = "i386 x86_64";
- WARNING_CFLAGS = "-Wall";
+ WARNING_CFLAGS = (
+ "-pedantic",
+ "-Wall",
+ "-Wextra",
+ "-Wpointer-arith",
+ "-Wformat=2",
+ "-Wfloat-equal",
+ "-Wstrict-overflow=4",
+ "-Wbad-function-cast",
+ "-Winline",
+ "-Wconversion",
+ );
};
name = Debug;
};
@@ -203,7 +219,9 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
+ CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = YES;
+ CURRENT_PROJECT_VERSION = 0.1.0;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -215,6 +233,10 @@
GCC_FAST_OBJC_DISPATCH = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\"",
+ "NDEBUG=1",
+ );
GCC_REUSE_STRINGS = YES;
GCC_STRICT_ALIASING = NO;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
@@ -233,7 +255,7 @@
LD_NO_PIE = NO;
LLVM_LTO = NO;
"LLVM_LTO[arch=x86_64]" = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = NO;
PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES;
@@ -246,7 +268,15 @@
6A57F70D13F5E614000BE6A9 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ INFOPLIST_FILE = Info.plist;
+ INFOPLIST_PREPROCESS = YES;
MACH_O_TYPE = mh_execute;
+ OTHER_LDFLAGS = (
+ "-sectcreate",
+ __TEXT,
+ __info_plist,
+ Info.plist,
+ );
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -254,7 +284,15 @@
6A57F70E13F5E614000BE6A9 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ INFOPLIST_FILE = Info.plist;
+ INFOPLIST_PREPROCESS = YES;
MACH_O_TYPE = mh_execute;
+ OTHER_LDFLAGS = (
+ "-sectcreate",
+ __TEXT,
+ __info_plist,
+ Info.plist,
+ );
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
View
24 ext/fsevent_watch/fsevent_watch/TSICTString.c
@@ -16,13 +16,13 @@ TSITStringFormat TSITStringDefaultFormat = kTSITStringFormatTNetstring;
static const CFRange BeginningRange = {0,0};
-static CFTypeID kCFDataTypeID = -1;
-static CFTypeID kCFStringTypeID = -1;
-static CFTypeID kCFNumberTypeID = -1;
-static CFTypeID kCFBooleanTypeID = -1;
-static CFTypeID kCFNullTypeID = -1;
-static CFTypeID kCFArrayTypeID = -1;
-static CFTypeID kCFDictionaryTypeID = -1;
+static CFTypeID kCFDataTypeID = -1UL;
+static CFTypeID kCFStringTypeID = -1UL;
+static CFTypeID kCFNumberTypeID = -1UL;
+static CFTypeID kCFBooleanTypeID = -1UL;
+static CFTypeID kCFNullTypeID = -1UL;
+static CFTypeID kCFArrayTypeID = -1UL;
+static CFTypeID kCFDictionaryTypeID = -1UL;
__attribute__((constructor)) void Init_TSICTString(void)
@@ -88,14 +88,14 @@ static inline CFDataRef TSICTStringCreateDataFromIntermediateRepresentation(TStr
UInt8* bufferBytes = CFDataGetMutableBytePtr(buffer);
size_t prefixLength = strlen(rep->length) + 1;
- CFDataReplaceBytes(buffer, BeginningRange, (const UInt8*)rep->length, prefixLength);
+ CFDataReplaceBytes(buffer, BeginningRange, (const UInt8*)rep->length, (CFIndex)prefixLength);
if (rep->format == kTSITStringFormatTNetstring) {
- const UInt8 ftag = TNetstringTypes[rep->type];
+ const UInt8 ftag = (UInt8)TNetstringTypes[rep->type];
CFDataAppendBytes(buffer, &ftag, 1);
bufferBytes[(prefixLength - 1)] = TNetstringSeparator;
} else if (rep->format == kTSITStringFormatOTNetstring) {
- const UInt8 ftag = OTNetstringTypes[rep->type];
+ const UInt8 ftag = (UInt8)OTNetstringTypes[rep->type];
bufferBytes[(prefixLength - 1)] = ftag;
}
@@ -315,13 +315,13 @@ TStringIRep* TSICTStringCreateWithNumberAndFormat(CFNumberRef number, TSITString
}
memmove(p, e, strlen(e)+1);
- data = CFDataCreate(kCFAllocatorDefault, (UInt8*)buf, strlen(buf));
+ data = CFDataCreate(kCFAllocatorDefault, (UInt8*)buf, (CFIndex)strlen(buf));
} else {
char buf[32];
SInt64 value;
CFNumberGetValue(number, numType, &value);
sprintf(buf, "%lli", value);
- data = CFDataCreate(kCFAllocatorDefault, (UInt8*)buf, strlen(buf));
+ data = CFDataCreate(kCFAllocatorDefault, (UInt8*)buf, (CFIndex)strlen(buf));
}
TStringIRep* rep = TSICTStringCreateWithDataOfTypeAndFormat(data, tag, format);
View
2  ext/fsevent_watch/fsevent_watch/cli.c
@@ -146,7 +146,7 @@ int cli_parser (int argc, const char** argv, struct cli_info* args_info)
if (optind < argc) {
int i = 0;
- args_info->inputs_num = argc - optind;
+ args_info->inputs_num = (unsigned int)(argc - optind);
args_info->inputs =
(char**)(malloc ((args_info->inputs_num)*sizeof(char*)));
while (optind < argc)
View
8 ext/fsevent_watch/fsevent_watch/cli.h
@@ -5,8 +5,14 @@
#define CLI_NAME "fsevent_watch"
#endif /* CLI_NAME */
+#ifndef PROJECT_VERSION
+#error "PROJECT_VERSION not set"
+#endif /* PROJECT_VERSION */
+
#ifndef CLI_VERSION
-#define CLI_VERSION "0.0.1"
+#define _str(s) #s
+#define _xstr(s) _str(s)
+#define CLI_VERSION _xstr(PROJECT_VERSION)
#endif /* CLI_VERSION */
#include "common.h"
View
181 ext/fsevent_watch/fsevent_watch/main.c
@@ -27,7 +27,6 @@ static struct {
// Prototypes
static void append_path(const char* path);
-static void append_path2(const char* path);
static inline void parse_cli_settings(int argc, const char* argv[]);
static void callback(FSEventStreamRef streamRef,
void* clientCallBackInfo,
@@ -36,23 +35,114 @@ static void callback(FSEventStreamRef streamRef,
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[]);
+
// Resolve a path and append it to the CLI settings structure
// The FSEvents API will, internally, resolve paths using a similar scheme.
// Performing this ahead of time makes things less confusing, IMHO.
-__attribute__((unused)) static void append_path(const char* path)
+static void append_path(const char* path)
{
#ifdef DEBUG
fprintf(stderr, "\n");
fprintf(stderr, "append_path called for: %s\n", path);
#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
+
+#ifdef DEBUG
+ fprintf(stderr, "compiled against 10.6+, using CFURLCreateFileReferenceURL\n");
+#endif
+
+ CFURLRef url = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8*)path, (CFIndex)strlen(path), false);
+ CFURLRef placeholder = CFURLCopyAbsoluteURL(url);
+ CFRelease(url);
+
+ CFMutableArrayRef imaginary = NULL;
+
+ // if we don't have an existing url, spin until we get to a parent that
+ // does exist, saving any imaginary components for appending back later
+ while(!CFURLResourceIsReachable(placeholder, NULL)) {
+#ifdef DEBUG
+ fprintf(stderr, "path does not exist\n");
+#endif
+
+ CFStringRef child;
+
+ if (imaginary == NULL) {
+ imaginary = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+ }
+
+ child = CFURLCopyLastPathComponent(placeholder);
+ CFArrayInsertValueAtIndex(imaginary, 0, child);
+ CFRelease(child);
+
+ url = CFURLCreateCopyDeletingLastPathComponent(NULL, placeholder);
+ CFRelease(placeholder);
+ placeholder = url;
+
+#ifdef DEBUG
+ fprintf(stderr, "parent: ");
+ CFShow(placeholder);
+#endif
+ }
+
+#ifdef DEBUG
+ fprintf(stderr, "path exists\n");
+#endif
+
+ // realpath() doesn't always return the correct case for a path, so this
+ // is a funky workaround that converts a path into a (volId/inodeId) pair
+ // and asks what the path should be for that. since it looks at the actual
+ // inode instead of returning the same case passed in like realpath()
+ // appears to do for HFS+, it should always be correct.
+ url = CFURLCreateFileReferenceURL(NULL, placeholder, NULL);
+ CFRelease(placeholder);
+ placeholder = CFURLCreateFilePathURL(NULL, url, NULL);
+ CFRelease(url);
+
+#ifdef DEBUG
+ fprintf(stderr, "path resolved to: ");
+ CFShow(placeholder);
+#endif
+
+ // if we stripped off any imaginary path components, append them back on
+ if (imaginary != NULL) {
+ CFIndex count = CFArrayGetCount(imaginary);
+ for (CFIndex i = 0; i<count; i++) {
+ CFStringRef component = CFArrayGetValueAtIndex(imaginary, i);
+#ifdef DEBUG
+ fprintf(stderr, "appending component: ");
+ CFShow(component);
+#endif
+ url = CFURLCreateCopyAppendingPathComponent(NULL, placeholder, component, false);
+ CFRelease(placeholder);
+ placeholder = url;
+ }
+ CFRelease(imaginary);
+ }
+
+#ifdef DEBUG
+ fprintf(stderr, "result: ");
+ CFShow(placeholder);
+#endif
+
+ CFStringRef cfPath = CFURLCopyFileSystemPath(placeholder, kCFURLPOSIXPathStyle);
+ CFArrayAppendValue(config.paths, cfPath);
+ CFRelease(cfPath);
+ CFRelease(placeholder);
+
+#else
+
+#ifdef DEBUG
+ fprintf(stderr, "compiled against 10.5, using realpath()\n");
+#endif
+
char fullPath[PATH_MAX + 1];
-
+
if (realpath(path, fullPath) == NULL) {
#ifdef DEBUG
fprintf(stderr, " realpath not directly resolvable from path\n");
#endif
-
+
if (path[0] != '/') {
#ifdef DEBUG
fprintf(stderr, " passed path is not absolute\n");
@@ -72,86 +162,19 @@ __attribute__((unused)) static void append_path(const char* path)
strlcpy(fullPath, path, sizeof(fullPath));
}
}
-
+
#ifdef DEBUG
fprintf(stderr, " resolved path to: %s\n", fullPath);
fprintf(stderr, "\n");
#endif
-
+
CFStringRef pathRef = CFStringCreateWithCString(kCFAllocatorDefault,
- fullPath,
- kCFStringEncodingUTF8);
+ fullPath,
+ kCFStringEncodingUTF8);
CFArrayAppendValue(config.paths, pathRef);
CFRelease(pathRef);
-}
-
-// straight from the rear
-static void append_path2(const char* path)
-{
-#ifdef DEBUG
- char fullPath[PATH_MAX + 1];
-
- fprintf(stderr, "\n");
- fprintf(stderr, "append_path2 called for: %s\n", path);
-#endif
-
- OSStatus err = noErr;
- FSRef fsref;
- AliasHandle itemAlias = NULL;
- CFStringRef pathString = NULL;
-
- err = FSPathMakeRefWithOptions((const UInt8*)path, kFSPathMakeRefDefaultOptions, &fsref, NULL);
-
- if (err == noErr) {
-#ifdef DEBUG
- fprintf(stderr, " FSRef created\n");
-#endif
- err = FSNewAlias(NULL, &fsref, &itemAlias);
-
- if (err == noErr) {
-#ifdef DEBUG
- fprintf(stderr, " AliasHandle created\n");
-#endif
- err = FSCopyAliasInfo(itemAlias, NULL, NULL, &pathString, NULL, NULL);
- }
-
- if (err == noErr) {
-#ifdef DEBUG
- fprintf(stderr, " Alias Info copied\n");
- CFStringGetFileSystemRepresentation(pathString, fullPath, PATH_MAX + 1);
- fprintf(stderr, " resolved path to: %s\n", fullPath);
- fprintf(stderr, "\n");
+
#endif
-
- CFArrayAppendValue(config.paths, pathString);
- }
- } else {
-#ifdef DEBUG
- fprintf(stderr, " assuming path does not YET exist\n");
-#endif
-
- CFURLRef pathURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
- (const UInt8*)path,
- strlen(path), true);
- pathString = CFURLCopyStrictPath(pathURL, NULL);
- CFArrayAppendValue(config.paths, pathString);
- CFRelease(pathURL);
-
-#ifdef DEBUG
- CFStringGetFileSystemRepresentation(pathString, fullPath, PATH_MAX + 1);
- fprintf(stderr, " resolved path to: %s\n", fullPath);
- fprintf(stderr, "\n");
-#endif
- }
-
- if (pathString != NULL) {
- CFRelease(pathString);
- }
-
- if (itemAlias != NULL) {
- DisposeHandle((Handle)itemAlias);
- assert(MemError() == noErr);
- }
}
// Parse commandline settings
@@ -212,10 +235,10 @@ static inline void parse_cli_settings(int argc, const char* argv[])
}
if (args_info.inputs_num == 0) {
- append_path2(".");
+ append_path(".");
} else {
for (unsigned int i=0; i < args_info.inputs_num; ++i) {
- append_path2(args_info.inputs[i]);
+ append_path(args_info.inputs[i]);
}
}
@@ -302,7 +325,7 @@ static void tstring_output_format(size_t numEvents,
CFStringRef path = CFStringCreateWithBytes(kCFAllocatorDefault,
(const UInt8*)paths[i],
- strlen(paths[i]),
+ (CFIndex)strlen(paths[i]),
kCFStringEncodingUTF8,
false);
CFDictionarySetValue(event, CFSTR("path"), path);
Please sign in to comment.
Something went wrong with that request. Please try again.