summaryrefslogtreecommitdiffstats
path: root/apps/cms.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2015-09-04 12:49:06 +0200
committerRichard Levitte <levitte@openssl.org>2015-09-06 01:35:54 +0200
commitbdd58d98467e9f0f6635c1628e1eae304383afb1 (patch)
tree1927fc4a65f8fd8b5705c5c5e0278beabf2c2b28 /apps/cms.c
parentd303b9d85e1888494785f87ebd9bd233e63564a9 (diff)
Change the way apps open their input and output files
The different apps had the liberty to decide whether they would open their input and output files in binary mode or not, which could be confusing if two different apps were handling the same type of file in different ways. The solution is to centralise the decision of low level file organisation, and that the apps would use a selection of formats to state the intent of the file. Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'apps/cms.c')
-rw-r--r--apps/cms.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/apps/cms.c b/apps/cms.c
index 599f21774e..2331ea2e28 100644
--- a/apps/cms.c
+++ b/apps/cms.c
@@ -247,7 +247,6 @@ int cms_main(int argc, char **argv)
NULL;
char *to = NULL, *from = NULL, *subject = NULL, *prog;
cms_key_param *key_first = NULL, *key_param = NULL;
- const char *inmode = "r", *outmode = "w";
int flags = CMS_DETACHED, noout = 0, print = 0, keyidx = -1, vpmtouched =
0;
int informat = FORMAT_SMIME, outformat = FORMAT_SMIME;
@@ -689,18 +688,14 @@ int cms_main(int argc, char **argv)
if (!(operation & SMIME_SIGNERS))
flags &= ~CMS_DETACHED;
- if (operation & SMIME_OP) {
- outmode = WB(outformat);
- } else {
+ if (!(operation & SMIME_OP)) {
if (flags & CMS_BINARY)
- outmode = "wb";
+ outformat = FORMAT_BINARY;
}
- if (operation & SMIME_IP) {
- inmode = RB(informat);
- } else {
+ if (!(operation & SMIME_IP)) {
if (flags & CMS_BINARY)
- inmode = "rb";
+ informat = FORMAT_BINARY;
}
if (operation == SMIME_ENCRYPT) {
@@ -770,7 +765,7 @@ int cms_main(int argc, char **argv)
goto end;
}
- in = bio_open_default(infile, inmode);
+ in = bio_open_default(infile, 'r', informat);
if (in == NULL)
goto end;
@@ -834,7 +829,7 @@ int cms_main(int argc, char **argv)
}
}
- out = bio_open_default(outfile, outmode);
+ out = bio_open_default(outfile, 'w', outformat);
if (out == NULL)
goto end;