Back to index

glibc  2.9
Defines | Functions
iolibio.h File Reference
#include <libio.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define _IO_pos_BAD   ((_IO_off64_t)(-1))
#define _IO_clearerr(FP)   ((FP)->_flags &= ~(_IO_ERR_SEEN|_IO_EOF_SEEN))
#define _IO_fseek(__fp, __offset, __whence)
#define _IO_rewind(FILE)   (void) _IO_seekoff_unlocked (FILE, 0, 0, _IOS_INPUT|_IOS_OUTPUT)
#define _IO_vprintf(FORMAT, ARGS)   INTUSE(_IO_vfprintf) (_IO_stdout, FORMAT, ARGS)
#define _IO_freopen(FILENAME, MODE, FP)
#define _IO_old_freopen(FILENAME, MODE, FP)   (_IO_old_file_close_it (FP), _IO_old_file_fopen(FP, FILENAME, MODE))
#define _IO_freopen64(FILENAME, MODE, FP)
#define _IO_fileno(FP)   ((FP)->_fileno)
#define _IO_pclose   _IO_fclose
#define _IO_setbuf(_FP, _BUF)   INTUSE(_IO_setbuffer)(_FP, _BUF, _IO_BUFSIZ)
#define _IO_setlinebuf(_FP)   INTUSE(_IO_setvbuf)(_FP, NULL, 1, 0)

Functions

int _IO_fclose (_IO_FILE *)
int _IO_new_fclose (_IO_FILE *)
int _IO_old_fclose (_IO_FILE *)
_IO_FILE_IO_fdopen (int, const char *) __THROW
_IO_FILE_IO_old_fdopen (int, const char *) __THROW
_IO_FILE_IO_new_fdopen (int, const char *) __THROW
int _IO_fflush (_IO_FILE *)
int _IO_fgetpos (_IO_FILE *, _IO_fpos_t *)
int _IO_fgetpos64 (_IO_FILE *, _IO_fpos64_t *)
char * _IO_fgets (char *, int, _IO_FILE *)
_IO_FILE_IO_fopen (const char *, const char *)
_IO_FILE_IO_old_fopen (const char *, const char *)
_IO_FILE_IO_new_fopen (const char *, const char *)
_IO_FILE_IO_fopen64 (const char *, const char *)
_IO_FILE__fopen_internal (const char *, const char *, int)
_IO_FILE__fopen_maybe_mmap (_IO_FILE *) __THROW
int _IO_fprintf (_IO_FILE *, const char *,...)
int _IO_fputs (const char *, _IO_FILE *)
 libc_hidden_proto (_IO_fputs) extern int _IO_fsetpos(_IO_FILE *
const _IO_fpos_t *int _IO_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *)
long int _IO_ftell (_IO_FILE *)
_IO_size_t _IO_fread (void *, _IO_size_t, _IO_size_t, _IO_FILE *)
_IO_size_t _IO_fwrite (const void *, _IO_size_t, _IO_size_t, _IO_FILE *)
char * _IO_gets (char *)
void _IO_perror (const char *) __THROW
int _IO_printf (const char *,...)
int _IO_puts (const char *)
int _IO_scanf (const char *,...)
void _IO_setbuffer (_IO_FILE *, char *, _IO_size_t) __THROW
int _IO_setvbuf (_IO_FILE *, char *, int, _IO_size_t) __THROW
int _IO_sscanf (const char *, const char *,...) __THROW
int _IO_sprintf (char *, const char *,...) __THROW
int _IO_ungetc (int, _IO_FILE *) __THROW
int _IO_vsscanf (const char *, const char *, _IO_va_list) __THROW
int _IO_vsprintf (char *, const char *, _IO_va_list) __THROW
int _IO_vswprintf (wchar_t *, _IO_size_t, const wchar_t *, _IO_va_list) __THROW
int _IO_obstack_vprintf (struct obstack *, const char *, _IO_va_list) __THROW
int _IO_obstack_printf (struct obstack *, const char *,...) __THROW
_IO_FILE_IO_popen (const char *, const char *) __THROW
_IO_FILE_IO_new_popen (const char *, const char *) __THROW
_IO_FILE_IO_old_popen (const char *, const char *) __THROW
int __new_pclose (_IO_FILE *) __THROW
int __old_pclose (_IO_FILE *) __THROW
_IO_FILE__new_freopen (const char *, const char *, _IO_FILE *) __THROW
_IO_FILE__old_freopen (const char *, const char *, _IO_FILE *) __THROW
void _IO_setbuffer_internal (_IO_FILE *, char *, _IO_size_t) __THROW
_IO_size_t _IO_fread_internal (void *, _IO_size_t, _IO_size_t, _IO_FILE *) __THROW
_IO_FILE_IO_fdopen_internal (int, const char *) __THROW
int _IO_vsprintf_internal (char *, const char *, _IO_va_list) __THROW
int _IO_fflush_internal (_IO_FILE *)
_IO_size_t _IO_fwrite_internal (const void *, _IO_size_t, _IO_size_t, _IO_FILE *)
long int _IO_ftell_internal (_IO_FILE *)
int _IO_fputs_internal (const char *, _IO_FILE *)
int _IO_setvbuf_internal (_IO_FILE *, char *, int, _IO_size_t) __THROW

