diff options
author | Tim Potter <tpot@samba.org> | 2002-05-07 06:28:27 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-05-07 06:28:27 +0000 |
commit | 099b006c3f0ac1b7cda973121d226f30452711ec (patch) | |
tree | bb6cc1826294d83f13ef9fe6b4e48bd9b858ffe7 /source3 | |
parent | 236d5effaccd563fda075577eed05db02ad55889 (diff) | |
download | samba-099b006c3f0ac1b7cda973121d226f30452711ec.tar.gz samba-099b006c3f0ac1b7cda973121d226f30452711ec.tar.bz2 samba-099b006c3f0ac1b7cda973121d226f30452711ec.zip |
Added cli_spoolss_enumjobs() function.
(This used to be commit aaa996355287fcd86873697f51a069ccb5a908b9)
Diffstat (limited to 'source3')
-rwxr-xr-x | source3/include/rpc_spoolss.h | 4 | ||||
-rw-r--r-- | source3/libsmb/cli_spoolss.c | 49 |
2 files changed, 48 insertions, 5 deletions
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index 71854b5d89..0cbbad19f9 100755 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -1199,8 +1199,8 @@ typedef struct job_info_ctr_info { union { - JOB_INFO_1 **job_info_1; - JOB_INFO_2 **job_info_2; + JOB_INFO_1 *job_info_1; + JOB_INFO_2 *job_info_2; void *info; } job; diff --git a/source3/libsmb/cli_spoolss.c b/source3/libsmb/cli_spoolss.c index cf356ef815..0458b29d54 100644 --- a/source3/libsmb/cli_spoolss.c +++ b/source3/libsmb/cli_spoolss.c @@ -1534,12 +1534,36 @@ done: return result; } +static void decode_jobs_1(TALLOC_CTX *mem_ctx, NEW_BUFFER *buffer, + uint32 num_jobs, JOB_INFO_1 **jobs) +{ + uint32 i; + + *jobs = (JOB_INFO_1 *)talloc(mem_ctx, num_jobs * sizeof(JOB_INFO_1)); + buffer->prs.data_offset = 0; + + for (i = 0; i < num_jobs; i++) + smb_io_job_info_1("", buffer, &((*jobs)[i]), 0); +} + +static void decode_jobs_2(TALLOC_CTX *mem_ctx, NEW_BUFFER *buffer, + uint32 num_jobs, JOB_INFO_2 **jobs) +{ + uint32 i; + + *jobs = (JOB_INFO_2 *)talloc(mem_ctx, num_jobs * sizeof(JOB_INFO_2)); + buffer->prs.data_offset = 0; + + for (i = 0; i < num_jobs; i++) + smb_io_job_info_2("", buffer, &((*jobs)[i]), 0); +} + /* Enumerate jobs */ WERROR cli_spoolss_enumjobs(struct cli_state *cli, TALLOC_CTX *mem_ctx, uint32 offered, uint32 *needed, - POLICY_HND *hnd, uint32 firstjob, uint32 numofjobs, - uint32 level) + POLICY_HND *hnd, uint32 level, uint32 firstjob, + uint32 num_jobs, uint32 *returned, JOB_INFO_CTR *ctr) { prs_struct qbuf, rbuf; SPOOL_Q_ENUMJOBS q; @@ -1559,7 +1583,7 @@ WERROR cli_spoolss_enumjobs(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Initialise input parameters */ - make_spoolss_q_enumjobs(&q, hnd, firstjob, numofjobs, level, &buffer, + make_spoolss_q_enumjobs(&q, hnd, firstjob, num_jobs, level, &buffer, offered); /* Marshall data and send request */ @@ -1580,6 +1604,25 @@ WERROR cli_spoolss_enumjobs(struct cli_state *cli, TALLOC_CTX *mem_ctx, if (needed) *needed = r.needed; + if (!W_ERROR_IS_OK(r.status)) + goto done; + + *returned = r.returned; + + switch(level) { + case 1: + decode_jobs_1(mem_ctx, r.buffer, r.returned, + &ctr->job.job_info_1); + break; + case 2: + decode_jobs_2(mem_ctx, r.buffer, r.returned, + &ctr->job.job_info_2); + break; + default: + DEBUG(3, ("unsupported info level %d", level)); + break; + } + done: prs_mem_free(&qbuf); prs_mem_free(&rbuf); |