]> git.cworth.org Git - apitrace/blobdiff - tracedump.cpp
Advertise GREMEDY extensions through glStringi too.
[apitrace] / tracedump.cpp
index 22f62e3692c5ce45857b86df235615dd99db9f49..c210a0c9dd097119076f38642398c2673087283b 100644 (file)
  */
 
 
+#include <string.h>
+
 #include "trace_parser.hpp"
 
 
+static bool color = true;
+
+
+static void usage(void) {
+    std::cout <<
+        "Usage: tracedump [OPTION] [TRACE...]\n"
+        "Dump TRACE to standard output.\n"
+        "\n"
+        "  --no-color   no colored syntax highlightint\n"
+        "  --no-colour  alias for --no-color\n"
+    ;
+}
+
+
 int main(int argc, char **argv)
 {
-    for (int i = 1; i < argc; ++i) {
+    int i;
+
+    for (i = 1; i < argc; ++i) {
+        const char *arg = argv[i];
+
+        if (arg[0] != '-') {
+            break;
+        }
+
+        if (!strcmp(arg, "--")) {
+            break;
+        } else if (!strcmp(arg, "--no-color") ||
+                   !strcmp(arg, "--no-colour")) {
+            color = false;
+        } else {
+            std::cerr << "error: unknown option " << arg << "\n";
+            usage();
+            return 1;
+        }
+    }
+
+    for (; i < argc; ++i) {
         Trace::Parser p;
-        if (p.open(argv[i])) {
-            Trace::Call *call;
-            call = p.parse_call();
-            while (call) {
-                std::cout << *call;
-                delete call;
-                call = p.parse_call();
-            }
+
+        if (!p.open(argv[i])) {
+            std::cerr << "error: failed to open " << argv[i] << "\n";
+            return 1;
+        }
+
+        Trace::Call *call;
+        while ((call = p.parse_call())) {
+            call->dump(std::cout, color);
+            delete call;
         }
     }
+
     return 0;
 }