summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2014-04-22 13:48:29 +0000
committerjsing <>2014-04-22 13:48:29 +0000
commit335624ea34460e308d267f139708f6d2a8b0f136 (patch)
tree781fa83c95f2e9676a6206a24e9c73058b9ca956 /src
parentfdc854f6ca80f31b8fb7bebb99b1b940952212ed (diff)
downloadopenbsd-335624ea34460e308d267f139708f6d2a8b0f136.tar.gz
openbsd-335624ea34460e308d267f139708f6d2a8b0f136.tar.bz2
openbsd-335624ea34460e308d267f139708f6d2a8b0f136.zip
More KNF.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/src/apps/openssl.c68
1 files changed, 37 insertions, 31 deletions
diff --git a/src/lib/libssl/src/apps/openssl.c b/src/lib/libssl/src/apps/openssl.c
index 008bbdc08b..03376667dd 100644
--- a/src/lib/libssl/src/apps/openssl.c
+++ b/src/lib/libssl/src/apps/openssl.c
@@ -109,7 +109,6 @@
109 * 109 *
110 */ 110 */
111 111
112
113#include <stdio.h> 112#include <stdio.h>
114#include <string.h> 113#include <string.h>
115#include <stdlib.h> 114#include <stdlib.h>
@@ -146,7 +145,7 @@ char *default_config_file = NULL;
146CONF *config = NULL; 145CONF *config = NULL;
147BIO *bio_err = NULL; 146BIO *bio_err = NULL;
148 147
149static void 148static void
150lock_dbg_cb(int mode, int type, const char *file, int line) 149lock_dbg_cb(int mode, int type, const char *file, int line)
151{ 150{
152 static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */ 151 static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */
@@ -198,7 +197,7 @@ err:
198 197
199#define ARGV Argv 198#define ARGV Argv
200 199
201int 200int
202main(int Argc, char *ARGV[]) 201main(int Argc, char *ARGV[])
203{ 202{
204 ARGS arg; 203 ARGS arg;
@@ -271,8 +270,8 @@ main(int Argc, char *ARGV[])
271 config = NCONF_new(NULL); 270 config = NCONF_new(NULL);
272 i = NCONF_load(config, p, &errline); 271 i = NCONF_load(config, p, &errline);
273 if (i == 0) { 272 if (i == 0) {
274 if (ERR_GET_REASON(ERR_peek_last_error()) 273 if (ERR_GET_REASON(ERR_peek_last_error()) ==
275 == CONF_R_NO_SUCH_FILE) { 274 CONF_R_NO_SUCH_FILE) {
276 BIO_printf(bio_err, 275 BIO_printf(bio_err,
277 "WARNING: can't open config file: %s\n", p); 276 "WARNING: can't open config file: %s\n", p);
278 ERR_clear_error(); 277 ERR_clear_error();
@@ -350,6 +349,7 @@ main(int Argc, char *ARGV[])
350 } 349 }
351 BIO_printf(bio_err, "bad exit\n"); 350 BIO_printf(bio_err, "bad exit\n");
352 ret = 1; 351 ret = 1;
352
353end: 353end:
354 if (to_free) 354 if (to_free)
355 free(to_free); 355 free(to_free);
@@ -380,7 +380,7 @@ end:
380#define LIST_PUBLIC_KEY_ALGORITHMS "list-public-key-algorithms" 380#define LIST_PUBLIC_KEY_ALGORITHMS "list-public-key-algorithms"
381 381
382 382
383static int 383static int
384do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]) 384do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[])
385{ 385{
386 FUNCTION f, *fp; 386 FUNCTION f, *fp;
@@ -416,16 +416,16 @@ do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[])
416 BIO_free_all(bio_stdout); 416 BIO_free_all(bio_stdout);
417 goto end; 417 goto end;
418 } else if ((strcmp(argv[0], "quit") == 0) || 418 } else if ((strcmp(argv[0], "quit") == 0) ||
419 (strcmp(argv[0], "q") == 0) || 419 (strcmp(argv[0], "q") == 0) ||
420 (strcmp(argv[0], "exit") == 0) || 420 (strcmp(argv[0], "exit") == 0) ||
421 (strcmp(argv[0], "bye") == 0)) { 421 (strcmp(argv[0], "bye") == 0)) {
422 ret = -1; 422 ret = -1;
423 goto end; 423 goto end;
424 } else if ((strcmp(argv[0], LIST_STANDARD_COMMANDS) == 0) || 424 } else if ((strcmp(argv[0], LIST_STANDARD_COMMANDS) == 0) ||
425 (strcmp(argv[0], LIST_MESSAGE_DIGEST_COMMANDS) == 0) || 425 (strcmp(argv[0], LIST_MESSAGE_DIGEST_COMMANDS) == 0) ||
426 (strcmp(argv[0], LIST_MESSAGE_DIGEST_ALGORITHMS) == 0) || 426 (strcmp(argv[0], LIST_MESSAGE_DIGEST_ALGORITHMS) == 0) ||
427 (strcmp(argv[0], LIST_CIPHER_COMMANDS) == 0) || 427 (strcmp(argv[0], LIST_CIPHER_COMMANDS) == 0) ||
428 (strcmp(argv[0], LIST_CIPHER_ALGORITHMS) == 0) || 428 (strcmp(argv[0], LIST_CIPHER_ALGORITHMS) == 0) ||
429 (strcmp(argv[0], LIST_PUBLIC_KEY_ALGORITHMS) == 0)) { 429 (strcmp(argv[0], LIST_PUBLIC_KEY_ALGORITHMS) == 0)) {
430 int list_type; 430 int list_type;
431 BIO *bio_stdout; 431 BIO *bio_stdout;
@@ -463,7 +463,8 @@ do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[])
463 ret = 0; 463 ret = 0;
464 goto end; 464 goto end;
465 } else { 465 } else {
466 BIO_printf(bio_err, "openssl:Error: '%s' is an invalid command.\n", 466 BIO_printf(bio_err,
467 "openssl:Error: '%s' is an invalid command.\n",
467 argv[0]); 468 argv[0]);
468 BIO_printf(bio_err, "\nStandard commands"); 469 BIO_printf(bio_err, "\nStandard commands");
469 i = 0; 470 i = 0;
@@ -505,7 +506,7 @@ end:
505 return (ret); 506 return (ret);
506} 507}
507 508
508static int 509static int
509SortFnByName(const void *_f1, const void *_f2) 510SortFnByName(const void *_f1, const void *_f2)
510{ 511{
511 const FUNCTION *f1 = _f1; 512 const FUNCTION *f1 = _f1;
@@ -516,10 +517,11 @@ SortFnByName(const void *_f1, const void *_f2)
516 return strcmp(f1->name, f2->name); 517 return strcmp(f1->name, f2->name);
517} 518}
518 519
519static void 520static void
520list_pkey(BIO * out) 521list_pkey(BIO * out)
521{ 522{
522 int i; 523 int i;
524
523 for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) { 525 for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
524 const EVP_PKEY_ASN1_METHOD *ameth; 526 const EVP_PKEY_ASN1_METHOD *ameth;
525 int pkey_id, pkey_base_id, pkey_flags; 527 int pkey_id, pkey_base_id, pkey_flags;
@@ -546,9 +548,9 @@ list_pkey(BIO * out)
546 } 548 }
547} 549}
548 550
549static void 551static void
550list_cipher_fn(const EVP_CIPHER * c, 552list_cipher_fn(const EVP_CIPHER * c, const char *from, const char *to,
551 const char *from, const char *to, void *arg) 553 void *arg)
552{ 554{
553 if (c) 555 if (c)
554 BIO_printf(arg, "%s\n", EVP_CIPHER_name(c)); 556 BIO_printf(arg, "%s\n", EVP_CIPHER_name(c));
@@ -561,15 +563,14 @@ list_cipher_fn(const EVP_CIPHER * c,
561 } 563 }
562} 564}
563 565
564static void 566static void
565list_cipher(BIO * out) 567list_cipher(BIO * out)
566{ 568{
567 EVP_CIPHER_do_all_sorted(list_cipher_fn, out); 569 EVP_CIPHER_do_all_sorted(list_cipher_fn, out);
568} 570}
569 571
570static void 572static void
571list_md_fn(const EVP_MD * m, 573list_md_fn(const EVP_MD * m, const char *from, const char *to, void *arg)
572 const char *from, const char *to, void *arg)
573{ 574{
574 if (m) 575 if (m)
575 BIO_printf(arg, "%s\n", EVP_MD_name(m)); 576 BIO_printf(arg, "%s\n", EVP_MD_name(m));
@@ -582,33 +583,38 @@ list_md_fn(const EVP_MD * m,
582 } 583 }
583} 584}
584 585
585static void 586static void
586list_md(BIO * out) 587list_md(BIO * out)
587{ 588{
588 EVP_MD_do_all_sorted(list_md_fn, out); 589 EVP_MD_do_all_sorted(list_md_fn, out);
589} 590}
590 591
591static int 592static int
592function_cmp(const FUNCTION * a, const FUNCTION * b) 593function_cmp(const FUNCTION * a, const FUNCTION * b)
593{ 594{
594 return strncmp(a->name, b->name, 8); 595 return strncmp(a->name, b->name, 8);
595} 596}
596static 597
597IMPLEMENT_LHASH_COMP_FN(function, FUNCTION) 598static IMPLEMENT_LHASH_COMP_FN(function, FUNCTION)
598 static unsigned long function_hash(const FUNCTION * a) 599
600static unsigned long
601function_hash(const FUNCTION * a)
599{ 602{
600 return lh_strhash(a->name); 603 return lh_strhash(a->name);
601} 604}
602static 605
603IMPLEMENT_LHASH_HASH_FN(function, FUNCTION) 606static IMPLEMENT_LHASH_HASH_FN(function, FUNCTION)
604 static LHASH_OF(FUNCTION) * prog_init(void) 607
608static LHASH_OF(FUNCTION) *
609prog_init(void)
605{ 610{
606 LHASH_OF(FUNCTION) * ret; 611 LHASH_OF(FUNCTION) * ret;
607 FUNCTION *f; 612 FUNCTION *f;
608 size_t i; 613 size_t i;
609 614
610 /* Purely so it looks nice when the user hits ? */ 615 /* Purely so it looks nice when the user hits ? */
611 for (i = 0, f = functions; f->name != NULL; ++f, ++i); 616 for (i = 0, f = functions; f->name != NULL; ++f, ++i)
617 ;
612 qsort(functions, i, sizeof *functions, SortFnByName); 618 qsort(functions, i, sizeof *functions, SortFnByName);
613 619
614 if ((ret = lh_FUNCTION_new()) == NULL) 620 if ((ret = lh_FUNCTION_new()) == NULL)