diff options
Diffstat (limited to 'source3/lib/util_file.c')
-rw-r--r-- | source3/lib/util_file.c | 21 |
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); } /**************************************************************************** |