Define Documentation

#define _IO_clearerr (   FP)    ((FP)->_flags &= ~(_IO_ERR_SEEN|_IO_EOF_SEEN))

Definition at line 56 of file iolibio.h.

#define _IO_fileno (   FP)    ((FP)->_fileno)

Definition at line 72 of file iolibio.h.

#define _IO_freopen (   FILENAME,
  MODE,
  FP 
)
Value:
(INTUSE(_IO_file_close_it)(FP), \
   INTUSE(_IO_file_fopen)(FP, FILENAME, MODE, 1))

Definition at line 64 of file iolibio.h.

#define _IO_freopen64 (   FILENAME,
  MODE,
  FP 
)
Value:
(INTUSE(_IO_file_close_it)(FP), \
   INTUSE(_IO_file_fopen)(FP, FILENAME, MODE, 0))

Definition at line 69 of file iolibio.h.

#define _IO_fseek (   __fp,
  __offset,
  __whence 
)
Value:

Definition at line 57 of file iolibio.h.

#define _IO_old_freopen (   FILENAME,
  MODE,
  FP 
)    (_IO_old_file_close_it (FP), _IO_old_file_fopen(FP, FILENAME, MODE))

Definition at line 67 of file iolibio.h.

#define _IO_pclose   _IO_fclose

Definition at line 78 of file iolibio.h.

#define _IO_pos_BAD   ((_IO_off64_t)(-1))

Definition at line 54 of file iolibio.h.

#define _IO_rewind (   FILE)    (void) _IO_seekoff_unlocked (FILE, 0, 0, _IOS_INPUT|_IOS_OUTPUT)

Definition at line 60 of file iolibio.h.

#define _IO_setbuf (   _FP,
  _BUF 
)    INTUSE(_IO_setbuffer)(_FP, _BUF, _IO_BUFSIZ)

Definition at line 79 of file iolibio.h.

#define _IO_setlinebuf (   _FP)    INTUSE(_IO_setvbuf)(_FP, NULL, 1, 0)

Definition at line 80 of file iolibio.h.

#define _IO_vprintf (   FORMAT,
  ARGS 
)    INTUSE(_IO_vfprintf) (_IO_stdout, FORMAT, ARGS)

Definition at line 62 of file iolibio.h.


Function Documentation

_IO_FILE* __fopen_internal ( const char *  ,
const char *  ,
int   
)

Definition at line 41 of file iofopen.c.

{
#ifdef _G_HAVE_MMAP
  if ((fp->_flags2 & _IO_FLAGS2_MMAP) && (fp->_flags & _IO_NO_WRITES))
    {
      /* Since this is read-only, we might be able to mmap the contents
        directly.  We delay the decision until the first read attempt by
        giving it a jump table containing functions that choose mmap or
        vanilla file operations and reset the jump table accordingly.  */

      if (fp->_mode <= 0)
       _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps_maybe_mmap;
      else
       _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_wfile_jumps_maybe_mmap;
      fp->_wide_data->_wide_vtable = &_IO_wfile_jumps_maybe_mmap;
    }
#endif
  return fp;
}

Here is the caller graph for this function:

_IO_FILE* __new_freopen ( const char *  ,
const char *  ,
_IO_FILE  
)
_IO_FILE* __old_freopen ( const char *  ,
const char *  ,
_IO_FILE  
)
_IO_FILE* _IO_fdopen ( int  ,
const char *   
)

