// The pdf data length are the last 4 bytes.
UInt32 pdfLen = 0;
pdfLen = *(UInt32 const *)(((UInt8 const *)[data bytes]) + [data length] - 4);
- pdfLen = NSSwapBigLongToHost(pdfLen); // make it big endian
+ pdfLen = NSSwapBigIntToHost(pdfLen); // make it big endian
if (pdfLen >= [data length] - 4) {
NSLog(@"Invalid file %@ for LinkBack", fileName);
return NO;
[file writeData:pdfData];
[file writeData:linkBackData];
- UInt32 pdfLen = NSSwapHostLongToBig([pdfData length]); // big endian
+ UInt32 pdfLen = NSSwapHostIntToBig([pdfData length]); // big endian
NSData * lenData = [NSData dataWithBytes:&pdfLen length:4];
[file writeData:lenData];
[file closeFile];
void LinkBackRunAppNotFoundPanel(NSString* appName, NSURL* url)
{
- int result ;
// strings for panel
NSBundle* b = [NSBundle bundleForClass: [LinkBack class]] ;
title = [NSString stringWithFormat: title, appName] ;
- result = NSRunCriticalAlertPanel(title, @"%@", ok, urlstr, nil, msg) ;
- if (NSAlertAlternateReturn == result) {
- [[NSWorkspace sharedWorkspace] openURL: url] ;
- }
+ NSAlert* alert = [[NSAlert alloc] init];
+ [alert setAlertStyle:NSAlertStyleCritical];
+ [alert setMessageText:title];
+ [alert setInformativeText:[NSString stringWithFormat:@"%@", msg]];
+ [alert addButtonWithTitle:ok];
+ [alert addButtonWithTitle:urlstr];
+ [alert beginSheetModalForWindow:[NSApp mainWindow] completionHandler:^(NSModalResponse returnCode) {
+ if (returnCode == NSAlertSecondButtonReturn)
+ [[NSWorkspace sharedWorkspace] openURL: url] ;
+ }];
}
+ (LinkBackServer*)LinkBackServerWithName:(NSString*)aName inApplication:(NSString*)bundleIdentifier launchIfNeeded:(BOOL)flag fallbackURL:(NSURL*)url appName:(NSString*)appName