/[pspp]/pspp/src/filename.c
ViewVC logotype

Diff of /pspp/src/filename.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by blp, Mon May 16 07:33:17 2005 UTC revision 1.14 by blp, Sun Jul 31 21:42:46 2005 UTC
# Line 20  Line 20 
20  #include <config.h>  #include <config.h>
21  #include "error.h"  #include "error.h"
22  #include "filename.h"  #include "filename.h"
23    #include <stdio.h>
24  #include <stdlib.h>  #include <stdlib.h>
25  #include <ctype.h>  #include <ctype.h>
26  #include <errno.h>  #include <errno.h>
# Line 28  Line 29 
29  #include "settings.h"  #include "settings.h"
30  #include "str.h"  #include "str.h"
31  #include "version.h"  #include "version.h"
32    #include "xreadlink.h"
33    
34    #include "gettext.h"
35    #define _(msgid) gettext (msgid)
36    
37  #include "debug-print.h"  #include "debug-print.h"
38    
# Line 38  Line 43 
43  #if HAVE_UNISTD_H  #if HAVE_UNISTD_H
44  #include <unistd.h>  #include <unistd.h>
45  #endif  #endif
46  #include "stat.h"  #include <sys/stat.h>
47    #include "stat-macros.h"
48  #endif  #endif
49    
50  #ifdef __WIN32__  #ifdef __WIN32__
# Line 619  fn_exists_p (const char *name) Line 625  fn_exists_p (const char *name)
625  #endif  #endif
626  }  }
627    
628  #ifdef unix  /* Returns the symbolic link value for FILENAME as a dynamically
629  /* Stolen from libc.info but heavily modified, this is a wrapper     allocated buffer, or a null pointer on failure. */
    around readlink() that allows for arbitrary filename length. */  
 char *  
 fn_readlink (const char *filename)  
 {  
   int size = 128;  
   
   for (;;)  
     {  
       char *buffer = xmalloc (size);  
       int nchars  = readlink (filename, buffer, size);  
       if (nchars == -1)  
         {  
           free (buffer);  
           return NULL;  
         }  
   
       if (nchars < size - 1)  
         {  
           buffer[nchars] = 0;  
           return buffer;  
         }  
       free (buffer);  
       size *= 2;  
     }  
 }  
 #else /* Not UNIX. */  
630  char *  char *
631  fn_readlink (const char *filename)  fn_readlink (const char *filename)
632  {  {
633    return NULL;    return xreadlink (filename, 32);
634  }  }
 #endif /* Not UNIX. */  
635    
636  /* Environment variables. */  /* Environment variables. */
637    

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26