Here is the caller graph for this function:

_IO_FILE* _IO_fdopen_internal ( int  ,
const char *   
)

Definition at line 33 of file iofflush.c.

{
  if (fp == NULL)
    return INTUSE(_IO_flush_all) ();
  else
    {
      int result;
      CHECK_FILE (fp, EOF);
      _IO_acquire_lock (fp);
      result = _IO_SYNC (fp) ? EOF : 0;
      _IO_release_lock (fp);
      return result;
    }
}

Here is the call graph for this function:

int _IO_fgetpos ( _IO_FILE ,
_IO_fpos_t  
)
char* _IO_fgets ( char *  ,
int  ,
_IO_FILE  
)

Definition at line 33 of file iofgets.c.

{
  _IO_size_t count;
  char *result;
  int old_error;
  CHECK_FILE (fp, NULL);
  if (n <= 0)
    return NULL;
  if (__builtin_expect (n == 1, 0))
    {
      /* Another irregular case: since we have to store a NUL byte and
        there is only room for exactly one byte, we don't have to
        read anything.  */
      buf[0] = '\0';
      return buf;
    }
  _IO_acquire_lock (fp);
  /* This is very tricky since a file descriptor may be in the
     non-blocking mode. The error flag doesn't mean much in this
     case. We return an error only when there is a new error. */
  old_error = fp->_IO_file_flags & _IO_ERR_SEEN;
  fp->_IO_file_flags &= ~_IO_ERR_SEEN;
  count = INTUSE(_IO_getline) (fp, buf, n - 1, '\n', 1);
  /* If we read in some bytes and errno is EAGAIN, that error will
     be reported for next read. */
  if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN)
                   && errno != EAGAIN))
    result = NULL;
  else
    {
      buf[count] = '\0';
      result = buf;
    }
  fp->_IO_file_flags |= old_error;
  _IO_release_lock (fp);
  return result;
}

Here is the call graph for this function:

_IO_FILE* _IO_fopen ( const char *  ,
const char *   
)
_IO_FILE* _IO_fopen64 ( const char *  ,
const char *   
)
int _IO_fprintf ( _IO_FILE ,
const char *  ,
  ... 
)
int _IO_fputs ( const char *  ,
_IO_FILE  
)
int _IO_fputs_internal ( const char *  ,
_IO_FILE  
)
_IO_size_t _IO_fread ( void *  ,
_IO_size_t  ,
_IO_size_t  ,
_IO_FILE  
)

Definition at line 32 of file iofread.c.

{
  _IO_size_t bytes_requested = size * count;
  _IO_size_t bytes_read;
  CHECK_FILE (fp, 0);
  if (bytes_requested == 0)
    return 0;
  _IO_acquire_lock (fp);
  bytes_read = INTUSE(_IO_sgetn) (fp, (char *) buf, bytes_requested);
  _IO_release_lock (fp);
  return bytes_requested == bytes_read ? count : bytes_read / size;
}

Here is the call graph for this function:

long int _IO_ftell ( _IO_FILE )

Definition at line 35 of file ioftell.c.

{
  _IO_off64_t pos;
  CHECK_FILE (fp, -1L);
  _IO_acquire_lock (fp);
  pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0);
  if (_IO_in_backup (fp) && pos != _IO_pos_BAD)
    {
      if (_IO_vtable_offset (fp) != 0 || fp->_mode <= 0)
       pos -= fp->_IO_save_end - fp->_IO_save_base;
    }
  _IO_release_lock (fp);
  if (pos == _IO_pos_BAD)
    {
#ifdef EIO
      if (errno == 0)
       __set_errno (EIO);
#endif
      return -1L;
    }
  if ((_IO_off64_t) (long int) pos != pos)
    {
#ifdef EOVERFLOW
      __set_errno (EOVERFLOW);
#endif
      return -1L;
    }
  return pos;
}

Here is the call graph for this function:

_IO_size_t _IO_fwrite ( const void *  ,
_IO_size_t  ,
_IO_size_t  ,
_IO_FILE  
)
char* _IO_gets ( char *  )

Definition at line 32 of file iogets.c.

