summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-12-07 19:26:04 +0000
committerJeremy Allison <jra@samba.org>2000-12-07 19:26:04 +0000
commitcf5b71994d6cdb2f81c390579f4a0e676926c6b9 (patch)
treeee7f1164bf48be2c95651e21bb88b41ec84859f6 /source3/lib
parent0d658c35eb9d8ec400ad0302ee11d489bb59bd77 (diff)
downloadsamba-cf5b71994d6cdb2f81c390579f4a0e676926c6b9.tar.gz
samba-cf5b71994d6cdb2f81c390579f4a0e676926c6b9.tar.bz2
samba-cf5b71994d6cdb2f81c390579f4a0e676926c6b9.zip
file_lines_load/file_lines_pload can now optionally convert unix_to_dos()
on read. Jeremy. (This used to be commit 76b8dd376d13eb4469417be217c966d54d333367)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_file.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index 33a687950d..1184dd0634 100644
--- a/source3/lib/util_file.c
+++ b/source3/lib/util_file.c
@@ -405,7 +405,7 @@ char *file_load(char *fname, size_t *size)
/****************************************************************************
parse a buffer into lines
****************************************************************************/
-static char **file_lines_parse(char *p, size_t size, int *numlines)
+static char **file_lines_parse(char *p, size_t size, int *numlines, BOOL convert)
{
int i;
char *s, **ret;
@@ -434,15 +434,21 @@ static char **file_lines_parse(char *p, size_t size, int *numlines)
if (s[0] == '\r') s[0] = 0;
}
+ if (convert) {
+ for (i = 0; i < *numlines; i++)
+ unix_to_dos(ret[i], True);
+ }
+
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()
+must be freed with file_lines_free(). If convert is true calls unix_to_dos on
+the list.
****************************************************************************/
-char **file_lines_load(char *fname, int *numlines)
+char **file_lines_load(char *fname, int *numlines, BOOL convert)
{
char *p;
size_t size;
@@ -450,15 +456,16 @@ char **file_lines_load(char *fname, int *numlines)
p = file_load(fname, &size);
if (!p) return NULL;
- return file_lines_parse(p, size, numlines);
+ return file_lines_parse(p, size, numlines, convert);
}
/****************************************************************************
load a pipe into memory and return an array of pointers to lines in the data
-must be freed with file_lines_free()
+must be freed with file_lines_free(). If convert is true calls unix_to_dos on
+the list.
****************************************************************************/
-char **file_lines_pload(char *syscmd, int *numlines)
+char **file_lines_pload(char *syscmd, int *numlines, BOOL convert)
{
char *p;
size_t size;
@@ -466,7 +473,7 @@ char **file_lines_pload(char *syscmd, int *numlines)
p = file_pload(syscmd, &size);
if (!p) return NULL;
- return file_lines_parse(p, size, numlines);
+ return file_lines_parse(p, size, numlines, convert);
}
/****************************************************************************