2 * Unix SMB/CIFS implementation.
3 * SMB parameters and setup
4 * Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
6 * Added afdgets() Jelmer Vernooij 2005
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 3 of the License, or (at your option)
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, see <http://www.gnu.org/licenses/>.
22 #ifndef __LIB_UTIL_UTIL_FILE_H__
23 #define __LIB_UTIL_UTIL_FILE_H__
29 * Read one line (data until next newline or eof) and allocate it
31 _PUBLIC_
char *afdgets(int fd
, TALLOC_CTX
*mem_ctx
, size_t hint
);
33 char *fgets_slash(TALLOC_CTX
*mem_ctx
, char *s2
, size_t maxlen
, FILE *f
);
36 load a file into memory from a fd.
38 _PUBLIC_
char *fd_load(int fd
, size_t *size
, size_t maxsize
, TALLOC_CTX
*mem_ctx
);
41 load a file into memory
43 _PUBLIC_
char *file_load(const char *fname
, size_t *size
, size_t maxsize
, TALLOC_CTX
*mem_ctx
);
46 load a file into memory and return an array of pointers to lines in the file
47 must be freed with talloc_free().
49 _PUBLIC_
char **file_lines_load(const char *fname
, int *numlines
, size_t maxsize
, TALLOC_CTX
*mem_ctx
);
52 load a fd into memory and return an array of pointers to lines in the file
53 must be freed with talloc_free(). If convert is true calls unix_to_dos on
56 _PUBLIC_
char **fd_lines_load(int fd
, int *numlines
, size_t maxsize
, TALLOC_CTX
*mem_ctx
);
58 char **file_lines_parse(const char *p
, size_t size
, int *numlines
, TALLOC_CTX
*mem_ctx
);
60 _PUBLIC_
bool file_save_mode(const char *fname
, const void *packet
,
61 size_t length
, mode_t mode
);
64 save a lump of data into a file. Mostly used for debugging
66 _PUBLIC_
bool file_save(const char *fname
, const void *packet
, size_t length
);
67 _PUBLIC_
int vfdprintf(int fd
, const char *format
, va_list ap
) PRINTF_ATTRIBUTE(2,0);
68 _PUBLIC_
int fdprintf(int fd
, const char *format
, ...) PRINTF_ATTRIBUTE(2,3);
71 compare two files, return true if the two files have the same content
73 bool file_compare(const char *path1
, const char *path2
);
76 load from a pipe into memory.
78 char *file_ploadv(char * const argl
[], size_t *size
);
80 FILE *fdopen_keepfd(int fd
, const char *mode
);