summaryrefslogtreecommitdiffstats
path: root/contrib/opie/libopie/open.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/opie/libopie/open.c')
-rw-r--r--contrib/opie/libopie/open.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/contrib/opie/libopie/open.c b/contrib/opie/libopie/open.c
index dac03a8..c0c76c2 100644
--- a/contrib/opie/libopie/open.c
+++ b/contrib/opie/libopie/open.c
@@ -1,13 +1,15 @@
/* open.c: The __opieopen() library function.
%%% copyright-cmetz-96
-This software is Copyright 1996-1998 by Craig Metz, All Rights Reserved.
-The Inner Net License Version 2 applies to this software.
+This software is Copyright 1996-2001 by Craig Metz, All Rights Reserved.
+The Inner Net License Version 3 applies to this software.
You should have received a copy of the license with this software. If
you didn't get a copy, you may request one from <license@inner.net>.
History:
+ Modified by cmetz for OPIE 2.4. More portable way to get the mode
+ string for fopen.
Created by cmetz for OPIE 2.3.
*/
#include "opie_cfg.h"
@@ -51,9 +53,23 @@ FILE *__opieopen FUNCTION((file, rw, mode), char *file AND int rw AND int mode)
return NULL;
{
- char *fmodes[] = { "r", "r+", "a" };
-
- if (!(f = fopen(file, fmodes[rw])))
+ char *fmode;
+
+ switch(rw) {
+ case 0:
+ fmode = "r";
+ break;
+ case 1:
+ fmode = "r+";
+ break;
+ case 2:
+ fmode = "a";
+ break;
+ default:
+ return NULL;
+ };
+
+ if (!(f = fopen(file, fmode)))
return NULL;
}
OpenPOWER on IntegriCloud