Update from stable branch.
authorDr. Stephen Henson <steve@openssl.org>
Fri, 22 Feb 2002 14:07:35 +0000 (14:07 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 22 Feb 2002 14:07:35 +0000 (14:07 +0000)
crypto/asn1/asn_moid.c

index b0337879887c34f6985e5220f0a8e4f75cc01c4a..be20db4bad7fed9f2208c4cae20388d91621499d 100644 (file)
 
 /* Simple ASN1 OID module: add all objects in a given section */
 
-/* NOTE: doesn't do anything other than print debug messages yet... */
 static int oid_module_init(CONF_IMODULE *md, const CONF *cnf)
        {
-       fprintf(stderr, "Called oid_module_init: name %s, value %s\n",
-                       CONF_imodule_get_name(md), CONF_imodule_get_value(md));
+       int i;
+       const char *oid_section;
+       STACK_OF(CONF_VALUE) *sktmp;
+       CONF_VALUE *oval;
+       oid_section = CONF_imodule_get_value(md);
+       if(!(sktmp = NCONF_get_section(cnf, oid_section)))
+               {
+               ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION);
+               return 0;
+               }
+       for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++)
+               {
+               oval = sk_CONF_VALUE_value(sktmp, i);
+               if(OBJ_create(oval->value, oval->name, oval->name) == NID_undef)
+                       {
+                       ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ADDING_OBJECT);
+                       return 0;
+                       }
+               }
        return 1;
-       }
-
-static void oid_module_finish(CONF_IMODULE *md)
-       {
-       fprintf(stderr, "Called oid_module_finish: name %s, value %s\n",
-                       CONF_imodule_get_name(md), CONF_imodule_get_value(md));
-       }
+}
 
 void ASN1_add_oid_module(void)
        {
-       CONF_module_add("oid_section", oid_module_init, oid_module_finish);
+       CONF_module_add("oid_section", oid_module_init, 0);
        }