From 4cdfa7814cda254acabe1040a2b2d0c4f5bc4295 Mon Sep 17 00:00:00 2001 From: markm Date: Thu, 21 Mar 2002 22:50:02 +0000 Subject: Vendor import of OPIE 2.4 --- contrib/opie/libopie/open.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'contrib/opie/libopie/open.c') 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 . 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; } -- cgit v1.1