rpc_parse/parse_shutdown.c

説明を見る。
00001 /*
00002  *  Unix SMB/CIFS implementation.
00003  *  RPC Pipe client / server routines
00004  *  Copyright (C) Jim McDonough (jmcd@us.ibm.com)   2003.
00005  *  Copyright (C) Gerald (Jerry) Carter             2002-2005.
00006  *  
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *  
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *  
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020  */
00021 
00022 #include "includes.h"
00023 
00024 #undef DBGC_CLASS
00025 #define DBGC_CLASS DBGC_RPC_PARSE
00026 
00027 /*******************************************************************
00028 Inits a structure.
00029 ********************************************************************/
00030 
00031 void init_shutdown_q_init(SHUTDOWN_Q_INIT *q_s, const char *msg,
00032                         uint32 timeout, BOOL do_reboot, BOOL force)
00033 {
00034         q_s->server = TALLOC_P( get_talloc_ctx(), uint16 );
00035         if (!q_s->server) {
00036                 smb_panic("init_shutdown_q_init: talloc fail.\n");
00037                 return;
00038         }
00039 
00040         *q_s->server = 0x1;
00041 
00042         q_s->message = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR4 );
00043         if (!q_s->message) {
00044                 smb_panic("init_shutdown_q_init: talloc fail.\n");
00045                 return;
00046         }
00047 
00048         if ( msg && *msg ) {
00049                 init_unistr4( q_s->message, msg, UNI_FLAGS_NONE );
00050 
00051                 /* Win2000 is apparently very sensitive to these lengths */
00052                 /* do a special case here */
00053 
00054                 q_s->message->string->uni_max_len++;
00055                 q_s->message->size += 2;
00056         }
00057 
00058         q_s->timeout = timeout;
00059 
00060         q_s->reboot = do_reboot ? 1 : 0;
00061         q_s->force = force ? 1 : 0;
00062 }
00063 
00064 /*******************************************************************
00065 ********************************************************************/
00066 
00067 void init_shutdown_q_init_ex(SHUTDOWN_Q_INIT_EX * q_u_ex, const char *msg,
00068                         uint32 timeout, BOOL do_reboot, BOOL force, uint32 reason)
00069 {
00070         SHUTDOWN_Q_INIT q_u;
00071         
00072         ZERO_STRUCT( q_u );
00073         
00074         init_shutdown_q_init( &q_u, msg, timeout, do_reboot, force );
00075         
00076         /* steal memory */
00077         
00078         q_u_ex->server  = q_u.server;
00079         q_u_ex->message = q_u.message;
00080         
00081         q_u_ex->reboot  = q_u.reboot;
00082         q_u_ex->force   = q_u.force;
00083         
00084         q_u_ex->reason = reason;
00085 }
00086 
00087 /*******************************************************************
00088 reads or writes a structure.
00089 ********************************************************************/
00090 
00091 BOOL shutdown_io_q_init(const char *desc, SHUTDOWN_Q_INIT *q_s, prs_struct *ps,
00092                         int depth)
00093 {
00094         if (q_s == NULL)
00095                 return False;
00096 
00097         prs_debug(ps, depth, desc, "shutdown_io_q_init");
00098         depth++;
00099 
00100         if (!prs_align(ps))
00101                 return False;
00102 
00103         if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
00104                 return False;
00105         if (!prs_align(ps))
00106                 return False;
00107 
00108         if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
00109                 return False;
00110 
00111         if (!prs_align(ps))
00112                 return False;
00113 
00114         if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
00115                 return False;
00116 
00117         if (!prs_uint8("force  ", ps, depth, &(q_s->force)))
00118                 return False;
00119         if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
00120                 return False;
00121 
00122         return True;
00123 }
00124 
00125 /*******************************************************************
00126 reads or writes a structure.
00127 ********************************************************************/
00128 BOOL shutdown_io_r_init(const char *desc, SHUTDOWN_R_INIT* r_s, prs_struct *ps,
00129                         int depth)
00130 {
00131         if (r_s == NULL)
00132                 return False;
00133 
00134         prs_debug(ps, depth, desc, "shutdown_io_r_init");
00135         depth++;
00136 
00137         if(!prs_align(ps))
00138                 return False;
00139 
00140         if(!prs_werror("status", ps, depth, &r_s->status))
00141                 return False;
00142 
00143         return True;
00144 }
00145 
00146 /*******************************************************************
00147 reads or writes a REG_Q_SHUTDOWN_EX structure.
00148 ********************************************************************/
00149 
00150 BOOL shutdown_io_q_init_ex(const char *desc, SHUTDOWN_Q_INIT_EX * q_s, prs_struct *ps,
00151                        int depth)
00152 {
00153         if (q_s == NULL)
00154                 return False;
00155 
00156         prs_debug(ps, depth, desc, "shutdown_io_q_init_ex");
00157         depth++;
00158 
00159         if (!prs_align(ps))
00160                 return False;
00161 
00162         if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
00163                 return False;
00164         if (!prs_align(ps))
00165                 return False;
00166 
00167         if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
00168                 return False;
00169 
00170         if (!prs_align(ps))
00171                 return False;
00172 
00173         if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
00174                 return False;
00175 
00176         if (!prs_uint8("force  ", ps, depth, &(q_s->force)))
00177                 return False;
00178         if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
00179                 return False;
00180 
00181         if (!prs_align(ps))
00182                 return False;
00183         if (!prs_uint32("reason", ps, depth, &(q_s->reason)))
00184                 return False;
00185 
00186 
00187         return True;
00188 }
00189 
00190 /*******************************************************************
00191 reads or writes a REG_R_SHUTDOWN_EX structure.
00192 ********************************************************************/
00193 BOOL shutdown_io_r_init_ex(const char *desc, SHUTDOWN_R_INIT_EX * r_s, prs_struct *ps,
00194                        int depth)
00195 {
00196         if (r_s == NULL)
00197                 return False;
00198 
00199         prs_debug(ps, depth, desc, "shutdown_io_r_init_ex");
00200         depth++;
00201 
00202         if(!prs_align(ps))
00203                 return False;
00204 
00205         if(!prs_werror("status", ps, depth, &r_s->status))
00206                 return False;
00207 
00208         return True;
00209 }
00210 
00211 
00212 /*******************************************************************
00213 Inits a structure.
00214 ********************************************************************/
00215 void init_shutdown_q_abort(SHUTDOWN_Q_ABORT *q_s)
00216 {
00217         q_s->server = TALLOC_P( get_talloc_ctx(), uint16 );
00218         if (!q_s->server) {
00219                 smb_panic("init_shutdown_q_abort: talloc fail.\n");
00220                 return;
00221         }
00222                 
00223         *q_s->server = 0x1;
00224 }
00225 
00226 /*******************************************************************
00227 reads or writes a structure.
00228 ********************************************************************/
00229 BOOL shutdown_io_q_abort(const char *desc, SHUTDOWN_Q_ABORT *q_s,
00230                          prs_struct *ps, int depth)
00231 {
00232         if (q_s == NULL)
00233                 return False;
00234 
00235         prs_debug(ps, depth, desc, "shutdown_io_q_abort");
00236         depth++;
00237 
00238         if (!prs_align(ps))
00239                 return False;
00240 
00241         if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
00242                 return False;
00243         if (!prs_align(ps))
00244                 return False;
00245 
00246         return True;
00247 }
00248 
00249 /*******************************************************************
00250 reads or writes a structure.
00251 ********************************************************************/
00252 BOOL shutdown_io_r_abort(const char *desc, SHUTDOWN_R_ABORT *r_s,
00253                          prs_struct *ps, int depth)
00254 {
00255         if (r_s == NULL)
00256                 return False;
00257 
00258         prs_debug(ps, depth, desc, "shutdown_io_r_abort");
00259         depth++;
00260 
00261         if (!prs_align(ps))
00262                 return False;
00263 
00264         if (!prs_werror("status", ps, depth, &r_s->status))
00265                 return False;
00266 
00267         return True;
00268 }

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