summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/libsmb/clientgen.c37
-rw-r--r--source3/smbwrapper/smbw.c10
-rw-r--r--source3/smbwrapper/smbw_stat.c10
4 files changed, 54 insertions, 4 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 29803cdbbc..f2b484ceec 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -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 *));
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 0e01370f5d..e4aa15c6eb 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -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
diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c
index 3a2cbcf5ac..0abe823e29 100644
--- a/source3/smbwrapper/smbw.c
+++ b/source3/smbwrapper/smbw.c
@@ -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;
}
diff --git a/source3/smbwrapper/smbw_stat.c b/source3/smbwrapper/smbw_stat.c
index 69ca38a2ae..d0b0e59b4f 100644
--- a/source3/smbwrapper/smbw_stat.c
+++ b/source3/smbwrapper/smbw_stat.c
@@ -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);
- *size = printjob.size;
- *m_time = printjob.t;
- return 0;
+ if (size) {
+ *size = printjob.size;
+ }
+ if (m_time) {
+ *m_time = printjob.t;
+ }
+ return printjob.id;
}