file_lines_load/file_lines_pload can now optionally convert unix_to_dos()
authorJeremy Allison <jra@samba.org>
Thu, 7 Dec 2000 19:26:04 +0000 (19:26 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 7 Dec 2000 19:26:04 +0000 (19:26 +0000)
on read.
Jeremy.

12 files changed:
source/include/proto.h
source/lib/util_file.c
source/param/loadparm.c
source/printing/print_cups.c
source/printing/print_svid.c
source/printing/printing.c
source/rpc_server/srv_samr.c
source/rpc_server/srv_spoolss_nt.c
source/smbd/dfree.c
source/smbd/groupname.c
source/smbd/lanman.c
source/smbd/password.c

index 62d978ee7a5a2aa72cf6e30ec878afedbc0e6c32..5c8adc8ca46f2a813028c8af3b26026e7fc6c35e 100644 (file)
@@ -444,8 +444,8 @@ int getfileline(void *vp, char *linebuf, int linebuf_size);
 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);
 
index 33a687950d43b2200c072ff60e5aba40f90237ef..1184dd0634ecb17f66bad2d3df99b440202462ea 100644 (file)
@@ -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);
 }
 
 /****************************************************************************
index b666cd3cf41b888dbd17e49336e71eca7c66bb3e..4a6ec83607495869fb2aad994bbadfb272671181 100644 (file)
@@ -2217,11 +2217,11 @@ static BOOL handle_source_env(char *pszParmValue, char **ptr)
 
        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)
index fff135e2a2a250739cf1003dd35968dd8190dea2..1e45df0c63ede618e22f41641d29867cdb541a4c 100644 (file)
@@ -121,7 +121,7 @@ void cups_printer_fn(void (*fn)(char *, char *))
                if (name == NULL)
                        break;
 
-               (*fn)(name, make_model);
+               (*fn)(unix_to_dos(name,False), make_model);
        }
 
        ippDelete(response);
@@ -171,7 +171,7 @@ int cups_printername_ok(char *name)
        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);
index 301f38867195bfd4936ed66f76783f0a9f3c2e2d..58a1d03f4989f69934625eef0dcc70c94211c3e1 100644 (file)
@@ -50,7 +50,7 @@ static void populate_printers(void)
        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++) {
@@ -107,7 +107,7 @@ void sysv_printer_fn(void (*fn)(char *, char *))
        if (printers == NULL)
                populate_printers();
        for (tmp = printers; tmp != NULL; tmp = tmp->next)
-               (fn)(tmp->name, "");
+               (fn)(unix_to_dos(tmp->name,False), "");
 }
 
 
index 68c371547f324e66bc371ad6dcab138f3685202b..e8dc4d7f34118a708206a33ec7c810cc279066cf 100644 (file)
@@ -339,7 +339,7 @@ static void print_queue_update(int snum)
        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 */
index ed3cf7df82779b2ce8c169da9b93b4697612a7ac..352852038ab847e44a6ba6c5b0a02b19ec7793e9 100644 (file)
@@ -128,7 +128,7 @@ static char *unmap_unixname(char *unix_user_name, int name_idx)
        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;
index 1ef6a8c11ba17b653e3c2bf3d136cdecd5e469d2..69cb79156b31cdae5636157221193d2b0283a336 100644 (file)
@@ -3480,7 +3480,7 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer)
        }
 
        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);
@@ -4604,7 +4604,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
                }
 
                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);
@@ -4702,7 +4702,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need
                }
 
                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);
index ee5722acd57e63d315b826564e158221f5d86129..c8c44371554748d1b75d047f2970dd28012a348e 100644 (file)
@@ -91,7 +91,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query,
                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)
index d53fa56a44f2771de8aa6a054828112e44b3a93a..d44e9a7a39c8f18964f0751678b0be284494bd9a 100644 (file)
@@ -101,7 +101,7 @@ void load_groupname_map(void)
    * 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)));
index 1e461f10a92104f671eec1adba417323d328413a..c9193db4a831c21d5fee7c5d4800125143ba7b18 100644 (file)
@@ -544,7 +544,7 @@ static void fill_printq_info_52(connection_struct *conn, int snum, int uLevel,
                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),
@@ -785,7 +785,7 @@ static int get_printerdrivernumber(int 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)));
@@ -1089,7 +1089,7 @@ static int get_server_info(uint32 servertype,
   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);
index f759f3b781c9e85fe68b68df46165c2ba48b38d4..f9657eb9ee3e9ef7b7b04d1f6dfcc1a8c6864b08 100644 (file)
@@ -854,7 +854,7 @@ static BOOL check_user_equiv(char *user, char *remote, char *equiv_file)
   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));