{
  _IO_size_t count;
  int ch;
  char *retval;

  _IO_acquire_lock (_IO_stdin);
  ch = _IO_getc_unlocked (_IO_stdin);
  if (ch == EOF)
    {
      retval = NULL;
      goto unlock_return;
    }
  if (ch == '\n')
    count = 0;
  else
    {
      /* This is very tricky since a file descriptor may be in the
        non-blocking mode. The error flag doesn't mean much in this
        case. We return an error only when there is a new error. */
      int old_error = _IO_stdin->_IO_file_flags & _IO_ERR_SEEN;
      _IO_stdin->_IO_file_flags &= ~_IO_ERR_SEEN;
      buf[0] = (char) ch;
      count = INTUSE(_IO_getline) (_IO_stdin, buf + 1, INT_MAX, '\n', 0) + 1;
      if (_IO_stdin->_IO_file_flags & _IO_ERR_SEEN)
       {
         retval = NULL;
         goto unlock_return;
       }
      else
       _IO_stdin->_IO_file_flags |= old_error;
    }
  buf[count] = 0;
  retval = buf;
unlock_return:
  _IO_release_lock (_IO_stdin);
  return retval;
}

Here is the call graph for this function:

Definition at line 41 of file iofclose.c.

{
  int status;

  CHECK_FILE(fp, EOF);

#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
  /* We desperately try to help programs which are using streams in a
     strange way and mix old and new functions.  Detect old streams
     here.  */
  if (_IO_vtable_offset (fp) != 0)
    return _IO_old_fclose (fp);
#endif

  /* First unlink the stream.  */
  if (fp->_IO_file_flags & _IO_IS_FILEBUF)
    INTUSE(_IO_un_link) ((struct _IO_FILE_plus *) fp);

  _IO_acquire_lock (fp);
  if (fp->_IO_file_flags & _IO_IS_FILEBUF)
    status = INTUSE(_IO_file_close_it) (fp);
  else
    status = fp->_flags & _IO_ERR_SEEN ? -1 : 0;
  _IO_release_lock (fp);
  _IO_FINISH (fp);
  if (fp->_mode > 0)
    {
#if _LIBC
      /* This stream has a wide orientation.  This means we have to free
        the conversion functions.  */
      struct _IO_codecvt *cc = fp->_codecvt;

      __libc_lock_lock (__gconv_lock);
      __gconv_release_step (cc->__cd_in.__cd.__steps);
      __gconv_release_step (cc->__cd_out.__cd.__steps);
      __libc_lock_unlock (__gconv_lock);
#endif
    }
  else
    {
      if (_IO_have_backup (fp))
       INTUSE(_IO_free_backup_area) (fp);
    }
  if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr)
    {
      fp->_IO_file_flags = 0;
      free(fp);
    }

  return status;
}

Here is the call graph for this function:

_IO_FILE* _IO_new_fdopen ( int  ,
const char *   
)

Definition at line 48 of file iofdopen.c.

{
  int read_write;
  int posix_mode = 0;
  struct locked_FILE
  {
    struct _IO_FILE_plus fp;
#ifdef _IO_MTSAFE_IO
    _IO_lock_t lock;
#endif
    struct _IO_wide_data wd;
  } *new_f;
  int fd_flags;
  int i;
  int use_mmap = 0;

  switch (*mode)
    {
    case 'r':
      read_write = _IO_NO_WRITES;
      break;
    case 'w':
      read_write = _IO_NO_READS;
      break;
    case 'a':
      posix_mode = O_APPEND;
      read_write = _IO_NO_READS|_IO_IS_APPENDING;
      break;
    default:
      MAYBE_SET_EINVAL;
      return NULL;
  }
  for (i = 1; i < 5; ++i)
    {
      switch (*++mode)
       {
       case '\0':
         break;
       case '+':
         read_write &= _IO_IS_APPENDING;
         break;
       case 'm':
         use_mmap = 1;
         continue;
       case 'x':
       case 'b':
       default:
         /* Ignore */
         continue;
       }
      break;
    }
#ifdef F_GETFL
  fd_flags = _IO_fcntl (fd, F_GETFL);
#ifndef O_ACCMODE
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
#endif
  if (fd_flags == -1)
    return NULL;

  if (((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES))
      || ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS)))
    {
      MAYBE_SET_EINVAL;
      return NULL;
    }

  /* The May 93 draft of P1003.4/D14.1 (redesignated as 1003.1b)
     [System Application Program Interface (API) Amendment 1:
     Realtime Extensions], Rationale B.8.3.3
     Open a Stream on a File Descriptor says:

         Although not explicitly required by POSIX.1, a good
         implementation of append ("a") mode would cause the
         O_APPEND flag to be set.

     (Historical implementations [such as Solaris2] do a one-time
     seek in fdopen.)

     However, we do not turn O_APPEND off if the mode is "w" (even
     though that would seem consistent) because that would be more
     likely to break historical programs.
     */
  if ((posix_mode & O_APPEND) && !(fd_flags & O_APPEND))
    {
#ifdef F_SETFL
      if (_IO_fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
#endif
       return NULL;
    }
#endif

  new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
  if (new_f == NULL)
    return NULL;
#ifdef _IO_MTSAFE_IO
  new_f->fp.file._lock = &new_f->lock;
#endif
  /* Set up initially to use the `maybe_mmap' jump tables rather than using
     __fopen_maybe_mmap to do it, because we need them in place before we
     call _IO_file_attach or else it will allocate a buffer immediately.  */
  _IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd,
#ifdef _G_HAVE_MMAP
              (use_mmap && (read_write & _IO_NO_WRITES))
              ? &_IO_wfile_jumps_maybe_mmap :
#endif
              &_IO_wfile_jumps);
  _IO_JUMPS (&new_f->fp) =
