diff options
| author | tb <> | 2023-03-06 14:32:06 +0000 |
|---|---|---|
| committer | tb <> | 2023-03-06 14:32:06 +0000 |
| commit | 2ba7dcfcbc2ef5aaeb8eb14f36f83bd57c22bcae (patch) | |
| tree | bbe07d6e06b695cebe22802551f2db0a61354d7c /src/usr.bin/openssl/crl2p7.c | |
| parent | cfc0cbdbaaa36a4b6adee60b5cf3f4a388554426 (diff) | |
| download | openbsd-2ba7dcfcbc2ef5aaeb8eb14f36f83bd57c22bcae.tar.gz openbsd-2ba7dcfcbc2ef5aaeb8eb14f36f83bd57c22bcae.tar.bz2 openbsd-2ba7dcfcbc2ef5aaeb8eb14f36f83bd57c22bcae.zip | |
Rename struct ${app}_config to plain cfg
All the structs are static and we need to reach into them many times.
Having a shorter name is more concise and results in less visual clutter.
It also avoids many overlong lines and we will be able to get rid of some
unfortunate line wrapping down the road.
Discussed with jsing
Diffstat (limited to 'src/usr.bin/openssl/crl2p7.c')
| -rw-r--r-- | src/usr.bin/openssl/crl2p7.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/usr.bin/openssl/crl2p7.c b/src/usr.bin/openssl/crl2p7.c index 0b0eae2a99..dfbc896a21 100644 --- a/src/usr.bin/openssl/crl2p7.c +++ b/src/usr.bin/openssl/crl2p7.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: crl2p7.c,v 1.10 2022/11/11 17:07:38 joshua Exp $ */ | 1 | /* $OpenBSD: crl2p7.c,v 1.11 2023/03/06 14:32:05 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -83,18 +83,18 @@ static struct { | |||
| 83 | int nocrl; | 83 | int nocrl; |
| 84 | char *outfile; | 84 | char *outfile; |
| 85 | int outformat; | 85 | int outformat; |
| 86 | } crl2p7_config; | 86 | } cfg; |
| 87 | 87 | ||
| 88 | static int | 88 | static int |
| 89 | crl2p7_opt_certfile(char *arg) | 89 | crl2p7_opt_certfile(char *arg) |
| 90 | { | 90 | { |
| 91 | if (crl2p7_config.certflst == NULL) | 91 | if (cfg.certflst == NULL) |
| 92 | crl2p7_config.certflst = sk_OPENSSL_STRING_new_null(); | 92 | cfg.certflst = sk_OPENSSL_STRING_new_null(); |
| 93 | if (crl2p7_config.certflst == NULL) { | 93 | if (cfg.certflst == NULL) { |
| 94 | fprintf(stderr, "out of memory\n"); | 94 | fprintf(stderr, "out of memory\n"); |
| 95 | return (1); | 95 | return (1); |
| 96 | } | 96 | } |
| 97 | if (!sk_OPENSSL_STRING_push(crl2p7_config.certflst, arg)) { | 97 | if (!sk_OPENSSL_STRING_push(cfg.certflst, arg)) { |
| 98 | fprintf(stderr, "out of memory\n"); | 98 | fprintf(stderr, "out of memory\n"); |
| 99 | return (1); | 99 | return (1); |
| 100 | } | 100 | } |
| @@ -115,34 +115,34 @@ static const struct option crl2p7_options[] = { | |||
| 115 | .argname = "file", | 115 | .argname = "file", |
| 116 | .desc = "Input file (default stdin)", | 116 | .desc = "Input file (default stdin)", |
| 117 | .type = OPTION_ARG, | 117 | .type = OPTION_ARG, |
| 118 | .opt.arg = &crl2p7_config.infile, | 118 | .opt.arg = &cfg.infile, |
| 119 | }, | 119 | }, |
| 120 | { | 120 | { |
| 121 | .name = "inform", | 121 | .name = "inform", |
| 122 | .argname = "format", | 122 | .argname = "format", |
| 123 | .desc = "Input format (DER or PEM (default))", | 123 | .desc = "Input format (DER or PEM (default))", |
| 124 | .type = OPTION_ARG_FORMAT, | 124 | .type = OPTION_ARG_FORMAT, |
| 125 | .opt.value = &crl2p7_config.informat, | 125 | .opt.value = &cfg.informat, |
| 126 | }, | 126 | }, |
| 127 | { | 127 | { |
| 128 | .name = "nocrl", | 128 | .name = "nocrl", |
| 129 | .desc = "Do not read CRL from input or include CRL in output", | 129 | .desc = "Do not read CRL from input or include CRL in output", |
| 130 | .type = OPTION_FLAG, | 130 | .type = OPTION_FLAG, |
| 131 | .opt.flag = &crl2p7_config.nocrl, | 131 | .opt.flag = &cfg.nocrl, |
| 132 | }, | 132 | }, |
| 133 | { | 133 | { |
| 134 | .name = "out", | 134 | .name = "out", |
| 135 | .argname = "file", | 135 | .argname = "file", |
| 136 | .desc = "Output file (default stdout)", | 136 | .desc = "Output file (default stdout)", |
| 137 | .type = OPTION_ARG, | 137 | .type = OPTION_ARG, |
| 138 | .opt.arg = &crl2p7_config.outfile, | 138 | .opt.arg = &cfg.outfile, |
| 139 | }, | 139 | }, |
| 140 | { | 140 | { |
| 141 | .name = "outform", | 141 | .name = "outform", |
| 142 | .argname = "format", | 142 | .argname = "format", |
| 143 | .desc = "Output format (DER or PEM (default))", | 143 | .desc = "Output format (DER or PEM (default))", |
| 144 | .type = OPTION_ARG_FORMAT, | 144 | .type = OPTION_ARG_FORMAT, |
| 145 | .opt.value = &crl2p7_config.outformat, | 145 | .opt.value = &cfg.outformat, |
| 146 | }, | 146 | }, |
| 147 | { NULL }, | 147 | { NULL }, |
| 148 | }; | 148 | }; |
| @@ -174,10 +174,10 @@ crl2pkcs7_main(int argc, char **argv) | |||
| 174 | exit(1); | 174 | exit(1); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | memset(&crl2p7_config, 0, sizeof(crl2p7_config)); | 177 | memset(&cfg, 0, sizeof(cfg)); |
| 178 | 178 | ||
| 179 | crl2p7_config.informat = FORMAT_PEM; | 179 | cfg.informat = FORMAT_PEM; |
| 180 | crl2p7_config.outformat = FORMAT_PEM; | 180 | cfg.outformat = FORMAT_PEM; |
| 181 | 181 | ||
| 182 | if (options_parse(argc, argv, crl2p7_options, NULL, NULL) != 0) { | 182 | if (options_parse(argc, argv, crl2p7_options, NULL, NULL) != 0) { |
| 183 | crl2p7_usage(); | 183 | crl2p7_usage(); |
| @@ -190,19 +190,19 @@ crl2pkcs7_main(int argc, char **argv) | |||
| 190 | ERR_print_errors(bio_err); | 190 | ERR_print_errors(bio_err); |
| 191 | goto end; | 191 | goto end; |
| 192 | } | 192 | } |
| 193 | if (!crl2p7_config.nocrl) { | 193 | if (!cfg.nocrl) { |
| 194 | if (crl2p7_config.infile == NULL) | 194 | if (cfg.infile == NULL) |
| 195 | BIO_set_fp(in, stdin, BIO_NOCLOSE); | 195 | BIO_set_fp(in, stdin, BIO_NOCLOSE); |
| 196 | else { | 196 | else { |
| 197 | if (BIO_read_filename(in, crl2p7_config.infile) <= 0) { | 197 | if (BIO_read_filename(in, cfg.infile) <= 0) { |
| 198 | perror(crl2p7_config.infile); | 198 | perror(cfg.infile); |
| 199 | goto end; | 199 | goto end; |
| 200 | } | 200 | } |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | if (crl2p7_config.informat == FORMAT_ASN1) | 203 | if (cfg.informat == FORMAT_ASN1) |
| 204 | crl = d2i_X509_CRL_bio(in, NULL); | 204 | crl = d2i_X509_CRL_bio(in, NULL); |
| 205 | else if (crl2p7_config.informat == FORMAT_PEM) | 205 | else if (cfg.informat == FORMAT_PEM) |
| 206 | crl = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL); | 206 | crl = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL); |
| 207 | else { | 207 | else { |
| 208 | BIO_printf(bio_err, | 208 | BIO_printf(bio_err, |
| @@ -236,9 +236,9 @@ crl2pkcs7_main(int argc, char **argv) | |||
| 236 | goto end; | 236 | goto end; |
| 237 | p7s->cert = cert_stack; | 237 | p7s->cert = cert_stack; |
| 238 | 238 | ||
| 239 | if (crl2p7_config.certflst) { | 239 | if (cfg.certflst) { |
| 240 | for (i = 0; i < sk_OPENSSL_STRING_num(crl2p7_config.certflst); i++) { | 240 | for (i = 0; i < sk_OPENSSL_STRING_num(cfg.certflst); i++) { |
| 241 | certfile = sk_OPENSSL_STRING_value(crl2p7_config.certflst, i); | 241 | certfile = sk_OPENSSL_STRING_value(cfg.certflst, i); |
| 242 | if (add_certs_from_file(cert_stack, certfile) < 0) { | 242 | if (add_certs_from_file(cert_stack, certfile) < 0) { |
| 243 | BIO_printf(bio_err, | 243 | BIO_printf(bio_err, |
| 244 | "error loading certificates\n"); | 244 | "error loading certificates\n"); |
| @@ -248,20 +248,20 @@ crl2pkcs7_main(int argc, char **argv) | |||
| 248 | } | 248 | } |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | sk_OPENSSL_STRING_free(crl2p7_config.certflst); | 251 | sk_OPENSSL_STRING_free(cfg.certflst); |
| 252 | 252 | ||
| 253 | if (crl2p7_config.outfile == NULL) { | 253 | if (cfg.outfile == NULL) { |
| 254 | BIO_set_fp(out, stdout, BIO_NOCLOSE); | 254 | BIO_set_fp(out, stdout, BIO_NOCLOSE); |
| 255 | } else { | 255 | } else { |
| 256 | if (BIO_write_filename(out, crl2p7_config.outfile) <= 0) { | 256 | if (BIO_write_filename(out, cfg.outfile) <= 0) { |
| 257 | perror(crl2p7_config.outfile); | 257 | perror(cfg.outfile); |
| 258 | goto end; | 258 | goto end; |
| 259 | } | 259 | } |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | if (crl2p7_config.outformat == FORMAT_ASN1) | 262 | if (cfg.outformat == FORMAT_ASN1) |
| 263 | i = i2d_PKCS7_bio(out, p7); | 263 | i = i2d_PKCS7_bio(out, p7); |
| 264 | else if (crl2p7_config.outformat == FORMAT_PEM) | 264 | else if (cfg.outformat == FORMAT_PEM) |
| 265 | i = PEM_write_bio_PKCS7(out, p7); | 265 | i = PEM_write_bio_PKCS7(out, p7); |
| 266 | else { | 266 | else { |
| 267 | BIO_printf(bio_err, | 267 | BIO_printf(bio_err, |
