Completed SCAN. Fixed problems with EXTERNAL.
authorSebastian Hammer <quinn@indexdata.com>
Tue, 20 Feb 1996 12:51:41 +0000 (12:51 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Tue, 20 Feb 1996 12:51:41 +0000 (12:51 +0000)
asn/proto.c
asn/prt-ext.c

index f2b4118..0390e50 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: proto.c,v $
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: proto.c,v $
- * Revision 1.43  1996-02-10 12:22:49  quinn
+ * Revision 1.44  1996-02-20 12:51:41  quinn
+ * Completed SCAN. Fixed problems with EXTERNAL.
+ *
+ * Revision 1.43  1996/02/10  12:22:49  quinn
  * Work on SCAN
  *
  * Revision 1.42  1996/01/22  09:46:31  quinn
  * Work on SCAN
  *
  * Revision 1.42  1996/01/22  09:46:31  quinn
@@ -1038,6 +1041,65 @@ int z_AlternativeTerm(ODR o, Z_AlternativeTerm **p, int opt)
     return opt && !o->error;
 }
 
     return opt && !o->error;
 }
 
+#if 1
+
+int z_ByDatabase(ODR o, Z_ByDatabase **p, int opt)
+{
+    if (!odr_sequence_begin(o, p, sizeof(**p)))
+       return opt && odr_ok(o);
+    return
+        z_DatabaseName(o, &(*p)->db, 1) &&
+       odr_implicit(o, odr_integer, &(*p)->num, ODR_CONTEXT, 1, 1) &&
+       z_OtherInformation(o, &(*p)->otherDbInfo, 1) &&
+       odr_sequence_end(o);
+}
+
+int z_ByDatabaseList(ODR o, Z_ByDatabaseList **p, int opt)
+{
+    if (!odr_initmember(o, p, sizeof(**p)))
+       return opt && odr_ok(o);
+    if (odr_sequence_of(o, z_ByDatabase, &(*p)->elements, &(*p)->num_elements))
+       return 1;
+    *p = 0;
+    return opt && odr_ok(o);
+}
+
+int z_ScanOccurrences(ODR o, Z_ScanOccurrences **p, int opt)
+{
+    Odr_arm arm[] =
+    {
+       {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_ScanOccurrences_global, odr_integer},
+       {ODR_EXPLICIT, ODR_CONTEXT, 3, Z_ScanOccurrences_byDatabase,
+           z_ByDatabaseList},
+       {-1, -1, -1, -1, 0}
+    };
+
+    if (!odr_initmember(o, p, sizeof(**p)))
+       return opt && odr_ok(o);
+    if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
+       return 1;
+    *p = 0;
+    return opt && odr_ok(o);
+}
+
+int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
+{
+    if (!odr_sequence_begin(o, p, sizeof(**p)))
+       return opt && odr_ok(o);
+    return
+        odr_explicit(o, z_AttributeList, &(*p)->attributes, ODR_CONTEXT,
+           1, 1) &&
+       z_ScanOccurrences(o, &(*p)->occurrences, 1) &&
+       z_OtherInformation(o, &(*p)->otherOccurInfo, 1) &&
+       odr_sequence_end(o);
+}
+
+#else
+
+/*
+ * Incomplete definition of occurencebyattributes.
+ */
+
 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
 {
     if (!odr_sequence_begin(o, p, sizeof(**p)))
 int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
 {
     if (!odr_sequence_begin(o, p, sizeof(**p)))
@@ -1048,6 +1110,8 @@ int z_OccurrenceByAttributes(ODR o, Z_OccurrenceByAttributes **p, int opt)
        odr_sequence_end(o);
 }
 
        odr_sequence_end(o);
 }
 
+#endif
+
 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
 {
     if (!odr_sequence_begin(o, p, sizeof(**p)))
 int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
 {
     if (!odr_sequence_begin(o, p, sizeof(**p)))
@@ -1056,6 +1120,8 @@ int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
        (willow_scan ? 
            odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
            z_Term(o, &(*p)->term, 0)) &&
        (willow_scan ? 
            odr_implicit(o, z_Term, &(*p)->term, ODR_CONTEXT, 1, 0) :
            z_Term(o, &(*p)->term, 0)) &&
+       odr_implicit(o, z_InternationalString, &(*p)->displayTerm, ODR_CONTEXT,
+           0, 1) &&
        z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
        odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
            ODR_CONTEXT, 4, 1) &&
        z_AttributeList(o, &(*p)->suggestedAttributes, 1) &&
        odr_implicit(o, z_AlternativeTerm, &(*p)->alternativeTerm,
            ODR_CONTEXT, 4, 1) &&
@@ -1063,6 +1129,7 @@ int z_TermInfo(ODR o, Z_TermInfo **p, int opt)
            2, 1) &&
        odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
            ODR_CONTEXT, 3, 1) &&
            2, 1) &&
        odr_implicit(o, z_OccurrenceByAttributes, &(*p)->byAttributes,
            ODR_CONTEXT, 3, 1) &&
+       z_OtherInformation(o, &(*p)->otherTermInfo, 1) &&
        odr_sequence_end(o);
 }
 
        odr_sequence_end(o);
 }
 
