If signing starts successfully, don't just turn it off automatically if
[jra/samba/.git] / source3 / printing / print_generic.c
index ef38d26493c54fbd9dc51706f172024fe910b842..9e0ea85bb9adcb6b0ad46e1ccd844649a9943fe0 100644 (file)
@@ -1,6 +1,5 @@
 /* 
-   Unix SMB/Netbios implementation.
-   Version 3.0
+   Unix SMB/CIFS implementation.
    printing command routines
    Copyright (C) Andrew Tridgell 1992-2000
    
@@ -19,6 +18,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include "includes.h"
 #include "printing.h"
 
 
@@ -47,8 +47,6 @@ struct printif        generic_printif =
                  generic_job_submit,
                };
 
-extern int DEBUGLEVEL;
-
 /****************************************************************************
 run a given print command 
 a null terminated list of value/substitute pairs is provided
@@ -58,7 +56,7 @@ static int print_run_command(int snum,char *command, int *outfd, ...)
 {
 
        pstring syscmd;
-       char *p, *arg;
+       char *arg;
        int ret;
        va_list ap;
        va_start(ap, outfd);
@@ -78,13 +76,9 @@ static int print_run_command(int snum,char *command, int *outfd, ...)
        }
        va_end(ap);
   
-       p = PRINTERNAME(snum);
-  
-       pstring_sub(syscmd, "%p", p);
-       standard_sub_snum(snum,syscmd);
+       pstring_sub(syscmd, "%p", PRINTERNAME(snum));
+       standard_sub_snum(snum,syscmd,sizeof(syscmd));
 
-       /* Convert script args to unix-codepage */
-       dos_to_unix(syscmd, True);
        ret = smbrun(syscmd,outfd);
 
        DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
@@ -151,6 +145,7 @@ static int generic_job_submit(int snum, struct printjob *pjob)
        pstring print_directory;
        char *wd, *p;
        pstring jobname;
+       fstring job_page_count, job_size;
 
        /* we print from the directory path to give the best chance of
            parsing the lpq output */
@@ -159,7 +154,7 @@ static int generic_job_submit(int snum, struct printjob *pjob)
                return 0;
 
        pstrcpy(print_directory, pjob->filename);
-       p = strrchr(print_directory,'/');
+       p = strrchr_m(print_directory,'/');
        if (!p)
                return 0;
        *p++ = 0;
@@ -169,14 +164,18 @@ static int generic_job_submit(int snum, struct printjob *pjob)
 
        pstrcpy(jobname, pjob->jobname);
        pstring_sub(jobname, "'", "_");
+       slprintf(job_page_count, sizeof(job_page_count)-1, "%d", pjob->page_count);
+       slprintf(job_size, sizeof(job_size)-1, "%lu", (unsigned long)pjob->size);
 
        /* send it to the system spooler */
        ret = print_run_command(snum, 
-                         lp_printcommand(snum), NULL,
-                         "%s", p,
-                         "%J", jobname,
-                         "%f", p,
-                         NULL);
+                       lp_printcommand(snum), NULL,
+                       "%s", p,
+                       "%J", jobname,
+                       "%f", p,
+                       "%z", job_size,
+                       "%c", job_page_count,
+                       NULL);
 
        chdir(wd);
 
@@ -195,9 +194,7 @@ static int generic_queue_get(int snum, print_queue_struct **q, print_status_stru
        print_queue_struct *queue = NULL;
        fstring printer_name;
               
-       /* Convert printer name (i.e. share name) to unix-codepage */
        fstrcpy(printer_name, lp_servicename(snum));
-       dos_to_unix(printer_name, True);
        
        print_run_command(snum, lp_lpqcommand(snum), &fd, NULL);
 
@@ -208,7 +205,7 @@ static int generic_queue_get(int snum, print_queue_struct **q, print_status_stru
        }
        
        numlines = 0;
-       qlines = fd_lines_load(fd, &numlines, True);
+       qlines = fd_lines_load(fd, &numlines);
        close(fd);
 
        /* turn the lpq output into a series of job structures */
@@ -218,6 +215,7 @@ static int generic_queue_get(int snum, print_queue_struct **q, print_status_stru
                queue = (print_queue_struct *)malloc(sizeof(print_queue_struct)*(numlines+1));
 
        if (queue) {
+               memset(queue, '\0', sizeof(print_queue_struct)*(numlines+1));
                for (i=0; i<numlines; i++) {
                        /* parse the line */
                        if (parse_lpq_entry(snum,qlines[i],