{NULL}
};
-static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf);
+static int do_generate(char *genstr, char *genconf, BUF_MEM *buf);
int asn1parse_main(int argc, char **argv)
{
case OPT_INFORM:
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &informat))
goto opthelp;
- goto end;
+ break;
case OPT_IN:
infile = opt_arg();
break;
argc = opt_num_rest();
argv = opt_rest();
+ if (!app_load_modules(NULL))
+ goto end;
+
if (oidfile != NULL) {
- in = bio_open_default(oidfile, "r");
+ in = bio_open_default(oidfile, "r");
if (in == NULL)
goto end;
OBJ_create_objects(in);
goto end; /* Pre-allocate :-) */
if (genstr || genconf) {
- num = do_generate(bio_err, genstr, genconf, buf);
+ num = do_generate(genstr, genconf, buf);
if (num < 0) {
ERR_print_errors(bio_err);
goto end;
BIO_free(b64);
if (ret != 0)
ERR_print_errors(bio_err);
- if (buf != NULL)
- BUF_MEM_free(buf);
- if (name != NULL)
- OPENSSL_free(name);
- if (header != NULL)
- OPENSSL_free(header);
- if (strictpem && str != NULL)
+ BUF_MEM_free(buf);
+ OPENSSL_free(name);
+ OPENSSL_free(header);
+ if (strictpem)
OPENSSL_free(str);
- if (at != NULL)
- ASN1_TYPE_free(at);
- if (osk != NULL)
- sk_OPENSSL_STRING_free(osk);
+ ASN1_TYPE_free(at);
+ sk_OPENSSL_STRING_free(osk);
OBJ_cleanup();
return (ret);
}
-static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf)
+static int do_generate(char *genstr, char *genconf, BUF_MEM *buf)
{
CONF *cnf = NULL;
int len;
- long errline;
unsigned char *p;
ASN1_TYPE *atyp = NULL;
if (genconf) {
- cnf = NCONF_new(NULL);
- if (!NCONF_load(cnf, genconf, &errline))
- goto conferr;
+ if ((cnf = app_load_config(genconf)) == NULL)
+ goto err;
if (!genstr)
genstr = NCONF_get_string(cnf, "default", "asn1");
if (!genstr) {
- BIO_printf(bio, "Can't find 'asn1' in '%s'\n", genconf);
+ BIO_printf(bio_err, "Can't find 'asn1' in '%s'\n", genconf);
goto err;
}
}
ASN1_TYPE_free(atyp);
return len;
- conferr:
-
- if (errline > 0)
- BIO_printf(bio, "Error on line %ld of config file '%s'\n",
- errline, genconf);
- else
- BIO_printf(bio, "Error loading config file '%s'\n", genconf);
-
err:
NCONF_free(cnf);
ASN1_TYPE_free(atyp);
-
return -1;
-
}