diff options
author | Tim Potter <tpot@samba.org> | 2002-05-07 06:36:22 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-05-07 06:36:22 +0000 |
commit | ee2306d88156af9b03c135889672e6ce3ec49636 (patch) | |
tree | b54f3cb10f782ba922561cb7ac82458643015c23 /source3/libsmb/cli_spoolss.c | |
parent | e8682b6c8e0bf0ed6e2cdec3c2e83e8771f88755 (diff) | |
download | samba-ee2306d88156af9b03c135889672e6ce3ec49636.tar.gz samba-ee2306d88156af9b03c135889672e6ce3ec49636.tar.bz2 samba-ee2306d88156af9b03c135889672e6ce3ec49636.zip |
Merge from HEAD:
>Added cli_spoolss_enumjobs() function.
>Added cmd_spoolss_enumjobs() function to rpcclient.
>
>The semantics of the src_len argument to rpcstr_pull() seem to have changed
>breaking most of the spoolss commands in rpcclient. Changed a bunch of
>0's to -1's to fix it.
(This used to be commit dce534d4373cc0f204d82e0876bb94db8dfeb628)
Diffstat (limited to 'source3/libsmb/cli_spoolss.c')
-rw-r--r-- | source3/libsmb/cli_spoolss.c | 49 |
1 files changed, 46 insertions, 3 deletions
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); |