s3:rpcclient: Use C99 initializer for cmd_set in cmd_shutdown
[samba.git] / source3 / rpcclient / cmd_shutdown.c
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 3 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, see <http://www.gnu.org/licenses/>.
21 */
22
23 #include "includes.h"
24 #include "rpcclient.h"
25
26 #if 0   /* don't uncomment this unless you remove the getopt() calls */
27         /* use net rpc shutdown instead */
28
29 /****************************************************************************
30 nt shutdown init
31 ****************************************************************************/
32 static NTSTATUS cmd_shutdown_init(struct cli_state *cli, TALLOC_CTX *mem_ctx,
33                                   int argc, const char **argv)
34 {
35         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
36         fstring msg;
37         uint32_t timeout = 20;
38         bool force = False;
39         bool reboot = False;
40         int opt;
41
42         *msg = 0;
43         optind = 0; /* TODO: test if this hack works on other systems too --simo */
44
45         while ((opt = getopt(argc, argv, "m:t:rf")) != EOF)
46         {
47                 /*fprintf (stderr, "[%s]\n", argv[argc-1]);*/
48         
49                 switch (opt)
50                 {
51                         case 'm':
52                                 fstrcpy(msg, optarg);
53                                 /*fprintf (stderr, "[%s|%s]\n", optarg, msg);*/
54                                 break;
55
56                         case 't':
57                                 timeout = atoi(optarg);
58                                 /*fprintf (stderr, "[%s|%d]\n", optarg, timeout);*/
59                                 break;
60
61                         case 'r':
62                                 reboot = True;
63                                 break;
64
65                         case 'f':
66                                 force = True;
67                                 break;
68
69                 }
70         }
71
72         /* create an entry */
73         result = cli_shutdown_init(cli, mem_ctx, msg, timeout, reboot, force);
74
75         if (NT_STATUS_IS_OK(result))
76                 DEBUG(5,("cmd_shutdown_init: query succeeded\n"));
77         else
78                 DEBUG(5,("cmd_shutdown_init: query failed\n"));
79
80         return result;
81 }
82
83 /****************************************************************************
84 abort a shutdown
85 ****************************************************************************/
86 static NTSTATUS cmd_shutdown_abort(struct cli_state *cli, 
87                                    TALLOC_CTX *mem_ctx, int argc, 
88                                    const char **argv)
89 {
90         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
91
92         result = cli_shutdown_abort(cli, mem_ctx);
93
94         if (NT_STATUS_IS_OK(result))
95                 DEBUG(5,("cmd_shutdown_abort: query succeeded\n"));
96         else
97                 DEBUG(5,("cmd_shutdown_abort: query failed\n"));
98
99         return result;
100 }
101 #endif
102
103
104 /* List of commands exported by this module */
105 struct cmd_set shutdown_commands[] = {
106
107         {
108                 .name = "SHUTDOWN",
109         },
110
111 #if 0
112         {
113                 .name               = "shutdowninit",
114                 .returntype         = RPC_RTYPE_NTSTATUS,
115                 .ntfn               = cmd_shutdown_init,
116                 .wfn                = NULL,
117                 .table              = &ndr_table_initshutdown.syntax_id,
118                 .rpc_pipe           = "Remote Shutdown (over shutdown pipe)",
119                 .description        = "syntax: shutdown [-m message] "
120                                       "[-t timeout] [-r] [-h] [-f] (-r == "
121                                       "reboot, -h == halt, -f == force)",
122         },
123
124         {
125                 .name               = "shutdownabort",
126                 .returntype         = RPC_RTYPE_NTSTATUS,
127                 .ntfn               = cmd_shutdown_abort,
128                 .wfn                = NULL,
129                 .table              = &ndr_table_initshutdown.syntax_id,
130                 .rpc_pipe           = "Abort Shutdown (over shutdown pipe)",
131                 .description        = "syntax: shutdownabort",
132         },
133 #endif
134         {
135                 .name = NULL,
136         },
137 };