diff options
author | Jeremy Allison <jra@samba.org> | 2002-03-19 02:35:12 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-03-19 02:35:12 +0000 |
commit | 72eb7dbd40b4faf3438951c297fb1fbf6f9011ac (patch) | |
tree | 24590ea1fa7876843072ebb00a4db26ad6986ca6 /source3 | |
parent | ffadd471b9664018b3010ab5d74e6d05b8886e66 (diff) | |
download | samba-72eb7dbd40b4faf3438951c297fb1fbf6f9011ac.tar.gz samba-72eb7dbd40b4faf3438951c297fb1fbf6f9011ac.tar.bz2 samba-72eb7dbd40b4faf3438951c297fb1fbf6f9011ac.zip |
Merge in JohnR's page count fixes.
Jeremy.
(This used to be commit 2e3133fbe5531b9bbc9bf46a04b27fa58e555f5a)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/printing.h | 1 | ||||
-rw-r--r-- | source3/include/smb.h | 1 | ||||
-rw-r--r-- | source3/printing/printing.c | 35 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 35 |
4 files changed, 64 insertions, 8 deletions
diff --git a/source3/include/printing.h b/source3/include/printing.h index 0a733b580a..9a0775186b 100644 --- a/source3/include/printing.h +++ b/source3/include/printing.h @@ -36,6 +36,7 @@ struct printjob { time_t starttime; /* when the job started spooling */ int status; /* the status of this job */ size_t size; /* the size of the job so far */ + int page_count; /* then number of pages so far */ BOOL spooled; /* has it been sent to the spooler yet? */ BOOL smbjob; /* set if the job is a SMB job */ fstring filename; /* the filename used to spool the file */ diff --git a/source3/include/smb.h b/source3/include/smb.h index 02645f35d3..34832edc79 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -506,6 +506,7 @@ typedef struct _print_queue_struct { int job; int size; + int page_count; int status; int priority; time_t time; diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 97eaaebcc4..7e1f59f590 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -796,12 +796,21 @@ write to a print file ****************************************************************************/ int print_job_write(int jobid, const char *buf, int size) { - int fd; + int return_code; + struct printjob *pjob = print_job_find(jobid); - fd = print_job_fd(jobid); - if (fd == -1) return -1; + if (!pjob) + return -1; + /* don't allow another process to get this info - it is meaningless */ + if (pjob->pid != local_pid) + return -1; - return write(fd, buf, size); + return_code = write(pjob->fd, buf, size); + if (return_code>0) { + pjob->size += size; + print_job_store(jobid, pjob); + } + return return_code; } /**************************************************************************** @@ -1044,6 +1053,23 @@ to open spool file %s.\n", pjob.filename)); } /**************************************************************************** + Update the number of pages spooled to jobid +****************************************************************************/ + +void print_job_endpage(int jobid) +{ + struct printjob *pjob = print_job_find(jobid); + if (!pjob) + return; + /* don't allow another process to get this info - it is meaningless */ + if (pjob->pid != local_pid) + return; + + pjob->page_count++; + print_job_store(jobid, pjob); +} + +/**************************************************************************** Print a file - called on closing the file. This spools the job. If normal close is false then we're tearing down the jobs - treat as an error. @@ -1137,6 +1163,7 @@ static int traverse_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void * ts->queue[i].job = jobid; ts->queue[i].size = pjob.size; + ts->queue[i].page_count = pjob.page_count; ts->queue[i].status = pjob.status; ts->queue[i].priority = 1; ts->queue[i].time = pjob.starttime; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 850d428165..e351f125bf 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2139,6 +2139,32 @@ static void spoolss_notify_job_size(int snum, } /******************************************************************* + * fill a notify_info_data with page info + ********************************************************************/ +static void spoolss_notify_total_pages(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) +{ + data->notify_data.value[0]=queue->page_count; + data->notify_data.value[1]=0; +} + +/******************************************************************* + * fill a notify_info_data with pages printed info. + ********************************************************************/ +static void spoolss_notify_pages_printed(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) +{ + data->notify_data.value[0]=0; /* Add code when back-end tracks this */ + data->notify_data.value[1]=0; +} + +/******************************************************************* Fill a notify_info_data with job position. ********************************************************************/ @@ -2258,8 +2284,8 @@ struct s_notify_info_data_table notify_info_data_table[] = { JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", ONE_VALUE, spoolss_notify_job_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, spoolss_notify_total_pages }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, spoolss_notify_pages_printed }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", ONE_VALUE, spoolss_notify_job_size }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_BYTES_PRINTED, "JOB_NOTIFY_BYTES_PRINTED", ONE_VALUE, NULL }, { END, END, "", END, NULL } @@ -4256,6 +4282,7 @@ WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO } Printer->page_started=False; + print_job_endpage(Printer->jobid); return WERR_OK; } @@ -5124,7 +5151,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, job_info->status=nt_printj_status(queue->status); job_info->priority=queue->priority; job_info->position=position; - job_info->totalpages=0; + job_info->totalpages=queue->page_count; job_info->pagesprinted=0; make_systemtime(&job_info->submitted, t); @@ -5168,7 +5195,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->position=position; job_info->starttime=0; job_info->untiltime=0; - job_info->totalpages=0; + job_info->totalpages=queue->page_count; job_info->size=queue->size; make_systemtime(&(job_info->submitted), t); job_info->timeelapsed=0; |