Update headers and omit CVS Ids.
[yaz-moved-to-github.git] / util / cql2xcql.c
index e389069..cee2646 100644 (file)
@@ -1,22 +1,43 @@
-/* $Id: cql2xcql.c,v 1.1 2003-10-27 12:21:39 adam Exp $
-   Copyright (C) 2002-2003
-   Index Data Aps
-
-This file is part of the YAZ toolkit.
-
-See the file LICENSE.
-*/
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2008 Index Data
+ * See the file LICENSE for details.
+ */
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <yaz/cql.h>
+#include <yaz/options.h>
 
 int main(int argc, char **argv)
 {
-    int r;
-    CQL_parser cp = cql_parser_create();
-    if (argc == 2)
-        r = cql_parser_string(cp, argv[1]);
+    CQL_parser cp;
+    int r = 0;
+    const char *fname = 0;
+    int iterations = 1;
+    int ret;
+    char *arg;
+
+    while ((ret = options("n:", argv, argc, &arg)) != -2)
+    {
+        switch (ret)
+        {
+        case 0:
+            fname = arg;
+            break;
+        case 'n':
+            iterations = atoi(arg);
+            break;
+        }
+    }
+
+    cp = cql_parser_create();
+    if (fname)
+    {
+        int i;
+        for (i = 0; i<iterations; i++)
+            r = cql_parser_string(cp, fname);
+    }
     else
         r = cql_parser_stdio(cp, stdin);
     if (r)
@@ -26,3 +47,11 @@ int main(int argc, char **argv)
     cql_parser_destroy(cp);
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+