Mohit Arya
Mohit Arya

Reputation: 94

Definition for function _IO_file_init and _IO_file_fopen

I am studying the implementation of C library function fopen() in Linux so I checked the glibc source code. In the source code I found how the fopen is implemented. But in the implementation of fopen two functions are called "_IO_file_init" and "_IO_file_fopen". But definition of these functions is not in the glibc source code.

Could any one please tell me where I can found the definition of functions "_IO_file_init" and "_IO_file_fopen".

Upvotes: 1

Views: 652

Answers (1)

mingganz
mingganz

Reputation: 363

The implementation is in file Fileops.c. Please note _IO_new_file_fopen is an alias of _IO_file_fopen.

_IO_FILE *
_IO_new_file_fopen (fp, filename, mode, is32not64)
     _IO_FILE *fp;
     const char *filename;
     const char *mode;
     int is32not64;
{
  int oflags = 0, omode;
  int read_write;
  int oprot = 0666;
  int i;
  _IO_FILE *result;
#ifdef _LIBC
  const char *cs;
  const char *last_recognized;
#endif

  if (_IO_file_is_open (fp))
    return 0;
  switch (*mode)
    {
    case 'r':
      omode = O_RDONLY;
...
}

BTW, I am looking at glic-2.19.

Upvotes: 1

Related Questions