/* imphandle.c (rsxnt) -- Copyright (c) 1996-1997 Rainer Schnitker */

#include "rsxnt.h"

int __imphandle(int fd)
{
    if (fd > 0 && fd < N_FILES) {

        EMXPROCESS *p = _rsxnt_get_process_ptr();

        if (p->file[fd].f_handle == INVALID_HANDLE_VALUE) {
            p->file[fd].f_handle = (HANDLE) fd;
            p->file[fd].f_mode = _rsxnt_get_ht_type((HANDLE) fd);
            p->file[fd].f_flags = 0;
            return fd;
        }
    }
    return _rsxnt_errno(EINVAL);
}
