]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - libio/oldfileops.c
Update copyright notices with scripts/update-copyrights.
[thirdparty/glibc.git] / libio / oldfileops.c
index be99a2500c3a9ab1187735109dd955f67cb0be5c..80e4b57ee2e71bccaf684f34248dc9a27bfd7e97 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997-2004, 2005, 2007, 2011
-   Free Software Foundation, Inc.
+/* Copyright (C) 1993-2013 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Per Bothner <bothner@cygnus.com>.
 
@@ -14,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -42,9 +40,7 @@
 #include <sys/stat.h>
 #include <string.h>
 #include <errno.h>
-#ifdef __STDC__
 #include <stdlib.h>
-#endif
 #ifndef errno
 extern int errno;
 #endif
@@ -80,7 +76,7 @@ extern int errno;
    to _IO_buf_base, though not necessarily if we have switched from
    get mode to put mode.  (The reason is to maintain the invariant
    that _IO_read_end corresponds to the external file position.)
-   _IO_write_base is non-NULL and usually equal to _IO_base_base.
+   _IO_write_base is non-NULL and usually equal to _IO_buf_base.
    We also have _IO_write_end == _IO_buf_end, but only in fully buffered mode.
    The un-flushed character are those between _IO_write_base and _IO_write_ptr.
 
@@ -126,7 +122,7 @@ _IO_old_file_init (fp)
   fp->file._old_offset = _IO_pos_BAD;
   fp->file._IO_file_flags |= CLOSED_FILEBUF_FLAGS;
 
-  INTUSE(_IO_link_in) (fp);
+  _IO_link_in (fp);
   fp->file._vtable_offset = ((int) sizeof (struct _IO_FILE)
                             - (int) sizeof (struct _IO_FILE_complete));
   fp->file._fileno = -1;
@@ -153,16 +149,17 @@ _IO_old_file_close_it (fp)
 
   write_status = _IO_old_do_flush (fp);
 
-  INTUSE(_IO_unsave_markers) (fp);
+  _IO_unsave_markers (fp);
 
-  close_status = _IO_SYSCLOSE (fp);
+  close_status = ((fp->_flags2 & _IO_FLAGS2_NOCLOSE) == 0
+                 ? _IO_SYSCLOSE (fp) : 0);
 
   /* Free buffer. */
-  INTUSE(_IO_setb) (fp, NULL, NULL, 0);
+  _IO_setb (fp, NULL, NULL, 0);
   _IO_setg (fp, NULL, NULL, NULL);
   _IO_setp (fp, NULL, NULL);
 
-  INTUSE(_IO_un_link) ((struct _IO_FILE_plus *) fp);
+  _IO_un_link ((struct _IO_FILE_plus *) fp);
   fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS;
   fp->_fileno = -1;
   fp->_old_offset = _IO_pos_BAD;
@@ -182,7 +179,7 @@ _IO_old_file_finish (fp, dummy)
       if (!(fp->_flags & _IO_DELETE_DONT_CLOSE))
        _IO_SYSCLOSE (fp);
     }
-  INTUSE(_IO_default_finish) (fp, 0);
+  _IO_default_finish (fp, 0);
 }
 
 _IO_FILE *
@@ -231,7 +228,7 @@ _IO_old_file_fopen (fp, filename, mode)
     if (_IO_SEEKOFF (fp, (_IO_off_t)0, _IO_seek_end, _IOS_INPUT|_IOS_OUTPUT)
        == _IO_pos_BAD && errno != ESPIPE)
       return NULL;
-  INTUSE(_IO_link_in) ((struct _IO_FILE_plus *) fp);
+  _IO_link_in ((struct _IO_FILE_plus *) fp);
   return fp;
 }
 
@@ -313,8 +310,7 @@ old_do_write (fp, data, to_do)
     }
   count = _IO_SYSWRITE (fp, data, to_do);
   if (fp->_cur_column && count)
-    fp->_cur_column = INTUSE(_IO_adjust_column) (fp->_cur_column - 1, data,
-                                                count) + 1;
+    fp->_cur_column = _IO_adjust_column (fp->_cur_column - 1, data, count) + 1;
   _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
   fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base;
   fp->_IO_write_end = ((fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED))
@@ -351,15 +347,15 @@ _IO_old_file_underflow (fp)
          free (fp->_IO_save_base);
          fp->_flags &= ~_IO_IN_BACKUP;
        }
-      INTUSE(_IO_doallocbuf) (fp);
+      _IO_doallocbuf (fp);
     }
 
   /* Flush all line buffered files before reading. */
   /* FIXME This can/should be moved to genops ?? */
   if (fp->_flags & (_IO_LINE_BUF|_IO_UNBUFFERED))
-    INTUSE(_IO_flush_all_linebuffered) ();
+    _IO_flush_all_linebuffered ();
 