#ifdef _G_HAVE_MMAP
    (use_mmap && (read_write & _IO_NO_WRITES)) ? &_IO_file_jumps_maybe_mmap :
#endif
      &_IO_file_jumps;
  INTUSE(_IO_file_init) (&new_f->fp);
#if  !_IO_UNIFIED_JUMPTABLES
  new_f->fp.vtable = NULL;
#endif
  if (INTUSE(_IO_file_attach) ((_IO_FILE *) &new_f->fp, fd) == NULL)
    {
      INTUSE(_IO_setb) (&new_f->fp.file, NULL, NULL, 0);
      INTUSE(_IO_un_link) (&new_f->fp);
      free (new_f);
      return NULL;
    }
  new_f->fp.file._flags &= ~_IO_DELETE_DONT_CLOSE;

  new_f->fp.file._IO_file_flags =
    _IO_mask_flags (&new_f->fp.file, read_write,
                  _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);

  return &new_f->fp.file;
}

Here is the call graph for this function:

_IO_FILE* _IO_new_fopen ( const char *  ,
const char *   
)
_IO_FILE* _IO_new_popen ( const char *  ,
const char *   
)
int _IO_obstack_printf ( struct obstack ,
const char *  ,
  ... 
)
int _IO_obstack_vprintf ( struct obstack ,
const char *  ,
_IO_va_list   
)

Here is the caller graph for this function:

Here is the caller graph for this function:

_IO_FILE* _IO_old_fdopen ( int  ,
const char *   
)
_IO_FILE* _IO_old_fopen ( const char *  ,
const char *   
)
_IO_FILE* _IO_old_popen ( const char *  ,
const char *   
)
void _IO_perror ( const char *  )
_IO_FILE* _IO_popen ( const char *  ,
const char *   
)
int _IO_printf ( const char *  ,
  ... 
)
int _IO_puts ( const char *  )
int _IO_scanf ( const char *  ,
  ... 
)
void _IO_setbuffer ( _IO_FILE ,
char *  ,
_IO_size_t   
)

Definition at line 32 of file iosetbuffer.c.

{
  CHECK_FILE (fp, );
  _IO_acquire_lock (fp);
  fp->_flags &= ~_IO_LINE_BUF;
  if (!buf)
    size = 0;
  (void) _IO_SETBUF (fp, buf, size);
  if (_IO_vtable_offset (fp) == 0 && fp->_mode == 0 && _IO_CHECK_WIDE (fp))
    /* We also have to set the buffer using the wide char function.  */
    (void) _IO_WSETBUF (fp, buf, size);
  _IO_release_lock (fp);
}

Here is the caller graph for this function:

void _IO_setbuffer_internal ( _IO_FILE ,
char *  ,
_IO_size_t   
)
int _IO_setvbuf ( _IO_FILE ,
char *  ,
int  ,
_IO_size_t   
)

Definition at line 36 of file iosetvbuf.c.

