source: branches/samba-3.0/source/rpcclient/cmd_shutdown.c

Last change on this file was 1, checked in by Paul Smedley, 18 years ago

Initial code import

File size: 3.4 KB
Line 
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.
8
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.
13
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.
18
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.
22*/
23
24#include "includes.h"
25#include "rpcclient.h"
26
27#if 0 /* don't uncomment this unless you remove the getopt() calls */
28 /* use net rpc shutdown instead */
29
30/****************************************************************************
31nt shutdown init
32****************************************************************************/
33static NTSTATUS cmd_shutdown_init(struct cli_state *cli, TALLOC_CTX *mem_ctx,
34 int argc, const char **argv)
35{
36 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
37 fstring msg;
38 uint32 timeout = 20;
39 BOOL force = False;
40 BOOL reboot = False;
41 int opt;
42
43 *msg = 0;
44 optind = 0; /* TODO: test if this hack works on other systems too --simo */
45
46 while ((opt = getopt(argc, argv, "m:t:rf")) != EOF)
47 {
48 /*fprintf (stderr, "[%s]\n", argv[argc-1]);*/
49
50 switch (opt)
51 {
52 case 'm':
53 fstrcpy(msg, optarg);
54 /*fprintf (stderr, "[%s|%s]\n", optarg, msg);*/
55 break;
56
57 case 't':
58 timeout = atoi(optarg);
59 /*fprintf (stderr, "[%s|%d]\n", optarg, timeout);*/
60 break;
61
62 case 'r':
63 reboot = True;
64 break;
65
66 case 'f':
67 force = True;
68 break;
69
70 }
71 }
72
73 /* create an entry */
74 result = cli_shutdown_init(cli, mem_ctx, msg, timeout, reboot, force);
75
76 if (NT_STATUS_IS_OK(result))
77 DEBUG(5,("cmd_shutdown_init: query succeeded\n"));
78 else
79 DEBUG(5,("cmd_shutdown_init: query failed\n"));
80
81 return result;
82}
83
84/****************************************************************************
85abort a shutdown
86****************************************************************************/
87static NTSTATUS cmd_shutdown_abort(struct cli_state *cli,
88 TALLOC_CTX *mem_ctx, int argc,
89 const char **argv)
90{
91 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
92
93 result = cli_shutdown_abort(cli, mem_ctx);
94
95 if (NT_STATUS_IS_OK(result))
96 DEBUG(5,("cmd_shutdown_abort: query succeeded\n"));
97 else
98 DEBUG(5,("cmd_shutdown_abort: query failed\n"));
99
100 return result;
101}
102#endif
103
104
105/* List of commands exported by this module */
106struct cmd_set shutdown_commands[] = {
107
108 { "SHUTDOWN" },
109
110#if 0
111 { "shutdowninit", RPC_RTYPE_NTSTATUS, cmd_shutdown_init, NULL, PI_SHUTDOWN, "Remote Shutdown (over shutdown pipe)",
112 "syntax: shutdown [-m message] [-t timeout] [-r] [-h] [-f] (-r == reboot, -h == halt, -f == force)" },
113
114 { "shutdownabort", RPC_RTYPE_NTSTATUS, cmd_shutdown_abort, NULL, PI_SHUTDOWN, "Abort Shutdown (over shutdown pipe)",
115 "syntax: shutdownabort" },
116#endif
117 { NULL }
118};
Note: See TracBrowser for help on using the repository browser.