Loading...
stdio/FreeBSD/fdopen.c Libc-1725.40.4 Libc-498
--- Libc/Libc-1725.40.4/stdio/FreeBSD/fdopen.c
+++ Libc/Libc-498/stdio/FreeBSD/fdopen.c
@@ -13,6 +13,10 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
@@ -30,20 +34,11 @@
  * SUCH DAMAGE.
  */
 
-#ifdef VARIANT_DARWINEXTSN
-#define _DARWIN_UNLIMITED_STREAMS
-#define COUNT	0
-#elif defined(VARIANT_LEGACY)
-#define COUNT	0
-#else
-#define COUNT	1
-#endif
-
 #if defined(LIBC_SCCS) && !defined(lint)
 static char sccsid[] = "@(#)fdopen.c	8.1 (Berkeley) 6/4/93";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/stdio/fdopen.c,v 1.11 2008/05/10 18:39:20 antoine Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/stdio/fdopen.c,v 1.7 2002/03/22 21:53:04 obrien Exp $");
 
 #include "namespace.h"
 #include <sys/types.h>
@@ -51,30 +46,20 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
-#include <limits.h>
 #include "un-namespace.h"
 #include "local.h"
-#include "libc_hooks_impl.h"
 
 FILE *
-fdopen(int fd, const char *mode)
+fdopen(fd, mode)
+	int fd;
+	const char *mode;
 {
 	FILE *fp;
+	static int nofile;
 	int flags, oflags, fdflags, tmp;
 
-	libc_hooks_will_read_cstring(mode);
-
-	/*
-	 * File descriptors are a full int, but _file is only a short.
-	 * If we get a valid file descriptor that is greater than
-	 * SHRT_MAX, then the fd will get sign-extended into an
-	 * invalid file descriptor.  Handle this case by failing the
-	 * open.
-	 */
-	if (fd > SHRT_MAX) {
-		errno = EMFILE;
-		return (NULL);
-	}
+	if (nofile == 0)
+		nofile = getdtablesize();
 
 	if ((flags = __sflags(mode, &oflags)) == 0)
 		return (NULL);
@@ -88,7 +73,7 @@
 		return (NULL);
 	}
 
-	if ((fp = __sfp(COUNT)) == NULL)
+	if ((fp = __sfp()) == NULL)
 		return (NULL);
 	fp->_flags = flags;
 	/*