diff options
author | Jeremy Allison <jra@samba.org> | 2002-06-28 00:17:15 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-06-28 00:17:15 +0000 |
commit | 452eb38df0553886313c9b19a945385d853e19ab (patch) | |
tree | d46f49dadc494afaf69456c2cc02860b0fc52721 /source3/utils | |
parent | a9093a1b5819d74e6dc21c413dc84f8fd3f181dc (diff) | |
download | samba-452eb38df0553886313c9b19a945385d853e19ab.tar.gz samba-452eb38df0553886313c9b19a945385d853e19ab.tar.bz2 samba-452eb38df0553886313c9b19a945385d853e19ab.zip |
Proper merge of all the working printing stuff from APPLIANCE_HEAD.
Now let's keep this in sync !
Jeremy.
(This used to be commit 3603cd4947df2c10df604447dc542932cb9e5d5a)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/smbcontrol.c | 110 |
1 files changed, 96 insertions, 14 deletions
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index 1a8b1a6ada..65519e8888 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -34,7 +34,7 @@ static struct { {"profile", MSG_PROFILE}, {"profilelevel", MSG_REQ_PROFILELEVEL}, {"debuglevel", MSG_REQ_DEBUGLEVEL}, - {"printer-notify", MSG_PRINTER_NOTIFY}, + {"printnotify", MSG_PRINTER_NOTIFY2 }, {"close-share", MSG_SMB_FORCE_TDIS}, {"samsync", MSG_SMB_SAM_SYNC}, {"samrepl", MSG_SMB_SAM_REPL}, @@ -341,24 +341,106 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params) } break; - case MSG_PRINTER_NOTIFY: - if (!strequal(dest, "smbd")) { - fprintf(stderr,"printer-notify can only be sent to smbd\n"); - return(False); - } + /* Send a notification message to a printer */ + + case MSG_PRINTER_NOTIFY2: { + char *cmd; + + /* Read subcommand */ + if (!params || !params[0]) { - fprintf(stderr, "printer-notify needs a printer name\n"); - return (False); + fprintf(stderr, "Must specify subcommand:\n"); + fprintf(stderr, "\tqueuepause <printername>\n"); + fprintf(stderr, "\tqueueresume <printername>\n"); + return False; } - { - char msg[8 + sizeof(fstring)]; - SIVAL(msg,0,PRINTER_CHANGE_ALL); - SIVAL(msg,4,0); - fstrcpy(&msg[8], params[0]); - retval = send_message(dest, MSG_PRINTER_NOTIFY, msg, 8 + strlen(params[0]) + 1, False); + cmd = params[0]; + + /* Pause a print queue */ + + if (strequal(cmd, "queuepause")) { + + if (!params[1]) { + fprintf(stderr, "queuepause command requires a printer name\n"); + return False; + } + + notify_printer_status_byname(params[1], PRINTER_STATUS_PAUSED); + break; + } + + /* Resume a print queue */ + + if (strequal(cmd, "queueresume")) { + + if (!params[1]) { + fprintf(stderr, "queueresume command requires a printer name\n"); + return False; + } + + notify_printer_status_byname(params[1], PRINTER_STATUS_OK); + break; } + + /* Pause a print job */ + + if (strequal(cmd, "jobpause")) { + int jobid; + + if (!params[1] || !params[2]) { + fprintf(stderr, "jobpause command requires a printer name and a jobid\n"); + return False; + } + + jobid = atoi(params[2]); + + notify_job_status_byname( + params[1], jobid, JOB_STATUS_PAUSED, + SPOOLSS_NOTIFY_MSG_UNIX_JOBID); + } + + /* Resume a print job */ + + if (strequal(cmd, "jobresume")) { + int jobid; + + if (!params[1] || !params[2]) { + fprintf(stderr, "jobresume command requires a printer name and a jobid\n"); + return False; + } + + jobid = atoi(params[2]); + + notify_job_status_byname( + params[1], jobid, JOB_STATUS_QUEUED, + SPOOLSS_NOTIFY_MSG_UNIX_JOBID); + } + + /* Delete a print job */ + + if (strequal(cmd, "jobdelete")) { + int jobid; + + if (!params[1] || !params[2]) { + fprintf(stderr, "jobdelete command requires a printer name and a jobid\n"); + return False; + } + + jobid = atoi(params[2]); + + notify_job_status_byname( + params[1], jobid, JOB_STATUS_DELETING, + SPOOLSS_NOTIFY_MSG_UNIX_JOBID); + + notify_job_status_byname( + params[1], jobid, JOB_STATUS_DELETING| + JOB_STATUS_DELETED, + SPOOLSS_NOTIFY_MSG_UNIX_JOBID); + } + break; + } case MSG_SMB_FORCE_TDIS: if (!strequal(dest, "smbd")) { |