From e90b65284812aaa5ff9e9935ce9bbad7791cbbcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:35:28 +0000 Subject: updated the 3.0 branch from the head branch - ready for alpha18 (This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce) --- source3/utils/smbcontrol.c | 157 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 127 insertions(+), 30 deletions(-) (limited to 'source3/utils/smbcontrol.c') diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index d680fa4489..65519e8888 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -3,6 +3,7 @@ program to send control messages to Samba processes Copyright (C) Andrew Tridgell 1994-1998 Copyright (C) 2001, 2002 by Martin Pool + Copyright (C) Simo Sorce 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,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}, @@ -105,17 +106,14 @@ Prints out the current Debug level returned by MSG_DEBUGLEVEL ****************************************************************************/ void debuglevel_function(int msg_type, pid_t src, void *buf, size_t len) { - int i; - int debuglevel_class[DBGC_LAST]; - - memcpy(debuglevel_class, buf, len); - - printf("Current debug level of PID %u is %d ",(unsigned int)src, debuglevel_class[0]); - for (i=1;i:level\n"); + /* first pass retrieve total lenght */ + for (p = params; p && *p ; p++) + dim += (strnlen(*p, 1024) +1); /* lenght + space */ + b = buf = malloc(dim); + if (!buf) { + fprintf(stderr, "Out of memory!"); return(False); - } else - send_message(dest, MSG_DEBUG, &dm, sizeof(dm), False); + } + /* now build a single string with all parameters */ + for(p = params; p && *p; p++) { + int l = strnlen(*p, 1024); + strncpy(b, *p, l); + b[l] = ' '; + b = b + l + 1; + } + b[-1] = '\0'; + + send_message(dest, MSG_DEBUG, buf, dim, False); + + free(buf); + break; } @@ -326,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 \n"); + fprintf(stderr, "\tqueueresume \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")) { -- cgit