SRW, CQL, 2003
[yaz-moved-to-github.git] / cql / cqlstdio.c
diff --git a/cql/cqlstdio.c b/cql/cqlstdio.c
new file mode 100644 (file)
index 0000000..7846f0d
--- /dev/null
@@ -0,0 +1,36 @@
+/* $Id: cqlstdio.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+   Copyright (C) 2002-2003
+   Index Data Aps
+
+This file is part of the YAZ toolkit.
+
+See the file LICENSE.
+*/
+
+#include <yaz/cql.h>
+
+int getbyte_stream(void *client_data)
+{
+    FILE *f = (FILE*) client_data;
+
+    int c = fgetc(f);
+    if (c == EOF)
+        return 0;
+    return c;
+}
+
+void ungetbyte_stream (int c, void *client_data)
+{
+    FILE *f = (FILE*) client_data;
+
+    if (c == 0)
+        c = EOF;
+    ungetc(c, f);
+}
+
+int cql_parser_stdio(CQL_parser cp, FILE *f)
+{
+    return cql_parser_stream(cp, getbyte_stream, ungetbyte_stream, f);
+}
+
+