Skip to content

Commit

Permalink
Adjust whitespace and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
specious committed Dec 20, 2017
1 parent 39da6b0 commit 959056e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,24 @@

int main(int argc, const char * argv[])
{

@autoreleasepool {

// handler command line -set argument
// read command line -set argument
NSUserDefaults *args = [NSUserDefaults standardUserDefaults];
NSString *set = [args stringForKey:@"set"];

// we're interested in things which can handle http/https
NSArray *urlschemerefs = [[NSArray alloc] initWithObjects:@"http", @"https", nil];

if (set == nil) {
// what is our current handler?
NSString *currentHandler = (__bridge NSString *) LSCopyDefaultHandlerForURLScheme(
(__bridge CFStringRef)([urlschemerefs objectAtIndex:0]));

currentHandler = [[currentHandler componentsSeparatedByString:@"."] lastObject];
printf("Current: %s\n\n", [currentHandler cStringUsingEncoding:NSUTF8StringEncoding]);
printf("Use -set <browser> to set a new default HTTP handler\n");
} else {
// lets figure out which handlers are available
// figure out which handlers are available
NSArray *HTTPHandlers = (__bridge NSArray *) LSCopyAllHandlersForURLScheme(
(__bridge CFStringRef)([urlschemerefs objectAtIndex:0]));
NSMutableDictionary *handlers = [NSMutableDictionary dictionary];
Expand All @@ -36,7 +34,7 @@ int main(int argc, const char * argv[])
NSArray *parts = [split componentsSeparatedByString:@"."];
[handlers setObject:split forKey:[[parts lastObject] lowercaseString]];
}

// set a new default
if ([handlers valueForKey:[set lowercaseString]] != nil) {
CFStringRef newHandler = (__bridge CFStringRef)([handlers valueForKey:[set lowercaseString]]);
Expand All @@ -49,10 +47,12 @@ int main(int argc, const char * argv[])
for (NSString *key in handlers) {
printf("- %s\n", [key cStringUsingEncoding:NSUTF8StringEncoding]);
}

return 1;
}
}
}

return 0;
}

0 comments on commit 959056e

Please sign in to comment.