* Sebastian Hammer, Adam Dickmeiss
*
* $Log: proto.c,v $
- * Revision 1.1 1995-02-06 16:44:47 quinn
+ * Revision 1.2 1995-02-06 21:26:07 quinn
+ * Repaired this evening's damages..
+ *
+ * Revision 1.1 1995/02/06 16:44:47 quinn
* First hack at Z/SR protocol
*
*/
#include <proto.h>
+/* ---------------------- INITIALIZE SERVICE ------------------- */
+
int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
{
return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
opt);
}
+/* ---------------------- INITIALIZE SERVICE ------------------- */
+
int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
{
Z_InitRequest *pp;
odr_sequence_end(o);
}
+/* ------------------------ SEARCH SERVICE ----------------------- */
+
+int z_ElementSetName(ODR o, Z_ElementSetName **p, int opt)
+{
+ return odr_implicit(o, odr_visiblestring, (char**) p, ODR_CONTEXT, 103,
+ opt);
+}
+
+int z_PreferredRecordSyntax(ODR o, Z_PreferredRecordSyntax **p, int opt)
+{
+ return odr_implicit(o, odr_oid, (Odr_oid**) p, ODR_CONTEXT, 104, opt);
+}
+
+int z_DatabaseSpecificUnit(ODR o, Z_DatabaseSpecificUnit **p, int opt)
+{
+ if (!odr_sequence_begin(o, p, sizeof(**p)))
+ return opt;
+ return
+ z_DatabaseName(o, &(*p)->databaseName, 0) &&
+ z_ElementSetName(o, &(*p)->elementSetName, 0) &&
+ odr_sequence_end(o);
+}
+
+int z_DatabaseSpecific(ODR o, Z_DatabaseSpecific **p, int opt)
+{
+ if (o->direction == ODR_DECODE && !*p)
+ *p = nalloc(o, sizeof(**p));
+ else if (!*p)
+ return opt;
+
+ odr_implicit_settag(o, ODR_CONTEXT, 1);
+ if (odr_sequence_of(o, z_DatabaseSpecificUnit, &(*p)->elements,
+ &(*p)->num_elements))
+ return 1;
+ *p = 0;
+ return 0;
+}
+
+int z_ElementSetNames(ODR o, Z_ElementSetNames **p, int opt)
+{
+ static Odr_arm arm[] =
+ {
+ {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_ElementSetNames_generic,
+ z_ElementSetName},
+ {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ElementSetNames_databaseSpecific,
+ z_DatabaseSpecific},
+ {-1, -1, -1, -1, 0}
+ };
+
+ if (!odr_constructed_begin(o, p, ODR_CONTEXT, 19, 0))
+ return opt;
+
+ if (o->direction == ODR_DECODE && !*p)
+ *p = nalloc(o, sizeof(**p));
+
+ if (odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
+ odr_constructed_enmd(o))
+ return 1;
+ *p = 0;
+ return 0;
+}
+
+/* ----------------------- RPN QUERY -----------------------*/
+
+int z_RPNStructure(ODR o, Z_RPNStructure, int opt);
+
+int z_Operand(ODR o, Z_Operand **p, int opt)
+{
+ Odr_arm arm[] =
+ {
+ {-1, -1, -1, Z_Operand_APT, z_AttributesPlusTerm},
+ {-1, -1, -1, Z_Operand_resultSetId, z_ResultSetId},
+ {-1, -1, -1, -1, 0}
+ };
+
+ if (o->direction ==ODR_DECODE && !*p)
+ *p = nalloc(o, sizeof(**p));
+ else if (!*p)
+ return opt;
+ if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
+ return 1;
+ *p = 0;
+ return opt;
+}
+
+int z_Complex(ODR o, Z_Complex **p, int opt)
+{
+ if (!odr_sequence_begin(o, p, sizeof(**p)))
+ return opt;
+ return
+ z_RPNStructure(o, &(*p)->s1, 0) &&
+ z_RPNStructure(o, &(*p)->s2, 0) &&
+ z_Operator(o, &(*p)->operator) &&
+ odr_sequence_end(o);
+}
+
+int z_RPNStructure(ODR o, Z_RPNStructure, int opt)
+{
+ Odr_arm arm[] =
+ {
+ {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_RPNStructure_simple, z_Operand),
+ {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_RPNStructure_complex, z_Complex},
+ {-1 -1, -1, -1, 0}
+ };
+
+ if (o->direction == ODR_DECODE && !*p)
+ *p = nalloc(o, sizeof(**p));
+ else if (!*p)
+ return opt;
+ if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
+ return 1;
+ *p = 0;
+ return opt;
+}
+
+int z_RPNQuery(ODR o, Z_RPNQuery **p, int opt)
+{
+ if (!odr_sequence_begin(o, p, sizeof(**p))
+ return opt;
+ return
+ odr_oid(o, &(*p)->attributeSetId, 0) &&
+ z_RPNStructure(o, &(*p)->RPNStructure, 0) &&
+ odr_sequence_end(o);
+}
+
+/* -----------------------END RPN QUERY ----------------------- */
+
+int z_Query(ODR o, Z_Query **p, int opt)
+{
+ Odr_arm arm[] =
+ {
+ {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Query_type_1, z_RPNQuery},
+ {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Query_type_2, odr_oct},
+ {-1, -1, -1, -1, 0}
+ };
+
+ if (o->direction == ODR_DECODE && !*p)
+ *p = nalloc(o, sizeof(**p);
+ else if (!*p)
+ return opt;
+ if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
+ return 1;
+ *p = 0;
+ return opt;
+}
+
int z_SearchRequest(ODR o, Z_SearchRequest **p, int opt)
{
Z_SearchRequest *pp;
odr_implicit(o, odr_bool, &pp->replaceIndicator, ODR_CONTEXT, 16, 1) &&
odr_implicit(o, odr_visiblestring, &pp->resultSetName, ODR_CONTEXT,
17, 9) &&
-
- /* MORE */
-
+ odr_implicit(o, z_ElementSetNames, &pp->smallSetElementSetNames,
+ ODR_CONTEXT, 100, 1) &&
+ odr_implicit(o, z_ElementSetNames, &pp->mediumSetElementSetNames,
+ ODR_CONTEXT, 101, 1) &&
+ z_PreferredRecordSyntax(o, &pp->preferredRecordSyntax, 1) &&
+ odr_explicit(o, z_query, ODR_CONTEXT, 21, 0) &&
odr_sequence_end(o);
}