summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/t_bitst.c
diff options
context:
space:
mode:
authorjsing <>2014-04-18 13:14:31 +0000
committerjsing <>2014-04-18 13:14:31 +0000
commit48839e33a53ed2d6e54cb31ec1a93635e0a4dc60 (patch)
treef569441b32f0a3293eba8921ed58e2489986006c /src/lib/libcrypto/asn1/t_bitst.c
parent8a0112534d8764e81ead87d96bc29f9f7087f881 (diff)
downloadopenbsd-48839e33a53ed2d6e54cb31ec1a93635e0a4dc60.tar.gz
openbsd-48839e33a53ed2d6e54cb31ec1a93635e0a4dc60.tar.bz2
openbsd-48839e33a53ed2d6e54cb31ec1a93635e0a4dc60.zip
More KNF.
Diffstat (limited to 'src/lib/libcrypto/asn1/t_bitst.c')
-rw-r--r--src/lib/libcrypto/asn1/t_bitst.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/lib/libcrypto/asn1/t_bitst.c b/src/lib/libcrypto/asn1/t_bitst.c
index 2e59a25fa1..1dc04beabf 100644
--- a/src/lib/libcrypto/asn1/t_bitst.c
+++ b/src/lib/libcrypto/asn1/t_bitst.c
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -61,15 +61,18 @@
61#include <openssl/conf.h> 61#include <openssl/conf.h>
62#include <openssl/x509v3.h> 62#include <openssl/x509v3.h>
63 63
64int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, 64int
65 BIT_STRING_BITNAME *tbl, int indent) 65ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
66 BIT_STRING_BITNAME *tbl, int indent)
66{ 67{
67 BIT_STRING_BITNAME *bnam; 68 BIT_STRING_BITNAME *bnam;
68 char first = 1; 69 char first = 1;
70
69 BIO_printf(out, "%*s", indent, ""); 71 BIO_printf(out, "%*s", indent, "");
70 for(bnam = tbl; bnam->lname; bnam++) { 72 for (bnam = tbl; bnam->lname; bnam++) {
71 if(ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) { 73 if (ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) {
72 if(!first) BIO_puts(out, ", "); 74 if (!first)
75 BIO_puts(out, ", ");
73 BIO_puts(out, bnam->lname); 76 BIO_puts(out, bnam->lname);
74 first = 0; 77 first = 0;
75 } 78 }
@@ -78,25 +81,31 @@ int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
78 return 1; 81 return 1;
79} 82}
80 83
81int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value, 84int
82 BIT_STRING_BITNAME *tbl) 85ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
86 BIT_STRING_BITNAME *tbl)
83{ 87{
84 int bitnum; 88 int bitnum;
89
85 bitnum = ASN1_BIT_STRING_num_asc(name, tbl); 90 bitnum = ASN1_BIT_STRING_num_asc(name, tbl);
86 if(bitnum < 0) return 0; 91 if (bitnum < 0)
87 if(bs) { 92 return 0;
88 if(!ASN1_BIT_STRING_set_bit(bs, bitnum, value)) 93 if (bs) {
94 if (!ASN1_BIT_STRING_set_bit(bs, bitnum, value))
89 return 0; 95 return 0;
90 } 96 }
91 return 1; 97 return 1;
92} 98}
93 99
94int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl) 100int
101ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl)
95{ 102{
96 BIT_STRING_BITNAME *bnam; 103 BIT_STRING_BITNAME *bnam;
97 for(bnam = tbl; bnam->lname; bnam++) { 104
98 if(!strcmp(bnam->sname, name) || 105 for (bnam = tbl; bnam->lname; bnam++) {
99 !strcmp(bnam->lname, name) ) return bnam->bitnum; 106 if (!strcmp(bnam->sname, name) ||
107 !strcmp(bnam->lname, name))
108 return bnam->bitnum;
100 } 109 }
101 return -1; 110 return -1;
102} 111}