summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2014-04-24 13:12:18 +0000
committerjsing <>2014-04-24 13:12:18 +0000
commit8a65de78d6ab37b17958bab8476deb179f0fc823 (patch)
treed1d4be97730800c68b8985fb9933a8633af8e775 /src/lib
parent14a6049b862353b3465ce67d3a36960a1de3cc44 (diff)
downloadopenbsd-8a65de78d6ab37b17958bab8476deb179f0fc823.tar.gz
openbsd-8a65de78d6ab37b17958bab8476deb179f0fc823.tar.bz2
openbsd-8a65de78d6ab37b17958bab8476deb179f0fc823.zip
More KNF.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c70
-rw-r--r--src/lib/libcrypto/ui/ui_openssl.c4
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_lib.c70
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_openssl.c4
4 files changed, 74 insertions, 74 deletions
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
index 58e4c5d722..5f9b484105 100644
--- a/src/lib/libcrypto/ui/ui_lib.c
+++ b/src/lib/libcrypto/ui/ui_lib.c
@@ -135,14 +135,14 @@ allocate_string_stack(UI *ui)
135} 135}
136 136
137static UI_STRING * 137static UI_STRING *
138general_allocate_prompt(UI *ui, const char *prompt, 138general_allocate_prompt(UI *ui, const char *prompt, int prompt_freeable,
139 int prompt_freeable, enum UI_string_types type, int input_flags, 139 enum UI_string_types type, int input_flags, char *result_buf)
140 char *result_buf)
141{ 140{
142 UI_STRING *ret = NULL; 141 UI_STRING *ret = NULL;
143 142
144 if (prompt == NULL) { 143 if (prompt == NULL) {
145 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, ERR_R_PASSED_NULL_PARAMETER); 144 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,
145 ERR_R_PASSED_NULL_PARAMETER);
146 } else if ((type == UIT_PROMPT || type == UIT_VERIFY || 146 } else if ((type == UIT_PROMPT || type == UIT_VERIFY ||
147 type == UIT_BOOLEAN) && result_buf == NULL) { 147 type == UIT_BOOLEAN) && result_buf == NULL) {
148 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER); 148 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER);
@@ -157,9 +157,9 @@ general_allocate_prompt(UI *ui, const char *prompt,
157} 157}
158 158
159static int 159static int
160general_allocate_string(UI *ui, const char *prompt, 160general_allocate_string(UI *ui, const char *prompt, int prompt_freeable,
161 int prompt_freeable, enum UI_string_types type, int input_flags, 161 enum UI_string_types type, int input_flags, char *result_buf, int minsize,
162 char *result_buf, int minsize, int maxsize, const char *test_buf) 162 int maxsize, const char *test_buf)
163{ 163{
164 int ret = -1; 164 int ret = -1;
165 UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable, 165 UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable,
@@ -181,20 +181,20 @@ general_allocate_string(UI *ui, const char *prompt,
181} 181}
182 182
183static int 183static int
184general_allocate_boolean(UI *ui, 184general_allocate_boolean(UI *ui, const char *prompt, const char *action_desc,
185 const char *prompt, const char *action_desc, 185 const char *ok_chars, const char *cancel_chars, int prompt_freeable,
186 const char *ok_chars, const char *cancel_chars, 186 enum UI_string_types type, int input_flags, char *result_buf)
187 int prompt_freeable, enum UI_string_types type, int input_flags,
188 char *result_buf)
189{ 187{
190 int ret = -1; 188 int ret = -1;
191 UI_STRING *s; 189 UI_STRING *s;
192 const char *p; 190 const char *p;
193 191
194 if (ok_chars == NULL) { 192 if (ok_chars == NULL) {
195 UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, ERR_R_PASSED_NULL_PARAMETER); 193 UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN,
194 ERR_R_PASSED_NULL_PARAMETER);
196 } else if (cancel_chars == NULL) { 195 } else if (cancel_chars == NULL) {
197 UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, ERR_R_PASSED_NULL_PARAMETER); 196 UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN,
197 ERR_R_PASSED_NULL_PARAMETER);
198 } else { 198 } else {
199 for (p = ok_chars; *p; p++) { 199 for (p = ok_chars; *p; p++) {
200 if (strchr(cancel_chars, *p)) { 200 if (strchr(cancel_chars, *p)) {
@@ -228,17 +228,17 @@ general_allocate_boolean(UI *ui,
228/* Returns the index to the place in the stack or -1 for error. Uses a 228/* Returns the index to the place in the stack or -1 for error. Uses a
229 direct reference to the prompt. */ 229 direct reference to the prompt. */
230int 230int
231UI_add_input_string(UI *ui, const char *prompt, int flags, 231UI_add_input_string(UI *ui, const char *prompt, int flags, char *result_buf,
232 char *result_buf, int minsize, int maxsize) 232 int minsize, int maxsize)
233{ 233{
234 return general_allocate_string(ui, prompt, 0, 234 return general_allocate_string(ui, prompt, 0, UIT_PROMPT, flags,
235 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); 235 result_buf, minsize, maxsize, NULL);
236} 236}
237 237
238/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */ 238/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */
239int 239int
240UI_dup_input_string(UI *ui, const char *prompt, int flags, 240UI_dup_input_string(UI *ui, const char *prompt, int flags, char *result_buf,
241 char *result_buf, int minsize, int maxsize) 241 int minsize, int maxsize)
242{ 242{
243 char *prompt_copy = NULL; 243 char *prompt_copy = NULL;
244 244
@@ -249,16 +249,16 @@ UI_dup_input_string(UI *ui, const char *prompt, int flags,
249 return 0; 249 return 0;
250 } 250 }
251 } 251 }
252 return general_allocate_string(ui, prompt_copy, 1, 252 return general_allocate_string(ui, prompt_copy, 1, UIT_PROMPT, flags,
253 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); 253 result_buf, minsize, maxsize, NULL);
254} 254}
255 255
256int 256int
257UI_add_verify_string(UI *ui, const char *prompt, int flags, 257UI_add_verify_string(UI *ui, const char *prompt, int flags, char *result_buf,
258 char *result_buf, int minsize, int maxsize, const char *test_buf) 258 int minsize, int maxsize, const char *test_buf)
259{ 259{
260 return general_allocate_string(ui, prompt, 0, 260 return general_allocate_string(ui, prompt, 0, UIT_VERIFY, flags,
261 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); 261 result_buf, minsize, maxsize, test_buf);
262} 262}
263 263
264int 264int
@@ -274,23 +274,21 @@ UI_dup_verify_string(UI *ui, const char *prompt, int flags,
274 return -1; 274 return -1;
275 } 275 }
276 } 276 }
277 return general_allocate_string(ui, prompt_copy, 1, 277 return general_allocate_string(ui, prompt_copy, 1, UIT_VERIFY, flags,
278 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); 278 result_buf, minsize, maxsize, test_buf);
279} 279}
280 280
281int 281int
282UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, 282UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
283 const char *ok_chars, const char *cancel_chars, 283 const char *ok_chars, const char *cancel_chars, int flags, char *result_buf)
284 int flags, char *result_buf)
285{ 284{
286 return general_allocate_boolean(ui, prompt, action_desc, 285 return general_allocate_boolean(ui, prompt, action_desc, ok_chars,
287 ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf); 286 cancel_chars, 0, UIT_BOOLEAN, flags, result_buf);
288} 287}
289 288
290int 289int
291UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, 290UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
292 const char *ok_chars, const char *cancel_chars, 291 const char *ok_chars, const char *cancel_chars, int flags, char *result_buf)
293 int flags, char *result_buf)
294{ 292{
295 char *prompt_copy = NULL; 293 char *prompt_copy = NULL;
296 char *action_desc_copy = NULL; 294 char *action_desc_copy = NULL;
@@ -424,6 +422,7 @@ void *
424UI_add_user_data(UI *ui, void *user_data) 422UI_add_user_data(UI *ui, void *user_data)
425{ 423{
426 void *old_data = ui->user_data; 424 void *old_data = ui->user_data;
425
427 ui->user_data = user_data; 426 ui->user_data = user_data;
428 return old_data; 427 return old_data;
429} 428}
@@ -514,6 +513,7 @@ UI_process(UI *ui)
514 } 513 }
515 } 514 }
516 } 515 }
516
517err: 517err:
518 if (ui->meth->ui_close_session && !ui->meth->ui_close_session(ui)) 518 if (ui->meth->ui_close_session && !ui->meth->ui_close_session(ui))
519 return -1; 519 return -1;
@@ -598,7 +598,7 @@ UI_set_method(UI *ui, const UI_METHOD *meth)
598UI_METHOD * 598UI_METHOD *
599UI_create_method(char *name) 599UI_create_method(char *name)
600{ 600{
601 UI_METHOD *ui_method = (UI_METHOD *) malloc(sizeof(UI_METHOD)); 601 UI_METHOD *ui_method = (UI_METHOD *)malloc(sizeof(UI_METHOD));
602 602
603 if (ui_method) { 603 if (ui_method) {
604 memset(ui_method, 0, sizeof(*ui_method)); 604 memset(ui_method, 0, sizeof(*ui_method));
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c
index ef483352ea..7ae1601e53 100644
--- a/src/lib/libcrypto/ui/ui_openssl.c
+++ b/src/lib/libcrypto/ui/ui_openssl.c
@@ -251,8 +251,8 @@ read_string(UI *ui, UI_STRING *uis)
251 fprintf(tty_out, "Verifying - %s", 251 fprintf(tty_out, "Verifying - %s",
252 UI_get0_output_string(uis)); 252 UI_get0_output_string(uis));
253 fflush(tty_out); 253 fflush(tty_out);
254 if ((ok = read_string_inner(ui, uis, 254 if ((ok = read_string_inner(ui, uis, UI_get_input_flags(uis) &
255 UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0) 255 UI_INPUT_FLAG_ECHO, 1)) <= 0)
256 return ok; 256 return ok;
257 if (strcmp(UI_get0_result_string(uis), 257 if (strcmp(UI_get0_result_string(uis),
258 UI_get0_test_string(uis)) != 0) { 258 UI_get0_test_string(uis)) != 0) {
diff --git a/src/lib/libssl/src/crypto/ui/ui_lib.c b/src/lib/libssl/src/crypto/ui/ui_lib.c
index 58e4c5d722..5f9b484105 100644
--- a/src/lib/libssl/src/crypto/ui/ui_lib.c
+++ b/src/lib/libssl/src/crypto/ui/ui_lib.c
@@ -135,14 +135,14 @@ allocate_string_stack(UI *ui)
135} 135}
136 136
137static UI_STRING * 137static UI_STRING *
138general_allocate_prompt(UI *ui, const char *prompt, 138general_allocate_prompt(UI *ui, const char *prompt, int prompt_freeable,
139 int prompt_freeable, enum UI_string_types type, int input_flags, 139 enum UI_string_types type, int input_flags, char *result_buf)
140 char *result_buf)
141{ 140{
142 UI_STRING *ret = NULL; 141 UI_STRING *ret = NULL;
143 142
144 if (prompt == NULL) { 143 if (prompt == NULL) {
145 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, ERR_R_PASSED_NULL_PARAMETER); 144 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT,
145 ERR_R_PASSED_NULL_PARAMETER);
146 } else if ((type == UIT_PROMPT || type == UIT_VERIFY || 146 } else if ((type == UIT_PROMPT || type == UIT_VERIFY ||
147 type == UIT_BOOLEAN) && result_buf == NULL) { 147 type == UIT_BOOLEAN) && result_buf == NULL) {
148 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER); 148 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER);
@@ -157,9 +157,9 @@ general_allocate_prompt(UI *ui, const char *prompt,
157} 157}
158 158
159static int 159static int
160general_allocate_string(UI *ui, const char *prompt, 160general_allocate_string(UI *ui, const char *prompt, int prompt_freeable,
161 int prompt_freeable, enum UI_string_types type, int input_flags, 161 enum UI_string_types type, int input_flags, char *result_buf, int minsize,
162 char *result_buf, int minsize, int maxsize, const char *test_buf) 162 int maxsize, const char *test_buf)
163{ 163{
164 int ret = -1; 164 int ret = -1;
165 UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable, 165 UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable,
@@ -181,20 +181,20 @@ general_allocate_string(UI *ui, const char *prompt,
181} 181}
182 182
183static int 183static int
184general_allocate_boolean(UI *ui, 184general_allocate_boolean(UI *ui, const char *prompt, const char *action_desc,
185 const char *prompt, const char *action_desc, 185 const char *ok_chars, const char *cancel_chars, int prompt_freeable,
186 const char *ok_chars, const char *cancel_chars, 186 enum UI_string_types type, int input_flags, char *result_buf)
187 int prompt_freeable, enum UI_string_types type, int input_flags,
188 char *result_buf)
189{ 187{
190 int ret = -1; 188 int ret = -1;
191 UI_STRING *s; 189 UI_STRING *s;
192 const char *p; 190 const char *p;
193 191
194 if (ok_chars == NULL) { 192 if (ok_chars == NULL) {
195 UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, ERR_R_PASSED_NULL_PARAMETER); 193 UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN,
194 ERR_R_PASSED_NULL_PARAMETER);
196 } else if (cancel_chars == NULL) { 195 } else if (cancel_chars == NULL) {
197 UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, ERR_R_PASSED_NULL_PARAMETER); 196 UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN,
197 ERR_R_PASSED_NULL_PARAMETER);
198 } else { 198 } else {
199 for (p = ok_chars; *p; p++) { 199 for (p = ok_chars; *p; p++) {
200 if (strchr(cancel_chars, *p)) { 200 if (strchr(cancel_chars, *p)) {
@@ -228,17 +228,17 @@ general_allocate_boolean(UI *ui,
228/* Returns the index to the place in the stack or -1 for error. Uses a 228/* Returns the index to the place in the stack or -1 for error. Uses a
229 direct reference to the prompt. */ 229 direct reference to the prompt. */
230int 230int
231UI_add_input_string(UI *ui, const char *prompt, int flags, 231UI_add_input_string(UI *ui, const char *prompt, int flags, char *result_buf,
232 char *result_buf, int minsize, int maxsize) 232 int minsize, int maxsize)
233{ 233{
234 return general_allocate_string(ui, prompt, 0, 234 return general_allocate_string(ui, prompt, 0, UIT_PROMPT, flags,
235 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); 235 result_buf, minsize, maxsize, NULL);
236} 236}
237 237
238/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */ 238/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */
239int 239int
240UI_dup_input_string(UI *ui, const char *prompt, int flags, 240UI_dup_input_string(UI *ui, const char *prompt, int flags, char *result_buf,
241 char *result_buf, int minsize, int maxsize) 241 int minsize, int maxsize)
242{ 242{
243 char *prompt_copy = NULL; 243 char *prompt_copy = NULL;
244 244
@@ -249,16 +249,16 @@ UI_dup_input_string(UI *ui, const char *prompt, int flags,
249 return 0; 249 return 0;
250 } 250 }
251 } 251 }
252 return general_allocate_string(ui, prompt_copy, 1, 252 return general_allocate_string(ui, prompt_copy, 1, UIT_PROMPT, flags,
253 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); 253 result_buf, minsize, maxsize, NULL);
254} 254}
255 255
256int 256int
257UI_add_verify_string(UI *ui, const char *prompt, int flags, 257UI_add_verify_string(UI *ui, const char *prompt, int flags, char *result_buf,
258 char *result_buf, int minsize, int maxsize, const char *test_buf) 258 int minsize, int maxsize, const char *test_buf)
259{ 259{
260 return general_allocate_string(ui, prompt, 0, 260 return general_allocate_string(ui, prompt, 0, UIT_VERIFY, flags,
261 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); 261 result_buf, minsize, maxsize, test_buf);
262} 262}
263 263
264int 264int
@@ -274,23 +274,21 @@ UI_dup_verify_string(UI *ui, const char *prompt, int flags,
274 return -1; 274 return -1;
275 } 275 }
276 } 276 }
277 return general_allocate_string(ui, prompt_copy, 1, 277 return general_allocate_string(ui, prompt_copy, 1, UIT_VERIFY, flags,
278 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); 278 result_buf, minsize, maxsize, test_buf);
279} 279}
280 280
281int 281int
282UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, 282UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
283 const char *ok_chars, const char *cancel_chars, 283 const char *ok_chars, const char *cancel_chars, int flags, char *result_buf)
284 int flags, char *result_buf)
285{ 284{
286 return general_allocate_boolean(ui, prompt, action_desc, 285 return general_allocate_boolean(ui, prompt, action_desc, ok_chars,
287 ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf); 286 cancel_chars, 0, UIT_BOOLEAN, flags, result_buf);
288} 287}
289 288
290int 289int
291UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, 290UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
292 const char *ok_chars, const char *cancel_chars, 291 const char *ok_chars, const char *cancel_chars, int flags, char *result_buf)
293 int flags, char *result_buf)
294{ 292{
295 char *prompt_copy = NULL; 293 char *prompt_copy = NULL;
296 char *action_desc_copy = NULL; 294 char *action_desc_copy = NULL;
@@ -424,6 +422,7 @@ void *
424UI_add_user_data(UI *ui, void *user_data) 422UI_add_user_data(UI *ui, void *user_data)
425{ 423{
426 void *old_data = ui->user_data; 424 void *old_data = ui->user_data;
425
427 ui->user_data = user_data; 426 ui->user_data = user_data;
428 return old_data; 427 return old_data;
429} 428}
@@ -514,6 +513,7 @@ UI_process(UI *ui)
514 } 513 }
515 } 514 }
516 } 515 }
516
517err: 517err:
518 if (ui->meth->ui_close_session && !ui->meth->ui_close_session(ui)) 518 if (ui->meth->ui_close_session && !ui->meth->ui_close_session(ui))
519 return -1; 519 return -1;
@@ -598,7 +598,7 @@ UI_set_method(UI *ui, const UI_METHOD *meth)
598UI_METHOD * 598UI_METHOD *
599UI_create_method(char *name) 599UI_create_method(char *name)
600{ 600{
601 UI_METHOD *ui_method = (UI_METHOD *) malloc(sizeof(UI_METHOD)); 601 UI_METHOD *ui_method = (UI_METHOD *)malloc(sizeof(UI_METHOD));
602 602
603 if (ui_method) { 603 if (ui_method) {
604 memset(ui_method, 0, sizeof(*ui_method)); 604 memset(ui_method, 0, sizeof(*ui_method));
diff --git a/src/lib/libssl/src/crypto/ui/ui_openssl.c b/src/lib/libssl/src/crypto/ui/ui_openssl.c
index ef483352ea..7ae1601e53 100644
--- a/src/lib/libssl/src/crypto/ui/ui_openssl.c
+++ b/src/lib/libssl/src/crypto/ui/ui_openssl.c
@@ -251,8 +251,8 @@ read_string(UI *ui, UI_STRING *uis)
251 fprintf(tty_out, "Verifying - %s", 251 fprintf(tty_out, "Verifying - %s",
252 UI_get0_output_string(uis)); 252 UI_get0_output_string(uis));
253 fflush(tty_out); 253 fflush(tty_out);
254 if ((ok = read_string_inner(ui, uis, 254 if ((ok = read_string_inner(ui, uis, UI_get_input_flags(uis) &
255 UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0) 255 UI_INPUT_FLAG_ECHO, 1)) <= 0)
256 return ok; 256 return ok;
257 if (strcmp(UI_get0_result_string(uis), 257 if (strcmp(UI_get0_result_string(uis),
258 UI_get0_test_string(uis)) != 0) { 258 UI_get0_test_string(uis)) != 0) {