rpcclient/cmd_shutdown.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    NT Domain Authentication SMB / MSRPC client
00004    Copyright (C) Andrew Tridgell                 1994-1997,
00005    Copyright (C) Luke Kenneth Casson Leighton    1996-1997,
00006    Copyright (C) Simo Sorce                      2001,
00007    Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
00008    
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; either version 2 of the License, or
00012    (at your option) any later version.
00013    
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018    
00019    You should have received a copy of the GNU General Public License
00020    along with this program; if not, write to the Free Software
00021    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00022 */
00023 
00024 #include "includes.h"
00025 #include "rpcclient.h"
00026 
00027 #if 0   /* don't uncomment this unless you remove the getopt() calls */
00028         /* use net rpc shutdown instead */
00029 
00030 /****************************************************************************
00031 nt shutdown init
00032 ****************************************************************************/
00033 static NTSTATUS cmd_shutdown_init(struct cli_state *cli, TALLOC_CTX *mem_ctx,
00034                                   int argc, const char **argv)
00035 {
00036         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
00037         fstring msg;
00038         uint32 timeout = 20;
00039         BOOL force = False;
00040         BOOL reboot = False;
00041         int opt;
00042 
00043         *msg = 0;
00044         optind = 0; /* TODO: test if this hack works on other systems too --simo */
00045 
00046         while ((opt = getopt(argc, argv, "m:t:rf")) != EOF)
00047         {
00048                 /*fprintf (stderr, "[%s]\n", argv[argc-1]);*/
00049         
00050                 switch (opt)
00051                 {
00052                         case 'm':
00053                                 fstrcpy(msg, optarg);
00054                                 /*fprintf (stderr, "[%s|%s]\n", optarg, msg);*/
00055                                 break;
00056 
00057                         case 't':
00058                                 timeout = atoi(optarg);
00059                                 /*fprintf (stderr, "[%s|%d]\n", optarg, timeout);*/
00060                                 break;
00061 
00062                         case 'r':
00063                                 reboot = True;
00064                                 break;
00065 
00066                         case 'f':
00067                                 force = True;
00068                                 break;
00069 
00070                 }
00071         }
00072 
00073         /* create an entry */
00074         result = cli_shutdown_init(cli, mem_ctx, msg, timeout, reboot, force);
00075 
00076         if (NT_STATUS_IS_OK(result))
00077                 DEBUG(5,("cmd_shutdown_init: query succeeded\n"));
00078         else
00079                 DEBUG(5,("cmd_shutdown_init: query failed\n"));
00080 
00081         return result;
00082 }
00083 
00084 /****************************************************************************
00085 abort a shutdown
00086 ****************************************************************************/
00087 static NTSTATUS cmd_shutdown_abort(struct cli_state *cli, 
00088                                    TALLOC_CTX *mem_ctx, int argc, 
00089                                    const char **argv)
00090 {
00091         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
00092 
00093         result = cli_shutdown_abort(cli, mem_ctx);
00094 
00095         if (NT_STATUS_IS_OK(result))
00096                 DEBUG(5,("cmd_shutdown_abort: query succeeded\n"));
00097         else
00098                 DEBUG(5,("cmd_shutdown_abort: query failed\n"));
00099 
00100         return result;
00101 }
00102 #endif
00103 
00104 
00105 /* List of commands exported by this module */
00106 struct cmd_set shutdown_commands[] = {
00107 
00108         { "SHUTDOWN"  },
00109 
00110 #if 0
00111         { "shutdowninit", RPC_RTYPE_NTSTATUS, cmd_shutdown_init, NULL, PI_SHUTDOWN, "Remote Shutdown (over shutdown pipe)",
00112                                 "syntax: shutdown [-m message] [-t timeout] [-r] [-h] [-f] (-r == reboot, -h == halt, -f == force)" },
00113                                 
00114         { "shutdownabort", RPC_RTYPE_NTSTATUS, cmd_shutdown_abort, NULL, PI_SHUTDOWN, "Abort Shutdown (over shutdown pipe)",
00115                                 "syntax: shutdownabort" },
00116 #endif
00117         { NULL }
00118 };

Sambaに対してSat Aug 29 21:23:22 2009に生成されました。  doxygen 1.4.7