1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

add support for unlink() on printer shares in smbwrapper. unlink()

will remove the job from the pirnt queue.
This commit is contained in:
Andrew Tridgell
-
parent 080fb61b69
commit 7bd738c30a
4 changed files with 54 additions and 4 deletions

View File

@ -418,6 +418,7 @@ BOOL cli_establish_connection(struct cli_state *cli,
struct nmb_name *calling, struct nmb_name *called,
char *service, char *service_type,
BOOL do_shutdown, BOOL do_tcon);
int cli_printjob_del(struct cli_state *cli, int job);
int cli_print_queue(struct cli_state *cli,
void (*fn)(struct print_job_info *));

View File

@ -2495,6 +2495,43 @@ BOOL cli_establish_connection(struct cli_state *cli,
}
/****************************************************************************
cancel a print job
****************************************************************************/
int cli_printjob_del(struct cli_state *cli, int job)
{
char *rparam = NULL;
char *rdata = NULL;
char *p;
int rdrcnt,rprcnt, ret = -1;
pstring param;
bzero(param,sizeof(param));
p = param;
SSVAL(p,0,81); /* DosPrintJobDel() */
p += 2;
pstrcpy(p,"W");
p = skip_string(p,1);
pstrcpy(p,"");
p = skip_string(p,1);
SSVAL(p,0,job);
p += 2;
if (cli_api(cli,
param, PTR_DIFF(p,param), 1024, /* Param, length, maxlen */
NULL, 0, CLI_BUFFER_SIZE, /* data, length, maxlen */
&rparam, &rprcnt, /* return params, length */
&rdata, &rdrcnt)) { /* return data, length */
ret = SVAL(rparam,0);
}
if (rparam) free(rparam);
if (rdata) free(rdata);
return ret;
}
/****************************************************************************
call fn() on each entry in a print queue

View File

@ -756,7 +756,15 @@ int smbw_unlink(const char *fname)
goto failed;
}
if (!cli_unlink(&srv->cli, path)) {
if (strncmp(srv->cli.dev, "LPT", 3) == 0) {
int job = smbw_stat_printjob(srv, path, NULL, NULL);
if (job == -1) {
goto failed;
}
if (cli_printjob_del(&srv->cli, job) != 0) {
goto failed;
}
} else if (!cli_unlink(&srv->cli, path)) {
errno = smbw_errno(&srv->cli);
goto failed;
}

View File

@ -100,9 +100,13 @@ int smbw_stat_printjob(struct smbw_server *srv,char *path,
fstrcpy(printjob.name, path);
cli_print_queue(&srv->cli, smbw_printjob_stat);
if (size) {
*size = printjob.size;
}
if (m_time) {
*m_time = printjob.t;
return 0;
}
return printjob.id;
}