index f9feee8..27d8db9 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: prt-ext.c,v $
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: prt-ext.c,v $
- * Revision 1.7  1995-10-12 10:34:38  quinn
+ * Revision 1.8  1996-02-20 12:51:44  quinn
+ * Completed SCAN. Fixed problems with EXTERNAL.
+ *
+ * Revision 1.7  1995/10/12  10:34:38  quinn
  * Added Espec-1.
  *
  * Revision 1.6  1995/09/29  17:11:55  quinn
  * Added Espec-1.
  *
  * Revision 1.6  1995/09/29  17:11:55  quinn
 
 #include <proto.h>
 
 
 #include <proto.h>
 
+/*
+ * The table below should be moved to the ODR structure itself and
+ * be an image of the association context: To help
+ * map indirect references when they show up. 
+ */
+static Z_ext_typeent type_table[] =
+{
+    {VAL_SUTRS, Z_External_sutrs, z_SUTRS},
+    {VAL_EXPLAIN, Z_External_explainRecord, z_ExplainRecord},
+    {VAL_RESOURCE1, Z_External_resourceReport1, z_ResourceReport1},
+    {VAL_RESOURCE2, Z_External_resourceReport2, z_ResourceReport2},
+    {VAL_PROMPT1, Z_External_promptObject1, z_PromptObject1 },
+    {VAL_GRS1, Z_External_grs1, z_GenericRecord},
+    {VAL_EXTENDED, Z_External_extendedService, z_TaskPackage},
+    {VAL_ITEMORDER, Z_External_itemOrder, z_ItemOrder},
+    {VAL_DIAG1, Z_External_diag1, z_DiagnosticFormat},
+    {VAL_ESPEC1, Z_External_espec1, z_Espec1},
+    {VAL_NONE, 0, 0}
+};
+
+Z_ext_typeent *z_ext_getentbyref(oid_value val)
+{
+    Z_ext_typeent *i;
+
+    for (i = type_table; i->dref != VAL_NONE; i++)
+       if (i->dref == val)
+           return i;
+    return 0;
+}
+
 int z_External(ODR o, Z_External **p, int opt)
 {
 int z_External(ODR o, Z_External **p, int opt)
 {
-   oident *oid;
+    oident *oid;
+    Z_ext_typeent *type;
 
     static Odr_arm arm[] =
     {
 
     static Odr_arm arm[] =
     {
@@ -57,29 +91,6 @@ int z_External(ODR o, Z_External **p, int opt)
        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_espec1, z_Espec1},
        {-1, -1, -1, -1, 0}
     };
        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_espec1, z_Espec1},
        {-1, -1, -1, -1, 0}
     };
-    /*
-     * The table below should be moved to the ODR structure itself and
-     * be an image of the association context: To help
-     * map indirect references when they show up. 
-     */
-    static struct
-    {
-       oid_value dref;
-       int what;          /* discriminator value for the external CHOICE */
-    } tab[] =
-    {
-       {VAL_SUTRS, Z_External_sutrs},
-       {VAL_EXPLAIN, Z_External_explainRecord},
-       {VAL_RESOURCE1, Z_External_resourceReport1},
-       {VAL_RESOURCE2, Z_External_resourceReport2},
-       {VAL_PROMPT1, Z_External_promptObject1},
-       {VAL_GRS1, Z_External_grs1},
-       {VAL_EXTENDED, Z_External_extendedService},
-       {VAL_ITEMORDER, Z_External_itemOrder},
-       {VAL_DIAG1, Z_External_diag1},
-       {VAL_ESPEC1, Z_External_espec1},
-       {VAL_NONE, 0}
-    };
 
     odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
     if (!odr_sequence_begin(o, p, sizeof(**p)))
 
     odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
     if (!odr_sequence_begin(o, p, sizeof(**p)))
@@ -92,16 +103,18 @@ int z_External(ODR o, Z_External **p, int opt)
      * Do we know this beast?
      */
     if (o->direction == ODR_DECODE && (*p)->direct_reference &&
      * Do we know this beast?
      */
     if (o->direction == ODR_DECODE && (*p)->direct_reference &&
-       (oid = oid_getentbyoid((*p)->direct_reference)))
+       (oid = oid_getentbyoid((*p)->direct_reference)) &&
+       (type = z_ext_getentbyref(oid->value)))
     {
     {
-       int i;
+       int class, tag, cons;
 
 
-       for (i = 0; tab[i].dref != VAL_NONE; i++)
-           if (oid->value == tab[i].dref)
-           {
-               odr_choice_bias(o, tab[i].what);
-               break;
-           }
+       /*
+        * We know it. If it's represented as an ASN.1 type, bias the CHOICE.
+        */
+       if (!odr_peektag(o, &class, &tag, &cons))
+           return opt && odr_ok(o);
+       if (class == ODR_CONTEXT && tag == 0 && cons == 1)
+           odr_choice_bias(o, type->what);
     }
     return
        odr_choice(o, arm, &(*p)->u, &(*p)->which) &&
     }
     return
        odr_choice(o, arm, &(*p)->u, &(*p)->which) &&