1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-21 09:34:19 +03:00

lib: Give lib/util/util_file.c its own header file

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
This commit is contained in:
Volker Lendecke 2024-04-10 13:02:39 +02:00 committed by Martin Schwenke
parent f42c5802fa
commit 0baae61e42
55 changed files with 136 additions and 58 deletions

View File

@ -22,6 +22,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "librpc/gen_ndr/samr.h" /* for struct samrPassword */
#include "auth/credentials/credentials.h"
#include "auth/credentials/credentials_internal.h"

View File

@ -21,6 +21,7 @@
#include "system/network.h"
#include "system/filesys.h"
#include "system/wait.h"
#include "lib/util/util_file.h"
#include <tdb.h>

View File

@ -30,6 +30,7 @@
#include "lib/util/dlinklist.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
#include "lib/util/util_file.h"
#include "lib/util/sys_rw.h"
#include "lib/util/util_process.h"

View File

@ -31,6 +31,7 @@
#include "lib/util/tevent_unix.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
#include "lib/util/util_file.h"
#include "lib/async_req/async_sock.h"
#include "protocol/protocol.h"

View File

@ -33,6 +33,7 @@
#include "version.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
#include "lib/util/util_file.h"
#include "lib/util/sys_rw.h"
#include "lib/util/smb_strtox.h"

View File

@ -20,7 +20,7 @@
*/
#include "includes.h"
#include "lib/util/samba_util.h"
#include "lib/util/util_file.h"
#include "fuzzing.h"
int main(int argc, char *argv[]) {

View File

@ -366,61 +366,6 @@ const char **str_list_make_v3_const(TALLOC_CTX *mem_ctx,
const char *string,
const char *sep);
/* The following definitions come from lib/util/util_file.c */
/**
* Read one line (data until next newline or eof) and allocate it
*/
_PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint);
char *fgets_slash(TALLOC_CTX *mem_ctx, char *s2, size_t maxlen, FILE *f);
/**
load a file into memory from a fd.
**/
_PUBLIC_ char *fd_load(int fd, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx);
char **file_lines_parse(const char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx);
/**
load a file into memory
**/
_PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx);
/**
load a file into memory and return an array of pointers to lines in the file
must be freed with talloc_free().
**/
_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
/**
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.
**/
_PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
_PUBLIC_ bool file_save_mode(const char *fname, const void *packet,
size_t length, mode_t mode);
/**
save a lump of data into a file. Mostly used for debugging
*/
_PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length);
_PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
_PUBLIC_ int fdprintf(int fd, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
/*
compare two files, return true if the two files have the same content
*/
bool file_compare(const char *path1, const char *path2);
/*
load from a pipe into memory.
*/
char *file_ploadv(char * const argl[], size_t *size);
/* The following definitions come from lib/util/util.c */

View File

@ -20,6 +20,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "system/filesys.h"
#include "torture/torture.h"
#include "torture/local/proto.h"

View File

@ -24,6 +24,7 @@
#include "system/filesys.h"
#include <talloc.h>
#include "lib/util/samba_util.h"
#include "lib/util/util_file.h"
#include "lib/util/sys_popen.h"
#include "lib/util/sys_rw.h"
#include "lib/util/debug.h"

80
lib/util/util_file.h Normal file
View File

@ -0,0 +1,80 @@
/*
* Unix SMB/CIFS implementation.
* SMB parameters and setup
* Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
*
* Added afdgets() Jelmer Vernooij 2005
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LIB_UTIL_UTIL_FILE_H__
#define __LIB_UTIL_UTIL_FILE_H__
#include "replace.h"
#include <talloc.h>
/**
* Read one line (data until next newline or eof) and allocate it
*/
_PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint);
char *fgets_slash(TALLOC_CTX *mem_ctx, char *s2, size_t maxlen, FILE *f);
/**
load a file into memory from a fd.
**/
_PUBLIC_ char *fd_load(int fd, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx);
/**
load a file into memory
**/
_PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx);
/**
load a file into memory and return an array of pointers to lines in the file
must be freed with talloc_free().
**/
_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
/**
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.
**/
_PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
char **file_lines_parse(const char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx);
_PUBLIC_ bool file_save_mode(const char *fname, const void *packet,
size_t length, mode_t mode);
/**
save a lump of data into a file. Mostly used for debugging
*/
_PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length);
_PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
_PUBLIC_ int fdprintf(int fd, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
/*
compare two files, return true if the two files have the same content
*/
bool file_compare(const char *path1, const char *path2);
/*
load from a pipe into memory.
*/
char *file_ploadv(char * const argl[], size_t *size);
#endif

View File

@ -22,6 +22,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "lib/util/util_net.h"
#include "system/filesys.h"
#include "system/network.h"

View File

@ -20,6 +20,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "../libcli/netlogon/netlogon.h"
NTSTATUS push_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,

View File

@ -19,6 +19,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "gpo.h"
#include "gpo_ini.h"
#include "system/filesys.h"

View File

@ -22,6 +22,7 @@
#include "replace.h"
#include "system/network.h"
#include <tevent.h>
#include "lib/util/util_file.h"
#include "lib/util/talloc_stack.h"
#include "lib/util/debug.h"
#include "lib/util/byteorder.h"

View File

@ -23,6 +23,7 @@
#include "system/network.h"
#include <tevent.h>
#include "lib/tsocket/tsocket.h"
#include "lib/util/util_file.h"
#include "lib/util/tevent_ntstatus.h"
#include "librpc/rpc/dcerpc.h"
#include "librpc/rpc/dcerpc_util.h"

View File

@ -19,6 +19,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "system/filesys.h"
#include "system/locale.h"
#include "librpc/ndr/libndr.h"

View File

@ -19,6 +19,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "librpc/wsp/wsp_util.h"
#include "librpc/gen_ndr/wsp.h"
#include "librpc/gen_ndr/ndr_wsp.h"

View File

@ -20,6 +20,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "system/filesys.h"
#include "auth.h"
#include "lib/gencache.h"

View File

@ -71,6 +71,7 @@
#include "client/client_proto.h"
#include "client/clitar_proto.h"
#include "libsmb/libsmb.h"
#include "lib/util/util_file.h"
#ifdef HAVE_LIBARCHIVE

View File

@ -26,6 +26,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "system/filesys.h"
#ifdef HAVE_SYS_SYSCTL_H

View File

@ -18,7 +18,8 @@
*/
#include "replace.h"
#include "lib/util_file.h"
#include "lib/util/util_file.h"
#include "source3/lib/util_file.h"
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
#include "lib/util/sys_rw.h"

View File

@ -24,6 +24,7 @@
#include "registry.h"
#include "../librpc/gen_ndr/ndr_preg.h"
#include "libgpo/gpext/gpext.h"
#include "lib/util/util_file.h"
#define GP_EXT_NAME "registry"

View File

@ -30,6 +30,7 @@
#include "../libcli/smb/smb2_create_ctx.h"
#include "lib/util/tevent_ntstatus.h"
#include "lib/util/tevent_unix.h"
#include "lib/util/util_file.h"
#include "offload_token.h"
#include "string_replace.h"
#include "hash_inode.h"

View File

@ -41,6 +41,7 @@
#include <glusterfs/api/glfs.h>
#include "lib/util/dlinklist.h"
#include "lib/util/tevent_unix.h"
#include "lib/util/util_file.h"
#include "smbd/globals.h"
#include "lib/util/sys_rw.h"
#include "smbprofile.h"

View File

@ -21,6 +21,7 @@
#include "include/ntioctl.h"
#include "system/filesys.h"
#include "smbd/smbd.h"
#include "lib/util/util_file.h"
/*
* Check whether a path can be shadow copied. Return the base volume, allowing

View File

@ -33,6 +33,7 @@
#include "libsmb/clirap.h"
#include "../libcli/smb/smbXcli_base.h"
#include "lib/util/string_wrappers.h"
#include "lib/util/util_file.h"
#include "source3/lib/substitute.h"
struct sync_record {

View File

@ -24,6 +24,7 @@
#include "system/filesys.h"
#include "nmbd/nmbd.h"
#include "util_tdb.h"
#include "lib/util/util_file.h"
#define WINS_LIST "wins.dat"
#define WINS_VERSION 1

View File

@ -55,6 +55,7 @@
#define LOADPARM_SUBSTITUTION_INTERNALS 1
#include "includes.h"
#include "lib/util/util_file.h"
#include "system/filesys.h"
#include "util_tdb.h"
#include "lib/param/loadparm.h"

View File

@ -21,6 +21,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "passdb/machine_sid.h"
#include "secrets.h"
#include "dbwrap/dbwrap.h"

View File

@ -20,6 +20,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "printing/nt_printing_os2.h"
/****************************************************************************

View File

@ -18,6 +18,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "printing.h"
#include "smbd/proto.h"
#include "source3/lib/substitute.h"

View File

@ -55,6 +55,7 @@
#include "includes.h"
#include "lib/util/util_file.h"
#include "system/filesys.h"
#include "printing/pcap.h"

View File

@ -54,6 +54,7 @@
#include "lib/util/debug.h"
#include "lib/util/server_id.h"
#include "lib/util/util_tdb.h"
#include "lib/util/util_file.h"
#include "lib/tdb_wrap/tdb_wrap.h"
#include "lib/async_req/async_sock.h"
#include "librpc/rpc/dcerpc_util.h"

View File

@ -28,6 +28,7 @@
up, all the errors returned are DOS errors, not NT status codes. */
#include "includes.h"
#include "lib/util/util_file.h"
#include "libsmb/namequery.h"
#include "ntdomain.h"
#include "nt_printing.h"

View File

@ -26,6 +26,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "source3/smbd/smbXsrv_session.h"

View File

@ -48,6 +48,7 @@
#include "lib/gencache.h"
#include "lib/util/sys_rw.h"
#include "lib/util/asn1.h"
#include "lib/util/util_file.h"
#include "lib/param/param.h"
#include "auth/gensec/gensec.h"
#include "lib/util/string_wrappers.h"

View File

@ -42,6 +42,7 @@
#include "utils/net_dns.h"
#include "auth/kerberos/pac_utils.h"
#include "lib/util/string_wrappers.h"
#include "lib/util/util_file.h"
#ifdef HAVE_JANSSON
#include <jansson.h>

View File

@ -22,6 +22,7 @@
#include "includes.h"
#include "utils/net.h"
#include "lib/eventlog/eventlog.h"
#include "lib/util/util_file.h"
/**
* Dump an *evt win32 eventlog file

View File

@ -24,6 +24,7 @@
#include "libcli/registry/util_reg.h"
#include "libcli/security/dom_sid.h"
#include "lib/cmdline/cmdline.h"
#include "lib/util/util_file.h"
int net_offlinejoin_usage(struct net_context *c, int argc, const char **argv)
{

View File

@ -24,6 +24,7 @@
#include "utils/net.h"
#include "../libcli/security/security.h"
#include "lib/util/string_wrappers.h"
#include "lib/util/util_file.h"
struct {
const char *us_errstr;

View File

@ -34,6 +34,7 @@
#include "../librpc/gen_ndr/ndr_lsa_c.h"
#include "util_sd.h"
#include "lib/param/param.h"
#include "lib/util/util_file.h"
static char DIRSEP_CHAR = '\\';

View File

@ -26,6 +26,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "lib/registry/registry.h"
#include "system/filesys.h"

View File

@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "includes.h"
#include "lib/util/util_file.h"
#include "system/filesys.h"
#include "system/time.h"
#include "lib/registry/tdr_regf.h"
@ -2218,7 +2219,8 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, const char *location,
pull = tdr_pull_init(regf);
pull->data.data = (uint8_t*)fd_load(regf->fd, &pull->data.length, 0, regf);
pull->data.data = (uint8_t*)
fd_load(regf->fd, &pull->data.length, 0, regf);
if (pull->data.data == NULL) {
DEBUG(0, ("Error reading data from file: %s\n", location));

View File

@ -21,6 +21,7 @@
#include "system/network.h"
#include "system/filesys.h"
#include "system/time.h"
#include "lib/util/util_file.h"
#include "../util/tevent_unix.h"
#include "../lib/tsocket/tsocket.h"
#include "../lib/tsocket/tsocket_internal.h"

View File

@ -20,6 +20,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "lib/tls/tls.h"
#include <gnutls/gnutls.h>

View File

@ -21,6 +21,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "libcli/dgram/libdgram.h"
#include "lib/socket/socket.h"
#include "libcli/resolve/resolve.h"

View File

@ -20,6 +20,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "libcli/dgram/libdgram.h"
#include "lib/socket/socket.h"
#include "libcli/resolve/resolve.h"

View File

@ -21,6 +21,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "system/filesys.h"
#include "../lib/util/dlinklist.h"
#include "lib/events/events.h"

View File

@ -21,6 +21,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "system/kerberos.h"
#include "auth/auth.h"
#include "auth/kerberos/kerberos.h"

View File

@ -19,6 +19,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/raw/raw_proto.h"
#include "system/time.h"

View File

@ -21,6 +21,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "lib/cmdline/cmdline.h"
#include "librpc/gen_ndr/ndr_drsuapi_c.h"
#include "librpc/gen_ndr/ndr_drsblobs.h"

View File

@ -20,6 +20,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "lib/cmdline/cmdline.h"
#include "lib/events/events.h"
#include "system/time.h"

View File

@ -18,6 +18,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "lib/cmdline/cmdline.h"
#include "lib/events/events.h"
#include "system/filesys.h"

View File

@ -19,6 +19,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "lib/cmdline/cmdline.h"
#include "system/time.h"
#include "system/wait.h"

View File

@ -19,6 +19,7 @@
*/
#include "includes.h"
#include "lib/util/util_file.h"
#include "lib/cmdline/cmdline.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/raw/raw_proto.h"