{
  int result;
  CHECK_FILE (fp, EOF);
  _IO_acquire_lock (fp);
  switch (mode)
    {
    case _IOFBF:
      fp->_IO_file_flags &= ~(_IO_LINE_BUF|_IO_UNBUFFERED);
      if (buf == NULL)
       {
         if (fp->_IO_buf_base == NULL)
           {
             /* There is no flag to distinguish between "fully buffered
               mode has been explicitly set" as opposed to "line
               buffering has not been explicitly set".  In both
               cases, _IO_LINE_BUF is off.  If this is a tty, and
               _IO_filedoalloc later gets called, it cannot know if
               it should set the _IO_LINE_BUF flag (because that is
               the default), or not (because we have explicitly asked
               for fully buffered mode).  So we make sure a buffer
               gets allocated now, and explicitly turn off line
               buffering.

               A possibly cleaner alternative would be to add an
               extra flag, but then flags are a finite resource.  */
             if (_IO_DOALLOCATE (fp) < 0)
              {
                result = EOF;
                goto unlock_return;
              }
             fp->_IO_file_flags &= ~_IO_LINE_BUF;
           }
         result = 0;
         goto unlock_return;
       }
      break;
    case _IOLBF:
      fp->_IO_file_flags &= ~_IO_UNBUFFERED;
      fp->_IO_file_flags |= _IO_LINE_BUF;
      if (buf == NULL)
       {
         result = 0;
         goto unlock_return;
       }
      break;
    case _IONBF:
      fp->_IO_file_flags &= ~_IO_LINE_BUF;
      fp->_IO_file_flags |= _IO_UNBUFFERED;
      buf = NULL;
      size = 0;
      break;
    default:
      result = EOF;
      goto unlock_return;
    }
  result = _IO_SETBUF (fp, buf, size) == NULL ? EOF : 0;

unlock_return:
  _IO_release_lock (fp);
  return result;
}

Here is the caller graph for this function:

int _IO_setvbuf_internal ( _IO_FILE ,
char *  ,
int  ,
_IO_size_t   
)
int _IO_sprintf ( char *  ,
const char *  ,
  ... 
)
int _IO_sscanf ( const char *  ,
const char *  ,
  ... 
)
int _IO_ungetc ( int  ,
_IO_FILE  
)

Definition at line 31 of file ioungetc.c.

{
  int result;
  CHECK_FILE (fp, EOF);
  if (c == EOF)
    return EOF;
  _IO_acquire_lock (fp); 
  result = INTUSE(_IO_sputbackc) (fp, (unsigned char) c);
  _IO_release_lock (fp);
  return result;
}

Here is the call graph for this function:

int _IO_vsprintf ( char *  ,
const char *  ,
_IO_va_list   
)

Here is the caller graph for this function:

int _IO_vsprintf_internal ( char *  ,
const char *  ,
_IO_va_list   
)
int _IO_vsscanf ( const char *  ,
const char *  ,
_IO_va_list   
)

Here is the caller graph for this function:

int _IO_vswprintf ( wchar_t *  ,
_IO_size_t  ,
const wchar_t *  ,
_IO_va_list   
)

Definition at line 96 of file vswprintf.c.

{
  _IO_wstrnfile sf;
  int ret;
  struct _IO_wide_data wd;
#ifdef _IO_MTSAFE_IO
  sf.f._sbf._f._lock = NULL;
#endif

  if (maxlen == 0)
    /* Since we have to write at least the terminating L'\0' a buffer
       length of zero always makes the function fail.  */
    return -1;

  _IO_no_init (&sf.f._sbf._f, _IO_USER_LOCK, 0, &wd, &_IO_wstrn_jumps);
  _IO_fwide (&sf.f._sbf._f, 1);
  string[0] = L'\0';
  _IO_wstr_init_static (&sf.f._sbf._f, string, maxlen - 1, string);
  ret = _IO_vfwprintf ((_IO_FILE *) &sf.f._sbf, format, args);

  if (sf.f._sbf._f._wide_data->_IO_buf_base == sf.overflow_buf)
    /* ISO C99 requires swprintf/vswprintf to return an error if the
       output does not fit in the provided buffer.  */
    return -1;

  /* Terminate the string.  */
  *sf.f._sbf._f._wide_data->_IO_write_ptr = '\0';

  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function: