/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	This program is distributed in the hope that it will be 
	useful, but WITHOUT ANY WARRANTY; without even the 
	implied warranty of MERCHANTABILITY or FITNESS FOR A 
	PARTICULAR PURPOSE.

**********************************************************************/


#include	<limits.h>
#include	"stream.h"
#include        <errno.h>
#include        <fcntl.h>
#include <io.h>

extern int now_open_files;

#define OPEN_MAX 508

int
s_check_resource()
{
	if ( now_open_files > (OPEN_MAX/2) )
		return -1;
	return 0;
}

int
s_check_resource2(int * op_max)
{
int ret;
        ret = 0;
		/*
        for ( i = 0 ; i <= OPEN_MAX ; i ++ ) {
                errno = 0;
				mode = fcntl(i,F_GETFL);
                if ( errno == EBADF )
                        continue;
                if(_eof(i) == -1 && errno == EBADF){
					continue;
				}
 
				ret ++;
        }
		*/
		if ( op_max )
			*op_max = OPEN_MAX;
        return ret;
}