Author: gd
Date: 2005-03-12 15:40:26 +0000 (Sat, 12 Mar 2005)
New Revision: 5774

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5774

Log:
Fix file_get_c_setprinter().

Guenther

Modified:
   trunk/source/printing/printerdb_file.c


Changeset:
Modified: trunk/source/printing/printerdb_file.c
===================================================================
--- trunk/source/printing/printerdb_file.c      2005-03-12 15:08:07 UTC (rev 
5773)
+++ trunk/source/printing/printerdb_file.c      2005-03-12 15:40:26 UTC (rev 
5774)
@@ -35,15 +35,16 @@
        char *file;
 };
 
-static BOOL file_find(TALLOC_CTX *mem_ctx, struct file_list **list,
-                     const char *directory) 
+static BOOL file_find(TALLOC_CTX *mem_ctx, const char *directory,
+                     struct file_list **list, int *num_files)
 {
        DIR *dir;
        struct file_list *entry;
        char *path, *filename;
        const char *dname;
-       int num_files = 0;
 
+       *num_files = 0;
+
        *list = TALLOC_ZERO_P(mem_ctx, struct file_list);
        if (*list == NULL)
                return False;
@@ -75,15 +76,15 @@
                entry->file = filename;
                DLIST_ADD(*list, entry);
 
-               ++num_files;
+               ++(*num_files);
         }
 
        closedir(dir);
 
-       if (num_files == 0)
+       if (*num_files == 0)
                return False;
 
-       DEBUG(0,("found: %d files\n", num_files));
+       DEBUG(0,("found: %d files\n", *num_files));
 
        return True;
 }
@@ -339,12 +340,13 @@
 uint32 file_update_c_setprinter(BOOL initialize) 
 {
        TALLOC_CTX *mem_ctx = talloc_init("file_update_c_setprinter");
-       char *filename;
+       char *filename, *printerdir;
        int len;
        uint8_t *buf;
        uint32 result = 0;
        uint32 c_setprinter;
-       uint32 printer_count = 23;
+       uint32 printer_count = 0;
+       struct file_list *file_list;
 
        if (mem_ctx == NULL)
                goto done;
@@ -354,8 +356,16 @@
        if (filename == NULL)
                goto done;
 
-       /* FIXME */
+       printerdir = talloc_asprintf(mem_ctx, "%s/%s", file_root, 
PRINTERS_PREFIX);
 
+       if (printerdir == NULL)
+               goto done;
+
+       file_list = NULL;
+
+       if (!file_find(mem_ctx, printerdir, &file_list, &printer_count))
+               goto done;
+
        if (!initialize)
                c_setprinter = file_get_c_setprinter() + printer_count;
        else
@@ -388,6 +398,7 @@
        int i;
        int n = 0;
        char *dirname;
+       int num_files;
        struct file_list *file_list, *temp_list;
 
        if (mem_ctx == NULL)
@@ -399,7 +410,7 @@
 
        file_list = NULL;
 
-       if (!file_find(mem_ctx, &file_list, dirname))
+       if (!file_find(mem_ctx, dirname, &file_list, &num_files))
                goto done;
                
        for (temp_list = file_list; temp_list; temp_list = temp_list->next) {
@@ -433,7 +444,6 @@
        if (mem_ctx != NULL)
                talloc_destroy(mem_ctx);
 
-       DEBUG(0,("file_get_forms: found %d forms\n", n));
        return n;
 }
 
@@ -545,6 +555,7 @@
        struct file_list *file_list, *temp_list;
        int n = 0;
        fstring *loc_list;
+       int num_files;
 
        /* never return -1 */
 
@@ -563,7 +574,7 @@
 
        file_list = NULL;
 
-       if (!file_find(mem_ctx, &file_list, filename)) {
+       if (!file_find(mem_ctx, filename, &file_list, &num_files)) {
                goto done;
        }
 

Reply via email to