Added files.
[yaz-moved-to-github.git] / z39.50 / z-univ.c
diff --git a/z39.50/z-univ.c b/z39.50/z-univ.c
new file mode 100644 (file)
index 0000000..27f010d
--- /dev/null
@@ -0,0 +1,40 @@
+/* YC 0.2 Tue Feb 29 16:45:14 CET 2000 */
+/* Module-C: ResourceReport-Format-Universe-1 */
+
+#include <yaz/z-univ.h>
+
+int z_UniverseReportHits (ODR o, Z_UniverseReportHits **p, int opt, const char *name)
+{
+       if (!odr_sequence_begin (o, p, sizeof(**p), name))
+               return opt && odr_ok (o);
+       return
+               z_StringOrNumeric(o, &(*p)->database, 0, "database") &&
+               z_StringOrNumeric(o, &(*p)->hits, 0, "hits") &&
+               odr_sequence_end (o);
+}
+
+int z_UniverseReportDuplicate (ODR o, Z_UniverseReportDuplicate **p, int opt, const char *name)
+{
+       if (!odr_sequence_begin (o, p, sizeof(**p), name))
+               return opt && odr_ok (o);
+       return
+               z_StringOrNumeric(o, &(*p)->hitno, 0, "hitno") &&
+               odr_sequence_end (o);
+}
+
+int z_UniverseReport (ODR o, Z_UniverseReport **p, int opt, const char *name)
+{
+       static Odr_arm arm[] = {
+               {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_UniverseReport_databaseHits,
+               (Odr_fun) z_UniverseReportHits, "databaseHits"},
+               {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_UniverseReport_duplicate,
+               (Odr_fun) z_UniverseReportDuplicate, "duplicate"},
+               {-1, -1, -1, -1, (Odr_fun) 0, 0}
+       };
+       if (!odr_sequence_begin (o, p, sizeof(**p), name))
+               return opt && odr_ok (o);
+       return
+               odr_integer(o, &(*p)->totalHits, 0, "totalHits") &&
+               odr_choice (o, arm, &(*p)->u, &(*p)->which, 0) &&
+               odr_sequence_end (o);
+}