-  INTUSE(_IO_switch_to_get_mode) (fp);
+  _IO_switch_to_get_mode (fp);
 
   /* This is very tricky. We have to adjust those
      pointers before we call _IO_SYSREAD () since
@@ -405,7 +401,7 @@ _IO_old_file_overflow (f, ch)
       /* Allocate a buffer if needed. */
       if (f->_IO_write_base == 0)
        {
-         INTUSE(_IO_doallocbuf) (f);
+         _IO_doallocbuf (f);
          _IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base);
        }
       /* Otherwise must be currently reading.
@@ -496,13 +492,13 @@ _IO_old_file_seekoff (fp, offset, dir, mode)
   /* Flush unwritten characters.
      (This may do an unneeded write if we seek within the buffer.
      But to be able to switch to reading, we would need to set
-     egptr to ptr.  That can't be done in the current design,
+     egptr to pptr.  That can't be done in the current design,
      which assumes file_ptr() is eGptr.  Anyway, since we probably
      end up flushing when we close(), it doesn't make much difference.)
-     FIXME: simulate mem-papped files. */
+     FIXME: simulate mem-mapped files. */
 
   if (fp->_IO_write_ptr > fp->_IO_write_base || _IO_in_put_mode (fp))
-    if (INTUSE(_IO_switch_to_get_mode) (fp))
+    if (_IO_switch_to_get_mode (fp))
       return EOF;
 
   if (fp->_IO_buf_base == NULL)
@@ -513,7 +509,7 @@ _IO_old_file_seekoff (fp, offset, dir, mode)
          free (fp->_IO_read_base);
          fp->_flags &= ~_IO_IN_BACKUP;
        }
-      INTUSE(_IO_doallocbuf) (fp);
+      _IO_doallocbuf (fp);
       _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
       _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
     }
@@ -534,7 +530,7 @@ _IO_old_file_seekoff (fp, offset, dir, mode)
       break;
     case _IO_seek_end:
       {
-       struct _G_stat64 st;
+       struct stat64 st;
        if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG (st.st_mode))
          {
            offset += st.st_size;
@@ -599,7 +595,7 @@ _IO_old_file_seekoff (fp, offset, dir, mode)
     }
 
 #ifdef TODO
-  INTUSE(_IO_unsave_markers) (fp);
+  _IO_unsave_markers (fp);
 #endif
 
   if (fp->_flags & _IO_NO_READS)
@@ -639,7 +635,7 @@ _IO_old_file_seekoff (fp, offset, dir, mode)
   return offset;
  dumb:
 
-  INTUSE(_IO_unsave_markers) (fp);
+  _IO_unsave_markers (fp);
   result = _IO_SYSSEEK (fp, offset, dir);
   if (result != EOF)
     {
@@ -676,7 +672,7 @@ _IO_old_file_write (f, data, n)
        {
          f->_flags |= _IO_ERR_SEEN;
          break;
-        }
+       }
       to_do -= count;
       data = (void *) ((char *) data + count);
     }
@@ -763,18 +759,18 @@ _IO_old_file_xsputn (f, data, n)
       do_write = to_do - (block_size >= 128 ? to_do % block_size : 0);
 
       if (do_write)
-        {
+       {
          count = old_do_write (f, s, do_write);
          to_do -= count;
          if (count < do_write)
            return n - to_do;
-        }
+       }
 
       /* Now write out the remainder.  Normally, this will fit in the
         buffer, but it's somewhat messier for line-buffered files,
         so we let _IO_default_xsputn handle the general case. */
       if (to_do)
-       to_do -= INTUSE(_IO_default_xsputn) (f, s+do_write, to_do);
+       to_do -= _IO_default_xsputn (f, s+do_write, to_do);
     }
   return n - to_do;
 }
@@ -786,20 +782,20 @@ const struct _IO_jump_t _IO_old_file_jumps =
   JUMP_INIT(finish, _IO_old_file_finish),
   JUMP_INIT(overflow, _IO_old_file_overflow),
   JUMP_INIT(underflow, _IO_old_file_underflow),
-  JUMP_INIT(uflow, INTUSE(_IO_default_uflow)),
-  JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)),
+  JUMP_INIT(uflow, _IO_default_uflow),
+  JUMP_INIT(pbackfail, _IO_default_pbackfail),
   JUMP_INIT(xsputn, _IO_old_file_xsputn),
-  JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)),
+  JUMP_INIT(xsgetn, _IO_default_xsgetn),
   JUMP_INIT(seekoff, _IO_old_file_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, _IO_old_file_setbuf),
   JUMP_INIT(sync, _IO_old_file_sync),
-  JUMP_INIT(doallocate, INTUSE(_IO_file_doallocate)),
-  JUMP_INIT(read, INTUSE(_IO_file_read)),
+  JUMP_INIT(doallocate, _IO_file_doallocate),
+  JUMP_INIT(read, _IO_file_read),
   JUMP_INIT(write, _IO_old_file_write),
-  JUMP_INIT(seek, INTUSE(_IO_file_seek)),
-  JUMP_INIT(close, INTUSE(_IO_file_close)),
-  JUMP_INIT(stat, INTUSE(_IO_file_stat))
+  JUMP_INIT(seek, _IO_file_seek),
+  JUMP_INIT(close, _IO_file_close),
+  JUMP_INIT(stat, _IO_file_stat)
 };
 
 compat_symbol (libc, _IO_old_do_write, _IO_do_write, GLIBC_2_0);