ret = talloc(talloc_autofree_context(), myFILE);
if (!ret) return NULL;
- ret->buf = file_load(FileName, &ret->size, ret);
+ ret->buf = file_load(FileName, &ret->size, 0, ret);
if( NULL == ret->buf )
{
DEBUG( 1,
/**
load a file into memory from a fd.
**/
-_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx);
+_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, TALLOC_CTX *mem_ctx);
+_PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx);
/**
mmap (if possible) or read a file
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, TALLOC_CTX *mem_ctx);
+_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, TALLOC_CTX *mem_ctx);
+_PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
/**
take a list of lines and modify them to produce a list where \ continues
#include "includes.h"
#include "system/shmem.h"
#include "system/filesys.h"
+#if _SAMBA_BUILD_ == 3
+#undef malloc
+#undef realloc
+#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count, false)
+#endif
/**
* @file
/**
load a file into memory from a fd.
**/
-_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char *fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx)
{
struct stat sbuf;
char *p;
+ size_t size;
if (fstat(fd, &sbuf) != 0) return NULL;
- p = (char *)talloc_size(mem_ctx, sbuf.st_size+1);
+ size = sbuf.st_size;
+
+ if (maxsize) {
+ size = MIN(size, maxsize);
+ }
+
+ p = (char *)talloc_size(mem_ctx, size+1);
if (!p) return NULL;
- if (read(fd, p, sbuf.st_size) != sbuf.st_size) {
+ if (read(fd, p, size) != size) {
talloc_free(p);
return NULL;
}
- p[sbuf.st_size] = 0;
+ p[size] = 0;
- if (size) *size = sbuf.st_size;
+ if (psize) *psize = size;
return p;
}
/**
load a file into memory
**/
-_PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx)
{
int fd;
char *p;
fd = open(fname,O_RDONLY);
if (fd == -1) return NULL;
- p = fd_load(fd, size, mem_ctx);
+ p = fd_load(fd, size, maxsize, mem_ctx);
close(fd);
}
#endif
if (!p) {
- p = file_load(fname, &s2, talloc_autofree_context());
+ p = file_load(fname, &s2, 0, talloc_autofree_context());
if (!p) return NULL;
if (s2 != size) {
DEBUG(1,("incorrect size for %s - got %d expected %d\n",
return p;
}
+/**
+ unmap or free memory
+**/
+
+bool unmap_file(void *start, size_t size)
+{
+#ifdef HAVE_MMAP
+ if (munmap( start, size ) != 0) {
+ DEBUG( 1, ("map_file: Failed to unmap address %p "
+ "of size %u - %s\n",
+ start, (unsigned int)size, strerror(errno) ));
+ return false;
+ }
+ return true;
+#else
+ talloc_free(start);
+ return true;
+#endif
+}
/**
parse a buffer into lines
'p' will be freed on error, and otherwise will be made a child of the returned array
**/
-static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx)
+char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx)
{
int i;
char *s, **ret;
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, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx)
{
char *p;
size_t size;
- p = file_load(fname, &size, mem_ctx);
+ p = file_load(fname, &size, maxsize, mem_ctx);
if (!p) return NULL;
return file_lines_parse(p, size, numlines, mem_ctx);
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, TALLOC_CTX *mem_ctx)
+_PUBLIC_ char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx)
{
char *p;
size_t size;
- p = fd_load(fd, &size, mem_ctx);
+ p = fd_load(fd, &size, maxsize, mem_ctx);
if (!p) return NULL;
return file_lines_parse(p, size, numlines, mem_ctx);
close(fd);
return ret == 0;
}
+
+
TDB_DATA string_tdb_data(const char *string)
{
- return make_tdb_data((const uint8 *)string, string ? strlen(string) : 0 );
+ return make_tdb_data((const uint8_t *)string, string ? strlen(string) : 0 );
}
TDB_DATA string_term_tdb_data(const char *string)
{
- return make_tdb_data((const uint8 *)string, string ? strlen(string) + 1 : 0);
+ return make_tdb_data((const uint8_t *)string, string ? strlen(string) + 1 : 0);
}
/****************************************************************************
lib/bitmap.o ../lib/crypto/crc32.o lib/dprintf.o $(UTIL_REG_OBJ) \
../lib/util/xfile.o ../lib/util/util_strlist.o lib/wins_srv.o \
lib/util_str.o lib/clobber.o lib/util_sid.o lib/util_uuid.o \
- lib/util_unistr.o lib/util_file.o ../lib/util/data_blob.o \
+ lib/util_unistr.o ../lib/util/util_file.o lib/util_file.o ../lib/util/data_blob.o \
lib/util.o lib/util_sock.o lib/sock_exec.o lib/util_sec.o \
lib/substitute.o lib/fsusage.o lib/dbwrap_util.o \
lib/ms_fnmatch.o lib/select.o lib/errmap_unix.o \
/* The following definitions come from lib/util_file.c */
char *fgets_slash(char *s2,int maxlen,XFILE *f);
-char *fd_load(int fd, size_t *psize, size_t maxsize);
-char *file_load(const char *fname, size_t *size, size_t maxsize);
+char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx);
+char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx);
bool unmap_file(void* start, size_t size);
-void *map_file(char *fname, size_t size);
-char **file_lines_load(const char *fname, int *numlines, size_t maxsize);
-char **fd_lines_load(int fd, int *numlines, size_t maxsize);
-char **file_lines_pload(char *syscmd, int *numlines);
+void *map_file(const char *fname, size_t size);
+char **file_lines_load(const char *fname, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
+char **fd_lines_load(int fd, int *numlines, size_t maxsize, TALLOC_CTX *mem_ctx);
+char **file_lines_pload(const char *syscmd, int *numlines);
void file_lines_free(char **lines);
void file_lines_slashcont(char **lines);
-bool file_save(const char *fname, void *packet, size_t length);
+bool file_save(const char *fname, const void *packet, size_t length);
/* The following definitions come from lib/util_nscd.c */
char *msgid, *msgstr;
TDB_DATA data;
- lines = file_lines_load(msg_file, &num_lines,0);
+ lines = file_lines_load(msg_file, &num_lines, 0, NULL);
if (!lines) {
return False;
}
if (tdb_lockall(tdb) != 0) {
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return False;
}
}
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
tdb_unlockall(tdb);
return True;
dp->bsize = 1024;
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
lines = NULL;
DEBUG (3, ("Parsed output of get_quota, ...\n"));
invalid_param:
- file_lines_free(lines);
+ TALLOC_FREE(lines);
DEBUG(0,("The output of get_quota_command is invalid!\n"));
return -1;
}
DEBUG (3, ("Read output from set_quota, \"%s\"\n", line));
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return 0;
}
#include "includes.h"
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
-/****************************************************************************
- 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)
-{
- char *s=s2;
- int len = 0;
- int c;
- bool start_of_line = True;
-
- if (x_feof(f)) {
- return(NULL);
- }
-
- if (maxlen <2) {
- return(NULL);
- }
-
- if (!s2) {
- maxlen = MIN(maxlen,8);
- s = (char *)SMB_MALLOC(maxlen);
- }
-
- if (!s) {
- return(NULL);
- }
-
- *s = 0;
-
- while (len < maxlen-1) {
- c = x_getc(f);
- switch (c) {
- case '\r':
- break;
- case '\n':
- while (len > 0 && s[len-1] == ' ') {
- s[--len] = 0;
- }
- if (len > 0 && s[len-1] == '\\') {
- s[--len] = 0;
- start_of_line = True;
- break;
- }
- return(s);
- case EOF:
- if (len <= 0 && !s2) {
- SAFE_FREE(s);
- }
- return(len>0?s:NULL);
- case ' ':
- if (start_of_line) {
- break;
- }
- default:
- start_of_line = False;
- s[len++] = c;
- s[len] = 0;
- }
-
- if (!s2 && len > maxlen-3) {
- maxlen *= 2;
- s = (char *)SMB_REALLOC(s,maxlen);
- if (!s) {
- DEBUG(0,("fgets_slash: failed to expand buffer!\n"));
- return(NULL);
- }
- }
- }
- return(s);
-}
-
-/****************************************************************************
+/**
Load from a pipe into memory.
-****************************************************************************/
+**/
-static char *file_pload(char *syscmd, size_t *size)
+static char *file_pload(const char *syscmd, size_t *size)
{
int fd, n;
char *p;
return p;
}
-/****************************************************************************
- Load a file into memory from a fd.
- Truncate at maxsize. If maxsize == 0 - no limit.
-****************************************************************************/
-
-char *fd_load(int fd, size_t *psize, size_t maxsize)
-{
- SMB_STRUCT_STAT sbuf;
- size_t size;
- char *p;
-
- if (sys_fstat(fd, &sbuf) != 0) {
- return NULL;
- }
-
- size = sbuf.st_size;
- if (maxsize) {
- size = MIN(size, maxsize);
- }
-
- p = (char *)SMB_MALLOC(size+1);
- if (!p) {
- return NULL;
- }
-
- if (read(fd, p, size) != size) {
- SAFE_FREE(p);
- return NULL;
- }
- p[size] = 0;
-
- if (psize) {
- *psize = size;
- }
-
- return p;
-}
-
-/****************************************************************************
- Load a file into memory.
-****************************************************************************/
-
-char *file_load(const char *fname, size_t *size, size_t maxsize)
-{
- int fd;
- char *p;
-
- if (!fname || !*fname) {
- return NULL;
- }
-
- fd = open(fname,O_RDONLY);
- if (fd == -1) {
- return NULL;
- }
-
- p = fd_load(fd, size, maxsize);
- close(fd);
- return p;
-}
-
-/*******************************************************************
- unmap or free memory
-*******************************************************************/
-
-bool unmap_file(void* start, size_t size)
-{
-#ifdef HAVE_MMAP
- if ( munmap( start, size ) != 0 ) {
- DEBUG( 1, ("map_file: Failed to unmap address %p "
- "of size %u - %s\n",
- start, (unsigned int)size, strerror(errno) ));
- return False;
- }
- return True;
-#else
- SAFE_FREE( start );
- return True;
-#endif
-}
-
-/*******************************************************************
- mmap (if possible) or read a file.
-********************************************************************/
-
-void *map_file(char *fname, size_t size)
-{
- size_t s2 = 0;
- void *p = NULL;
-#ifdef HAVE_MMAP
- int fd;
- fd = open(fname, O_RDONLY, 0);
- if (fd == -1) {
- DEBUG(2,("map_file: Failed to load %s - %s\n", fname, strerror(errno)));
- return NULL;
- }
- p = mmap(NULL, size, PROT_READ, MAP_SHARED|MAP_FILE, fd, 0);
- close(fd);
- if (p == MAP_FAILED) {
- DEBUG(1,("map_file: Failed to mmap %s - %s\n", fname, strerror(errno)));
- return NULL;
- }
-#endif
- if (!p) {
- p = file_load(fname, &s2, 0);
- if (!p) {
- return NULL;
- }
- if (s2 != size) {
- DEBUG(1,("map_file: incorrect size for %s - got %lu expected %lu\n",
- fname, (unsigned long)s2, (unsigned long)size));
- SAFE_FREE(p);
- return NULL;
- }
- }
- return p;
-}
-
-/****************************************************************************
- Parse a buffer into lines.
-****************************************************************************/
-
-static char **file_lines_parse(char *p, size_t size, int *numlines)
-{
- int i;
- char *s, **ret;
-
- if (!p) {
- return NULL;
- }
-
- for (s = p, i=0; s < p+size; s++) {
- if (s[0] == '\n') i++;
- }
-
- ret = SMB_MALLOC_ARRAY(char *, i+2);
- if (!ret) {
- SAFE_FREE(p);
- return NULL;
- }
- memset(ret, 0, sizeof(ret[0])*(i+2));
-
- ret[0] = p;
- for (s = p, i=0; s < p+size; s++) {
- if (s[0] == '\n') {
- s[0] = 0;
- i++;
- ret[i] = s+1;
- }
- if (s[0] == '\r') {
- s[0] = 0;
- }
- }
-
- /* remove any blank lines at the end */
- while (i > 0 && ret[i-1][0] == 0) {
- i--;
- }
-
- if (numlines) {
- *numlines = i;
- }
-
- return ret;
-}
-
-/****************************************************************************
- Load a file into memory and return an array of pointers to lines in the file
- must be freed with file_lines_free().
-****************************************************************************/
-
-char **file_lines_load(const char *fname, int *numlines, size_t maxsize)
-{
- char *p;
- size_t size = 0;
-
- p = file_load(fname, &size, maxsize);
- if (!p) {
- return NULL;
- }
-
- return file_lines_parse(p, size, numlines);
-}
-
-/****************************************************************************
- Load a fd into memory and return an array of pointers to lines in the file
- must be freed with file_lines_free(). If convert is true calls unix_to_dos on
- the list.
-****************************************************************************/
-char **fd_lines_load(int fd, int *numlines, size_t maxsize)
-{
- char *p;
- size_t size;
- p = fd_load(fd, &size, maxsize);
- if (!p) {
- return NULL;
- }
-
- return file_lines_parse(p, size, numlines);
-}
-
-/****************************************************************************
+/**
Load a pipe into memory and return an array of pointers to lines in the data
must be freed with file_lines_free().
-****************************************************************************/
+**/
-char **file_lines_pload(char *syscmd, int *numlines)
+char **file_lines_pload(const char *syscmd, int *numlines)
{
char *p;
size_t size;
return NULL;
}
- return file_lines_parse(p, size, numlines);
-}
-
-/****************************************************************************
- Free lines loaded with file_lines_load.
-****************************************************************************/
-
-void file_lines_free(char **lines)
-{
- if (!lines) {
- return;
- }
- SAFE_FREE(lines[0]);
- SAFE_FREE(lines);
-}
-
-/****************************************************************************
- Take a list of lines and modify them to produce a list where \ continues
- a line.
-****************************************************************************/
-
-void file_lines_slashcont(char **lines)
-{
- int i, j;
-
- for (i=0; lines[i];) {
- int len = strlen(lines[i]);
- if (lines[i][len-1] == '\\') {
- lines[i][len-1] = ' ';
- if (lines[i+1]) {
- char *p = &lines[i][len];
- while (p < lines[i+1]) {
- *p++ = ' ';
- }
- for (j = i+1; lines[j]; j++) {
- lines[j] = lines[j+1];
- }
- }
- } else {
- i++;
- }
- }
-}
-
-/****************************************************************************
- Save a lump of data into a file. Mostly used for debugging.
-****************************************************************************/
-
-bool file_save(const char *fname, void *packet, size_t length)
-{
- int fd;
- fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0644);
- if (fd == -1) {
- return False;
- }
- if (write(fd, packet, length) != (size_t)length) {
- return False;
- }
- close(fd);
- return True;
+ return file_lines_parse(p, size, numlines, NULL);
}
return NT_STATUS_INVALID_PARAMETER;
}
- data_in = (uint8 *)file_load(filename_in, &n, 0);
+ data_in = (uint8 *)file_load(filename_in, &n, 0, NULL);
if (!data_in) {
status = NT_STATUS_NO_SUCH_FILE;
goto out;
close(tmp_fd);
}
- SAFE_FREE(data_in);
+ TALLOC_FREE(data_in);
return status;
}
return -1;
}
- lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE);
+ lines = fd_lines_load(fd, &numlines, MAX_USERSHARE_FILE_SIZE, NULL);
close(fd);
if (lines == NULL) {
/* Should we allow printers to be shared... ? */
ctx = talloc_init("usershare_sd_xctx");
if (!ctx) {
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return 1;
}
iService, lines, numlines, &sharepath,
&comment, &psd, &guest_ok) != USERSHARE_OK) {
talloc_destroy(ctx);
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return -1;
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
/* Everything ok - add the service possibly using a template. */
if (iService < 0) {
{
if (!f)
return;
- SAFE_FREE(f->buf);
+ TALLOC_FREE(f->buf);
SAFE_FREE(f);
}
if (!ret)
return NULL;
- ret->buf = file_load(FileName, &ret->size, 0);
+ ret->buf = file_load(FileName, &ret->size, 0, NULL);
if( NULL == ret->buf ) {
DEBUG( lvl, ("%s Unable to open configuration file \"%s\":\n\t%s\n",
func, FileName, strerror(errno)) );
int numlines;
bool ret;
- lines = file_lines_load(fname, &numlines,0);
+ lines = file_lines_load(fname, &numlines,0, NULL);
if (!lines || numlines < 1) {
- if (lines) file_lines_free(lines);
+ if (lines) TALLOC_FREE(lines);
return False;
}
ret = string_to_sid(sid, lines[0]);
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return ret;
}
return;
}
- lines = file_lines_load(mapfile, &numlines,0);
+ lines = file_lines_load(mapfile, &numlines,0,NULL);
if (numlines == 0 || lines == NULL) {
DEBUG(0,("No entries in OS/2 driver map %s\n",mapfile));
- SAFE_FREE(lines);
+ TALLOC_FREE(lines);
return;
}
DEBUG(3,("Mapped windows driver %s to os2 driver%s\n",drivername,os2_name));
set_last_from_to(drivername,os2_name);
fstrcpy(drivername,os2_name);
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return;
}
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
}
/****************************************************************************
}
numlines = 0;
- qlines = fd_lines_load(fd, &numlines,0);
+ qlines = fd_lines_load(fd, &numlines,0,NULL);
close(fd);
/* turn the lpq output into a series of job structures */
if (numlines && qlines) {
queue = SMB_MALLOC_ARRAY(print_queue_struct, numlines+1);
if (!queue) {
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
*q = NULL;
return 0;
}
}
}
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
*q = queue;
return qcount;
}
scheduler = file_lines_pload("/usr/bin/lpstat -r", NULL);
if(!strcmp(*scheduler,"scheduler is running")){
DEBUG(3,("No Printers found!!!\n"));
- file_lines_free(scheduler);
+ TALLOC_FREE(scheduler);
return True;
}
else{
DEBUG(3,("Scheduler is not running!!!\n"));
- file_lines_free(scheduler);
+ TALLOC_FREE(scheduler);
return False;
}
#else
/* add it to the cache */
if (!pcap_cache_add(name, NULL)) {
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return False;
}
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return True;
}
numlines = 0;
/* Get lines and convert them back to dos-codepage */
- qlines = fd_lines_load(fd, &numlines, 0);
+ qlines = fd_lines_load(fd, &numlines, 0, NULL);
DEBUGADD(10,("Lines returned = [%d]\n", numlines));
close(fd);
DEBUGADD(6,("Line[0] = [%s]\n", qlines[0]));
}
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return True;
}
}
numlines = 0;
- qlines = fd_lines_load(fd, &numlines, 0);
+ qlines = fd_lines_load(fd, &numlines, 0, NULL);
DEBUGADD(10,("Lines returned = [%d]\n", numlines));
close(fd);
}
result = enumports_hook(talloc_tos(), &numlines, &qlines );
if (!W_ERROR_IS_OK(result)) {
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return result;
}
if((ports=SMB_MALLOC_ARRAY( PORT_INFO_1, numlines )) == NULL) {
DEBUG(10,("Returning WERR_NOMEM [%s]\n",
dos_errstr(WERR_NOMEM)));
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return WERR_NOMEM;
}
fill_port_1(&ports[i], qlines[i]);
}
}
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
*returned = numlines;
result = enumports_hook(talloc_tos(), &numlines, &qlines );
if ( !W_ERROR_IS_OK(result)) {
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return result;
}
if(numlines) {
if((ports=SMB_MALLOC_ARRAY( PORT_INFO_2, numlines)) == NULL) {
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return WERR_NOMEM;
}
}
}
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
*returned = numlines;
*bsize = STR_TO_SMB_BIG_UINT(p, NULL);
else
*bsize = 1024;
- file_lines_free(lines);
+ TALLOC_FREE(lines);
DEBUG (3, ("Parsed output of dfree, dsize=%u, dfree=%u, bsize=%u\n",
(unsigned int)*dsize, (unsigned int)*dfree, (unsigned int)*bsize));
bool local_list_only;
int i;
- lines = file_lines_load(lock_path(SERVER_LIST), NULL, 0);
+ lines = file_lines_load(lock_path(SERVER_LIST), NULL, 0, NULL);
if (!lines) {
DEBUG(4,("Can't open %s - %s\n",lock_path(SERVER_LIST),strerror(errno)));
return 0;
*servers = SMB_REALLOC_ARRAY(*servers,struct srv_info_struct, alloced);
if (!*servers) {
DEBUG(0,("get_server_info: failed to enlarge servers info struct!\n"));
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return 0;
}
memset((char *)((*servers)+count),'\0',sizeof(**servers)*(alloced-count));
}
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return count;
}
}
numlines = 0;
- qlines = fd_lines_load(fd, &numlines,0);
+ qlines = fd_lines_load(fd, &numlines,0, NULL);
DEBUGADD(10,("Lines returned = [%d]\n", numlines));
close(fd);
fstrcpy( user, qlines[0] );
}
- file_lines_free(qlines);
+ TALLOC_FREE(qlines);
return numlines != 0;
}
return -1;
}
- lines = fd_lines_load(fd, &numlines, 10240);
+ lines = fd_lines_load(fd, &numlines, 10240, NULL);
close(fd);
if (lines == NULL) {
&psd,
&guest_ok);
- file_lines_free(lines);
+ TALLOC_FREE(lines);
if (us_err != USERSHARE_OK) {
d_fprintf(stderr, "info_fn: file %s is not a well formed usershare file.\n",
char **lines;
int i, numlines;
- lines = file_lines_load(file, &numlines, NULL);
+ lines = file_lines_load(file, &numlines, 0, NULL);
if (lines == NULL)
{
size_t size;
char *contents;
- contents = file_load(path, &size, mem_ctx);
+ contents = file_load(path, &size, 0, mem_ctx);
talloc_free(path);
if (contents == NULL)
return WERR_BADFILE;
pull = tdr_pull_init(regf, regf->iconv_convenience);
- pull->data.data = (uint8_t*)fd_load(regf->fd, &pull->data.length, 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\n"));
if (dhpfile && *dhpfile) {
gnutls_datum_t dhparms;
size_t size;
- dhparms.data = (uint8_t *)file_load(dhpfile, &size, mem_ctx);
+ dhparms.data = (uint8_t *)file_load(dhpfile, &size, 0, mem_ctx);
if (!dhparms.data) {
DEBUG(0,("Failed to read DH Parms from %s\n", dhpfile));
/* generate the seeds - after this everything is deterministic */
if (options.use_preset_seeds) {
int numops;
- char **preset = file_lines_load(options.seeds_file, &numops, NULL);
+ char **preset = file_lines_load(options.seeds_file, &numops, 0, NULL);
if (!preset) {
printf("Failed to load %s - %s\n", options.seeds_file, strerror(errno));
exit(1);
}
if (ignore_file) {
- options.ignore_patterns = file_lines_load(ignore_file, NULL, NULL);
+ options.ignore_patterns = file_lines_load(ignore_file, NULL, 0, NULL);
}
argv_new = discard_const_p(char *, poptGetArgs(pc));