delorie.com/djgpp/doc/libc/libc_357.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

__FSEXT_alloc_fd

Syntax

 
#include <sys/fsext.h>

int __FSEXT_alloc_fd(__FSEXT_Function *_function);

Description

This function is part of the File System Extensions. It is used by extensions that fully emulate the I/O functions, and thus don't have a corresponding DOS file handle. Upon the first call, this function opens DOS's `NUL' device, so as to allocate a handle that DOS won't then reuse. Upon subsequent calls, that handle is duplicated by calling the DOS dup function; this makes all of the handles use a single entry in the System File Table, and thus be independent of what the `FILES=' parameter of `CONFIG.SYS' says. __FSEXT_alloc_fd also assigns the handler function for the handle it returns.

The module is responsible for calling _close on the descriptor after setting the handler function to zero in the extended close handler.

Return Value

If successful, a new file descriptor is returned. On error, a negative number is returned and errno is set to indicate the error.

Portability

ANSI/ISO C No
POSIX No

Example

 
int socket()
{
  int fd = __FSEXT_alloc_fd(socket_handler);
  init_socket(fd);
  return fd;
}


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004