on read.
Jeremy.
char *fgets_slash(char *s2,int maxlen,FILE *f);
char *file_pload(char *syscmd, size_t *size);
char *file_load(char *fname, size_t *size);
-char **file_lines_load(char *fname, int *numlines);
-char **file_lines_pload(char *syscmd, int *numlines);
+char **file_lines_load(char *fname, int *numlines, BOOL convert);
+char **file_lines_pload(char *syscmd, int *numlines, BOOL convert);
void file_lines_free(char **lines);
void file_lines_slashcont(char **lines);
/****************************************************************************
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;
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;
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;
p = file_pload(syscmd, &size);
if (!p) return NULL;
- return file_lines_parse(p, size, numlines);
+ return file_lines_parse(p, size, numlines, convert);
}
/****************************************************************************
if (*p == '|')
{
- lines = file_lines_pload(p + 1, NULL);
+ lines = file_lines_pload(p + 1, NULL, True);
}
else
{
- lines = file_lines_load(fname, NULL);
+ lines = file_lines_load(fname, NULL, True);
}
if (!lines)
if (name == NULL)
break;
- (*fn)(name, make_model);
+ (*fn)(unix_to_dos(name,False), make_model);
}
ippDelete(response);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
"attributes-natural-language", NULL, language->language);
- snprintf(uri, sizeof(uri), "ipp://localhost/printers/%s", name);
+ snprintf(uri, sizeof(uri), "ipp://localhost/printers/%s", dos_to_unix(name,False));
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
char **lines;
int i;
- lines = file_lines_pload("/usr/bin/lpstat -v", NULL);
+ lines = file_lines_pload("/usr/bin/lpstat -v", NULL, False);
if (!lines) return;
for (i=0;lines[i];i++) {
if (printers == NULL)
populate_printers();
for (tmp = printers; tmp != NULL; tmp = tmp->next)
- (fn)(tmp->name, "");
+ (fn)(unix_to_dos(tmp->name,False), "");
}
print_run_command(snum, cmd, tmp_file, NULL);
numlines = 0;
- qlines = file_lines_load(tmp_file, &numlines);
+ qlines = file_lines_load(tmp_file, &numlines, True);
unlink(tmp_file);
/* turn the lpq output into a series of job structures */
if (!*unix_user_name) return NULL;
if (!*mapfile) return NULL;
- lines = file_lines_load(mapfile, NULL);
+ lines = file_lines_load(mapfile, NULL,False);
if (!lines) {
DEBUG(0,("unmap_unixname: can't open username map %s\n", mapfile));
return NULL;
}
numlines = 0;
- qlines = file_lines_load(tmp_file, &numlines);
+ qlines = file_lines_load(tmp_file, &numlines, True);
DEBUGADD(10,("Lines returned = [%d]\n", numlines));
DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file));
unlink(tmp_file);
}
numlines = 0;
- qlines = file_lines_load(tmp_file, &numlines);
+ qlines = file_lines_load(tmp_file, &numlines,True);
DEBUGADD(10,("Lines returned = [%d]\n", numlines));
DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file));
unlink(tmp_file);
}
numlines = 0;
- qlines = file_lines_load(tmp_file, &numlines);
+ qlines = file_lines_load(tmp_file, &numlines,True);
DEBUGADD(10,("Lines returned = [%d]\n", numlines));
DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file));
unlink(tmp_file);
slprintf(syscmd, sizeof(syscmd), "%s %s", dfree_command, path);
DEBUG (3, ("disk_free: Running command %s\n", syscmd));
- lines = file_lines_pload(syscmd, NULL);
+ lines = file_lines_pload(syscmd, NULL, True);
if (lines) {
char *line = lines[0];
if (strlen(line) > 0)
* Load the file.
*/
- lines = file_lines_load(groupname_map_file,NULL);
+ lines = file_lines_load(groupname_map_file,NULL,False);
if (!lines) {
DEBUG(0,("load_groupname_map: can't open groupname map %s. Error was %s\n",
groupname_map_file, strerror(errno)));
DEBUG(10,("snum: %d\nlp_printerdriver: [%s]\nlp_driverfile: [%s]\n",
snum, lp_printerdriver(snum), lp_driverfile(snum)));
- lines = file_lines_load(lp_driverfile(snum),NULL);
+ lines = file_lines_load(lp_driverfile(snum),NULL, False);
if (!lines)
{
DEBUG(3,("Can't open %s - %s\n", lp_driverfile(snum),
DEBUG(10,("snum: %d\nlp_printerdriver: [%s]\nlp_driverfile: [%s]\n",
snum, lp_printerdriver(snum), lp_driverfile(snum)));
- lines = file_lines_load(lp_driverfile(snum), NULL);
+ lines = file_lines_load(lp_driverfile(snum), NULL, False);
if (!lines)
{
DEBUG(3,("Can't open %s - %s\n", lp_driverfile(snum),strerror(errno)));
BOOL local_list_only;
int i;
- lines = file_lines_load(lock_path(SERVER_LIST), NULL);
+ lines = file_lines_load(lock_path(SERVER_LIST), NULL, False);
if (!lines) {
DEBUG(4,("Can't open %s - %s\n",lock_path(SERVER_LIST),strerror(errno)));
return(0);
int plus_allowed = 1;
char *file_host;
char *file_user;
- char **lines = file_lines_load(equiv_file, NULL);
+ char **lines = file_lines_load(equiv_file, NULL, False);
int i;
DEBUG(5, ("check_user_equiv %s %s %s\n", user, remote, equiv_file));