/*
 * getdtablesize -- call getrlimit
 */

#include "hostenv.h"
#if	!defined(USE_GETDTABLESIZE) && !defined(USE_NOFILE)

#include <sys/resource.h>
getdtablesize()
{
        struct rlimit res;
        int stat;
#ifdef	RLIMIT_NFILE /* Usually _POSIX_SOURCE, but also some others.. */
        stat = getrlimit(RLIMIT_NFILE, &res);
#else	/* Of BSD fame.. */
        stat = getrlimit(RLIMIT_NOFILE, &res);
#endif
        if (stat < 0) return(-1);
        return(res.rlim_cur);
}

#endif	/* !USE_GETDTABLESIZE */

#ifdef	USE_NOFILE /* XX: AARGH... Linux is sticky thing to port to.. */

int
getdtablesize()
{
	return 256; 
}
#endif
