home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / tar-1.11.8-src.tgz / tar.out / fsf / tar / lib / safe-stat.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  2KB  |  61 lines

  1. /* safe-stat.h -- EINTR-safe interface to stat
  2.    Copyright (C) 1994 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.    
  18. /* Written by Jim Meyering <meyering@comco.com>.  */
  19.  
  20. #ifndef _safe_stat_h_
  21. #define _safe_stat_h_ 1
  22.  
  23. /* NOTE: you must include the following headers (in the listed order)
  24.    before this one: <sys/types.h>, <sys/stat.h>.  */
  25.  
  26. #include <errno.h>
  27.  
  28. #ifndef errno
  29. extern int errno;
  30. #endif
  31.  
  32. #ifndef __GNUC__
  33. #define __inline /* empty */
  34. #endif
  35.  
  36. /* On some systems, stat can return EINTR.  */
  37.  
  38. #ifndef EINTR
  39. # define SAFE_STAT(name, buf) stat (name, buf)
  40. #else
  41. # ifndef __static
  42. #   define __static static
  43. # endif
  44. # define SAFE_STAT(name, buf) safe_stat (name, buf)
  45. __static __inline int
  46. safe_stat (name, buf)
  47.      const char *name;
  48.      struct stat *buf;
  49. {
  50.   int ret;
  51.  
  52.   do
  53.     ret = stat (name, buf);
  54.   while (ret < 0 && errno == EINTR);
  55.  
  56.   return ret;
  57. }
  58. #endif
  59.  
  60. #endif /* _safe_stat_h_ */
  61.