├── CodeFlow ├── en.lproj │ ├── InfoPlist.strings │ ├── FLFlowchartViewController.xib │ └── MainWindow.xib ├── folder64.png ├── icn_New_File.m_512.png ├── WNBreak.h ├── WNReturn.h ├── WNComment.h ├── WNWhileLoop.h ├── WNCodeBlock.h ├── NSData+Gzip.h ├── WNBooleanExpression.h ├── CodeFlow-Prefix.pch ├── WNForLoop.h ├── main.m ├── WNBooleanExpression.m ├── WNConditionalChain.h ├── imageblending.txt ├── WNFastEnumeration.h ├── FLFileBrowserViewController.h ├── WNConditional.h ├── RGBtoHSL.txt ├── FLAppDelegate.h ├── WNStatement.h ├── FLFlowchartViewController.h ├── WNBreak.m ├── WNReturn.m ├── NSData+Base64.h ├── WNComment.m ├── CodeFlow-Info.plist ├── adjusthsl.txt ├── WNFastEnumeration.m ├── FLFileBrowserViewController.m ├── NSData+Gzip.m ├── FLAppDelegate.m ├── WNCodeBlock.m ├── WNWhileLoop.m ├── WNConditional.m ├── WNStatement.m ├── WNConditionalChain.m ├── FLFlowchartViewController.m ├── WNForLoop.m ├── NSData+Base64.m └── RegexKitLite.h ├── CodeFlowTests ├── en.lproj │ └── InfoPlist.strings ├── CodeFlowTests-Prefix.pch ├── CodeFlowTests.h ├── CodeFlowTests.m └── CodeFlowTests-Info.plist ├── .gitignore ├── graphviz-cgi ├── graphviz-cgi │ ├── graphviz-cgi-Prefix.pch │ ├── NSData+Gzip.h │ ├── NSData+Base64.h │ ├── GVGraphArguments.h │ ├── GVGraphDefaultAttributes.h │ ├── main.m │ ├── GVGraphArguments.m │ ├── GVGraph.h │ ├── NSData+Gzip.m │ ├── CGI.h │ ├── graphviz_cgi.1 │ ├── GVGraphDefaultAttributes.m │ ├── GVGraph.m │ ├── NSData+Base64.m │ └── CGI.m └── graphviz-cgi.xcodeproj │ ├── project.xcworkspace │ └── contents.xcworkspacedata │ └── project.pbxproj └── CodeFlow.xcodeproj └── project.xcworkspace └── contents.xcworkspacedata /CodeFlow/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CodeFlowTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | .DS_Store 3 | *.mode1v3 4 | *.pbxuser 5 | *.perspectivev3 6 | xcuserdata 7 | -------------------------------------------------------------------------------- /CodeFlow/folder64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmkilger/CodeFlow/HEAD/CodeFlow/folder64.png -------------------------------------------------------------------------------- /CodeFlow/icn_New_File.m_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cmkilger/CodeFlow/HEAD/CodeFlow/icn_New_File.m_512.png -------------------------------------------------------------------------------- /CodeFlowTests/CodeFlowTests-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'CodeFlowTests' target in the 'CodeFlowTests' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/graphviz-cgi-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'graphviz-cgi' target in the 'graphviz-cgi' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CodeFlow.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CodeFlow/WNBreak.h: -------------------------------------------------------------------------------- 1 | // 2 | // WNBreak.h 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 7/5/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WNStatement.h" 11 | 12 | 13 | @interface WNBreak : WNStatement 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /CodeFlow/WNReturn.h: -------------------------------------------------------------------------------- 1 | // 2 | // WNReturn.h 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 7/5/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WNStatement.h" 11 | 12 | 13 | @interface WNReturn : WNStatement 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /CodeFlow/WNComment.h: -------------------------------------------------------------------------------- 1 | // 2 | // WNComment.h 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 7/5/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WNStatement.h" 11 | 12 | 13 | @interface WNComment : WNStatement 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /CodeFlow/WNWhileLoop.h: -------------------------------------------------------------------------------- 1 | // 2 | // WNWhileLoop.h 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WNConditional.h" 11 | 12 | @class WNConditional; 13 | 14 | @interface WNWhileLoop : WNConditional 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /CodeFlowTests/CodeFlowTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // CodeFlowTests.h 3 | // CodeFlowTests 4 | // 5 | // Created by Cory Kilger on 7/17/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface CodeFlowTests : SenTestCase { 13 | @private 14 | 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /CodeFlow/WNCodeBlock.h: -------------------------------------------------------------------------------- 1 | // 2 | // WNCodeBlock.h 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 7/3/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WNStatement.h" 11 | 12 | 13 | @interface WNCodeBlock : WNStatement 14 | 15 | @property (retain) NSArray * statements; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /CodeFlow/NSData+Gzip.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Gzip.h 3 | // tmxparse 4 | // 5 | // Created by Cory Kilger on 2/16/10. 6 | // Copyright 2010 Rivetal, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSData (Gzip) 13 | 14 | // gzip compression utilities 15 | - (NSData *)gzipInflate; 16 | - (NSData *)gzipDeflate; 17 | 18 | @end -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/NSData+Gzip.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Gzip.h 3 | // tmxparse 4 | // 5 | // Created by Cory Kilger on 2/16/10. 6 | // Copyright 2010 Rivetal, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSData (Gzip) 13 | 14 | // gzip compression utilities 15 | - (NSData *)gzipInflate; 16 | - (NSData *)gzipDeflate; 17 | 18 | @end -------------------------------------------------------------------------------- /CodeFlow/WNBooleanExpression.h: -------------------------------------------------------------------------------- 1 | // 2 | // WNBooleanExpression.h 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WNStatement.h" 11 | 12 | 13 | @interface WNBooleanExpression : WNStatement 14 | 15 | @property (retain) NSString * expression; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /CodeFlow/CodeFlow-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'CodeFlow' target in the 'CodeFlow' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /CodeFlow/WNForLoop.h: -------------------------------------------------------------------------------- 1 | // 2 | // WNForLoop.h 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WNWhileLoop.h" 11 | 12 | 13 | @interface WNForLoop : WNWhileLoop 14 | 15 | @property (retain) NSString * initialExpression; 16 | @property (retain) NSString * endExpression; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /CodeFlow/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CodeFlow 4 | // 5 | // Created by Cory Kilger on 7/17/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | [pool release]; 16 | return retVal; 17 | } 18 | -------------------------------------------------------------------------------- /CodeFlow/WNBooleanExpression.m: -------------------------------------------------------------------------------- 1 | // 2 | // WNBooleanExpression.m 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "WNBooleanExpression.h" 10 | 11 | 12 | @implementation WNBooleanExpression 13 | 14 | @synthesize expression; 15 | 16 | - (void)dealloc { 17 | [expression release]; 18 | [super dealloc]; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /CodeFlow/WNConditionalChain.h: -------------------------------------------------------------------------------- 1 | // 2 | // WNIfElseChain.h 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WNStatement.h" 11 | 12 | @class WNBooleanExpression; 13 | 14 | @interface WNConditionalChain : WNStatement 15 | 16 | @property (retain) NSArray * conditionals; 17 | @property (retain) WNStatement * elseStatement; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CodeFlow/imageblending.txt: -------------------------------------------------------------------------------- 1 | { 2 | CGImageRef imageRef = CKImageCreateByBlendingImages(bottom.CGImage, top.CGImage, blendMode, offset); 3 | UIImage * image = nil; 4 | if ([[UIImage class] respondsToSelector:@selector(imageWithCGImage:scale:orientation:)]) 5 | image = [UIImage imageWithCGImage:imageRef scale:[top scale] orientation:UIImageOrientationUp]; 6 | else 7 | image = [UIImage imageWithCGImage:imageRef]; 8 | CGImageRelease(imageRef); 9 | return image; 10 | } -------------------------------------------------------------------------------- /CodeFlow/WNFastEnumeration.h: -------------------------------------------------------------------------------- 1 | // 2 | // WNFastEnumeration.h 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 7/4/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WNStatement.h" 11 | 12 | 13 | @interface WNFastEnumeration : WNStatement 14 | 15 | @property (retain) NSString * variableDeclaration; 16 | @property (retain) NSString * collection; 17 | @property (retain) WNStatement * statement; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /CodeFlow/FLFileBrowserViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FLFileBrowserViewController.h 3 | // CodeFlow 4 | // 5 | // Created by Cory Kilger on 7/17/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class FLFlowchartViewController; 12 | 13 | @interface FLFileBrowserViewController : UITableViewController 14 | 15 | @property (nonatomic, retain) IBOutlet FLFlowchartViewController *flowchartViewController; 16 | @property (nonatomic, retain) NSString * folder; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /CodeFlow/WNConditional.h: -------------------------------------------------------------------------------- 1 | // 2 | // WNConditional.h 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WNStatement.h" 11 | 12 | @class WNBooleanExpression; 13 | 14 | @interface WNConditional : WNStatement 15 | 16 | @property (retain) WNBooleanExpression * condition; 17 | @property (retain) WNStatement * statement; 18 | 19 | - (NSString *)edgeDeclarationsToTrueNode:(NSString *)trueNode falseNode:(NSString *)falseNode breakNode:(NSString *)breakNode; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /CodeFlowTests/CodeFlowTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CodeFlowTests.m 3 | // CodeFlowTests 4 | // 5 | // Created by Cory Kilger on 7/17/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "CodeFlowTests.h" 10 | 11 | 12 | @implementation CodeFlowTests 13 | 14 | - (void)setUp 15 | { 16 | [super setUp]; 17 | 18 | // Set-up code here. 19 | } 20 | 21 | - (void)tearDown 22 | { 23 | // Tear-down code here. 24 | 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample 29 | { 30 | STFail(@"Unit tests are not implemented yet in CodeFlowTests"); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /CodeFlow/RGBtoHSL.txt: -------------------------------------------------------------------------------- 1 | { 2 | float mincolor = fminf(fminf(r, g), b); 3 | float maxcolor = fmaxf(fmaxf(r, g), b); 4 | 5 | *h = 0; 6 | *s = 0; 7 | *l = (maxcolor + mincolor)/2; 8 | 9 | if (maxcolor == mincolor) 10 | return; 11 | 12 | if (*l < 0.5) 13 | *s = (maxcolor - mincolor)/(maxcolor + mincolor); 14 | else 15 | *s = (maxcolor - mincolor)/(2.0 - maxcolor - mincolor); 16 | 17 | if (r == maxcolor) 18 | *h = (g - b)/(maxcolor - mincolor); 19 | else if (g == maxcolor) 20 | *h = 2.0 + (b - r)/(maxcolor - mincolor); 21 | else 22 | *h = 4.0 + (r - g)/(maxcolor - mincolor); 23 | 24 | *h /= 6; 25 | } -------------------------------------------------------------------------------- /CodeFlow/FLAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // CodeFlowAppDelegate.h 3 | // CodeFlow 4 | // 5 | // Created by Cory Kilger on 7/17/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class FLFileBrowserViewController; 12 | @class FLFlowchartViewController; 13 | 14 | @interface FLAppDelegate : NSObject 15 | 16 | @property (nonatomic, retain) IBOutlet UIWindow *window; 17 | @property (nonatomic, retain) IBOutlet UISplitViewController *splitViewController; 18 | @property (nonatomic, retain) IBOutlet FLFileBrowserViewController *rootViewController; 19 | @property (nonatomic, retain) IBOutlet FLFlowchartViewController *detailViewController; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /CodeFlow/WNStatement.h: -------------------------------------------------------------------------------- 1 | // 2 | // WNCodeComponent.h 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface WNStatement : NSObject 13 | 14 | @property (retain) NSString * value; 15 | 16 | + (id) statementWithString:(NSString *)string; 17 | + (id) parseString:(NSString *)string location:(NSUInteger *)location; 18 | 19 | - (NSString *)prettyPrintWithIndentation:(NSUInteger)indentation; 20 | 21 | - (NSString *)graph; 22 | - (NSString *)nodeDeclarations; 23 | - (NSString *)edgeDeclarationsToNode:(NSString *)nextNode breakNode:(NSString *)breakNode; 24 | - (NSString *)firstNode; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /CodeFlow/FLFlowchartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FLFlowchartViewController.h 3 | // CodeFlow 4 | // 5 | // Created by Cory Kilger on 7/17/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FLFlowchartViewController : UIViewController 12 | 13 | @property (nonatomic, retain) IBOutlet UIToolbar *toolbar; 14 | @property (nonatomic, retain) IBOutlet UILabel *detailDescriptionLabel; 15 | @property (nonatomic, retain) IBOutlet UIWebView * webView; 16 | @property (nonatomic, retain) IBOutlet UIActivityIndicatorView * activityIndicator; 17 | 18 | - (void)setFile:(NSString *)filePath; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /CodeFlowTests/CodeFlowTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.corykilger.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /CodeFlow/WNBreak.m: -------------------------------------------------------------------------------- 1 | // 2 | // WNBreak.m 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 7/5/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "WNBreak.h" 10 | 11 | 12 | @implementation WNBreak 13 | 14 | + (id) parseString:(NSString *)string location:(NSUInteger *)location { 15 | NSInteger startPos = *location; 16 | while (*location < [string length]) { 17 | unichar character = [string characterAtIndex:*location]; 18 | if (character == ';') { 19 | (*location)++; 20 | WNBreak * statement = [[WNBreak alloc] init]; 21 | statement.value = [string substringWithRange:NSMakeRange(startPos, *location-startPos)]; 22 | return [statement autorelease]; 23 | } 24 | (*location)++; 25 | } 26 | return nil; 27 | } 28 | 29 | - (NSString *)edgeDeclarationsToNode:(NSString *)nextNode breakNode:(NSString *)breakNode { 30 | return [NSString stringWithFormat:@"%@ -> %@;\n", [self firstNode], breakNode]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /CodeFlow/WNReturn.m: -------------------------------------------------------------------------------- 1 | // 2 | // WNReturn.m 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 7/5/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "WNReturn.h" 10 | 11 | 12 | @implementation WNReturn 13 | 14 | + (id) parseString:(NSString *)string location:(NSUInteger *)location { 15 | NSInteger startPos = *location; 16 | while (*location < [string length]) { 17 | unichar character = [string characterAtIndex:*location]; 18 | if (character == ';') { 19 | (*location)++; 20 | WNReturn * statement = [[WNReturn alloc] init]; 21 | statement.value = [string substringWithRange:NSMakeRange(startPos, *location-startPos)]; 22 | return [statement autorelease]; 23 | } 24 | (*location)++; 25 | } 26 | return nil; 27 | } 28 | 29 | - (NSString *)edgeDeclarationsToNode:(NSString *)nextNode breakNode:(NSString *)breakNode { 30 | return [NSString stringWithFormat:@"%@ -> node_end;\n", [self firstNode]]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /CodeFlow/NSData+Base64.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Base64.h 3 | // base64 4 | // 5 | // Created by Matt Gallagher on 2009/06/03. 6 | // Copyright 2009 Matt Gallagher. All rights reserved. 7 | // 8 | // Permission is given to use this source code file, free of charge, in any 9 | // project, commercial or otherwise, entirely at your risk, with the condition 10 | // that any redistribution (in part or whole) of source code must retain 11 | // this copyright and permission notice. Attribution in compiled projects is 12 | // appreciated but not required. 13 | // 14 | 15 | #import 16 | 17 | void *NewBase64Decode( 18 | const char *inputBuffer, 19 | NSUInteger length, 20 | size_t *outputLength); 21 | 22 | char *NewBase64Encode( 23 | const void *inputBuffer, 24 | size_t length, 25 | bool separateLines, 26 | size_t *outputLength); 27 | 28 | @interface NSData (Base64) 29 | 30 | + (NSData *)dataFromBase64String:(NSString *)aString; 31 | - (NSString *)base64EncodedString; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/NSData+Base64.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Base64.h 3 | // base64 4 | // 5 | // Created by Matt Gallagher on 2009/06/03. 6 | // Copyright 2009 Matt Gallagher. All rights reserved. 7 | // 8 | // Permission is given to use this source code file, free of charge, in any 9 | // project, commercial or otherwise, entirely at your risk, with the condition 10 | // that any redistribution (in part or whole) of source code must retain 11 | // this copyright and permission notice. Attribution in compiled projects is 12 | // appreciated but not required. 13 | // 14 | 15 | #import 16 | 17 | void *NewBase64Decode( 18 | const char *inputBuffer, 19 | NSUInteger length, 20 | size_t *outputLength); 21 | 22 | char *NewBase64Encode( 23 | const void *inputBuffer, 24 | size_t length, 25 | bool separateLines, 26 | size_t *outputLength); 27 | 28 | @interface NSData (Base64) 29 | 30 | + (NSData *)dataFromBase64String:(NSString *)aString; 31 | - (NSString *)base64EncodedString; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /CodeFlow/WNComment.m: -------------------------------------------------------------------------------- 1 | // 2 | // WNComment.m 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 7/5/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "WNComment.h" 10 | 11 | 12 | @implementation WNComment 13 | 14 | + (id) parseString:(NSString *)string location:(NSUInteger *)location { 15 | if ([[string substringWithRange:NSMakeRange(*location, 2)] isEqualToString:@"//"]) { 16 | while (*location < [string length]) { 17 | unichar character = [string characterAtIndex:*location]; 18 | if (character == '\n' || character == '\r') 19 | return nil; 20 | (*location)++; 21 | } 22 | } 23 | else if ([[string substringWithRange:NSMakeRange(*location, 2)] isEqualToString:@"/*"]) { 24 | while (*location < [string length]) { 25 | unichar character = [string characterAtIndex:*location]; 26 | if (character == '*' && ([string length] - *location) >= 2 && [[string substringWithRange:NSMakeRange(*location, 2)] isEqualToString:@"*/"]) { 27 | (*location) += 2; 28 | return nil; 29 | } 30 | (*location)++; 31 | } 32 | } 33 | 34 | return nil; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/GVGraphArguments.h: -------------------------------------------------------------------------------- 1 | /* $Id: GVGraphArguments.h,v 1.4 2011/01/25 16:30:51 ellson Exp $ $Revision: 1.4 $ */ 2 | /* vim:set shiftwidth=4 ts=8: */ 3 | 4 | /************************************************************************* 5 | * Copyright (c) 2011 AT&T Intellectual Property 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the Eclipse Public License v1.0 8 | * which accompanies this distribution, and is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Contributors: See CVS logs. Details at http://www.graphviz.org/ 12 | *************************************************************************/ 13 | 14 | #import 15 | 16 | @class GVGraph; 17 | 18 | @interface GVGraphArguments : NSMutableDictionary { 19 | GVGraph *_graph; 20 | NSMutableDictionary *_arguments; 21 | } 22 | 23 | - (id)initWithGraph:(GVGraph *)graph; 24 | 25 | /* dictionary primitive methods */ 26 | - (NSUInteger)count; 27 | - (NSEnumerator *)keyEnumerator; 28 | - (id)objectForKey:(id)aKey; 29 | 30 | /* mutable dictionary primitive methods */ 31 | - (void)setObject:(id)anObject forKey:(id)aKey; 32 | - (void)removeObjectForKey:(id)aKey; 33 | 34 | - (void)dealloc; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/GVGraphDefaultAttributes.h: -------------------------------------------------------------------------------- 1 | /* $Id: GVGraphDefaultAttributes.h,v 1.6 2011/01/25 16:30:51 ellson Exp $ $Revision: 1.6 $ */ 2 | /* vim:set shiftwidth=4 ts=8: */ 3 | 4 | /************************************************************************* 5 | * Copyright (c) 2011 AT&T Intellectual Property 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the Eclipse Public License v1.0 8 | * which accompanies this distribution, and is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Contributors: See CVS logs. Details at http://www.graphviz.org/ 12 | *************************************************************************/ 13 | 14 | #import 15 | 16 | #include "types.h" 17 | #include "graph.h" 18 | 19 | @class GVGraph; 20 | 21 | @interface GVGraphDefaultAttributes : NSMutableDictionary 22 | { 23 | GVGraph *_graph; 24 | void *_proto; 25 | } 26 | 27 | - (id)initWithGraph:(GVGraph *)graph prototype:(void *)proto; 28 | 29 | /* dictionary primitive methods */ 30 | - (NSUInteger)count; 31 | - (NSEnumerator *)keyEnumerator; 32 | - (id)objectForKey:(id)aKey; 33 | 34 | /* mutable dictionary primitive methods */ 35 | - (void)setObject:(id)anObject forKey:(id)aKey; 36 | - (void)removeObjectForKey:(id)aKey; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /CodeFlow/CodeFlow-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.corykilger.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | NSMainNibFile 30 | MainWindow 31 | UISupportedInterfaceOrientations~ipad 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationPortraitUpsideDown 35 | UIInterfaceOrientationLandscapeLeft 36 | UIInterfaceOrientationLandscapeRight 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // graphviz-cgi 4 | // 5 | // Created by Cory Kilger on 7/17/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "GVGraph.h" 11 | #import "CGI.h" 12 | #import "NSData+Gzip.h" 13 | #import "NSData+Base64.h" 14 | 15 | int main (int argc, const char * argv[]) { 16 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 17 | 18 | NSData * content = [[CGI defaultCGI] content]; 19 | NSString * contentString = [[NSString alloc] initWithData:content encoding:NSUTF8StringEncoding]; 20 | //NSString * contentString = @"H4sICHlQeU0AA0F2YW50R2FyZGUuZ3YA3ZJJT4NAGIbPzK+YcLYpXW7CJGxiFUul" 21 | // "uOthkCkzFgZKp4ua/vdCTRON2uiJhMub+db3y5OJWFzgnL4DqQNbCHYr6VXSPwZl" 22 | // "7gFOMi44Tokm60vMhYOLiLSMLJvKcE5xTrQwW8MViwTVFEgJi6koHykuYsY1WTlS" 23 | // "ZCAlOCSJpqqBbrg2NDzfsv2yJkPTdt192PkIxyPdHAydqoyApAY+UgMLfTNX22W2" 24 | // "FP9Lk2Fa9olzOjhzz92LoTe69MfB1fXN7d39zwM4fI7IJKbsJZkmKc/yWTEXi+Vq" 25 | // "/fr2b4dH/udt7R0IhJ4qxt0DjL0wYbMFqRX1/obmEO/9QtwiKasN9c68OYz7BxjX" 26 | // "/as/39AY4mADtoCCMYvMBQAA"; 27 | 28 | content = [NSData dataFromBase64String:contentString]; 29 | content = [content gzipInflate]; 30 | 31 | GVGraph * graph = [[GVGraph alloc] initWithData:content error:nil]; 32 | [graph.arguments setValue:@"dot" forKey:@"layout"]; 33 | content = [graph renderWithFormat:@"pdf:quartz"]; 34 | content = [content gzipDeflate]; 35 | 36 | if (!content) { 37 | [[CGI defaultCGI] print:@"ERROR"]; 38 | exit(-1); 39 | } 40 | 41 | [[CGI defaultCGI] print:@"%@", [content base64EncodedString]]; 42 | 43 | [contentString release]; 44 | [pool drain]; 45 | 46 | return 0; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /CodeFlow/adjusthsl.txt: -------------------------------------------------------------------------------- 1 | { 2 | 3 | hue /= 360.0; 4 | saturation /= 100.0; 5 | lightness /= 100.0; 6 | 7 | if (hue < 0) 8 | hue += 1.0; 9 | 10 | void * bitmapData = NULL; 11 | CGContextRef context = CKBitmapContextAndDataCreateWithImage([self CGImage], &bitmapData); 12 | 13 | UInt32 * data = bitmapData; 14 | 15 | size_t width = CGBitmapContextGetWidth(context); 16 | size_t height = CGBitmapContextGetHeight(context); 17 | 18 | for (size_t x = 0; x < width; x++) { 19 | for (size_t y = 0; y < height; y++) { 20 | NSUInteger index = y*width+x; 21 | UInt32 color = data[index]; 22 | int rInt, gInt, bInt, aInt; 23 | UInt32ToRGB(color, &rInt, &gInt, &bInt, &aInt); 24 | CGFloat h, s, l; 25 | CGFloat r = rInt/255.0, g = gInt/255.0, b = bInt/255.0; 26 | RGBToHSL(r, g, b, &h, &s, &l); 27 | 28 | h = h+hue; 29 | if (h > 1.0) 30 | h -= 1.0; 31 | 32 | if (saturation < 0) 33 | s = s*(1.0+saturation); 34 | else if (saturation > 0) 35 | s = (1.0-s)*saturation+s; 36 | 37 | if (lightness < 0) 38 | l = l*(1.0+lightness); 39 | else if (lightness > 0) 40 | l = (1.0-l)*lightness+l; 41 | 42 | HSLToRGB(h, s, l, &r, &g, &b); 43 | color = RGBToUInt32(r*255, g*255, b*255, aInt); 44 | data[index] = color; 45 | } 46 | } 47 | 48 | CGImageRef newImage = CGBitmapContextCreateImage(context); 49 | UIImage * image = nil; 50 | if ([[UIImage class] respondsToSelector:@selector(imageWithCGImage:scale:orientation:)]) 51 | image = [UIImage imageWithCGImage:newImage scale:[self scale] orientation:UIImageOrientationUp]; 52 | else 53 | image = [UIImage imageWithCGImage:newImage]; 54 | 55 | CGImageRelease(newImage); 56 | CGContextRelease(context); 57 | free(bitmapData); 58 | 59 | return image; 60 | } -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/GVGraphArguments.m: -------------------------------------------------------------------------------- 1 | /* $Id: GVGraphArguments.m,v 1.4 2011/01/25 16:30:51 ellson Exp $ $Revision: 1.4 $ */ 2 | /* vim:set shiftwidth=4 ts=8: */ 3 | 4 | /************************************************************************* 5 | * Copyright (c) 2011 AT&T Intellectual Property 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the Eclipse Public License v1.0 8 | * which accompanies this distribution, and is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Contributors: See CVS logs. Details at http://www.graphviz.org/ 12 | *************************************************************************/ 13 | 14 | #import "GVGraphArguments.h" 15 | #import "GVGraph.h" 16 | 17 | @implementation GVGraphArguments 18 | 19 | - (id)initWithGraph:(GVGraph *)graph 20 | { 21 | if ((self = [super init])) { 22 | _graph = graph; /* no retain to avoid a retain cycle */ 23 | _arguments = [[NSMutableDictionary alloc] init]; 24 | } 25 | return self; 26 | } 27 | 28 | - (NSUInteger)count 29 | { 30 | return [_arguments count]; 31 | } 32 | 33 | - (NSEnumerator *)keyEnumerator 34 | { 35 | return [_arguments keyEnumerator]; 36 | } 37 | 38 | - (id)objectForKey:(id)aKey 39 | { 40 | return [_arguments objectForKey:aKey]; 41 | } 42 | 43 | /* mutable dictionary primitive methods */ 44 | - (void)setObject:(id)anObject forKey:(id)aKey 45 | { 46 | [_arguments setObject:anObject forKey:aKey]; 47 | [_graph noteChanged:YES]; 48 | } 49 | 50 | - (void)removeObjectForKey:(id)aKey 51 | { 52 | [_arguments removeObjectForKey:aKey]; 53 | [_graph noteChanged:YES]; 54 | } 55 | 56 | - (void)dealloc 57 | { 58 | [_arguments release]; 59 | [super dealloc]; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/GVGraph.h: -------------------------------------------------------------------------------- 1 | /* $Id: GVGraph.h,v 1.8 2011/01/25 16:30:51 ellson Exp $ $Revision: 1.8 $ */ 2 | /* vim:set shiftwidth=4 ts=8: */ 3 | 4 | /************************************************************************* 5 | * Copyright (c) 2011 AT&T Intellectual Property 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the Eclipse Public License v1.0 8 | * which accompanies this distribution, and is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Contributors: See CVS logs. Details at http://www.graphviz.org/ 12 | *************************************************************************/ 13 | 14 | #import 15 | 16 | #include "gvc.h" 17 | 18 | @class GVGraphArguments; 19 | @class GVGraphDefaultAttributes; 20 | 21 | @interface GVGraph : NSObject 22 | { 23 | graph_t *_graph; 24 | BOOL _freeLastLayout; 25 | 26 | GVGraphArguments *_arguments; 27 | GVGraphDefaultAttributes *_graphAttributes; 28 | GVGraphDefaultAttributes *_defaultNodeAttributes; 29 | GVGraphDefaultAttributes *_defaultEdgeAttributes; 30 | } 31 | 32 | @property(readonly) graph_t *graph; 33 | @property(readonly) GVGraphArguments *arguments; 34 | @property(readonly) GVGraphDefaultAttributes *graphAttributes; 35 | @property(readonly) GVGraphDefaultAttributes *defaultNodeAttributes; 36 | @property(readonly) GVGraphDefaultAttributes *defaultEdgeAttributes; 37 | 38 | + (void)initialize; 39 | + (NSArray *)pluginsWithAPI:(api_t)api; 40 | 41 | - (id)initWithData:(NSData *)data error:(NSError **)outError; 42 | - (id)initWithURL:(NSURL *)URL error:(NSError **)outError; 43 | 44 | - (NSData *)renderWithFormat:(NSString *)format; 45 | - (void)renderWithFormat:(NSString*)format toURL:(NSURL *)URL; 46 | - (void)noteChanged:(BOOL)relayout; 47 | 48 | - (BOOL)writeToURL:(NSURL *)URL error:(NSError **)outError; 49 | 50 | - (void)dealloc; 51 | 52 | @end 53 | 54 | extern NSString *const GVGraphvizErrorDomain; 55 | 56 | enum { 57 | GVNoError, 58 | GVFileParseError 59 | }; 60 | -------------------------------------------------------------------------------- /CodeFlow/WNFastEnumeration.m: -------------------------------------------------------------------------------- 1 | // 2 | // WNFastEnumeration.m 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 7/4/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "WNFastEnumeration.h" 10 | #import "WNCodeBlock.h" 11 | 12 | 13 | @implementation WNFastEnumeration 14 | 15 | @synthesize variableDeclaration; 16 | @synthesize collection; 17 | @synthesize statement; 18 | 19 | - (void)dealloc { 20 | [variableDeclaration release]; 21 | [collection release]; 22 | [statement release]; 23 | [super dealloc]; 24 | } 25 | 26 | - (NSString *)prettyPrintWithIndentation:(NSUInteger)indentation { 27 | NSMutableString * string = [NSMutableString string]; 28 | for (int i = 0; i < indentation; i++) 29 | [string appendString:@"\t"]; 30 | [string appendFormat:@"for (%@ in %@)", self.variableDeclaration, self.collection]; 31 | if ([self.statement isKindOfClass:[WNCodeBlock class]]) { 32 | [string appendFormat:@" %@", [[self.statement prettyPrintWithIndentation:indentation] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; 33 | } 34 | else { 35 | [string appendString:@"\n"]; 36 | for (int i = 0; i < indentation; i++) 37 | [string appendString:@"\t"]; 38 | [string appendString:self.statement.value]; 39 | } 40 | return string; 41 | } 42 | 43 | #pragma mark - 44 | 45 | - (NSString *)nodeDeclarations { 46 | NSMutableString * nodes = [NSMutableString string]; 47 | [nodes appendFormat:@"\tnode node_%x_condition [label = \"%@ in %@\", shape = diamond];\n", self, [self.variableDeclaration stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""], [self.collection stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]]; 48 | [nodes appendString:[self.statement nodeDeclarations]]; 49 | return nodes; 50 | } 51 | 52 | - (NSString *)edgeDeclarationsToNode:(NSString *)nextNode breakNode:(NSString *)breakNode { 53 | NSMutableString * edges = [NSMutableString string]; 54 | [edges appendFormat:@"\tnode_%x_condition -> %@ [label = \"Yes\"];\n", self, [self.statement firstNode]]; 55 | if (nextNode) 56 | [edges appendFormat:@"\tnode_%x_condition -> %@ [label = \"No\"];\n", self, nextNode]; 57 | [edges appendString:[self.statement edgeDeclarationsToNode:[NSString stringWithFormat:@"node_%x_condition", self] breakNode:nextNode]]; 58 | return edges; 59 | } 60 | 61 | - (NSString *)firstNode { 62 | return [NSString stringWithFormat:@"node_%x_condition", self]; 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /CodeFlow/FLFileBrowserViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FLFileBrowserViewController.m 3 | // CodeFlow 4 | // 5 | // Created by Cory Kilger on 7/17/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "FLFileBrowserViewController.h" 10 | #import "FLFlowchartViewController.h" 11 | 12 | @implementation FLFileBrowserViewController 13 | 14 | @synthesize flowchartViewController, folder; 15 | 16 | - (void)viewDidLoad { 17 | [super viewDidLoad]; 18 | self.clearsSelectionOnViewWillAppear = NO; 19 | self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0); 20 | } 21 | 22 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 23 | return YES; 24 | } 25 | 26 | #pragma mark - Table view 27 | 28 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 29 | return 1; 30 | } 31 | 32 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 33 | return 3; 34 | } 35 | 36 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 37 | static NSString *CellIdentifier = @"Cell"; 38 | 39 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 40 | if (cell == nil) { 41 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 42 | } 43 | 44 | // Configure the cell. 45 | cell.imageView.image = [UIImage imageNamed:@"icn_New_File.m_512.png"]; 46 | switch (indexPath.row) { 47 | case 0: 48 | cell.textLabel.text = @"AdjustHSL.m"; 49 | break; 50 | case 1: 51 | cell.textLabel.text = @"ImageBlending.m"; 52 | break; 53 | case 2: 54 | cell.textLabel.text = @"RGBtoHSL.m"; 55 | break; 56 | default: 57 | break; 58 | } 59 | 60 | return cell; 61 | } 62 | 63 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 64 | switch (indexPath.row) { 65 | case 0: 66 | [flowchartViewController setFile:[[NSBundle mainBundle] pathForResource:@"adjusthsl.txt" ofType:nil]]; 67 | break; 68 | case 1: 69 | [flowchartViewController setFile:[[NSBundle mainBundle] pathForResource:@"RGBtoHSL.txt" ofType:nil]]; 70 | break; 71 | case 2: 72 | [flowchartViewController setFile:[[NSBundle mainBundle] pathForResource:@"imageblending.txt" ofType:nil]]; 73 | break; 74 | default: 75 | break; 76 | } 77 | } 78 | 79 | - (void)dealloc { 80 | [flowchartViewController release]; 81 | [super dealloc]; 82 | } 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /CodeFlow/NSData+Gzip.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Gzip.m 3 | // tmxparse 4 | // 5 | // Created by Cory Kilger on 2/16/10. 6 | // Copyright 2010 Rivetal, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSData+Gzip.h" 10 | #import 11 | 12 | 13 | @implementation NSData (Gzip) 14 | 15 | - (NSData *)gzipInflate 16 | { 17 | if ([self length] == 0) return self; 18 | 19 | unsigned full_length = [self length]; 20 | unsigned half_length = [self length] / 2; 21 | 22 | NSMutableData *decompressed = [NSMutableData dataWithLength: full_length + half_length]; 23 | BOOL done = NO; 24 | int status; 25 | 26 | z_stream strm; 27 | strm.next_in = (Bytef *)[self bytes]; 28 | strm.avail_in = [self length]; 29 | strm.total_out = 0; 30 | strm.zalloc = Z_NULL; 31 | strm.zfree = Z_NULL; 32 | 33 | if (inflateInit2(&strm, (15+32)) != Z_OK) return nil; 34 | while (!done) 35 | { 36 | // Make sure we have enough room and reset the lengths. 37 | if (strm.total_out >= [decompressed length]) 38 | [decompressed increaseLengthBy: half_length]; 39 | strm.next_out = [decompressed mutableBytes] + strm.total_out; 40 | strm.avail_out = [decompressed length] - strm.total_out; 41 | 42 | // Inflate another chunk. 43 | status = inflate (&strm, Z_SYNC_FLUSH); 44 | if (status == Z_STREAM_END) done = YES; 45 | else if (status != Z_OK) break; 46 | } 47 | if (inflateEnd (&strm) != Z_OK) return nil; 48 | 49 | // Set real length. 50 | if (done) 51 | { 52 | [decompressed setLength: strm.total_out]; 53 | return [NSData dataWithData: decompressed]; 54 | } 55 | else return nil; 56 | } 57 | 58 | - (NSData *)gzipDeflate 59 | { 60 | if ([self length] == 0) return self; 61 | 62 | z_stream strm; 63 | 64 | strm.zalloc = Z_NULL; 65 | strm.zfree = Z_NULL; 66 | strm.opaque = Z_NULL; 67 | strm.total_out = 0; 68 | strm.next_in=(Bytef *)[self bytes]; 69 | strm.avail_in = [self length]; 70 | 71 | // Compresssion Levels: 72 | // Z_NO_COMPRESSION 73 | // Z_BEST_SPEED 74 | // Z_BEST_COMPRESSION 75 | // Z_DEFAULT_COMPRESSION 76 | 77 | if (deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, (15+16), 8, Z_DEFAULT_STRATEGY) != Z_OK) return nil; 78 | 79 | NSMutableData *compressed = [NSMutableData dataWithLength:16384]; // 16K chunks for expansion 80 | 81 | do { 82 | 83 | if (strm.total_out >= [compressed length]) 84 | [compressed increaseLengthBy: 16384]; 85 | 86 | strm.next_out = [compressed mutableBytes] + strm.total_out; 87 | strm.avail_out = [compressed length] - strm.total_out; 88 | 89 | deflate(&strm, Z_FINISH); 90 | 91 | } while (strm.avail_out == 0); 92 | 93 | deflateEnd(&strm); 94 | 95 | [compressed setLength: strm.total_out]; 96 | return [NSData dataWithData:compressed]; 97 | } 98 | 99 | @end -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/NSData+Gzip.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Gzip.m 3 | // tmxparse 4 | // 5 | // Created by Cory Kilger on 2/16/10. 6 | // Copyright 2010 Rivetal, Inc. All rights reserved. 7 | // 8 | 9 | #import "NSData+Gzip.h" 10 | #import 11 | 12 | 13 | @implementation NSData (Gzip) 14 | 15 | - (NSData *)gzipInflate 16 | { 17 | if ([self length] == 0) return self; 18 | 19 | unsigned full_length = [self length]; 20 | unsigned half_length = [self length] / 2; 21 | 22 | NSMutableData *decompressed = [NSMutableData dataWithLength: full_length + half_length]; 23 | BOOL done = NO; 24 | int status; 25 | 26 | z_stream strm; 27 | strm.next_in = (Bytef *)[self bytes]; 28 | strm.avail_in = [self length]; 29 | strm.total_out = 0; 30 | strm.zalloc = Z_NULL; 31 | strm.zfree = Z_NULL; 32 | 33 | if (inflateInit2(&strm, (15+32)) != Z_OK) return nil; 34 | while (!done) 35 | { 36 | // Make sure we have enough room and reset the lengths. 37 | if (strm.total_out >= [decompressed length]) 38 | [decompressed increaseLengthBy: half_length]; 39 | strm.next_out = [decompressed mutableBytes] + strm.total_out; 40 | strm.avail_out = [decompressed length] - strm.total_out; 41 | 42 | // Inflate another chunk. 43 | status = inflate (&strm, Z_SYNC_FLUSH); 44 | if (status == Z_STREAM_END) done = YES; 45 | else if (status != Z_OK) break; 46 | } 47 | if (inflateEnd (&strm) != Z_OK) return nil; 48 | 49 | // Set real length. 50 | if (done) 51 | { 52 | [decompressed setLength: strm.total_out]; 53 | return [NSData dataWithData: decompressed]; 54 | } 55 | else return nil; 56 | } 57 | 58 | - (NSData *)gzipDeflate 59 | { 60 | if ([self length] == 0) return self; 61 | 62 | z_stream strm; 63 | 64 | strm.zalloc = Z_NULL; 65 | strm.zfree = Z_NULL; 66 | strm.opaque = Z_NULL; 67 | strm.total_out = 0; 68 | strm.next_in=(Bytef *)[self bytes]; 69 | strm.avail_in = [self length]; 70 | 71 | // Compresssion Levels: 72 | // Z_NO_COMPRESSION 73 | // Z_BEST_SPEED 74 | // Z_BEST_COMPRESSION 75 | // Z_DEFAULT_COMPRESSION 76 | 77 | if (deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, (15+16), 8, Z_DEFAULT_STRATEGY) != Z_OK) return nil; 78 | 79 | NSMutableData *compressed = [NSMutableData dataWithLength:16384]; // 16K chunks for expansion 80 | 81 | do { 82 | 83 | if (strm.total_out >= [compressed length]) 84 | [compressed increaseLengthBy: 16384]; 85 | 86 | strm.next_out = [compressed mutableBytes] + strm.total_out; 87 | strm.avail_out = [compressed length] - strm.total_out; 88 | 89 | deflate(&strm, Z_FINISH); 90 | 91 | } while (strm.avail_out == 0); 92 | 93 | deflateEnd(&strm); 94 | 95 | [compressed setLength: strm.total_out]; 96 | return [NSData dataWithData:compressed]; 97 | } 98 | 99 | @end -------------------------------------------------------------------------------- /CodeFlow/FLAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // CodeFlowAppDelegate.m 3 | // CodeFlow 4 | // 5 | // Created by Cory Kilger on 7/17/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "FLAppDelegate.h" 10 | 11 | #import "FLFileBrowserViewController.h" 12 | 13 | @implementation FLAppDelegate 14 | 15 | @synthesize window=_window; 16 | @synthesize splitViewController=_splitViewController; 17 | @synthesize rootViewController=_rootViewController; 18 | @synthesize detailViewController=_detailViewController; 19 | 20 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 21 | { 22 | // Override point for customization after application launch. 23 | // Add the split view controller's view to the window and display. 24 | self.window.rootViewController = self.splitViewController; 25 | [self.window makeKeyAndVisible]; 26 | return YES; 27 | } 28 | 29 | - (void)applicationWillResignActive:(UIApplication *)application 30 | { 31 | /* 32 | Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 33 | Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 34 | */ 35 | } 36 | 37 | - (void)applicationDidEnterBackground:(UIApplication *)application 38 | { 39 | /* 40 | Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 41 | If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 42 | */ 43 | } 44 | 45 | - (void)applicationWillEnterForeground:(UIApplication *)application 46 | { 47 | /* 48 | Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 49 | */ 50 | } 51 | 52 | - (void)applicationDidBecomeActive:(UIApplication *)application 53 | { 54 | /* 55 | Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 56 | */ 57 | } 58 | 59 | - (void)applicationWillTerminate:(UIApplication *)application 60 | { 61 | /* 62 | Called when the application is about to terminate. 63 | Save data if appropriate. 64 | See also applicationDidEnterBackground:. 65 | */ 66 | } 67 | 68 | - (void)dealloc 69 | { 70 | [_window release]; 71 | [_splitViewController release]; 72 | [_rootViewController release]; 73 | [_detailViewController release]; 74 | [super dealloc]; 75 | } 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /CodeFlow/WNCodeBlock.m: -------------------------------------------------------------------------------- 1 | // 2 | // WNCodeBlock.m 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 7/3/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "WNCodeBlock.h" 10 | 11 | 12 | @implementation WNCodeBlock 13 | 14 | @synthesize statements; 15 | 16 | - (void)dealloc { 17 | [statements release]; 18 | [super dealloc]; 19 | } 20 | 21 | + (id) parseString:(NSString *)string location:(NSUInteger *)location { 22 | NSAssert([string characterAtIndex:*location] == '{', @"String should start with '{', is %@", [string substringFromIndex:*location]); 23 | 24 | (*location)++; 25 | NSMutableArray * statements = [NSMutableArray array]; 26 | while (*location < [string length]) { 27 | unichar character = [string characterAtIndex:*location]; 28 | if (isspace(character)) { 29 | (*location)++; 30 | } 31 | else if (character == '}') { 32 | (*location)++; 33 | WNCodeBlock * codeBlock = [[WNCodeBlock alloc] init]; 34 | codeBlock.statements = [NSArray arrayWithArray:statements]; 35 | return [codeBlock autorelease]; 36 | } 37 | else { 38 | WNStatement * statement = [WNStatement parseString:string location:location]; 39 | if (statement) 40 | [statements addObject:statement]; 41 | } 42 | } 43 | 44 | return nil; 45 | } 46 | 47 | - (NSString *)prettyPrintWithIndentation:(NSUInteger)indentation { 48 | NSMutableString * string = [NSMutableString string]; 49 | for (int i = 0; i < indentation; i++) 50 | [string appendString:@"\t"]; 51 | [string appendString:@"{"]; 52 | for (WNStatement * statement in self.statements) { 53 | [string appendString:@"\n"]; 54 | [string appendString:[statement prettyPrintWithIndentation:indentation+1]]; 55 | } 56 | [string appendString:@"\n"]; 57 | for (int i = 0; i < indentation; i++) 58 | [string appendString:@"\t"]; 59 | [string appendString:@"}"]; 60 | return string; 61 | } 62 | 63 | - (NSString *)description { 64 | return [self prettyPrintWithIndentation:0]; 65 | } 66 | 67 | #pragma mark - 68 | 69 | - (NSString *)nodeDeclarations { 70 | NSMutableString * nodes = [NSMutableString string]; 71 | for (WNStatement * statement in statements) 72 | [nodes appendString:[statement nodeDeclarations]]; 73 | return nodes; 74 | } 75 | 76 | - (NSString *)edgeDeclarationsToNode:(NSString *)nextNode breakNode:(NSString *)breakNode { 77 | NSMutableString * edges = [NSMutableString string]; 78 | WNStatement * prevStatement = nil; 79 | for (WNStatement * statement in statements) { 80 | NSString * firstNode = [statement firstNode]; 81 | if (prevStatement && firstNode) 82 | [edges appendString:[prevStatement edgeDeclarationsToNode:firstNode breakNode:breakNode]]; 83 | prevStatement = statement; 84 | } 85 | if (prevStatement && nextNode) 86 | [edges appendString:[prevStatement edgeDeclarationsToNode:nextNode breakNode:breakNode]]; 87 | return edges; 88 | } 89 | 90 | - (NSString *)firstNode { 91 | WNStatement * firstStatement = ([statements count] > 0) ? [statements objectAtIndex:0] : nil; 92 | return [firstStatement firstNode]; 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/CGI.h: -------------------------------------------------------------------------------- 1 | // Created by Cory Kilger on 5/26/11. 2 | // 3 | // Copyright (c) 2011 Cory Kilger 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | 26 | @interface CGI : NSObject 27 | 28 | + (CGI *) defaultCGI; 29 | 30 | @property (nonatomic, retain, readonly) NSString * httpHost; 31 | @property (nonatomic, retain, readonly) NSString * httpUserAgent; 32 | @property (nonatomic, retain, readonly) NSString * httpAccept; 33 | @property (nonatomic, retain, readonly) NSString * httpAcceptLanguage; 34 | @property (nonatomic, retain, readonly) NSString * contentType; 35 | @property (nonatomic, retain, readonly) NSString * httpCookie; 36 | @property (nonatomic, retain, readonly) NSString * httpAcceptEncoding; 37 | @property (nonatomic, retain, readonly) NSNumber * contentLength; 38 | @property (nonatomic, retain, readonly) NSString * httpConnection; 39 | @property (nonatomic, retain, readonly) NSString * path; 40 | @property (nonatomic, retain, readonly) NSString * serverSignature; 41 | @property (nonatomic, retain, readonly) NSString * serverSoftware; 42 | @property (nonatomic, retain, readonly) NSString * serverName; 43 | @property (nonatomic, retain, readonly) NSString * serverAddr; 44 | @property (nonatomic, retain, readonly) NSNumber * serverPort; 45 | @property (nonatomic, retain, readonly) NSString * remoteAddr; 46 | @property (nonatomic, retain, readonly) NSString * documentRoot; 47 | @property (nonatomic, retain, readonly) NSString * serverAdmin; 48 | @property (nonatomic, retain, readonly) NSString * scriptFilename; 49 | @property (nonatomic, retain, readonly) NSNumber * remotePort; 50 | @property (nonatomic, retain, readonly) NSString * gatewayInterface; 51 | @property (nonatomic, retain, readonly) NSString * serverProtocol; 52 | @property (nonatomic, retain, readonly) NSString * requestMethod; 53 | @property (nonatomic, retain, readonly) NSString * queryString; 54 | @property (nonatomic, retain, readonly) NSString * requestUri; 55 | @property (nonatomic, retain, readonly) NSString * scriptName; 56 | 57 | @property (nonatomic, retain, readonly) NSData * content; 58 | @property (nonatomic, retain, readonly) NSDictionary * allHeaderFields; 59 | 60 | - (void) setValue:(NSString *)value forHeaderField:(NSString *)field; 61 | - (void) print:(NSString *)format, ...; 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/graphviz_cgi.1: -------------------------------------------------------------------------------- 1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. 2 | .\"See Also: 3 | .\"man mdoc.samples for a complete listing of options 4 | .\"man mdoc for the short list of editing options 5 | .\"/usr/share/misc/mdoc.template 6 | .Dd 7/17/11 \" DATE 7 | .Dt graphviz-cgi 1 \" Program name and manual section number 8 | .Os Darwin 9 | .Sh NAME \" Section Header - required - don't modify 10 | .Nm graphviz-cgi, 11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key 12 | .\" words here as the database is built based on the words here and in the .ND line. 13 | .Nm Other_name_for_same_program(), 14 | .Nm Yet another name for the same program. 15 | .\" Use .Nm macro to designate other names for the documented program. 16 | .Nd This line parsed for whatis database. 17 | .Sh SYNOPSIS \" Section Header - required - don't modify 18 | .Nm 19 | .Op Fl abcd \" [-abcd] 20 | .Op Fl a Ar path \" [-a path] 21 | .Op Ar file \" [file] 22 | .Op Ar \" [file ...] 23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline 24 | arg2 ... \" Arguments 25 | .Sh DESCRIPTION \" Section Header - required - don't modify 26 | Use the .Nm macro to refer to your program throughout the man page like such: 27 | .Nm 28 | Underlining is accomplished with the .Ar macro like this: 29 | .Ar underlined text . 30 | .Pp \" Inserts a space 31 | A list of items with descriptions: 32 | .Bl -tag -width -indent \" Begins a tagged list 33 | .It item a \" Each item preceded by .It macro 34 | Description of item a 35 | .It item b 36 | Description of item b 37 | .El \" Ends the list 38 | .Pp 39 | A list of flags and their descriptions: 40 | .Bl -tag -width -indent \" Differs from above in tag removed 41 | .It Fl a \"-a flag as a list item 42 | Description of -a flag 43 | .It Fl b 44 | Description of -b flag 45 | .El \" Ends the list 46 | .Pp 47 | .\" .Sh ENVIRONMENT \" May not be needed 48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1 49 | .\" .It Ev ENV_VAR_1 50 | .\" Description of ENV_VAR_1 51 | .\" .It Ev ENV_VAR_2 52 | .\" Description of ENV_VAR_2 53 | .\" .El 54 | .Sh FILES \" File used or created by the topic of the man page 55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact 56 | .It Pa /usr/share/file_name 57 | FILE_1 description 58 | .It Pa /Users/joeuser/Library/really_long_file_name 59 | FILE_2 description 60 | .El \" Ends the list 61 | .\" .Sh DIAGNOSTICS \" May not be needed 62 | .\" .Bl -diag 63 | .\" .It Diagnostic Tag 64 | .\" Diagnostic informtion here. 65 | .\" .It Diagnostic Tag 66 | .\" Diagnostic informtion here. 67 | .\" .El 68 | .Sh SEE ALSO 69 | .\" List links in ascending order by section, alphabetically within a section. 70 | .\" Please do not reference files that do not exist without filing a bug report 71 | .Xr a 1 , 72 | .Xr b 1 , 73 | .Xr c 1 , 74 | .Xr a 2 , 75 | .Xr b 2 , 76 | .Xr a 3 , 77 | .Xr b 3 78 | .\" .Sh BUGS \" Document known, unremedied bugs 79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/GVGraphDefaultAttributes.m: -------------------------------------------------------------------------------- 1 | /* $Id: GVGraphDefaultAttributes.m,v 1.5 2011/01/25 16:30:51 ellson Exp $ $Revision: 1.5 $ */ 2 | /* vim:set shiftwidth=4 ts=8: */ 3 | 4 | /************************************************************************* 5 | * Copyright (c) 2011 AT&T Intellectual Property 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the Eclipse Public License v1.0 8 | * which accompanies this distribution, and is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Contributors: See CVS logs. Details at http://www.graphviz.org/ 12 | *************************************************************************/ 13 | 14 | #import "GVGraphDefaultAttributes.h" 15 | #import "GVGraph.h" 16 | 17 | @interface GVGraphDefaultAttributeKeyEnumerator : NSEnumerator 18 | { 19 | void *_proto; 20 | Agsym_t *_nextSymbol; 21 | } 22 | 23 | - (id)initWithPrototype:(void *)proto; 24 | - (NSArray *)allObjects; 25 | - (id)nextObject; 26 | 27 | @end 28 | 29 | @implementation GVGraphDefaultAttributeKeyEnumerator 30 | 31 | - (id)initWithPrototype:(void *)proto 32 | { 33 | if ((self = [super init])) { 34 | _proto = proto; 35 | _nextSymbol = agfstattr(_proto); 36 | } 37 | return self; 38 | } 39 | 40 | - (NSArray *)allObjects 41 | { 42 | NSMutableArray* all = [NSMutableArray array]; 43 | for (; _nextSymbol; _nextSymbol = agnxtattr(_proto, _nextSymbol)) { 44 | char *attributeValue = _nextSymbol->value; 45 | if (attributeValue && *attributeValue) 46 | [all addObject:[NSString stringWithUTF8String:attributeValue]]; 47 | } 48 | 49 | return all; 50 | } 51 | 52 | - (id)nextObject 53 | { 54 | for (; _nextSymbol; _nextSymbol = agnxtattr(_proto, _nextSymbol)) { 55 | char *attributeValue = _nextSymbol->value; 56 | if (attributeValue && *attributeValue) 57 | return [NSString stringWithUTF8String:attributeValue]; 58 | } 59 | return nil; 60 | } 61 | 62 | @end 63 | 64 | @implementation GVGraphDefaultAttributes 65 | 66 | - (id)initWithGraph:(GVGraph *)graph prototype:(void *)proto 67 | { 68 | if ((self = [super init])) { 69 | _graph = graph; /* not retained to avoid a retain cycle */ 70 | _proto = proto; 71 | } 72 | return self; 73 | } 74 | 75 | - (NSUInteger)count 76 | { 77 | NSUInteger symbolCount = 0; 78 | Agsym_t *nextSymbol; 79 | for (nextSymbol = agfstattr(_proto); nextSymbol; nextSymbol = agnxtattr(_proto, nextSymbol)) 80 | if (nextSymbol->value && *(nextSymbol->value)) 81 | ++symbolCount; 82 | return symbolCount; 83 | } 84 | 85 | - (NSEnumerator *)keyEnumerator 86 | { 87 | return [[[GVGraphDefaultAttributeKeyEnumerator alloc] initWithPrototype:_proto] autorelease]; 88 | } 89 | 90 | - (id)objectForKey:(id)aKey 91 | { 92 | id object = nil; 93 | Agsym_t *attributeSymbol = agfindattr(_proto, (char*)[aKey UTF8String]); 94 | if (attributeSymbol) { 95 | char *attributeValue = attributeSymbol->value; 96 | if (attributeValue && *attributeValue) 97 | object = [NSString stringWithUTF8String:attributeValue]; 98 | } 99 | return object; 100 | } 101 | 102 | - (void)setObject:(id)anObject forKey:(id)aKey 103 | { 104 | agattr(_proto, (char *)[aKey UTF8String], (char *)[anObject UTF8String]); 105 | [_graph noteChanged:YES]; 106 | } 107 | 108 | - (void)removeObjectForKey:(id)aKey 109 | { 110 | agattr(_proto, (char *)[aKey UTF8String], ""); 111 | [_graph noteChanged:YES]; 112 | } 113 | @end 114 | -------------------------------------------------------------------------------- /CodeFlow/WNWhileLoop.m: -------------------------------------------------------------------------------- 1 | // 2 | // WNWhileLoop.m 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "WNWhileLoop.h" 10 | #import "WNBooleanExpression.h" 11 | #import "WNCodeBlock.h" 12 | 13 | 14 | @implementation WNWhileLoop 15 | 16 | + (id) parseString:(NSString *)string location:(NSUInteger *)location { 17 | NSAssert([[string substringWithRange:NSMakeRange(*location, 5)] isEqualToString:@"while"], @"%@ does not start with 'while'", [string substringFromIndex:*location]); 18 | 19 | NSUInteger parenthesisCount = 0; 20 | NSUInteger firstParenthesisPos = -1; 21 | NSUInteger lastParenthesisPos = -1; 22 | for (NSUInteger pos = *location; pos < [string length]; pos++) { 23 | unichar character = [string characterAtIndex:pos]; 24 | if (character == '(') { 25 | parenthesisCount++; 26 | if (firstParenthesisPos == -1 && character == '(') 27 | firstParenthesisPos = pos; 28 | } 29 | else if (character == ')') { 30 | if (parenthesisCount == 1) { 31 | lastParenthesisPos = pos; 32 | break; 33 | } 34 | parenthesisCount--; 35 | } 36 | } 37 | 38 | if (firstParenthesisPos == -1 || lastParenthesisPos == -1) { 39 | *location = [string length]; 40 | return nil; 41 | } 42 | 43 | *location = lastParenthesisPos+1; 44 | 45 | WNWhileLoop * whileLoop = [[WNWhileLoop alloc] init]; 46 | WNBooleanExpression * condition = [[WNBooleanExpression alloc] init]; 47 | condition.expression = [string substringWithRange:NSMakeRange(firstParenthesisPos+1, lastParenthesisPos-firstParenthesisPos-1)]; 48 | whileLoop.condition = condition; 49 | whileLoop.statement = [WNStatement parseString:string location:location]; 50 | [condition release]; 51 | 52 | return [whileLoop autorelease]; 53 | } 54 | 55 | - (NSString *)prettyPrintWithIndentation:(NSUInteger)indentation { 56 | NSMutableString * string = [NSMutableString string]; 57 | for (int i = 0; i < indentation; i++) 58 | [string appendString:@"\t"]; 59 | [string appendFormat:@"while (%@)", self.condition.expression]; 60 | if ([self.statement isKindOfClass:[WNCodeBlock class]]) { 61 | [string appendFormat:@" %@", [[self.statement prettyPrintWithIndentation:indentation] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; 62 | } 63 | else { 64 | [string appendString:@"\n"]; 65 | for (int i = 0; i < indentation; i++) 66 | [string appendString:@"\t"]; 67 | [string appendString:self.statement.value]; 68 | } 69 | return string; 70 | } 71 | 72 | - (NSString *)description { 73 | return [self prettyPrintWithIndentation:0]; 74 | } 75 | 76 | #pragma mark - 77 | 78 | - (NSString *)nodeDeclarations { 79 | NSMutableString * nodes = [NSMutableString string]; 80 | [nodes appendFormat:@"\tnode node_%x_condition [label = \"%@\", shape = diamond];\n", self, [self.condition.expression stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]]; 81 | [nodes appendString:[self.statement nodeDeclarations]]; 82 | return nodes; 83 | } 84 | 85 | - (NSString *)edgeDeclarationsToNode:(NSString *)nextNode breakNode:(NSString *)breakNode { 86 | NSMutableString * edges = [NSMutableString string]; 87 | [edges appendFormat:@"\tnode_%x_condition -> %@ [label = \"Yes\"];\n", self, [self.statement firstNode]]; 88 | if (nextNode) 89 | [edges appendFormat:@"\tnode_%x_condition -> %@ [label = \"No\"];\n", self, nextNode]; 90 | [edges appendString:[self.statement edgeDeclarationsToNode:[NSString stringWithFormat:@"node_%x_condition", self] breakNode:nextNode]]; 91 | return edges; 92 | } 93 | 94 | - (NSString *)firstNode { 95 | return [NSString stringWithFormat:@"node_%x_condition", self]; 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /CodeFlow/WNConditional.m: -------------------------------------------------------------------------------- 1 | // 2 | // WNConditional.m 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "WNConditional.h" 10 | #import "WNBooleanExpression.h" 11 | #import "WNCodeBlock.h" 12 | 13 | 14 | @implementation WNConditional 15 | 16 | @synthesize condition; 17 | @synthesize statement; 18 | 19 | - (void)dealloc { 20 | [condition release]; 21 | [statement release]; 22 | [super dealloc]; 23 | } 24 | 25 | + (id) parseString:(NSString *)string location:(NSUInteger *)location { 26 | NSAssert([[string substringWithRange:NSMakeRange(*location, 2)] isEqualToString:@"if"], @"'%@' does not start with 'if'", [string substringFromIndex:*location]); 27 | 28 | NSUInteger parenthesisCount = 0; 29 | NSUInteger firstParenthesisPos = -1; 30 | NSUInteger lastParenthesisPos = -1; 31 | for (NSUInteger pos = *location; pos < [string length]; pos++) { 32 | unichar character = [string characterAtIndex:pos]; 33 | if (character == '(') { 34 | parenthesisCount++; 35 | if (firstParenthesisPos == -1 && character == '(') 36 | firstParenthesisPos = pos; 37 | } 38 | else if (character == ')') { 39 | if (parenthesisCount == 1) { 40 | lastParenthesisPos = pos; 41 | break; 42 | } 43 | parenthesisCount--; 44 | } 45 | } 46 | 47 | if (firstParenthesisPos == -1 || lastParenthesisPos == -1) { 48 | *location = [string length]; 49 | return nil; 50 | } 51 | 52 | *location = lastParenthesisPos+1; 53 | 54 | WNConditional * ifStatement = [[WNConditional alloc] init]; 55 | WNBooleanExpression * condition = [[WNBooleanExpression alloc] init]; 56 | condition.expression = [string substringWithRange:NSMakeRange(firstParenthesisPos+1, lastParenthesisPos-firstParenthesisPos-1)]; 57 | ifStatement.condition = condition; 58 | ifStatement.statement = [WNStatement parseString:string location:location]; 59 | [condition release]; 60 | 61 | return [ifStatement autorelease]; 62 | } 63 | 64 | - (NSString *)prettyPrintWithIndentation:(NSUInteger)indentation { 65 | NSMutableString * string = [NSMutableString string]; 66 | for (int i = 0; i < indentation; i++) 67 | [string appendString:@"\t"]; 68 | [string appendFormat:@"if (%@)", self.condition.expression]; 69 | if ([self.statement isKindOfClass:[WNCodeBlock class]]) { 70 | [string appendFormat:@" %@", [[self.statement prettyPrintWithIndentation:indentation] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; 71 | } 72 | else { 73 | [string appendString:@"\n"]; 74 | for (int i = 0; i <= indentation; i++) 75 | [string appendString:@"\t"]; 76 | [string appendString:self.statement.value]; 77 | } 78 | return string; 79 | } 80 | 81 | - (NSString *)description { 82 | return [self prettyPrintWithIndentation:0]; 83 | } 84 | 85 | #pragma mark - 86 | 87 | - (NSString *)nodeDeclarations { 88 | NSMutableString * nodes = [NSMutableString string]; 89 | [nodes appendFormat:@"\tnode node_%x_condition [label = \"%@\", shape = diamond];\n", self, [self.condition.expression stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]]; 90 | [nodes appendString:[self.statement nodeDeclarations]]; 91 | return nodes; 92 | } 93 | 94 | - (NSString *)edgeDeclarationsToNode:(NSString *)nextNode breakNode:(NSString *)breakNode { 95 | [NSException raise:@"WNNotImplementedException" format:@"%@ should not be used. Use -edgeDeclarationsToTrueNode:fasleNode instead"]; 96 | return nil; 97 | } 98 | 99 | - (NSString *)edgeDeclarationsToTrueNode:(NSString *)trueNode falseNode:(NSString *)falseNode breakNode:(NSString *)breakNode { 100 | NSMutableString * edges = [NSMutableString string]; 101 | [edges appendFormat:@"\tnode_%x_condition -> %@ [label = \"Yes\"];\n", self, [self.statement firstNode]]; 102 | if (trueNode) 103 | [edges appendFormat:@"\tnode_%x_condition -> %@ [label = \"No\"];\n", self, falseNode]; 104 | [edges appendString:[self.statement edgeDeclarationsToNode:trueNode breakNode:breakNode]]; 105 | return edges; 106 | } 107 | 108 | - (NSString *)firstNode { 109 | return [NSString stringWithFormat:@"node_%x_condition", self]; 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /CodeFlow/WNStatement.m: -------------------------------------------------------------------------------- 1 | // 2 | // WNCodeComponent.m 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "WNStatement.h" 10 | #import "WNWhileLoop.h" 11 | #import "WNBooleanExpression.h" 12 | #import "WNCodeBlock.h" 13 | #import "WNConditionalChain.h" 14 | #import "WNForLoop.h" 15 | #import "WNReturn.h" 16 | #import "WNComment.h" 17 | #import "WNBreak.h" 18 | 19 | 20 | @implementation WNStatement 21 | 22 | @synthesize value; 23 | 24 | - (id)init 25 | { 26 | self = [super init]; 27 | if (self) { 28 | // Initialization code here. 29 | } 30 | 31 | return self; 32 | } 33 | 34 | - (void)dealloc 35 | { 36 | [value release]; 37 | [super dealloc]; 38 | } 39 | 40 | + (id) parseString:(NSString *)string location:(NSUInteger *)location { 41 | 42 | // TODO: switch 43 | 44 | NSInteger startPos = -1; 45 | while (*location < [string length]) { 46 | unichar character = [string characterAtIndex:*location]; 47 | if (startPos != -1); 48 | else if (isspace(character)) { 49 | (*location)++; 50 | continue; 51 | } 52 | else if (character == 'w' && ([string length] - *location) >= 5 && [[string substringWithRange:NSMakeRange(*location, 5)] isEqualToString:@"while"]) { 53 | return [WNWhileLoop parseString:string location:location]; 54 | } 55 | else if (character == 'i' && ([string length] - *location) >= 2 && [[string substringWithRange:NSMakeRange(*location, 2)] isEqualToString:@"if"]) { 56 | return [WNConditionalChain parseString:string location:location]; 57 | } 58 | else if (character == 'f' && ([string length] - *location) >= 3 && [[string substringWithRange:NSMakeRange(*location, 3)] isEqualToString:@"for"]) { 59 | return [WNForLoop parseString:string location:location]; 60 | } 61 | else if (character == 'r' && ([string length] - *location) >= 6 && [[string substringWithRange:NSMakeRange(*location, 6)] isEqualToString:@"return"]) { 62 | return [WNReturn parseString:string location:location]; 63 | } 64 | else if (character == 'b' && ([string length] - *location) >= 5 && [[string substringWithRange:NSMakeRange(*location, 5)] isEqualToString:@"break"]) { 65 | return [WNBreak parseString:string location:location]; 66 | } 67 | else if (character == '{') { 68 | return [WNCodeBlock parseString:string location:location]; 69 | } 70 | else if (character == '/') { 71 | return [WNComment parseString:string location:location]; 72 | } 73 | 74 | // Single statement 75 | if (startPos == -1) { 76 | startPos = *location; 77 | } 78 | if (startPos != -1 && character == ';') { 79 | (*location)++; 80 | WNStatement * statement = [[WNStatement alloc] init]; 81 | statement.value = [string substringWithRange:NSMakeRange(startPos, *location-startPos)]; 82 | if ([statement.value hasPrefix:@"else "]) 83 | NSLog(@"sdfg kjhdsfkgjhdfgkdfd"); 84 | return [statement autorelease]; 85 | } 86 | 87 | (*location)++; 88 | } 89 | return nil; 90 | } 91 | 92 | + (id) statementWithString:(NSString *)string { 93 | NSUInteger location = 0; 94 | return [self parseString:[NSString stringWithFormat:@"%@", string] location:&location]; 95 | } 96 | 97 | - (NSString *)prettyPrintWithIndentation:(NSUInteger)indentation { 98 | NSMutableString * string = [NSMutableString string]; 99 | for (int i = 0; i < indentation; i++) 100 | [string appendString:@"\t"]; 101 | [string appendString:self.value]; 102 | return string; 103 | } 104 | 105 | - (NSString *)description { 106 | return [self prettyPrintWithIndentation:0]; 107 | } 108 | 109 | #pragma mark - 110 | 111 | - (NSString *)graph { 112 | NSMutableString * graph = [NSMutableString string]; 113 | [graph appendString:@"digraph {\n"]; 114 | [graph appendString:@"\tnode node_start [label = \"Start\", shape = ellipse];\n"]; 115 | [graph appendString:@"\tnode node_end [label = \"End\", shape = ellipse];\n"]; 116 | [graph appendString:[self nodeDeclarations]]; 117 | [graph appendFormat:@"\tnode_start -> %@;\n", [self firstNode]]; 118 | [graph appendString:[self edgeDeclarationsToNode:@"node_end" breakNode:@"node_end"]]; 119 | [graph appendString:@"}\n"]; 120 | return graph; 121 | } 122 | 123 | - (NSString *)nodeDeclarations { 124 | if ([self.value hasPrefix:@"else"]) 125 | NSLog(@"sdflgk hdsfkjgh dsfk"); 126 | return [NSString stringWithFormat:@"\tnode %@ [label = \"%@\", shape = box];\n", [self firstNode], [self.value stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]]; 127 | } 128 | 129 | - (NSString *)edgeDeclarationsToNode:(NSString *)nextNode breakNode:(NSString *)breakNode { 130 | return [NSString stringWithFormat:@"\t%@ -> %@;\n", [self firstNode], nextNode]; 131 | } 132 | 133 | - (NSString *)firstNode { 134 | return [NSString stringWithFormat:@"node_%x", self]; 135 | } 136 | 137 | @end 138 | -------------------------------------------------------------------------------- /CodeFlow/WNConditionalChain.m: -------------------------------------------------------------------------------- 1 | // 2 | // WNIfElseChain.m 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "WNConditionalChain.h" 10 | #import "WNConditional.h" 11 | #import "WNCodeBlock.h" 12 | 13 | 14 | @implementation WNConditionalChain 15 | 16 | @synthesize conditionals; 17 | @synthesize elseStatement; 18 | 19 | - (void)dealloc { 20 | [conditionals release]; 21 | [elseStatement release]; 22 | [super dealloc]; 23 | } 24 | 25 | + (id) parseString:(NSString *)string location:(NSUInteger *)location { 26 | NSAssert([[string substringWithRange:NSMakeRange(*location, 2)] isEqualToString:@"if"], @"'%@' does not start with 'if'", [string substringFromIndex:*location]); 27 | 28 | NSMutableArray * conditionals = [NSMutableArray array]; 29 | WNStatement * elseStatement = nil; 30 | while (*location < [string length]) { 31 | unichar character = [string characterAtIndex:*location]; 32 | if (isspace(character)) { 33 | (*location)++; 34 | continue; 35 | } 36 | else if (character == 'i' && ([string length] - *location) >= 2 && [[string substringWithRange:NSMakeRange(*location, 2)] isEqualToString:@"if"]) { 37 | WNConditional * conditional = [WNConditional parseString:string location:location]; 38 | if (conditional) 39 | [conditionals addObject:conditional]; 40 | } 41 | else if (character == 'e' && ([string length] - *location) >= 4 && [[string substringWithRange:NSMakeRange(*location, 4)] isEqualToString:@"else"]) { 42 | *location += 4; 43 | while (*location < [string length]) { 44 | character = [string characterAtIndex:*location]; 45 | if (!isspace(character)) 46 | break; 47 | (*location)++; 48 | } 49 | if (character == 'i' && ([string length] - *location) >= 2 && [[string substringWithRange:NSMakeRange(*location, 2)] isEqualToString:@"if"]) { 50 | WNConditional * conditional = [WNConditional parseString:string location:location]; 51 | if (conditional) 52 | [conditionals addObject:conditional]; 53 | } 54 | else { 55 | elseStatement = [WNStatement parseString:string location:location]; 56 | if (elseStatement) 57 | break; 58 | } 59 | } 60 | else { 61 | break; 62 | } 63 | } 64 | 65 | WNConditionalChain * conditionalChain = [[WNConditionalChain alloc] init]; 66 | conditionalChain.conditionals = conditionals; 67 | conditionalChain.elseStatement = elseStatement; 68 | 69 | return [conditionalChain autorelease]; 70 | } 71 | 72 | - (NSString *)prettyPrintWithIndentation:(NSUInteger)indentation { 73 | NSMutableString * string = [NSMutableString string]; 74 | BOOL firstDone = NO; 75 | for (WNConditional * conditional in self.conditionals) { 76 | if (firstDone) { 77 | [string appendString:@"\n"]; 78 | for (int i = 0; i < indentation; i++) 79 | [string appendString:@"\t"]; 80 | [string appendFormat:@"else %@", [[conditional prettyPrintWithIndentation:indentation] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; 81 | } 82 | else { 83 | [string appendString:[conditional prettyPrintWithIndentation:indentation]]; 84 | firstDone = YES; 85 | } 86 | } 87 | if (elseStatement) { 88 | [string appendString:@"\n"]; 89 | for (int i = 0; i < indentation; i++) 90 | [string appendString:@"\t"]; 91 | [string appendString:@"else"]; 92 | if ([elseStatement isKindOfClass:[WNCodeBlock class]]) { 93 | [string appendFormat:@" %@", [elseStatement prettyPrintWithIndentation:indentation]]; 94 | } 95 | else { 96 | [string appendString:@"\n"]; 97 | for (int i = 0; i < indentation; i++) 98 | [string appendString:@"\t"]; 99 | [string appendString:elseStatement.value]; 100 | } 101 | } 102 | return string; 103 | } 104 | 105 | - (NSString *)description { 106 | return [self prettyPrintWithIndentation:0]; 107 | } 108 | 109 | #pragma mark - 110 | 111 | - (NSString *)nodeDeclarations { 112 | NSMutableString * nodes = [NSMutableString string]; 113 | for (WNConditional * conditional in conditionals) 114 | [nodes appendString:[conditional nodeDeclarations]]; 115 | if (elseStatement) 116 | [nodes appendString:[elseStatement nodeDeclarations]]; 117 | return nodes; 118 | } 119 | 120 | - (NSString *)edgeDeclarationsToNode:(NSString *)nextNode breakNode:(NSString *)breakNode { 121 | NSMutableString * edges = [NSMutableString string]; 122 | WNConditional * prevConditional = nil; 123 | for (WNConditional * conditional in conditionals) { 124 | NSString * firstNode = [conditional firstNode]; 125 | if (prevConditional && firstNode) 126 | [edges appendString:[prevConditional edgeDeclarationsToTrueNode:nextNode falseNode:firstNode breakNode:breakNode]]; 127 | prevConditional = conditional; 128 | } 129 | if (prevConditional) { 130 | if (elseStatement) { 131 | [edges appendString:[prevConditional edgeDeclarationsToTrueNode:nextNode falseNode:[elseStatement firstNode] breakNode:breakNode]]; 132 | if (nextNode) { 133 | [edges appendString:[elseStatement edgeDeclarationsToNode:nextNode breakNode:breakNode]]; 134 | } 135 | } 136 | else if (nextNode) { 137 | [edges appendString:[prevConditional edgeDeclarationsToTrueNode:nextNode falseNode:nextNode breakNode:breakNode]]; 138 | } 139 | } 140 | return edges; 141 | } 142 | 143 | - (NSString *)firstNode { 144 | return [conditionals count] > 0 ? [[conditionals objectAtIndex:0] firstNode] : nil; 145 | } 146 | 147 | @end 148 | -------------------------------------------------------------------------------- /CodeFlow/FLFlowchartViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FLFlowchartViewController.m 3 | // CodeFlow 4 | // 5 | // Created by Cory Kilger on 7/17/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "FLFlowchartViewController.h" 10 | #import "FLFileBrowserViewController.h" 11 | #import "NSData+Gzip.h" 12 | #import "NSData+Base64.h" 13 | #import "WNStatement.h" 14 | 15 | 16 | @interface FLFlowchartViewController () 17 | 18 | @property (nonatomic, retain) UIPopoverController *popoverController; 19 | @property (nonatomic, retain) NSMutableData * data; 20 | 21 | @end 22 | 23 | 24 | @implementation FLFlowchartViewController 25 | 26 | @synthesize toolbar; 27 | @synthesize detailDescriptionLabel; 28 | @synthesize popoverController; 29 | @synthesize webView; 30 | @synthesize activityIndicator; 31 | @synthesize data; 32 | 33 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 34 | return YES; 35 | } 36 | 37 | #pragma mark - Split view support 38 | 39 | - (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController: (UIPopoverController *)pc { 40 | barButtonItem.title = @"Files"; 41 | NSMutableArray *items = [[self.toolbar items] mutableCopy]; 42 | [items insertObject:barButtonItem atIndex:0]; 43 | [self.toolbar setItems:items animated:YES]; 44 | [items release]; 45 | self.popoverController = pc; 46 | } 47 | 48 | - (void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem { 49 | NSMutableArray *items = [[self.toolbar items] mutableCopy]; 50 | [items removeObjectAtIndex:0]; 51 | [self.toolbar setItems:items animated:YES]; 52 | [items release]; 53 | self.popoverController = nil; 54 | } 55 | 56 | #pragma mark - View cycle 57 | 58 | - (void)viewDidLoad { 59 | [super viewDidLoad]; 60 | } 61 | 62 | - (void)viewDidUnload { 63 | [super viewDidUnload]; 64 | self.popoverController = nil; 65 | self.detailDescriptionLabel = nil; 66 | } 67 | 68 | #pragma mark - Set file 69 | 70 | // !!!: This all assumes the view is loaded 71 | 72 | - (void)setFile:(NSString *)filePath { 73 | self.detailDescriptionLabel.hidden = YES; 74 | self.webView.alpha = 0.0; 75 | [self.activityIndicator startAnimating]; 76 | 77 | NSString * input = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; 78 | WNStatement * statement = [WNStatement statementWithString:input]; 79 | input = [statement graph]; 80 | NSData * content = [input dataUsingEncoding:NSUTF8StringEncoding]; 81 | content = [content gzipDeflate]; 82 | NSString * requestBodyString = [content base64EncodedString]; 83 | NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://Gideon.local/cgi-bin/graphviz-cgi"]]; 84 | [request setHTTPMethod:@"POST"]; 85 | [request setHTTPBody:[requestBodyString dataUsingEncoding:NSUTF8StringEncoding]]; 86 | [NSURLConnection connectionWithRequest:request delegate:self]; 87 | } 88 | 89 | #pragma mark Connection delegate 90 | 91 | - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { 92 | self.data = [NSMutableData data]; 93 | } 94 | 95 | - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)newData { 96 | [self.data appendData:newData]; 97 | } 98 | 99 | - (void)connectionDidFinishLoading:(NSURLConnection *)connection { 100 | NSString * string = [[NSString alloc] initWithData:self.data encoding:NSUTF8StringEncoding]; 101 | 102 | if ([string isEqualToString:@"ERROR"]) { 103 | [string release]; 104 | [self.activityIndicator stopAnimating]; 105 | [[[[UIAlertView alloc] initWithTitle:@"ERROR" message:@"There was an error generating the flowchart." delegate:nil cancelButtonTitle:@"Bummer." otherButtonTitles:nil] autorelease] show]; 106 | return; 107 | } 108 | 109 | NSData * content = [NSData dataFromBase64String:string]; 110 | content = [content gzipInflate]; 111 | NSString * filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 112 | filePath = [filePath stringByAppendingPathComponent:@"flowchart.pdf"]; // TODO: use a more dynamic path 113 | [content writeToFile:filePath atomically:YES]; 114 | [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]]; 115 | } 116 | 117 | - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { 118 | [self.activityIndicator stopAnimating]; 119 | [[[[UIAlertView alloc] initWithTitle:@"Network error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"Ah, man." otherButtonTitles:nil] autorelease] show]; 120 | } 121 | 122 | #pragma mark Web view dlegate 123 | 124 | - (void)webViewDidFinishLoad:(UIWebView *)webView { 125 | [UIView animateWithDuration:0.15 animations:^(void) { 126 | self.webView.alpha = 1.0; 127 | }]; 128 | [self.activityIndicator stopAnimating]; 129 | } 130 | 131 | - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { 132 | [[[[UIAlertView alloc] initWithTitle:@"ERROR" message:@"There was an error loading the flowchart." delegate:nil cancelButtonTitle:@"Sheesh." otherButtonTitles:nil] autorelease] show]; 133 | } 134 | 135 | #pragma mark - Memory management 136 | 137 | - (void)dealloc { 138 | [popoverController release]; 139 | [toolbar release]; 140 | [detailDescriptionLabel release]; 141 | [webView release]; 142 | [activityIndicator release]; 143 | [data release]; 144 | [super dealloc]; 145 | } 146 | 147 | @end 148 | -------------------------------------------------------------------------------- /CodeFlow/WNForLoop.m: -------------------------------------------------------------------------------- 1 | // 2 | // WNForLoop.m 3 | // Walnut 4 | // 5 | // Created by Cory Kilger on 6/13/11. 6 | // Copyright 2011 Cory Kilger. All rights reserved. 7 | // 8 | 9 | #import "WNForLoop.h" 10 | #import "WNBooleanExpression.h" 11 | #import "WNCodeBlock.h" 12 | #import "WNFastEnumeration.h" 13 | #import "RegexKitLite.h" 14 | 15 | 16 | @implementation WNForLoop 17 | 18 | @synthesize initialExpression; 19 | @synthesize endExpression; 20 | 21 | - (void)dealloc { 22 | [initialExpression release]; 23 | [endExpression release]; 24 | [super dealloc]; 25 | } 26 | 27 | + (id) parseString:(NSString *)string location:(NSUInteger *)location { 28 | NSAssert([[string substringWithRange:NSMakeRange(*location, 3)] isEqualToString:@"for"], @"%@ does not start with 'for'", [string substringFromIndex:*location]); 29 | 30 | NSUInteger parenthesisCount = 0; 31 | NSUInteger firstParenthesisPos = -1; 32 | NSUInteger lastParenthesisPos = -1; 33 | for (NSUInteger pos = *location; pos < [string length]; pos++) { 34 | unichar character = [string characterAtIndex:pos]; 35 | if (character == '(') { 36 | parenthesisCount++; 37 | if (firstParenthesisPos == -1 && character == '(') 38 | firstParenthesisPos = pos; 39 | } 40 | else if (character == ')') { 41 | if (parenthesisCount == 1) { 42 | lastParenthesisPos = pos; 43 | break; 44 | } 45 | parenthesisCount--; 46 | } 47 | } 48 | 49 | if (firstParenthesisPos == -1 || lastParenthesisPos == -1) { 50 | *location = [string length]; 51 | return nil; 52 | } 53 | 54 | *location = lastParenthesisPos+1; 55 | 56 | NSString * insideParenthesis = [string substringWithRange:NSMakeRange(firstParenthesisPos+1, lastParenthesisPos-firstParenthesisPos-1)]; 57 | NSArray * forComponents = [insideParenthesis componentsSeparatedByString:@";"]; 58 | NSArray * enumerationComponents = [insideParenthesis componentsSeparatedByRegex:@"\\sin\\s"]; 59 | if ([forComponents count] == 3) { 60 | WNForLoop * forLoop = [[WNForLoop alloc] init]; 61 | WNBooleanExpression * condition = [[WNBooleanExpression alloc] init]; 62 | forLoop.condition = condition; 63 | forLoop.initialExpression = [[forComponents objectAtIndex:0] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 64 | condition.expression = [[forComponents objectAtIndex:1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 65 | forLoop.endExpression = [[forComponents objectAtIndex:2] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 66 | [condition release]; 67 | forLoop.statement = [WNStatement parseString:string location:location]; 68 | return [forLoop autorelease]; 69 | } 70 | else if ([enumerationComponents count] == 2) { 71 | WNFastEnumeration * fastEnumeration = [[WNFastEnumeration alloc] init]; 72 | fastEnumeration.variableDeclaration = [[enumerationComponents objectAtIndex:0] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 73 | fastEnumeration.collection = [[enumerationComponents objectAtIndex:1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 74 | fastEnumeration.statement = [WNStatement parseString:string location:location]; 75 | return [fastEnumeration autorelease]; 76 | } 77 | return nil; 78 | } 79 | 80 | - (NSString *)prettyPrintWithIndentation:(NSUInteger)indentation { 81 | NSMutableString * string = [NSMutableString string]; 82 | for (int i = 0; i < indentation; i++) 83 | [string appendString:@"\t"]; 84 | [string appendFormat:@"for (%@; %@; %@)", self.initialExpression, self.condition.expression, self.endExpression]; 85 | if ([self.statement isKindOfClass:[WNCodeBlock class]]) { 86 | [string appendFormat:@" %@", [[self.statement prettyPrintWithIndentation:indentation] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; 87 | } 88 | else { 89 | [string appendString:@"\n"]; 90 | for (int i = 0; i < indentation; i++) 91 | [string appendString:@"\t"]; 92 | [string appendString:self.statement.value]; 93 | } 94 | return string; 95 | } 96 | 97 | - (NSString *)description { 98 | return [self prettyPrintWithIndentation:0]; 99 | } 100 | 101 | #pragma mark - 102 | 103 | - (NSString *)nodeDeclarations { 104 | NSMutableString * nodes = [NSMutableString string]; 105 | [nodes appendFormat:@"\tnode node_%x_initial [label = \"%@\", shape = box];\n", self, [self.initialExpression stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]]; 106 | [nodes appendFormat:@"\tnode node_%x_condition [label = \"%@\", shape = diamond];\n", self, [self.condition.expression stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]]; 107 | [nodes appendFormat:@"\tnode node_%x_update [label = \"%@\", shape = box];\n", self, [self.endExpression stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]]; 108 | [nodes appendString:[self.statement nodeDeclarations]]; 109 | return nodes; 110 | } 111 | 112 | - (NSString *)edgeDeclarationsToNode:(NSString *)nextNode breakNode:(NSString *)breakNode { 113 | NSMutableString * edges = [NSMutableString string]; 114 | [edges appendFormat:@"\tnode_%x_initial -> node_%x_condition;\n", self, self]; 115 | [edges appendFormat:@"\tnode_%x_update -> node_%x_condition;\n", self, self]; 116 | [edges appendFormat:@"\tnode_%x_condition -> %@ [label = \"Yes\"];\n", self, [self.statement firstNode]]; 117 | if (nextNode) 118 | [edges appendFormat:@"\tnode_%x_condition -> %@ [label = \"No\"];\n", self, nextNode]; 119 | [edges appendString:[self.statement edgeDeclarationsToNode:[NSString stringWithFormat:@"node_%x_update", self] breakNode:nextNode]]; 120 | return edges; 121 | } 122 | 123 | - (NSString *)firstNode { 124 | return [NSString stringWithFormat:@"node_%x_initial", self]; 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/GVGraph.m: -------------------------------------------------------------------------------- 1 | /* $Id: GVGraph.m,v 1.13 2011/01/25 16:30:51 ellson Exp $ $Revision: 1.13 $ */ 2 | /* vim:set shiftwidth=4 ts=8: */ 3 | 4 | /************************************************************************* 5 | * Copyright (c) 2011 AT&T Intellectual Property 6 | * All rights reserved. This program and the accompanying materials 7 | * are made available under the terms of the Eclipse Public License v1.0 8 | * which accompanies this distribution, and is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Contributors: See CVS logs. Details at http://www.graphviz.org/ 12 | *************************************************************************/ 13 | 14 | 15 | #import "GVGraph.h" 16 | #import "GVGraphArguments.h" 17 | #import "GVGraphDefaultAttributes.h" 18 | 19 | NSString *const GVGraphvizErrorDomain = @"GVGraphvizErrorDomain"; 20 | 21 | extern double PSinputscale; 22 | 23 | static GVC_t *_graphContext = nil; 24 | 25 | @implementation GVGraph 26 | 27 | @synthesize graph = _graph; 28 | @synthesize arguments = _arguments; 29 | @synthesize graphAttributes = _graphAttributes; 30 | @synthesize defaultNodeAttributes = _defaultNodeAttributes; 31 | @synthesize defaultEdgeAttributes = _defaultEdgeAttributes; 32 | 33 | extern char *gvplugin_list(GVC_t * gvc, api_t api, const char *str); 34 | 35 | + (void)initialize 36 | { 37 | _graphContext = gvContext(); 38 | } 39 | 40 | + (NSArray *)pluginsWithAPI:(api_t)api 41 | { 42 | NSMutableSet *plugins = [NSMutableSet set]; 43 | 44 | /* go through each non-empty plugin in the list, ignoring the package part */ 45 | char *pluginList = gvplugin_list(_graphContext, api, ":"); 46 | char *restOfPlugins; 47 | char *nextPlugin; 48 | for (restOfPlugins = pluginList; (nextPlugin = strsep(&restOfPlugins, " "));) { 49 | if (*nextPlugin) { 50 | char *lastColon = strrchr(nextPlugin, ':'); 51 | if (lastColon) { 52 | *lastColon = '\0'; 53 | [plugins addObject:[NSString stringWithCString:nextPlugin encoding:NSUTF8StringEncoding]]; 54 | } 55 | } 56 | } 57 | free(pluginList); 58 | 59 | return [[plugins allObjects] sortedArrayUsingSelector:@selector(compare:)]; 60 | } 61 | 62 | - (id)initWithURL:(NSURL *)URL error:(NSError **)outError 63 | { 64 | if ((self = [super init])) { 65 | if ([URL isFileURL]) { 66 | /* open a FILE* on the file URL */ 67 | FILE *file = fopen([[URL path] fileSystemRepresentation], "r"); 68 | if (!file) { 69 | if (outError) 70 | *outError = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:nil]; 71 | [self autorelease]; 72 | return nil; 73 | } 74 | 75 | _graph = agread(file); 76 | if (!_graph) { 77 | if (outError) 78 | *outError = [NSError errorWithDomain:GVGraphvizErrorDomain code:GVFileParseError userInfo:nil]; 79 | [self autorelease]; 80 | return nil; 81 | } 82 | fclose(file); 83 | } 84 | else { 85 | /* read the URL into memory */ 86 | NSMutableData *memory = [NSMutableData dataWithContentsOfURL:URL options:0 error:outError]; 87 | if (!memory) { 88 | [self autorelease]; 89 | return nil; 90 | } 91 | 92 | /* null terminate the data */ 93 | char nullByte = '\0'; 94 | [memory appendBytes:&nullByte length:1]; 95 | 96 | _graph = agmemread((char*)[memory bytes]); 97 | if (!_graph) { 98 | if (outError) 99 | *outError = [NSError errorWithDomain:GVGraphvizErrorDomain code:GVFileParseError userInfo:nil]; 100 | [self autorelease]; 101 | return nil; 102 | } 103 | } 104 | 105 | _freeLastLayout = NO; 106 | _arguments = [[GVGraphArguments alloc] initWithGraph:self]; 107 | _graphAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:_graph]; 108 | _defaultNodeAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:agprotonode(_graph)]; 109 | _defaultEdgeAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:agprotoedge(_graph)]; 110 | } 111 | 112 | return self; 113 | } 114 | 115 | - (id)initWithData:(NSData *)data error:(NSError **)outError { 116 | if ((self = [super init])) { 117 | /* read the URL into memory */ 118 | NSMutableData *memory = [NSMutableData dataWithData:data]; 119 | if (!memory) { 120 | [self autorelease]; 121 | return nil; 122 | } 123 | 124 | /* null terminate the data */ 125 | char nullByte = '\0'; 126 | [memory appendBytes:&nullByte length:1]; 127 | 128 | _graph = agmemread((char*)[memory bytes]); 129 | if (!_graph) { 130 | if (outError) 131 | *outError = [NSError errorWithDomain:GVGraphvizErrorDomain code:GVFileParseError userInfo:nil]; 132 | [self autorelease]; 133 | return nil; 134 | } 135 | 136 | _freeLastLayout = NO; 137 | _arguments = [[GVGraphArguments alloc] initWithGraph:self]; 138 | _graphAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:_graph]; 139 | _defaultNodeAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:agprotonode(_graph)]; 140 | _defaultEdgeAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:agprotoedge(_graph)]; 141 | } 142 | 143 | return self; 144 | } 145 | 146 | - (BOOL)writeToURL:(NSURL *)URL error:(NSError **)outError 147 | { 148 | if ([URL isFileURL]) { 149 | /* open a FILE* on the file URL */ 150 | FILE *file = fopen([[URL path] fileSystemRepresentation], "w"); 151 | if (!file) { 152 | if (outError) 153 | *outError = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:nil]; 154 | return NO; 155 | } 156 | 157 | /* write it out */ 158 | if (agwrite(_graph, file) != 0) { 159 | if (outError) 160 | *outError = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:nil]; 161 | return NO; 162 | } 163 | 164 | fclose(file); 165 | return YES; 166 | } 167 | else 168 | /* can't write out to non-file URL */ 169 | return NO; 170 | } 171 | 172 | - (void)noteChanged:(BOOL)relayout 173 | { 174 | /* if we need to layout, apply globals and then relayout */ 175 | if (relayout) { 176 | NSString* layout = [_arguments objectForKey:@"layout"]; 177 | if (layout) { 178 | if (_freeLastLayout) 179 | gvFreeLayout(_graphContext, _graph); 180 | 181 | /* apply scale */ 182 | NSString* scale = [_arguments objectForKey:@"scale"]; 183 | PSinputscale = scale ? [scale doubleValue] : 0.0; 184 | if (PSinputscale == 0.0) 185 | PSinputscale = 72.0; 186 | 187 | if (gvLayout(_graphContext, _graph, (char*)[layout UTF8String]) != 0) 188 | @throw [NSException exceptionWithName:@"GVException" reason:@"bad layout" userInfo:nil]; 189 | _freeLastLayout = YES; 190 | } 191 | } 192 | 193 | 194 | [[NSNotificationCenter defaultCenter] postNotificationName: @"GVGraphDidChange" object:self]; 195 | } 196 | 197 | - (NSData*)renderWithFormat:(NSString *)format 198 | { 199 | char *renderedData = NULL; 200 | unsigned int renderedLength = 0; 201 | if (gvRenderData(_graphContext, _graph, (char*)[format UTF8String], &renderedData, &renderedLength) != 0) 202 | @throw [NSException exceptionWithName:@"GVException" reason:@"bad render" userInfo:nil]; 203 | return [NSData dataWithBytesNoCopy:renderedData length:renderedLength freeWhenDone:YES]; 204 | 205 | } 206 | 207 | - (void)renderWithFormat:(NSString *)format toURL:(NSURL *)URL 208 | { 209 | if ([URL isFileURL]) { 210 | if (gvRenderFilename(_graphContext, _graph, (char*)[format UTF8String], (char*)[[URL path] UTF8String]) != 0) 211 | @throw [NSException exceptionWithName:@"GVException" reason:@"bad render" userInfo:nil]; 212 | } 213 | else 214 | [[self renderWithFormat:format] writeToURL:URL atomically:NO]; 215 | } 216 | 217 | 218 | - (void)dealloc 219 | { 220 | if (_graph) 221 | agclose(_graph); 222 | 223 | [_arguments release]; 224 | [_graphAttributes release]; 225 | [_defaultNodeAttributes release]; 226 | [_defaultEdgeAttributes release]; 227 | 228 | [super dealloc]; 229 | } 230 | 231 | @end 232 | -------------------------------------------------------------------------------- /CodeFlow/NSData+Base64.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Base64.m 3 | // base64 4 | // 5 | // Created by Matt Gallagher on 2009/06/03. 6 | // Copyright 2009 Matt Gallagher. All rights reserved. 7 | // 8 | // Permission is given to use this source code file, free of charge, in any 9 | // project, commercial or otherwise, entirely at your risk, with the condition 10 | // that any redistribution (in part or whole) of source code must retain 11 | // this copyright and permission notice. Attribution in compiled projects is 12 | // appreciated but not required. 13 | // 14 | 15 | #import "NSData+Base64.h" 16 | 17 | // 18 | // Mapping from 6 bit pattern to ASCII character. 19 | // 20 | static unsigned char base64EncodeLookup[65] = 21 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 22 | 23 | // 24 | // Definition for "masked-out" areas of the base64DecodeLookup mapping 25 | // 26 | #define xx 65 27 | 28 | // 29 | // Mapping from ASCII character to 6 bit pattern. 30 | // 31 | static unsigned char base64DecodeLookup[256] = 32 | { 33 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 34 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 35 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 62, xx, xx, xx, 63, 36 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, xx, xx, xx, xx, xx, xx, 37 | xx, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 38 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, xx, xx, xx, xx, xx, 39 | xx, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 40 | 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, xx, xx, xx, xx, xx, 41 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 42 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 43 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 44 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 45 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 46 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 47 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 48 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 49 | }; 50 | 51 | // 52 | // Fundamental sizes of the binary and base64 encode/decode units in bytes 53 | // 54 | #define BINARY_UNIT_SIZE 3 55 | #define BASE64_UNIT_SIZE 4 56 | 57 | // 58 | // NewBase64Decode 59 | // 60 | // Decodes the base64 ASCII string in the inputBuffer to a newly malloced 61 | // output buffer. 62 | // 63 | // inputBuffer - the source ASCII string for the decode 64 | // length - the length of the string or -1 (to specify strlen should be used) 65 | // outputLength - if not-NULL, on output will contain the decoded length 66 | // 67 | // returns the decoded buffer. Must be free'd by caller. Length is given by 68 | // outputLength. 69 | // 70 | void *NewBase64Decode( 71 | const char *inputBuffer, 72 | NSUInteger length, 73 | size_t *outputLength) 74 | { 75 | 76 | size_t outputBufferSize = (length / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE; 77 | unsigned char *outputBuffer = (unsigned char *)malloc(outputBufferSize); 78 | 79 | size_t i = 0; 80 | size_t j = 0; 81 | while (i < length) 82 | { 83 | // 84 | // Accumulate 4 valid characters (ignore everything else) 85 | // 86 | unsigned char accumulated[BASE64_UNIT_SIZE]; 87 | 88 | accumulated[0] = 0; 89 | accumulated[1] = 0; 90 | accumulated[2] = 0; 91 | accumulated[3] = 0; 92 | 93 | size_t accumulateIndex = 0; 94 | while (i < length) 95 | { 96 | unsigned char decode = base64DecodeLookup[inputBuffer[i++]]; 97 | if (decode != xx) 98 | { 99 | accumulated[accumulateIndex] = decode; 100 | accumulateIndex++; 101 | 102 | if (accumulateIndex == BASE64_UNIT_SIZE) 103 | { 104 | break; 105 | } 106 | } 107 | } 108 | 109 | // 110 | // Store the 6 bits from each of the 4 characters as 3 bytes 111 | // 112 | outputBuffer[j] = (accumulated[0] << 2) | (accumulated[1] >> 4); 113 | outputBuffer[j + 1] = (accumulated[1] << 4) | (accumulated[2] >> 2); 114 | outputBuffer[j + 2] = (accumulated[2] << 6) | accumulated[3]; 115 | j += accumulateIndex - 1; 116 | } 117 | 118 | if (outputLength) 119 | { 120 | *outputLength = j; 121 | } 122 | return outputBuffer; 123 | } 124 | 125 | // 126 | // NewBase64Decode 127 | // 128 | // Encodes the arbitrary data in the inputBuffer as base64 into a newly malloced 129 | // output buffer. 130 | // 131 | // inputBuffer - the source data for the encode 132 | // length - the length of the input in bytes 133 | // separateLines - if zero, no CR/LF characters will be added. Otherwise 134 | // a CR/LF pair will be added every 64 encoded chars. 135 | // outputLength - if not-NULL, on output will contain the encoded length 136 | // (not including terminating 0 char) 137 | // 138 | // returns the encoded buffer. Must be free'd by caller. Length is given by 139 | // outputLength. 140 | // 141 | char *NewBase64Encode( 142 | const void *buffer, 143 | size_t length, 144 | bool separateLines, 145 | size_t *outputLength) 146 | { 147 | const unsigned char *inputBuffer = (const unsigned char *)buffer; 148 | 149 | #define MAX_NUM_PADDING_CHARS 2 150 | #define OUTPUT_LINE_LENGTH 64 151 | #define INPUT_LINE_LENGTH ((OUTPUT_LINE_LENGTH / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE) 152 | #define CR_LF_SIZE 2 153 | 154 | // 155 | // Byte accurate calculation of final buffer size 156 | // 157 | size_t outputBufferSize = 158 | ((length / BINARY_UNIT_SIZE) 159 | + ((length % BINARY_UNIT_SIZE) ? 1 : 0)) 160 | * BASE64_UNIT_SIZE; 161 | if (separateLines) 162 | { 163 | outputBufferSize += 164 | (outputBufferSize / OUTPUT_LINE_LENGTH) * CR_LF_SIZE; 165 | } 166 | 167 | // 168 | // Include space for a terminating zero 169 | // 170 | outputBufferSize += 1; 171 | 172 | // 173 | // Allocate the output buffer 174 | // 175 | char *outputBuffer = (char *)malloc(outputBufferSize); 176 | if (!outputBuffer) 177 | { 178 | return NULL; 179 | } 180 | 181 | size_t i = 0; 182 | size_t j = 0; 183 | const size_t lineLength = separateLines ? INPUT_LINE_LENGTH : length; 184 | size_t lineEnd = lineLength; 185 | 186 | while (true) 187 | { 188 | if (lineEnd > length) 189 | { 190 | lineEnd = length; 191 | } 192 | 193 | for (; i + BINARY_UNIT_SIZE - 1 < lineEnd; i += BINARY_UNIT_SIZE) 194 | { 195 | // 196 | // Inner loop: turn 48 bytes into 64 base64 characters 197 | // 198 | outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; 199 | outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4) 200 | | ((inputBuffer[i + 1] & 0xF0) >> 4)]; 201 | outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i + 1] & 0x0F) << 2) 202 | | ((inputBuffer[i + 2] & 0xC0) >> 6)]; 203 | outputBuffer[j++] = base64EncodeLookup[inputBuffer[i + 2] & 0x3F]; 204 | } 205 | 206 | if (lineEnd == length) 207 | { 208 | break; 209 | } 210 | 211 | // 212 | // Add the newline 213 | // 214 | outputBuffer[j++] = '\r'; 215 | outputBuffer[j++] = '\n'; 216 | lineEnd += lineLength; 217 | } 218 | 219 | if (i + 1 < length) 220 | { 221 | // 222 | // Handle the single '=' case 223 | // 224 | outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; 225 | outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4) 226 | | ((inputBuffer[i + 1] & 0xF0) >> 4)]; 227 | outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i + 1] & 0x0F) << 2]; 228 | outputBuffer[j++] = '='; 229 | } 230 | else if (i < length) 231 | { 232 | // 233 | // Handle the double '=' case 234 | // 235 | outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; 236 | outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0x03) << 4]; 237 | outputBuffer[j++] = '='; 238 | outputBuffer[j++] = '='; 239 | } 240 | outputBuffer[j] = 0; 241 | 242 | // 243 | // Set the output length and return the buffer 244 | // 245 | if (outputLength) 246 | { 247 | *outputLength = j; 248 | } 249 | return outputBuffer; 250 | } 251 | 252 | @implementation NSData (Base64) 253 | 254 | // 255 | // dataFromBase64String: 256 | // 257 | // Creates an NSData object containing the base64 decoded representation of 258 | // the base64 string 'aString' 259 | // 260 | // Parameters: 261 | // aString - the base64 string to decode 262 | // 263 | // returns the autoreleased NSData representation of the base64 string 264 | // 265 | + (NSData *)dataFromBase64String:(NSString *)aString 266 | { 267 | NSData *data = [aString dataUsingEncoding:NSASCIIStringEncoding]; 268 | size_t outputLength; 269 | void *outputBuffer = NewBase64Decode([data bytes], [data length], &outputLength); 270 | NSData *result = [NSData dataWithBytes:outputBuffer length:outputLength]; 271 | free(outputBuffer); 272 | return result; 273 | } 274 | 275 | // 276 | // base64EncodedString 277 | // 278 | // Creates an NSString object that contains the base 64 encoding of the 279 | // receiver's data. Lines are broken at 64 characters long. 280 | // 281 | // returns an autoreleased NSString being the base 64 representation of the 282 | // receiver. 283 | // 284 | - (NSString *)base64EncodedString 285 | { 286 | size_t outputLength; 287 | char *outputBuffer = 288 | NewBase64Encode([self bytes], [self length], true, &outputLength); 289 | 290 | NSString *result = 291 | [[[NSString alloc] 292 | initWithBytes:outputBuffer 293 | length:outputLength 294 | encoding:NSASCIIStringEncoding] 295 | autorelease]; 296 | free(outputBuffer); 297 | return result; 298 | } 299 | 300 | @end 301 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/NSData+Base64.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Base64.m 3 | // base64 4 | // 5 | // Created by Matt Gallagher on 2009/06/03. 6 | // Copyright 2009 Matt Gallagher. All rights reserved. 7 | // 8 | // Permission is given to use this source code file, free of charge, in any 9 | // project, commercial or otherwise, entirely at your risk, with the condition 10 | // that any redistribution (in part or whole) of source code must retain 11 | // this copyright and permission notice. Attribution in compiled projects is 12 | // appreciated but not required. 13 | // 14 | 15 | #import "NSData+Base64.h" 16 | 17 | // 18 | // Mapping from 6 bit pattern to ASCII character. 19 | // 20 | static unsigned char base64EncodeLookup[65] = 21 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 22 | 23 | // 24 | // Definition for "masked-out" areas of the base64DecodeLookup mapping 25 | // 26 | #define xx 65 27 | 28 | // 29 | // Mapping from ASCII character to 6 bit pattern. 30 | // 31 | static unsigned char base64DecodeLookup[256] = 32 | { 33 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 34 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 35 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 62, xx, xx, xx, 63, 36 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, xx, xx, xx, xx, xx, xx, 37 | xx, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 38 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, xx, xx, xx, xx, xx, 39 | xx, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 40 | 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, xx, xx, xx, xx, xx, 41 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 42 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 43 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 44 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 45 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 46 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 47 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 48 | xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 49 | }; 50 | 51 | // 52 | // Fundamental sizes of the binary and base64 encode/decode units in bytes 53 | // 54 | #define BINARY_UNIT_SIZE 3 55 | #define BASE64_UNIT_SIZE 4 56 | 57 | // 58 | // NewBase64Decode 59 | // 60 | // Decodes the base64 ASCII string in the inputBuffer to a newly malloced 61 | // output buffer. 62 | // 63 | // inputBuffer - the source ASCII string for the decode 64 | // length - the length of the string or -1 (to specify strlen should be used) 65 | // outputLength - if not-NULL, on output will contain the decoded length 66 | // 67 | // returns the decoded buffer. Must be free'd by caller. Length is given by 68 | // outputLength. 69 | // 70 | void *NewBase64Decode( 71 | const char *inputBuffer, 72 | NSUInteger length, 73 | size_t *outputLength) 74 | { 75 | 76 | size_t outputBufferSize = (length / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE; 77 | unsigned char *outputBuffer = (unsigned char *)malloc(outputBufferSize); 78 | 79 | size_t i = 0; 80 | size_t j = 0; 81 | while (i < length) 82 | { 83 | // 84 | // Accumulate 4 valid characters (ignore everything else) 85 | // 86 | unsigned char accumulated[BASE64_UNIT_SIZE]; 87 | 88 | accumulated[0] = 0; 89 | accumulated[1] = 0; 90 | accumulated[2] = 0; 91 | accumulated[3] = 0; 92 | 93 | size_t accumulateIndex = 0; 94 | while (i < length) 95 | { 96 | unsigned char decode = base64DecodeLookup[inputBuffer[i++]]; 97 | if (decode != xx) 98 | { 99 | accumulated[accumulateIndex] = decode; 100 | accumulateIndex++; 101 | 102 | if (accumulateIndex == BASE64_UNIT_SIZE) 103 | { 104 | break; 105 | } 106 | } 107 | } 108 | 109 | // 110 | // Store the 6 bits from each of the 4 characters as 3 bytes 111 | // 112 | outputBuffer[j] = (accumulated[0] << 2) | (accumulated[1] >> 4); 113 | outputBuffer[j + 1] = (accumulated[1] << 4) | (accumulated[2] >> 2); 114 | outputBuffer[j + 2] = (accumulated[2] << 6) | accumulated[3]; 115 | j += accumulateIndex - 1; 116 | } 117 | 118 | if (outputLength) 119 | { 120 | *outputLength = j; 121 | } 122 | return outputBuffer; 123 | } 124 | 125 | // 126 | // NewBase64Decode 127 | // 128 | // Encodes the arbitrary data in the inputBuffer as base64 into a newly malloced 129 | // output buffer. 130 | // 131 | // inputBuffer - the source data for the encode 132 | // length - the length of the input in bytes 133 | // separateLines - if zero, no CR/LF characters will be added. Otherwise 134 | // a CR/LF pair will be added every 64 encoded chars. 135 | // outputLength - if not-NULL, on output will contain the encoded length 136 | // (not including terminating 0 char) 137 | // 138 | // returns the encoded buffer. Must be free'd by caller. Length is given by 139 | // outputLength. 140 | // 141 | char *NewBase64Encode( 142 | const void *buffer, 143 | size_t length, 144 | bool separateLines, 145 | size_t *outputLength) 146 | { 147 | const unsigned char *inputBuffer = (const unsigned char *)buffer; 148 | 149 | #define MAX_NUM_PADDING_CHARS 2 150 | #define OUTPUT_LINE_LENGTH 64 151 | #define INPUT_LINE_LENGTH ((OUTPUT_LINE_LENGTH / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE) 152 | #define CR_LF_SIZE 2 153 | 154 | // 155 | // Byte accurate calculation of final buffer size 156 | // 157 | size_t outputBufferSize = 158 | ((length / BINARY_UNIT_SIZE) 159 | + ((length % BINARY_UNIT_SIZE) ? 1 : 0)) 160 | * BASE64_UNIT_SIZE; 161 | if (separateLines) 162 | { 163 | outputBufferSize += 164 | (outputBufferSize / OUTPUT_LINE_LENGTH) * CR_LF_SIZE; 165 | } 166 | 167 | // 168 | // Include space for a terminating zero 169 | // 170 | outputBufferSize += 1; 171 | 172 | // 173 | // Allocate the output buffer 174 | // 175 | char *outputBuffer = (char *)malloc(outputBufferSize); 176 | if (!outputBuffer) 177 | { 178 | return NULL; 179 | } 180 | 181 | size_t i = 0; 182 | size_t j = 0; 183 | const size_t lineLength = separateLines ? INPUT_LINE_LENGTH : length; 184 | size_t lineEnd = lineLength; 185 | 186 | while (true) 187 | { 188 | if (lineEnd > length) 189 | { 190 | lineEnd = length; 191 | } 192 | 193 | for (; i + BINARY_UNIT_SIZE - 1 < lineEnd; i += BINARY_UNIT_SIZE) 194 | { 195 | // 196 | // Inner loop: turn 48 bytes into 64 base64 characters 197 | // 198 | outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; 199 | outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4) 200 | | ((inputBuffer[i + 1] & 0xF0) >> 4)]; 201 | outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i + 1] & 0x0F) << 2) 202 | | ((inputBuffer[i + 2] & 0xC0) >> 6)]; 203 | outputBuffer[j++] = base64EncodeLookup[inputBuffer[i + 2] & 0x3F]; 204 | } 205 | 206 | if (lineEnd == length) 207 | { 208 | break; 209 | } 210 | 211 | // 212 | // Add the newline 213 | // 214 | outputBuffer[j++] = '\r'; 215 | outputBuffer[j++] = '\n'; 216 | lineEnd += lineLength; 217 | } 218 | 219 | if (i + 1 < length) 220 | { 221 | // 222 | // Handle the single '=' case 223 | // 224 | outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; 225 | outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4) 226 | | ((inputBuffer[i + 1] & 0xF0) >> 4)]; 227 | outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i + 1] & 0x0F) << 2]; 228 | outputBuffer[j++] = '='; 229 | } 230 | else if (i < length) 231 | { 232 | // 233 | // Handle the double '=' case 234 | // 235 | outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; 236 | outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0x03) << 4]; 237 | outputBuffer[j++] = '='; 238 | outputBuffer[j++] = '='; 239 | } 240 | outputBuffer[j] = 0; 241 | 242 | // 243 | // Set the output length and return the buffer 244 | // 245 | if (outputLength) 246 | { 247 | *outputLength = j; 248 | } 249 | return outputBuffer; 250 | } 251 | 252 | @implementation NSData (Base64) 253 | 254 | // 255 | // dataFromBase64String: 256 | // 257 | // Creates an NSData object containing the base64 decoded representation of 258 | // the base64 string 'aString' 259 | // 260 | // Parameters: 261 | // aString - the base64 string to decode 262 | // 263 | // returns the autoreleased NSData representation of the base64 string 264 | // 265 | + (NSData *)dataFromBase64String:(NSString *)aString 266 | { 267 | NSData *data = [aString dataUsingEncoding:NSASCIIStringEncoding]; 268 | size_t outputLength; 269 | void *outputBuffer = NewBase64Decode([data bytes], [data length], &outputLength); 270 | NSData *result = [NSData dataWithBytes:outputBuffer length:outputLength]; 271 | free(outputBuffer); 272 | return result; 273 | } 274 | 275 | // 276 | // base64EncodedString 277 | // 278 | // Creates an NSString object that contains the base 64 encoding of the 279 | // receiver's data. Lines are broken at 64 characters long. 280 | // 281 | // returns an autoreleased NSString being the base 64 representation of the 282 | // receiver. 283 | // 284 | - (NSString *)base64EncodedString 285 | { 286 | size_t outputLength; 287 | char *outputBuffer = 288 | NewBase64Encode([self bytes], [self length], true, &outputLength); 289 | 290 | NSString *result = 291 | [[[NSString alloc] 292 | initWithBytes:outputBuffer 293 | length:outputLength 294 | encoding:NSASCIIStringEncoding] 295 | autorelease]; 296 | free(outputBuffer); 297 | return result; 298 | } 299 | 300 | @end 301 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi/CGI.m: -------------------------------------------------------------------------------- 1 | // Created by Cory Kilger on 5/26/11. 2 | // 3 | // Copyright (c) 2011 Cory Kilger 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "CGI.H" 24 | 25 | static CGI * defaultCGI = nil; 26 | 27 | 28 | @interface CGI () 29 | 30 | @property (nonatomic, retain) NSMutableDictionary * header; 31 | @property (nonatomic, assign) BOOL printedHeader; 32 | 33 | - (id) initPrivately; // We don't override init, which can be called externally 34 | 35 | @end 36 | 37 | 38 | @implementation CGI 39 | 40 | @synthesize header, printedHeader; 41 | 42 | + (CGI *) defaultCGI { 43 | static dispatch_once_t onceToken; 44 | dispatch_once(&onceToken, ^{ 45 | defaultCGI = [[super allocWithZone:nil] initPrivately]; 46 | }); 47 | return defaultCGI; 48 | } 49 | 50 | - (id)initPrivately { 51 | if (!(self = [super init])) 52 | return nil; 53 | self.header = [NSMutableDictionary dictionary]; 54 | return self; 55 | } 56 | 57 | #pragma mark - Singleton 58 | 59 | // Methods that assist this class in acting as a singleton 60 | + (id)allocWithZone:(NSZone*)zone { return defaultCGI; } 61 | - (id)copyWithZone:(NSZone *)zone { return self; } 62 | - (id)retain { return self; } 63 | - (NSUInteger)retainCount { return UINT_MAX; } 64 | - (void)release {} 65 | - (id)autorelease { return self; } 66 | 67 | #pragma mark - Properties 68 | 69 | - (NSString *) httpHost { 70 | static NSString * httpHost = nil; 71 | static dispatch_once_t onceToken; 72 | dispatch_once(&onceToken, ^{ 73 | httpHost = [[NSString alloc] initWithCString:getenv("HTTP_HOST") encoding:NSUTF8StringEncoding]; 74 | }); 75 | return httpHost; 76 | } 77 | 78 | - (NSString *) httpUserAgent { 79 | static NSString * httpUserAgent = nil; 80 | static dispatch_once_t onceToken; 81 | dispatch_once(&onceToken, ^{ 82 | httpUserAgent = [[NSString alloc] initWithCString:getenv("HTTP_USER_AGENT") encoding:NSUTF8StringEncoding]; 83 | }); 84 | return httpUserAgent; 85 | } 86 | 87 | - (NSString *) httpAccept { 88 | static NSString * httpAccept = nil; 89 | static dispatch_once_t onceToken; 90 | dispatch_once(&onceToken, ^{ 91 | httpAccept = [[NSString alloc] initWithCString:getenv("HTTP_ACCEPT") encoding:NSUTF8StringEncoding]; 92 | }); 93 | return httpAccept; 94 | } 95 | 96 | - (NSString *) httpAcceptLanguage { 97 | static NSString * httpAcceptLanguage = nil; 98 | static dispatch_once_t onceToken; 99 | dispatch_once(&onceToken, ^{ 100 | httpAcceptLanguage = [[NSString alloc] initWithCString:getenv("HTTP_ACCEPT_LANGUAGE") encoding:NSUTF8StringEncoding]; 101 | }); 102 | return httpAcceptLanguage; 103 | } 104 | 105 | - (NSString *) contentType { 106 | static NSString * contentType = nil; 107 | static dispatch_once_t onceToken; 108 | dispatch_once(&onceToken, ^{ 109 | contentType = [[NSString alloc] initWithCString:getenv("CONTENT_TYPE") encoding:NSUTF8StringEncoding]; 110 | }); 111 | return contentType; 112 | } 113 | 114 | - (NSString *) httpCookie { 115 | static NSString * httpCookie = nil; 116 | static dispatch_once_t onceToken; 117 | dispatch_once(&onceToken, ^{ 118 | httpCookie = [[NSString alloc] initWithCString:getenv("HTTP_COOKIE") encoding:NSUTF8StringEncoding]; 119 | }); 120 | return httpCookie; 121 | } 122 | 123 | - (NSString *) httpAcceptEncoding { 124 | static NSString * httpAcceptEncoding = nil; 125 | static dispatch_once_t onceToken; 126 | dispatch_once(&onceToken, ^{ 127 | httpAcceptEncoding = [[NSString alloc] initWithCString:getenv("HTTP_ACCEPT_ENCODING") encoding:NSUTF8StringEncoding]; 128 | }); 129 | return httpAcceptEncoding; 130 | } 131 | 132 | - (NSNumber *) contentLength { 133 | static NSNumber * contentLength = nil; 134 | static dispatch_once_t onceToken; 135 | dispatch_once(&onceToken, ^{ 136 | NSString * string = [[NSString alloc] initWithCString:getenv("CONTENT_LENGTH") encoding:NSUTF8StringEncoding]; 137 | contentLength = (string) ? [[NSNumber alloc] initWithInteger:[string integerValue]] : nil; 138 | [string release]; 139 | }); 140 | return contentLength; 141 | } 142 | 143 | - (NSString *) httpConnection { 144 | static NSString * httpConnection = nil; 145 | static dispatch_once_t onceToken; 146 | dispatch_once(&onceToken, ^{ 147 | httpConnection = [[NSString alloc] initWithCString:getenv("HTTP_CONNECTION") encoding:NSUTF8StringEncoding]; 148 | }); 149 | return httpConnection; 150 | } 151 | 152 | - (NSString *) path { 153 | static NSString * path = nil; 154 | static dispatch_once_t onceToken; 155 | dispatch_once(&onceToken, ^{ 156 | path = [[NSString alloc] initWithCString:getenv("PATH") encoding:NSUTF8StringEncoding]; 157 | }); 158 | return path; 159 | } 160 | 161 | - (NSString *) serverSignature { 162 | static NSString * serverSignature = nil; 163 | static dispatch_once_t onceToken; 164 | dispatch_once(&onceToken, ^{ 165 | serverSignature = [[NSString alloc] initWithCString:getenv("SERVER_SIGNATURE") encoding:NSUTF8StringEncoding]; 166 | }); 167 | return serverSignature; 168 | } 169 | 170 | - (NSString *) serverSoftware { 171 | static NSString * serverSoftware = nil; 172 | static dispatch_once_t onceToken; 173 | dispatch_once(&onceToken, ^{ 174 | serverSoftware = [[NSString alloc] initWithCString:getenv("SERVER_SOFTWARE") encoding:NSUTF8StringEncoding]; 175 | }); 176 | return serverSoftware; 177 | } 178 | 179 | - (NSString *) serverName { 180 | static NSString * serverName = nil; 181 | static dispatch_once_t onceToken; 182 | dispatch_once(&onceToken, ^{ 183 | serverName = [[NSString alloc] initWithCString:getenv("SERVER_NAME") encoding:NSUTF8StringEncoding]; 184 | }); 185 | return serverName; 186 | } 187 | 188 | - (NSString *) serverAddr { 189 | static NSString * serverAddr = nil; 190 | static dispatch_once_t onceToken; 191 | dispatch_once(&onceToken, ^{ 192 | serverAddr = [[NSString alloc] initWithCString:getenv("SERVER_ADDR") encoding:NSUTF8StringEncoding]; 193 | }); 194 | return serverAddr; 195 | } 196 | 197 | - (NSNumber *) serverPort { 198 | static NSNumber * serverPort = nil; 199 | static dispatch_once_t onceToken; 200 | dispatch_once(&onceToken, ^{ 201 | NSString * string = [[NSString alloc] initWithCString:getenv("SERVER_PORT") encoding:NSUTF8StringEncoding]; 202 | serverPort = (string) ? [[NSNumber alloc] initWithInteger:[string integerValue]] : nil; 203 | [string release]; 204 | }); 205 | return serverPort; 206 | } 207 | 208 | - (NSString *) remoteAddr { 209 | static NSString * remoteAddr = nil; 210 | static dispatch_once_t onceToken; 211 | dispatch_once(&onceToken, ^{ 212 | remoteAddr = [[NSString alloc] initWithCString:getenv("REMOTE_ADDR") encoding:NSUTF8StringEncoding]; 213 | }); 214 | return remoteAddr; 215 | } 216 | 217 | - (NSString *) documentRoot { 218 | static NSString * documentRoot = nil; 219 | static dispatch_once_t onceToken; 220 | dispatch_once(&onceToken, ^{ 221 | documentRoot = [[NSString alloc] initWithCString:getenv("DOCUMENT_ROOT") encoding:NSUTF8StringEncoding]; 222 | }); 223 | return documentRoot; 224 | } 225 | 226 | - (NSString *) serverAdmin { 227 | static NSString * serverAdmin = nil; 228 | static dispatch_once_t onceToken; 229 | dispatch_once(&onceToken, ^{ 230 | serverAdmin = [[NSString alloc] initWithCString:getenv("SERVER_ADMIN") encoding:NSUTF8StringEncoding]; 231 | }); 232 | return serverAdmin; 233 | } 234 | 235 | - (NSString *) scriptFilename { 236 | static NSString * scriptFilename = nil; 237 | static dispatch_once_t onceToken; 238 | dispatch_once(&onceToken, ^{ 239 | scriptFilename = [[NSString alloc] initWithCString:getenv("SCRIPT_FILENAME") encoding:NSUTF8StringEncoding]; 240 | }); 241 | return scriptFilename; 242 | } 243 | 244 | - (NSNumber *) remotePort { 245 | static NSNumber * remotePort = nil; 246 | static dispatch_once_t onceToken; 247 | dispatch_once(&onceToken, ^{ 248 | NSString * string = [[NSString alloc] initWithCString:getenv("REMOTE_PORT") encoding:NSUTF8StringEncoding]; 249 | remotePort = (string) ? [[NSNumber alloc] initWithInteger:[string integerValue]] : nil; 250 | [string release]; 251 | }); 252 | return remotePort; 253 | } 254 | 255 | - (NSString *) gatewayInterface { 256 | static NSString * gatewayInterface = nil; 257 | static dispatch_once_t onceToken; 258 | dispatch_once(&onceToken, ^{ 259 | gatewayInterface = [[NSString alloc] initWithCString:getenv("GATEWAY_INTERFACE") encoding:NSUTF8StringEncoding]; 260 | }); 261 | return gatewayInterface; 262 | } 263 | 264 | - (NSString *) serverProtocol { 265 | static NSString * serverProtocol = nil; 266 | static dispatch_once_t onceToken; 267 | dispatch_once(&onceToken, ^{ 268 | serverProtocol = [[NSString alloc] initWithCString:getenv("SERVER_PROTOCOL") encoding:NSUTF8StringEncoding]; 269 | }); 270 | return serverProtocol; 271 | } 272 | 273 | - (NSString *) requestMethod { 274 | static NSString * requestMethod = nil; 275 | static dispatch_once_t onceToken; 276 | dispatch_once(&onceToken, ^{ 277 | requestMethod = [[NSString alloc] initWithCString:getenv("REQUEST_METHOD") encoding:NSUTF8StringEncoding]; 278 | }); 279 | return requestMethod; 280 | } 281 | 282 | - (NSString *) queryString { 283 | static NSString * queryString = nil; 284 | static dispatch_once_t onceToken; 285 | dispatch_once(&onceToken, ^{ 286 | queryString = [[NSString alloc] initWithCString:getenv("QUERY_STRING") encoding:NSUTF8StringEncoding]; 287 | }); 288 | return queryString; 289 | } 290 | 291 | - (NSString *) requestUri { 292 | static NSString * requestUri = nil; 293 | static dispatch_once_t onceToken; 294 | dispatch_once(&onceToken, ^{ 295 | requestUri = [[NSString alloc] initWithCString:getenv("REQUEST_URI") encoding:NSUTF8StringEncoding]; 296 | }); 297 | return requestUri; 298 | } 299 | 300 | - (NSString *) scriptName { 301 | static NSString * scriptName = nil; 302 | static dispatch_once_t onceToken; 303 | dispatch_once(&onceToken, ^{ 304 | scriptName = [[NSString alloc] initWithCString:getenv("SCRIPT_NAME") encoding:NSUTF8StringEncoding]; 305 | }); 306 | return scriptName; 307 | } 308 | 309 | #pragma mark - Header & Content 310 | 311 | - (NSData *) content { 312 | static NSData * content = nil; 313 | static dispatch_once_t onceToken; 314 | dispatch_once(&onceToken, ^{ 315 | NSFileHandle * input = [NSFileHandle fileHandleWithStandardInput]; 316 | content = [[input readDataToEndOfFile] retain]; 317 | }); 318 | return content; 319 | } 320 | 321 | - (NSDictionary *)allHeaderFields { 322 | return [NSDictionary dictionaryWithDictionary:self.header]; 323 | } 324 | 325 | - (void) setValue:(NSString *)value forHeaderField:(NSString *)field { 326 | NSAssert(printedHeader == NO, @"Cannot change the header after printing"); 327 | [header setValue:value forKey:field]; 328 | } 329 | 330 | - (void) print:(NSString *)format, ... { 331 | static dispatch_once_t onceToken; 332 | dispatch_once(&onceToken, ^{ 333 | [header enumerateKeysAndObjectsWithOptions:0 usingBlock:^(id key, id obj, BOOL *stop) { 334 | const char * field = [[key description] cStringUsingEncoding:NSUTF8StringEncoding]; 335 | const char * value = [[obj description] cStringUsingEncoding:NSUTF8StringEncoding]; 336 | printf("%s: %s\n", field, value); 337 | }]; 338 | printf("\n"); 339 | }); 340 | 341 | va_list arguments; 342 | va_start(arguments, format); 343 | NSString * string = [[NSString alloc] initWithFormat:format arguments:arguments]; 344 | va_end(arguments); 345 | printf("%s", [string cStringUsingEncoding:NSUTF8StringEncoding]); 346 | [string release]; 347 | } 348 | 349 | @end 350 | -------------------------------------------------------------------------------- /graphviz-cgi/graphviz-cgi.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9A9B809F13D2E4DD00A0EB37 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A9B809E13D2E4DD00A0EB37 /* Foundation.framework */; }; 11 | 9A9B80A213D2E4DD00A0EB37 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A9B80A113D2E4DD00A0EB37 /* main.m */; }; 12 | 9A9B80B113D2E4E900A0EB37 /* CGI.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A9B80AC13D2E4E900A0EB37 /* CGI.m */; }; 13 | 9A9B80B213D2E4E900A0EB37 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A9B80AE13D2E4E900A0EB37 /* NSData+Base64.m */; }; 14 | 9A9B80B313D2E4E900A0EB37 /* NSData+Gzip.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A9B80B013D2E4E900A0EB37 /* NSData+Gzip.m */; }; 15 | 9A9B80BC13D2E68A00A0EB37 /* GVGraph.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A9B80BB13D2E68A00A0EB37 /* GVGraph.m */; }; 16 | 9A9B80C513D2E7DD00A0EB37 /* GVGraphArguments.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A9B80C213D2E7DC00A0EB37 /* GVGraphArguments.m */; }; 17 | 9A9B80C613D2E7DD00A0EB37 /* GVGraphDefaultAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A9B80C413D2E7DC00A0EB37 /* GVGraphDefaultAttributes.m */; }; 18 | 9A9B80C813D2E80300A0EB37 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A9B80C713D2E80300A0EB37 /* libz.dylib */; }; 19 | 9A9B80CA13D2E86900A0EB37 /* libgraph.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A9B80C913D2E86900A0EB37 /* libgraph.dylib */; }; 20 | 9A9B80CC13D2E88300A0EB37 /* libgvc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A9B80CB13D2E88300A0EB37 /* libgvc.dylib */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXCopyFilesBuildPhase section */ 24 | 9A9B809813D2E4DD00A0EB37 /* CopyFiles */ = { 25 | isa = PBXCopyFilesBuildPhase; 26 | buildActionMask = 2147483647; 27 | dstPath = /usr/share/man/man1/; 28 | dstSubfolderSpec = 0; 29 | files = ( 30 | ); 31 | runOnlyForDeploymentPostprocessing = 1; 32 | }; 33 | /* End PBXCopyFilesBuildPhase section */ 34 | 35 | /* Begin PBXFileReference section */ 36 | 9A9B809A13D2E4DD00A0EB37 /* graphviz-cgi */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "graphviz-cgi"; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | 9A9B809E13D2E4DD00A0EB37 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 38 | 9A9B80A113D2E4DD00A0EB37 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 39 | 9A9B80A413D2E4DD00A0EB37 /* graphviz-cgi-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "graphviz-cgi-Prefix.pch"; sourceTree = ""; }; 40 | 9A9B80A513D2E4DD00A0EB37 /* graphviz_cgi.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = graphviz_cgi.1; sourceTree = ""; }; 41 | 9A9B80AB13D2E4E900A0EB37 /* CGI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGI.h; sourceTree = ""; }; 42 | 9A9B80AC13D2E4E900A0EB37 /* CGI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CGI.m; sourceTree = ""; }; 43 | 9A9B80AD13D2E4E900A0EB37 /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Base64.h"; sourceTree = ""; }; 44 | 9A9B80AE13D2E4E900A0EB37 /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Base64.m"; sourceTree = ""; }; 45 | 9A9B80AF13D2E4E900A0EB37 /* NSData+Gzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Gzip.h"; sourceTree = ""; }; 46 | 9A9B80B013D2E4E900A0EB37 /* NSData+Gzip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Gzip.m"; sourceTree = ""; }; 47 | 9A9B80BA13D2E68A00A0EB37 /* GVGraph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GVGraph.h; sourceTree = ""; }; 48 | 9A9B80BB13D2E68A00A0EB37 /* GVGraph.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GVGraph.m; sourceTree = ""; }; 49 | 9A9B80C113D2E7DC00A0EB37 /* GVGraphArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GVGraphArguments.h; sourceTree = ""; }; 50 | 9A9B80C213D2E7DC00A0EB37 /* GVGraphArguments.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GVGraphArguments.m; sourceTree = ""; }; 51 | 9A9B80C313D2E7DC00A0EB37 /* GVGraphDefaultAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GVGraphDefaultAttributes.h; sourceTree = ""; }; 52 | 9A9B80C413D2E7DC00A0EB37 /* GVGraphDefaultAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GVGraphDefaultAttributes.m; sourceTree = ""; }; 53 | 9A9B80C713D2E80300A0EB37 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 54 | 9A9B80C913D2E86900A0EB37 /* libgraph.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgraph.dylib; path = /usr/local/lib/libgraph.dylib; sourceTree = ""; }; 55 | 9A9B80CB13D2E88300A0EB37 /* libgvc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgvc.dylib; path = /usr/local/lib/libgvc.dylib; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | 9A9B809713D2E4DD00A0EB37 /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | 9A9B80C813D2E80300A0EB37 /* libz.dylib in Frameworks */, 64 | 9A9B80CA13D2E86900A0EB37 /* libgraph.dylib in Frameworks */, 65 | 9A9B80CC13D2E88300A0EB37 /* libgvc.dylib in Frameworks */, 66 | 9A9B809F13D2E4DD00A0EB37 /* Foundation.framework in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | /* End PBXFrameworksBuildPhase section */ 71 | 72 | /* Begin PBXGroup section */ 73 | 9A9B808F13D2E4DD00A0EB37 = { 74 | isa = PBXGroup; 75 | children = ( 76 | 9A9B80A013D2E4DD00A0EB37 /* graphviz-cgi */, 77 | 9A9B809D13D2E4DD00A0EB37 /* Frameworks */, 78 | 9A9B809B13D2E4DD00A0EB37 /* Products */, 79 | ); 80 | sourceTree = ""; 81 | }; 82 | 9A9B809B13D2E4DD00A0EB37 /* Products */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 9A9B809A13D2E4DD00A0EB37 /* graphviz-cgi */, 86 | ); 87 | name = Products; 88 | sourceTree = ""; 89 | }; 90 | 9A9B809D13D2E4DD00A0EB37 /* Frameworks */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 9A9B80C713D2E80300A0EB37 /* libz.dylib */, 94 | 9A9B80CB13D2E88300A0EB37 /* libgvc.dylib */, 95 | 9A9B80C913D2E86900A0EB37 /* libgraph.dylib */, 96 | 9A9B809E13D2E4DD00A0EB37 /* Foundation.framework */, 97 | ); 98 | name = Frameworks; 99 | sourceTree = ""; 100 | }; 101 | 9A9B80A013D2E4DD00A0EB37 /* graphviz-cgi */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 9A9B80A113D2E4DD00A0EB37 /* main.m */, 105 | 9A9B80AB13D2E4E900A0EB37 /* CGI.h */, 106 | 9A9B80AC13D2E4E900A0EB37 /* CGI.m */, 107 | 9A9B80AD13D2E4E900A0EB37 /* NSData+Base64.h */, 108 | 9A9B80AE13D2E4E900A0EB37 /* NSData+Base64.m */, 109 | 9A9B80AF13D2E4E900A0EB37 /* NSData+Gzip.h */, 110 | 9A9B80B013D2E4E900A0EB37 /* NSData+Gzip.m */, 111 | 9A9B80BA13D2E68A00A0EB37 /* GVGraph.h */, 112 | 9A9B80BB13D2E68A00A0EB37 /* GVGraph.m */, 113 | 9A9B80C113D2E7DC00A0EB37 /* GVGraphArguments.h */, 114 | 9A9B80C213D2E7DC00A0EB37 /* GVGraphArguments.m */, 115 | 9A9B80C313D2E7DC00A0EB37 /* GVGraphDefaultAttributes.h */, 116 | 9A9B80C413D2E7DC00A0EB37 /* GVGraphDefaultAttributes.m */, 117 | 9A9B80A513D2E4DD00A0EB37 /* graphviz_cgi.1 */, 118 | 9A9B80A313D2E4DD00A0EB37 /* Supporting Files */, 119 | ); 120 | path = "graphviz-cgi"; 121 | sourceTree = ""; 122 | }; 123 | 9A9B80A313D2E4DD00A0EB37 /* Supporting Files */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 9A9B80A413D2E4DD00A0EB37 /* graphviz-cgi-Prefix.pch */, 127 | ); 128 | name = "Supporting Files"; 129 | sourceTree = ""; 130 | }; 131 | /* End PBXGroup section */ 132 | 133 | /* Begin PBXNativeTarget section */ 134 | 9A9B809913D2E4DD00A0EB37 /* graphviz-cgi */ = { 135 | isa = PBXNativeTarget; 136 | buildConfigurationList = 9A9B80A813D2E4DD00A0EB37 /* Build configuration list for PBXNativeTarget "graphviz-cgi" */; 137 | buildPhases = ( 138 | 9A9B809613D2E4DD00A0EB37 /* Sources */, 139 | 9A9B809713D2E4DD00A0EB37 /* Frameworks */, 140 | 9A9B809813D2E4DD00A0EB37 /* CopyFiles */, 141 | ); 142 | buildRules = ( 143 | ); 144 | dependencies = ( 145 | ); 146 | name = "graphviz-cgi"; 147 | productName = "graphviz-cgi"; 148 | productReference = 9A9B809A13D2E4DD00A0EB37 /* graphviz-cgi */; 149 | productType = "com.apple.product-type.tool"; 150 | }; 151 | /* End PBXNativeTarget section */ 152 | 153 | /* Begin PBXProject section */ 154 | 9A9B809113D2E4DD00A0EB37 /* Project object */ = { 155 | isa = PBXProject; 156 | attributes = { 157 | ORGANIZATIONNAME = "Cory Kilger"; 158 | }; 159 | buildConfigurationList = 9A9B809413D2E4DD00A0EB37 /* Build configuration list for PBXProject "graphviz-cgi" */; 160 | compatibilityVersion = "Xcode 3.2"; 161 | developmentRegion = English; 162 | hasScannedForEncodings = 0; 163 | knownRegions = ( 164 | en, 165 | ); 166 | mainGroup = 9A9B808F13D2E4DD00A0EB37; 167 | productRefGroup = 9A9B809B13D2E4DD00A0EB37 /* Products */; 168 | projectDirPath = ""; 169 | projectRoot = ""; 170 | targets = ( 171 | 9A9B809913D2E4DD00A0EB37 /* graphviz-cgi */, 172 | ); 173 | }; 174 | /* End PBXProject section */ 175 | 176 | /* Begin PBXSourcesBuildPhase section */ 177 | 9A9B809613D2E4DD00A0EB37 /* Sources */ = { 178 | isa = PBXSourcesBuildPhase; 179 | buildActionMask = 2147483647; 180 | files = ( 181 | 9A9B80A213D2E4DD00A0EB37 /* main.m in Sources */, 182 | 9A9B80B113D2E4E900A0EB37 /* CGI.m in Sources */, 183 | 9A9B80B213D2E4E900A0EB37 /* NSData+Base64.m in Sources */, 184 | 9A9B80B313D2E4E900A0EB37 /* NSData+Gzip.m in Sources */, 185 | 9A9B80BC13D2E68A00A0EB37 /* GVGraph.m in Sources */, 186 | 9A9B80C513D2E7DD00A0EB37 /* GVGraphArguments.m in Sources */, 187 | 9A9B80C613D2E7DD00A0EB37 /* GVGraphDefaultAttributes.m in Sources */, 188 | ); 189 | runOnlyForDeploymentPostprocessing = 0; 190 | }; 191 | /* End PBXSourcesBuildPhase section */ 192 | 193 | /* Begin XCBuildConfiguration section */ 194 | 9A9B80A613D2E4DD00A0EB37 /* Debug */ = { 195 | isa = XCBuildConfiguration; 196 | buildSettings = { 197 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 198 | GCC_C_LANGUAGE_STANDARD = gnu99; 199 | GCC_OPTIMIZATION_LEVEL = 0; 200 | GCC_PREPROCESSOR_DEFINITIONS = DEBUG; 201 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 202 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 203 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 204 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 205 | GCC_WARN_UNUSED_VARIABLE = YES; 206 | MACOSX_DEPLOYMENT_TARGET = 10.6; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = macosx; 209 | }; 210 | name = Debug; 211 | }; 212 | 9A9B80A713D2E4DD00A0EB37 /* Release */ = { 213 | isa = XCBuildConfiguration; 214 | buildSettings = { 215 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 216 | GCC_C_LANGUAGE_STANDARD = gnu99; 217 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 218 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 219 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 220 | GCC_WARN_UNUSED_VARIABLE = YES; 221 | MACOSX_DEPLOYMENT_TARGET = 10.6; 222 | SDKROOT = macosx; 223 | }; 224 | name = Release; 225 | }; 226 | 9A9B80A913D2E4DD00A0EB37 /* Debug */ = { 227 | isa = XCBuildConfiguration; 228 | buildSettings = { 229 | ALWAYS_SEARCH_USER_PATHS = NO; 230 | COPY_PHASE_STRIP = NO; 231 | FRAMEWORK_SEARCH_PATHS = ( 232 | "$(inherited)", 233 | "\"$(SRCROOT)\"", 234 | ); 235 | GCC_DYNAMIC_NO_PIC = NO; 236 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 237 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 238 | GCC_PREFIX_HEADER = "graphviz-cgi/graphviz-cgi-Prefix.pch"; 239 | LIBRARY_SEARCH_PATHS = /usr/local/lib/; 240 | PRODUCT_NAME = "$(TARGET_NAME)"; 241 | USER_HEADER_SEARCH_PATHS = "/Users/cmkilger/Downloads/graphviz-2.28.0/lib/common /Users/cmkilger/Downloads/graphviz-2.28.0/lib/cdt /Users/cmkilger/Downloads/graphviz-2.28.0/lib/pathplan /Users/cmkilger/Downloads/graphviz-2.28.0/lib/graph /Users/cmkilger/Downloads/graphviz-2.28.0/lib/gvc"; 242 | }; 243 | name = Debug; 244 | }; 245 | 9A9B80AA13D2E4DD00A0EB37 /* Release */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | ALWAYS_SEARCH_USER_PATHS = NO; 249 | COPY_PHASE_STRIP = YES; 250 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 251 | FRAMEWORK_SEARCH_PATHS = ( 252 | "$(inherited)", 253 | "\"$(SRCROOT)\"", 254 | ); 255 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 256 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 257 | GCC_PREFIX_HEADER = "graphviz-cgi/graphviz-cgi-Prefix.pch"; 258 | LIBRARY_SEARCH_PATHS = /usr/local/lib/; 259 | PRODUCT_NAME = "$(TARGET_NAME)"; 260 | USER_HEADER_SEARCH_PATHS = "/Users/cmkilger/Downloads/graphviz-2.28.0/lib/common /Users/cmkilger/Downloads/graphviz-2.28.0/lib/cdt /Users/cmkilger/Downloads/graphviz-2.28.0/lib/pathplan /Users/cmkilger/Downloads/graphviz-2.28.0/lib/graph /Users/cmkilger/Downloads/graphviz-2.28.0/lib/gvc"; 261 | }; 262 | name = Release; 263 | }; 264 | /* End XCBuildConfiguration section */ 265 | 266 | /* Begin XCConfigurationList section */ 267 | 9A9B809413D2E4DD00A0EB37 /* Build configuration list for PBXProject "graphviz-cgi" */ = { 268 | isa = XCConfigurationList; 269 | buildConfigurations = ( 270 | 9A9B80A613D2E4DD00A0EB37 /* Debug */, 271 | 9A9B80A713D2E4DD00A0EB37 /* Release */, 272 | ); 273 | defaultConfigurationIsVisible = 0; 274 | defaultConfigurationName = Release; 275 | }; 276 | 9A9B80A813D2E4DD00A0EB37 /* Build configuration list for PBXNativeTarget "graphviz-cgi" */ = { 277 | isa = XCConfigurationList; 278 | buildConfigurations = ( 279 | 9A9B80A913D2E4DD00A0EB37 /* Debug */, 280 | 9A9B80AA13D2E4DD00A0EB37 /* Release */, 281 | ); 282 | defaultConfigurationIsVisible = 0; 283 | defaultConfigurationName = Release; 284 | }; 285 | /* End XCConfigurationList section */ 286 | }; 287 | rootObject = 9A9B809113D2E4DD00A0EB37 /* Project object */; 288 | } 289 | -------------------------------------------------------------------------------- /CodeFlow/en.lproj/FLFlowchartViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 800 5 | 10K540 6 | 844 7 | 1038.36 8 | 461.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 141 12 | 13 | 14 | YES 15 | 16 | 17 | YES 18 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 19 | 20 | 21 | YES 22 | 23 | YES 24 | 25 | 26 | YES 27 | 28 | 29 | 30 | YES 31 | 32 | IBFilesOwner 33 | IBIPadFramework 34 | 35 | 36 | IBFirstResponder 37 | IBIPadFramework 38 | 39 | 40 | 41 | 274 42 | 43 | YES 44 | 45 | 46 | 298 47 | {{20, 475}, {728, 21}} 48 | 49 | 50 | 51 | 3 52 | MQA 53 | 54 | YES 55 | NO 56 | IBIPadFramework 57 | Choose a file to generate a graph 58 | 59 | Helvetica 60 | 17 61 | 16 62 | 63 | 64 | 3 65 | MC41AA 66 | 67 | 2 68 | 69 | 70 | 71 | 1 72 | 10 73 | 1 74 | 75 | 76 | 77 | 290 78 | {768, 44} 79 | 80 | 81 | NO 82 | NO 83 | IBIPadFramework 84 | 85 | YES 86 | 87 | 88 | 89 | 90 | 274 91 | {{0, 44}, {768, 960}} 92 | 93 | 94 | 95 | 1 96 | MSAxIDEAA 97 | 98 | 0.0 99 | IBIPadFramework 100 | YES 101 | 1 102 | YES 103 | 104 | 105 | 106 | -2147483347 107 | {{374, 492}, {20, 20}} 108 | 109 | NO 110 | IBIPadFramework 111 | 2 112 | 113 | 114 | {{0, 20}, {768, 1004}} 115 | 116 | 117 | NO 118 | 119 | 2 120 | 121 | IBIPadFramework 122 | 123 | 124 | 125 | 126 | YES 127 | 128 | 129 | view 130 | 131 | 132 | 133 | 12 134 | 135 | 136 | 137 | toolbar 138 | 139 | 140 | 141 | 65 142 | 143 | 144 | 145 | detailDescriptionLabel 146 | 147 | 148 | 149 | 66 150 | 151 | 152 | 153 | webView 154 | 155 | 156 | 157 | 68 158 | 159 | 160 | 161 | activityIndicator 162 | 163 | 164 | 165 | 71 166 | 167 | 168 | 169 | delegate 170 | 171 | 172 | 173 | 72 174 | 175 | 176 | 177 | 178 | YES 179 | 180 | 0 181 | 182 | 183 | 184 | 185 | 186 | -1 187 | 188 | 189 | File's Owner 190 | 191 | 192 | -2 193 | 194 | 195 | 196 | 197 | 8 198 | 199 | 200 | YES 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 45 210 | 211 | 212 | 213 | 214 | 63 215 | 216 | 217 | YES 218 | 219 | 220 | 221 | 222 | 67 223 | 224 | 225 | 226 | 227 | 69 228 | 229 | 230 | 231 | 232 | 233 | 234 | YES 235 | 236 | YES 237 | -1.CustomClassName 238 | -2.CustomClassName 239 | 45.IBPluginDependency 240 | 63.IBPluginDependency 241 | 67.IBPluginDependency 242 | 69.IBPluginDependency 243 | 8.IBEditorWindowLastContentRect 244 | 8.IBPluginDependency 245 | 246 | 247 | YES 248 | FLFlowchartViewController 249 | UIResponder 250 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 251 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 252 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 253 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 254 | {{194, 0}, {783, 856}} 255 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 256 | 257 | 258 | 259 | YES 260 | 261 | 262 | YES 263 | 264 | 265 | 266 | 267 | YES 268 | 269 | 270 | YES 271 | 272 | 273 | 274 | 72 275 | 276 | 277 | 278 | YES 279 | 280 | FLFlowchartViewController 281 | UIViewController 282 | 283 | YES 284 | 285 | YES 286 | activityIndicator 287 | detailDescriptionLabel 288 | toolbar 289 | webView 290 | 291 | 292 | YES 293 | UIActivityIndicatorView 294 | UILabel 295 | UIToolbar 296 | UIWebView 297 | 298 | 299 | 300 | YES 301 | 302 | YES 303 | activityIndicator 304 | detailDescriptionLabel 305 | toolbar 306 | webView 307 | 308 | 309 | YES 310 | 311 | activityIndicator 312 | UIActivityIndicatorView 313 | 314 | 315 | detailDescriptionLabel 316 | UILabel 317 | 318 | 319 | toolbar 320 | UIToolbar 321 | 322 | 323 | webView 324 | UIWebView 325 | 326 | 327 | 328 | 329 | IBUserSource 330 | 331 | 332 | 333 | 334 | 335 | 0 336 | IBIPadFramework 337 | 338 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 339 | 340 | 341 | 342 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 343 | 344 | 345 | YES 346 | 347 | 3 348 | 141 349 | 350 | 351 | -------------------------------------------------------------------------------- /CodeFlow/RegexKitLite.h: -------------------------------------------------------------------------------- 1 | // 2 | // RegexKitLite.h 3 | // http://regexkit.sourceforge.net/ 4 | // Licensed under the terms of the BSD License, as specified below. 5 | // 6 | 7 | /* 8 | Copyright (c) 2008-2010, John Engelhart 9 | 10 | All rights reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without 13 | modification, are permitted provided that the following conditions are met: 14 | 15 | * Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above copyright 19 | notice, this list of conditions and the following disclaimer in the 20 | documentation and/or other materials provided with the distribution. 21 | 22 | * Neither the name of the Zang Industries nor the names of its 23 | contributors may be used to endorse or promote products derived from 24 | this software without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 32 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 33 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 34 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 36 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | #ifdef __OBJC__ 40 | #import 41 | #import 42 | #import 43 | #import 44 | #import 45 | #endif // __OBJC__ 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | #ifndef REGEXKITLITE_VERSION_DEFINED 58 | #define REGEXKITLITE_VERSION_DEFINED 59 | 60 | #define _RKL__STRINGIFY(b) #b 61 | #define _RKL_STRINGIFY(a) _RKL__STRINGIFY(a) 62 | #define _RKL_JOIN_VERSION(a,b) _RKL_STRINGIFY(a##.##b) 63 | #define _RKL_VERSION_STRING(a,b) _RKL_JOIN_VERSION(a,b) 64 | 65 | #define REGEXKITLITE_VERSION_MAJOR 4 66 | #define REGEXKITLITE_VERSION_MINOR 0 67 | 68 | #define REGEXKITLITE_VERSION_CSTRING _RKL_VERSION_STRING(REGEXKITLITE_VERSION_MAJOR, REGEXKITLITE_VERSION_MINOR) 69 | #define REGEXKITLITE_VERSION_NSSTRING @REGEXKITLITE_VERSION_CSTRING 70 | 71 | #endif // REGEXKITLITE_VERSION_DEFINED 72 | 73 | #if !defined(RKL_BLOCKS) && defined(NS_BLOCKS_AVAILABLE) && (NS_BLOCKS_AVAILABLE == 1) 74 | #define RKL_BLOCKS 1 75 | #endif 76 | 77 | #if defined(RKL_BLOCKS) && (RKL_BLOCKS == 1) 78 | #define _RKL_BLOCKS_ENABLED 1 79 | #endif // defined(RKL_BLOCKS) && (RKL_BLOCKS == 1) 80 | 81 | #if defined(_RKL_BLOCKS_ENABLED) && !defined(__BLOCKS__) 82 | #warning RegexKitLite support for Blocks is enabled, but __BLOCKS__ is not defined. This compiler may not support Blocks, in which case the behavior is undefined. This will probably cause numerous compiler errors. 83 | #endif // defined(_RKL_BLOCKS_ENABLED) && !defined(__BLOCKS__) 84 | 85 | // For Mac OS X < 10.5. 86 | #ifndef NSINTEGER_DEFINED 87 | #define NSINTEGER_DEFINED 88 | #if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 89 | typedef long NSInteger; 90 | typedef unsigned long NSUInteger; 91 | #define NSIntegerMin LONG_MIN 92 | #define NSIntegerMax LONG_MAX 93 | #define NSUIntegerMax ULONG_MAX 94 | #else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 95 | typedef int NSInteger; 96 | typedef unsigned int NSUInteger; 97 | #define NSIntegerMin INT_MIN 98 | #define NSIntegerMax INT_MAX 99 | #define NSUIntegerMax UINT_MAX 100 | #endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 101 | #endif // NSINTEGER_DEFINED 102 | 103 | #ifndef RKLREGEXOPTIONS_DEFINED 104 | #define RKLREGEXOPTIONS_DEFINED 105 | 106 | // These must be identical to their ICU regex counterparts. See http://www.icu-project.org/userguide/regexp.html 107 | enum { 108 | RKLNoOptions = 0, 109 | RKLCaseless = 2, 110 | RKLComments = 4, 111 | RKLDotAll = 32, 112 | RKLMultiline = 8, 113 | RKLUnicodeWordBoundaries = 256 114 | }; 115 | typedef uint32_t RKLRegexOptions; // This must be identical to the ICU 'flags' argument type. 116 | 117 | #endif // RKLREGEXOPTIONS_DEFINED 118 | 119 | #ifndef RKLREGEXENUMERATIONOPTIONS_DEFINED 120 | #define RKLREGEXENUMERATIONOPTIONS_DEFINED 121 | 122 | enum { 123 | RKLRegexEnumerationNoOptions = 0UL, 124 | RKLRegexEnumerationCapturedStringsNotRequired = 1UL << 9, 125 | RKLRegexEnumerationReleaseStringReturnedByReplacementBlock = 1UL << 10, 126 | RKLRegexEnumerationFastCapturedStringsXXX = 1UL << 11, 127 | }; 128 | typedef NSUInteger RKLRegexEnumerationOptions; 129 | 130 | #endif // RKLREGEXENUMERATIONOPTIONS_DEFINED 131 | 132 | #ifndef _REGEXKITLITE_H_ 133 | #define _REGEXKITLITE_H_ 134 | 135 | #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465) 136 | #define RKL_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) 137 | #else 138 | #define RKL_DEPRECATED_ATTRIBUTE 139 | #endif 140 | 141 | #if defined(NS_REQUIRES_NIL_TERMINATION) 142 | #define RKL_REQUIRES_NIL_TERMINATION NS_REQUIRES_NIL_TERMINATION 143 | #else // defined(NS_REQUIRES_NIL_TERMINATION) 144 | #define RKL_REQUIRES_NIL_TERMINATION 145 | #endif // defined(NS_REQUIRES_NIL_TERMINATION) 146 | 147 | // This requires a few levels of rewriting to get the desired results. 148 | #define _RKL_CONCAT_2(c,d) c ## d 149 | #define _RKL_CONCAT(a,b) _RKL_CONCAT_2(a,b) 150 | 151 | #ifdef RKL_PREPEND_TO_METHODS 152 | #define RKL_METHOD_PREPEND(x) _RKL_CONCAT(RKL_PREPEND_TO_METHODS, x) 153 | #else // RKL_PREPEND_TO_METHODS 154 | #define RKL_METHOD_PREPEND(x) x 155 | #endif // RKL_PREPEND_TO_METHODS 156 | 157 | // If it looks like low memory notifications might be available, add code to register and respond to them. 158 | // This is (should be) harmless if it turns out that this isn't the case, since the notification that we register for, 159 | // UIApplicationDidReceiveMemoryWarningNotification, is dynamically looked up via dlsym(). 160 | #if ((defined(TARGET_OS_EMBEDDED) && (TARGET_OS_EMBEDDED != 0)) || (defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE != 0))) && (!defined(RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS) || (RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS != 0)) 161 | #define RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS 1 162 | #endif 163 | 164 | #ifdef __OBJC__ 165 | 166 | // NSException exception name. 167 | extern NSString * const RKLICURegexException; 168 | 169 | // NSError error domains and user info keys. 170 | extern NSString * const RKLICURegexErrorDomain; 171 | 172 | extern NSString * const RKLICURegexEnumerationOptionsErrorKey; 173 | extern NSString * const RKLICURegexErrorCodeErrorKey; 174 | extern NSString * const RKLICURegexErrorNameErrorKey; 175 | extern NSString * const RKLICURegexLineErrorKey; 176 | extern NSString * const RKLICURegexOffsetErrorKey; 177 | extern NSString * const RKLICURegexPreContextErrorKey; 178 | extern NSString * const RKLICURegexPostContextErrorKey; 179 | extern NSString * const RKLICURegexRegexErrorKey; 180 | extern NSString * const RKLICURegexRegexOptionsErrorKey; 181 | extern NSString * const RKLICURegexReplacedCountErrorKey; 182 | extern NSString * const RKLICURegexReplacedStringErrorKey; 183 | extern NSString * const RKLICURegexReplacementStringErrorKey; 184 | extern NSString * const RKLICURegexSubjectRangeErrorKey; 185 | extern NSString * const RKLICURegexSubjectStringErrorKey; 186 | 187 | @interface NSString (RegexKitLiteAdditions) 188 | 189 | + (void)RKL_METHOD_PREPEND(clearStringCache); 190 | 191 | // Although these are marked as deprecated, a bug in GCC prevents a warning from being issues for + class methods. Filed bug with Apple, #6736857. 192 | + (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex RKL_DEPRECATED_ATTRIBUTE; 193 | + (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex options:(RKLRegexOptions)options error:(NSError **)error RKL_DEPRECATED_ATTRIBUTE; 194 | 195 | - (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex; 196 | - (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex range:(NSRange)range; 197 | - (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error; 198 | 199 | - (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex; 200 | - (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex inRange:(NSRange)range; 201 | - (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error; 202 | 203 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex; 204 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex capture:(NSInteger)capture; 205 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex inRange:(NSRange)range; 206 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error; 207 | 208 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex; 209 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex capture:(NSInteger)capture; 210 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex inRange:(NSRange)range; 211 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error; 212 | 213 | - (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement; 214 | - (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange; 215 | - (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error; 216 | 217 | //// >= 3.0 218 | 219 | - (NSInteger)RKL_METHOD_PREPEND(captureCount); 220 | - (NSInteger)RKL_METHOD_PREPEND(captureCountWithOptions):(RKLRegexOptions)options error:(NSError **)error; 221 | 222 | - (BOOL)RKL_METHOD_PREPEND(isRegexValid); 223 | - (BOOL)RKL_METHOD_PREPEND(isRegexValidWithOptions):(RKLRegexOptions)options error:(NSError **)error; 224 | 225 | - (void)RKL_METHOD_PREPEND(flushCachedRegexData); 226 | 227 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex; 228 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex capture:(NSInteger)capture; 229 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex range:(NSRange)range; 230 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range capture:(NSInteger)capture error:(NSError **)error; 231 | 232 | 233 | - (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex; 234 | - (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range; 235 | - (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error; 236 | 237 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex; 238 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range; 239 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error; 240 | 241 | //// >= 4.0 242 | 243 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION; 244 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex range:(NSRange)range withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION; 245 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION; 246 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withFirstKey:(id)firstKey arguments:(va_list)varArgsList; 247 | 248 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeys:(id *)keys forCaptures:(int *)captures count:(NSUInteger)count; 249 | 250 | - (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION; 251 | - (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex range:(NSRange)range withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION; 252 | - (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION; 253 | - (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withFirstKey:(id)firstKey arguments:(va_list)varArgsList; 254 | 255 | - (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeys:(id *)keys forCaptures:(int *)captures count:(NSUInteger)count; 256 | 257 | #ifdef _RKL_BLOCKS_ENABLED 258 | 259 | - (BOOL)RKL_METHOD_PREPEND(enumerateStringsMatchedByRegex):(NSString *)regex usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block; 260 | - (BOOL)RKL_METHOD_PREPEND(enumerateStringsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block; 261 | 262 | - (BOOL)RKL_METHOD_PREPEND(enumerateStringsSeparatedByRegex):(NSString *)regex usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block; 263 | - (BOOL)RKL_METHOD_PREPEND(enumerateStringsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block; 264 | 265 | - (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block; 266 | - (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block; 267 | 268 | #endif // _RKL_BLOCKS_ENABLED 269 | 270 | @end 271 | 272 | @interface NSMutableString (RegexKitLiteAdditions) 273 | 274 | - (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement; 275 | - (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange; 276 | - (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error; 277 | 278 | //// >= 4.0 279 | 280 | #ifdef _RKL_BLOCKS_ENABLED 281 | 282 | - (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block; 283 | - (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block; 284 | 285 | #endif // _RKL_BLOCKS_ENABLED 286 | 287 | @end 288 | 289 | #endif // __OBJC__ 290 | 291 | #endif // _REGEXKITLITE_H_ 292 | 293 | #ifdef __cplusplus 294 | } // extern "C" 295 | #endif 296 | -------------------------------------------------------------------------------- /CodeFlow/en.lproj/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 800 5 | 10K540 6 | 1306 7 | 1038.36 8 | 461.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 301 12 | 13 | 14 | IBProxyObject 15 | IBUINavigationController 16 | IBUIViewController 17 | IBUICustomObject 18 | IBUISplitViewController 19 | IBUIWindow 20 | IBUITableViewController 21 | IBUINavigationBar 22 | IBUINavigationItem 23 | 24 | 25 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 26 | 27 | 28 | 29 | 30 | IBFilesOwner 31 | IBIPadFramework 32 | 33 | 34 | IBFirstResponder 35 | IBIPadFramework 36 | 37 | 38 | 39 | 292 40 | {768, 1024} 41 | 42 | 43 | 44 | 45 | 1 46 | MSAxIDEAA 47 | 48 | NO 49 | NO 50 | 51 | 2 52 | 53 | IBIPadFramework 54 | YES 55 | 56 | 57 | IBIPadFramework 58 | 59 | 60 | 61 | 62 | 2 63 | 64 | 65 | 3 66 | 3 67 | 68 | IBIPadFramework 69 | YES 70 | 71 | 72 | 73 | 2 74 | 75 | 76 | 1 77 | 1 78 | 79 | IBIPadFramework 80 | NO 81 | 82 | 83 | 256 84 | {0, 0} 85 | YES 86 | YES 87 | IBIPadFramework 88 | 89 | 90 | 91 | 92 | 93 | Files 94 | IBIPadFramework 95 | 96 | 97 | 98 | 2 99 | 100 | 101 | 1 102 | 1 103 | 104 | IBIPadFramework 105 | NO 106 | 107 | 108 | 109 | 110 | 111 | 112 | FLFlowchartViewController 113 | 114 | 1 115 | 1 116 | 117 | IBIPadFramework 118 | NO 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | window 127 | 128 | 129 | 130 | 4 131 | 132 | 133 | 134 | delegate 135 | 136 | 137 | 138 | 17 139 | 140 | 141 | 142 | splitViewController 143 | 144 | 145 | 146 | 43 147 | 148 | 149 | 150 | rootViewController 151 | 152 | 153 | 154 | 44 155 | 156 | 157 | 158 | detailViewController 159 | 160 | 161 | 162 | 45 163 | 164 | 165 | 166 | delegate 167 | 168 | 169 | 170 | 49 171 | 172 | 173 | 174 | flowchartViewController 175 | 176 | 177 | 178 | 50 179 | 180 | 181 | 182 | 183 | 184 | 0 185 | 186 | 187 | 188 | 189 | 190 | -1 191 | 192 | 193 | File's Owner 194 | 195 | 196 | -2 197 | 198 | 199 | 200 | 201 | 2 202 | 203 | 204 | 205 | 206 | 3 207 | 208 | 209 | 210 | 211 | 37 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 38 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 39 230 | 231 | 232 | 233 | 234 | 40 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 41 243 | 244 | 245 | 246 | 247 | 42 248 | 249 | 250 | 251 | 252 | 253 | 254 | UIApplication 255 | UIResponder 256 | {{190, 57}, {783, 799}} 257 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 258 | FLAppDelegate 259 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 260 | {{794, 594}, {1024, 768}} 261 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 262 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 263 | FLFlowchartViewController 264 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 265 | FLFileBrowserViewController 266 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 267 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 268 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 269 | 270 | 271 | 272 | 273 | 274 | 50 275 | 276 | 277 | 278 | 279 | FLAppDelegate 280 | NSObject 281 | 282 | FLFlowchartViewController 283 | FLFileBrowserViewController 284 | UISplitViewController 285 | UIWindow 286 | 287 | 288 | 289 | detailViewController 290 | FLFlowchartViewController 291 | 292 | 293 | rootViewController 294 | FLFileBrowserViewController 295 | 296 | 297 | splitViewController 298 | UISplitViewController 299 | 300 | 301 | window 302 | UIWindow 303 | 304 | 305 | 306 | IBProjectSource 307 | ./Classes/FLAppDelegate.h 308 | 309 | 310 | 311 | FLFileBrowserViewController 312 | UITableViewController 313 | 314 | flowchartViewController 315 | FLFlowchartViewController 316 | 317 | 318 | flowchartViewController 319 | 320 | flowchartViewController 321 | FLFlowchartViewController 322 | 323 | 324 | 325 | IBProjectSource 326 | ./Classes/FLFileBrowserViewController.h 327 | 328 | 329 | 330 | FLFlowchartViewController 331 | UIViewController 332 | 333 | UIActivityIndicatorView 334 | UILabel 335 | UIToolbar 336 | UIWebView 337 | 338 | 339 | 340 | activityIndicator 341 | UIActivityIndicatorView 342 | 343 | 344 | detailDescriptionLabel 345 | UILabel 346 | 347 | 348 | toolbar 349 | UIToolbar 350 | 351 | 352 | webView 353 | UIWebView 354 | 355 | 356 | 357 | IBProjectSource 358 | ./Classes/FLFlowchartViewController.h 359 | 360 | 361 | 362 | 363 | 0 364 | IBIPadFramework 365 | 366 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 367 | 368 | 369 | 370 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 371 | 372 | 373 | YES 374 | 3 375 | 301 376 | 377 | 378 | --------------------------------------------------------------------------------