/* @(#)fdup.c	1.11 00/12/03 Copyright 1986, 1995 J. Schilling */
/*
 *	Copyright (c) 1986, 1995 J. Schilling
 */
/*@@C@@*/

#include "io.h"

/*
 * XXX We need to switch to fseeko()/ftello() sometime in the future.
 * XXX See io.h hack.
 */

EXPORT FILE *
fdup(f)
	register FILE  *f;
{
	int  newfd;

	down(f);
	if ((newfd = dup(fileno(f))) < 0)
        	return (FILE *) NULL;

	lseek(newfd, ftell(f), SEEK_SET);
	return (_fcons((FILE *)0, newfd, (FI_READ | FI_WRITE | FI_CLOSE)));
} 

