1 /* 2 * Copyright 2008, Haiku. 3 * Distributed under the terms of the MIT license. 4 * 5 * Authors: 6 * Michael Pfeiffer <laplace@users.sourceforge.net> 7 */ 8 9 #include <stdio.h> 10 #include <stdlib.h> 11 #include <string.h> 12 #include <List.h> 13 14 void TestScanner(); 15 void TestParser(); 16 void TestPPDParser(bool all, bool verbose = true); 17 void TestExtractUI(); 18 19 const char* gPPDFile = "aptollw1.ppd"; 20 21 static BList gArgs; 22 23 bool enabled(const char* name, const char* arg) 24 { 25 gArgs.AddItem((void*)name); 26 if (arg == NULL) return false; 27 if (strcmp(arg, "all") == 0) return true; 28 return strcmp(arg, name) == 0; 29 } 30 31 void printArgs(const char* programName) 32 { 33 fprintf(stderr, "%s: argument\n", programName); 34 fprintf(stderr, "Argument is missing. The available arguments are:\n"); 35 fprintf(stderr, " all\n"); 36 for (int i = 0; i < gArgs.CountItems(); i ++) { 37 fprintf(stderr, " %s\n", (const char*)gArgs.ItemAt(i)); 38 } 39 } 40 41 int main(int argc, char* argv[]) 42 { 43 const char* arg = argc >= 2 ? argv[1] : NULL; 44 45 if (argc >= 3) { 46 gPPDFile = argv[2]; 47 } 48 49 if (enabled("scanner", arg)) { 50 TestScanner(); 51 } 52 if (enabled("parser", arg)) { 53 TestParser(); 54 } 55 if (enabled("ppd", arg)) { 56 TestPPDParser(true); 57 } 58 if (enabled("header", arg)) { 59 TestPPDParser(false); 60 } 61 if (enabled("ui", arg)) { 62 TestExtractUI(); 63 } 64 if (enabled("ppd-timing", arg)) { 65 TestPPDParser(true, false); 66 } 67 if (enabled("header-timing", arg)) { 68 TestPPDParser(false, false); 69 } 70 71 if (arg == NULL) { 72 printArgs(argv[0]); 73 } 74 } 75