1 /* @(#)cvmod.c 2.9 04/08/08 Copyright 1986, 1995-2003 J. Schilling */ 2 /* 3 * Copyright (c) 1986, 1995-2003 J. Schilling 4 */ 5 /* 6 * The contents of this file are subject to the terms of the 7 * Common Development and Distribution License, Version 1.0 only 8 * (the "License"). You may not use this file except in compliance 9 * with the License. 10 * 11 * See the file CDDL.Schily.txt in this distribution for details. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file CDDL.Schily.txt from this distribution. 15 */ 16 17 #include "schilyio.h" 18 19 #ifndef O_BINARY 20 #define O_BINARY 0 21 #endif 22 #ifndef O_LARGEFILE 23 #define O_LARGEFILE 0 24 #endif 25 26 EXPORT int 27 _cvmod(mode, omode, flag) 28 const char *mode; 29 int *omode; 30 int *flag; 31 { 32 while (*mode) { 33 switch (*mode) { 34 35 case 'r': *omode |= O_RDONLY; *flag |= FI_READ; break; 36 case 'w': *omode |= O_WRONLY; *flag |= FI_WRITE; break; 37 case 'e': *omode |= O_EXCL; break; 38 case 'c': *omode |= O_CREAT; *flag |= FI_CREATE; break; 39 case 't': *omode |= O_TRUNC; *flag |= FI_TRUNC; break; 40 case 'a': *omode |= O_APPEND; *flag |= FI_APPEND; break; 41 case 'u': *flag |= FI_UNBUF; break; 42 /* dummy on UNIX */ 43 case 'b': *omode |= O_BINARY; *flag |= FI_BINARY; break; 44 /* 45 * XXX do we need this ? 46 * XXX May this be a problem? 47 */ 48 case 'l': *omode |= O_LARGEFILE; break; 49 default: raisecond(_badmode, 0L); 50 return (0); 51 } 52 mode++; 53 } 54 if (*flag & FI_READ && *flag & FI_WRITE) { 55 *omode &= ~(O_RDONLY|O_WRONLY); 56 *omode |= O_RDWR; 57 } 58 return (1); 59 } 60