r4879: Fix rewinddir -> rewind_dir. Noticed by James Peach.
[Samba/gebeck_regimport.git] / source3 / rpcclient / cmd_shutdown.c
blobe42ec30ac13103d742771b1294e577cea0f9bba9
1 /*
2 Unix SMB/CIFS implementation.
3 NT Domain Authentication SMB / MSRPC client
4 Copyright (C) Andrew Tridgell 1994-1997,
5 Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6 Copyright (C) Simo Sorce 2001,
7 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "includes.h"
25 #include "rpcclient.h"
27 /****************************************************************************
28 nt shutdown init
29 ****************************************************************************/
30 static NTSTATUS cmd_shutdown_init(struct cli_state *cli, TALLOC_CTX *mem_ctx,
31 int argc, const char **argv)
33 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
34 fstring msg;
35 uint32 timeout = 20;
36 BOOL force = False;
37 BOOL reboot = False;
38 int opt;
40 *msg = 0;
41 optind = 0; /* TODO: test if this hack works on other systems too --simo */
43 while ((opt = getopt(argc, argv, "m:t:rf")) != EOF)
45 /*fprintf (stderr, "[%s]\n", argv[argc-1]);*/
47 switch (opt)
49 case 'm':
50 fstrcpy(msg, optarg);
51 /*fprintf (stderr, "[%s|%s]\n", optarg, msg);*/
52 break;
54 case 't':
55 timeout = atoi(optarg);
56 /*fprintf (stderr, "[%s|%d]\n", optarg, timeout);*/
57 break;
59 case 'r':
60 reboot = True;
61 break;
63 case 'f':
64 force = True;
65 break;
70 /* create an entry */
71 result = cli_shutdown_init(cli, mem_ctx, msg, timeout, reboot, force);
73 if (NT_STATUS_IS_OK(result))
74 DEBUG(5,("cmd_shutdown_init: query succeeded\n"));
75 else
76 DEBUG(5,("cmd_shutdown_init: query failed\n"));
78 return result;
81 /****************************************************************************
82 abort a shutdown
83 ****************************************************************************/
84 static NTSTATUS cmd_shutdown_abort(struct cli_state *cli,
85 TALLOC_CTX *mem_ctx, int argc,
86 const char **argv)
88 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
90 result = cli_shutdown_abort(cli, mem_ctx);
92 if (NT_STATUS_IS_OK(result))
93 DEBUG(5,("cmd_shutdown_abort: query succeeded\n"));
94 else
95 DEBUG(5,("cmd_shutdown_abort: query failed\n"));
97 return result;
101 /* List of commands exported by this module */
102 struct cmd_set shutdown_commands[] = {
104 { "SHUTDOWN" },
106 { "shutdowninit", RPC_RTYPE_NTSTATUS, cmd_shutdown_init, NULL, PI_SHUTDOWN, "Remote Shutdown (over shutdown pipe)",
107 "syntax: shutdown [-m message] [-t timeout] [-r] [-h] [-f] (-r == reboot, -h == halt, -f == force)" },
109 { "shutdownabort", RPC_RTYPE_NTSTATUS, cmd_shutdown_abort, NULL, PI_SHUTDOWN, "Abort Shutdown (over shutdown pipe)",
110 "syntax: shutdownabort" },
111 { NULL }