/* $XConsortium: fcntl.c /main/3 1995/11/01 17:11:43 rswiston $ */ /*************************************************************** * * * AT&T - PROPRIETARY * * * * THIS IS PROPRIETARY SOURCE CODE LICENSED BY * * AT&T CORP. * * * * Copyright (c) 1995 AT&T Corp. * * All Rights Reserved * * * * This software is licensed by AT&T Corp. * * under the terms and conditions of the license in * * http://www.research.att.com/orgs/ssr/book/reuse * * * * This software was created by the * * Software Engineering Research Department * * AT&T Bell Laboratories * * * * For further information contact * * gsf@research.att.com * * * ***************************************************************/ /* : : generated by proto : : */ #if !defined(__PROTO__) #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) #if defined(__cplusplus) #define __MANGLE__ "C" #else #define __MANGLE__ #endif #define __STDARG__ #define __PROTO__(x) x #define __OTORP__(x) #define __PARAM__(n,o) n #if !defined(__STDC__) && !defined(__cplusplus) #if !defined(c_plusplus) #define const #endif #define signed #define void int #define volatile #define __V_ char #else #define __V_ void #endif #else #define __PROTO__(x) () #define __OTORP__(x) x #define __PARAM__(n,o) o #define __MANGLE__ #define __V_ char #define const #define signed #define void int #define volatile #endif #if defined(__cplusplus) || defined(c_plusplus) #define __VARARG__ ... #else #define __VARARG__ #endif #if defined(__STDARG__) #define __VA_START__(p,a) va_start(p,a) #else #define __VA_START__(p,a) va_start(p) #endif #endif #include #ifndef fcntl NoN(fcntl) #else #include #include #include #if F_SETFD >= _ast_F_LOCAL #if _sys_filio #include #endif #endif #if _lib_fcntl #undef fcntl extern __MANGLE__ int fcntl __PROTO__((int, int, ...)); #endif int _ast_fcntl __PARAM__((int fd, int op, ...), (va_alist)) __OTORP__(va_dcl) { __OTORP__(int fd; int op; ) int n; int save_errno; struct stat st; va_list ap; save_errno = errno; __VA_START__(ap, op); __OTORP__(fd = va_arg(ap, int );op = va_arg(ap, int );) if (op >= _ast_F_LOCAL) switch (op) { #if F_DUPFD >= _ast_F_LOCAL case F_DUPFD: n = va_arg(ap, int); op = dup2(fd, n); break; #endif #if F_GETFL >= _ast_F_LOCAL case F_GETFL: op = fstat(fd, &st); break; #endif #if F_SETFD >= _ast_F_LOCAL && defined(FIOCLEX) case F_SETFD: n = va_arg(ap, int); op = ioctl(fd, n == FD_CLOEXEC ? FIOCLEX : FIONCLEX, 0); break; #endif default: errno = EINVAL; op = -1; break; } else #if _lib_fcntl op = fcntl(fd, op, va_arg(ap, int)); #else { errno = EINVAL; op = -1; } #endif va_end(ap); return(op); } #endif