r16516: Get rid of file_exists() as there already is a file_exist().
[samba.git] / source / lib / util / util_file.c
index 5e55b818731726db604d4332cb3eccdcf676f038..99432ad8bbd4a4a7bba76d27fcd512d663c49078 100644 (file)
@@ -34,7 +34,7 @@ read a line from a file with possible \ continuation chars.
 Blanks at the start or end of a line are stripped.
 The string will be allocated if s2 is NULL
 **/
-char *fgets_slash(char *s2,int maxlen,XFILE *f)
+_PUBLIC_ char *fgets_slash(char *s2,int maxlen,XFILE *f)
 {
   char *s=s2;
   int len = 0;
@@ -82,6 +82,7 @@ char *fgets_slash(char *s2,int maxlen,XFILE *f)
        case ' ':
          if (start_of_line)
            break;
+         /* fall through */
        default:
          start_of_line = False;
          s[len++] = c;
@@ -106,7 +107,7 @@ char *fgets_slash(char *s2,int maxlen,XFILE *f)
 /**
  * Read one line (data until next newline or eof) and allocate it 
  */
-char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint)
+_PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint)
 {
        char *data = NULL;
        ssize_t alloc_size = 0, offset = 0, ret;
@@ -156,8 +157,7 @@ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint)
 /**
 load a file into memory from a fd.
 **/
-
-char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
 {
        struct stat sbuf;
        char *p;
@@ -181,7 +181,7 @@ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
 /**
 load a file into memory
 **/
-char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx)
 {
        int fd;
        char *p;
@@ -202,7 +202,7 @@ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx)
 /**
 mmap (if possible) or read a file
 **/
-void *map_file(const char *fname, size_t size)
+_PUBLIC_ void *map_file(const char *fname, size_t size)
 {
        size_t s2 = 0;
        void *p = NULL;
@@ -278,7 +278,7 @@ static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *
 load a file into memory and return an array of pointers to lines in the file
 must be freed with talloc_free(). 
 **/
-char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx)
 {
        char *p;
        char **lines;
@@ -299,7 +299,7 @@ load a fd into memory and return an array of pointers to lines in the file
 must be freed with talloc_free(). If convert is true calls unix_to_dos on
 the list.
 **/
-char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx)
 {
        char *p;
        char **lines;
@@ -320,7 +320,7 @@ char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx)
 take a list of lines and modify them to produce a list where \ continues
 a line
 **/
-void file_lines_slashcont(char **lines)
+_PUBLIC_ void file_lines_slashcont(char **lines)
 {
        int i, j;
 
@@ -342,7 +342,7 @@ void file_lines_slashcont(char **lines)
 /**
   save a lump of data into a file. Mostly used for debugging 
 */
-BOOL file_save(const char *fname, const void *packet, size_t length)
+_PUBLIC_ BOOL file_save(const char *fname, const void *packet, size_t length)
 {
        int fd;
        fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0644);
@@ -356,22 +356,13 @@ BOOL file_save(const char *fname, const void *packet, size_t length)
        return True;
 }
 
-/**
-  see if a file exists
-*/
-BOOL file_exists(const char *path)
-{
-       struct stat st;
-       return (stat(path, &st) == 0);
-}
-
-int vfdprintf(int fd, const char *format, va_list ap) _PRINTF_ATTRIBUTE(2,0)
+_PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) _PRINTF_ATTRIBUTE(2,0)
 {
        char *p;
        int len, ret;
        va_list ap2;
 
-       VA_COPY(ap2, ap);
+       va_copy(ap2, ap);
 
        len = vasprintf(&p, format, ap2);
        if (len <= 0) return len;
@@ -380,7 +371,7 @@ int vfdprintf(int fd, const char *format, va_list ap) _PRINTF_ATTRIBUTE(2,0)
        return ret;
 }
 
-int fdprintf(int fd, const char *format, ...) _PRINTF_ATTRIBUTE(2,3)
+_PUBLIC_ int fdprintf(int fd, const char *format, ...) _PRINTF_ATTRIBUTE(2,3)
 {
        va_list ap;
        int ret;