Created
February 13, 2012 00:20
-
-
Save jtdreisb/1812018 to your computer and use it in GitHub Desktop.
utility that syncs an arbitrary bundle id's prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC = clang | |
CFLAGS = -Wall -g | |
LDFLAGS = -framework CoreFoundation | |
TARG = syncdefaults | |
SRC=\v | |
syncdefaults.c\ | |
HFILES=\ | |
OBJS= $(patsubst %.c, %.o, $(SRC)) | |
all: $(TARG) | |
clean: | |
rm -f $(OBJS) *~ | |
%.o: %.c | |
$(CC) $(CFLAGS) -c -o $@ $< | |
$(TARG): $(OBJS) $(HFILES) | |
$(CC) $(LDFLAGS) -o $(TARG) $(OBJS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <CoreFoundation/CoreFoundation.h> | |
//#include <CoreFoundation/CFPreferences.h> | |
void | |
usage ( void ) { | |
printf("usage : syncdefaults <bundle domain>"); | |
exit(1); | |
} | |
int | |
main(int argc, char ** argv) { | |
if (argc == 2) { | |
CFStringRef bundleDomain = CFStringCreateWithCString(kCFAllocatorDefault, argv[1], kCFStringEncodingUTF8); | |
if ( CFPreferencesSynchronize(bundleDomain, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ) == false) { | |
printf("Failed to write userdefaults for %s\n", argv[1]); | |
exit(1); | |
} | |
} else { | |
usage(); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment