/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include "sfhdr.h"
** If f is not nil, it is taken as an existing stream that should be
** closed and its structure reused for the new stream.
**
** Written by Kiem-Phong Vo.
*/
#if _BLD_sfio && defined(__EXPORT__)
#define extern __EXPORT__
#endif
extern
#undef extern
#if __STD_C
#else
Sfio_t* f; /* old stream structure */
char* mode; /* mode of the stream */
#endif
{
SFMTXDECL(f);
/* get the control flags */
/* changing the control flags */
}
}
else /* make sure there is no buffered data */
{ if(sfsync(f) < 0)
}
if(f->file >= 0 )
{ /* set file access control */
}
#if !O_cloexec
if (fflags & SF_FD_CLOEXEC)
SETCLOEXEC(f->file);
#endif
}
SFMTXRETURN(f,f);
}
-1,sflags);
}
else
{ if(!file)
#if _has_oflags /* open the file */
errno = 0;
#else
errno = 0;
if(fd >= 0)
}
errno = 0;
}
}
errno = 0;
errno = 0;
}
}
#endif
if(fd < 0)
/* we may have to reset the file descriptor to its old value */
}
return f;
}
#if __STD_C
#else
int* oflagsp;
int* fflagsp;
int* uflagp;
#endif
{
if(!mode)
return 0;
/* construct the open flags */
while(1) switch(*mode++)
{
case 'a' :
continue;
case 'b' :
continue;
case 'e' :
fflags |= SF_FD_CLOEXEC;
continue;
case 'm' :
uflag = 0;
continue;
case 'r' :
continue;
case 's' :
continue;
case 't' :
continue;
case 'u' :
uflag = 1;
continue;
case 'w' :
continue;
case 'x' :
continue;
case 'F':
/* stdio compatibility -- fd >= FOPEN_MAX (or other magic number) ok */
continue;
case 'W' :
sflags |= SF_WCWIDTH;
uflag = 0;
continue;
case '+' :
if(sflags)
continue;
default :
#endif
if(oflagsp)
if(fflagsp)
if(uflagp)
return sflags;
}
}