Remove smb_np_struct
[Samba/gebeck_regimport.git] / source3 / rpc_server / srv_eventlog.c
blobda761c905eaee7322a66738119aa493fadad482c
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Marcin Krzysztof Porwit 2005.
5 * Copyright (C) Gerald Carter 2005 - 2007
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
23 #undef DBGC_CLASS
24 #define DBGC_CLASS DBGC_RPC_SRV
26 static bool proxy_eventlog_call(pipes_struct *p, uint8 opnum)
28 struct api_struct *fns;
29 int n_fns;
31 eventlog_get_pipe_fns(&fns, &n_fns);
33 if (opnum >= n_fns)
34 return False;
36 if (fns[opnum].opnum != opnum) {
37 smb_panic("EVENTLOG function table not sorted\n");
40 return fns[opnum].fn(p);
43 static bool api_eventlog_open_eventlog(pipes_struct *p)
45 return proxy_eventlog_call(p, NDR_EVENTLOG_OPENEVENTLOGW);
48 static bool api_eventlog_close_eventlog(pipes_struct *p)
50 return proxy_eventlog_call( p, NDR_EVENTLOG_CLOSEEVENTLOG );
53 static bool api_eventlog_get_num_records(pipes_struct *p)
55 return proxy_eventlog_call(p, NDR_EVENTLOG_GETNUMRECORDS);
58 static bool api_eventlog_get_oldest_entry(pipes_struct *p)
60 return proxy_eventlog_call(p, NDR_EVENTLOG_GETOLDESTRECORD);
63 static bool api_eventlog_read_eventlog(pipes_struct *p)
65 EVENTLOG_Q_READ_EVENTLOG q_u;
66 EVENTLOG_R_READ_EVENTLOG r_u;
67 prs_struct *data = &p->in_data.data;
68 prs_struct *rdata = &p->out_data.rdata;
70 ZERO_STRUCT(q_u);
71 ZERO_STRUCT(r_u);
73 if (!(eventlog_io_q_read_eventlog("", &q_u, data, 0))) {
74 DEBUG(0, ("eventlog_io_q_read_eventlog: unable to unmarshall EVENTLOG_Q_READ_EVENTLOG.\n"));
75 return False;
78 r_u.status = _eventlog_read_eventlog(p, &q_u, &r_u);
80 if (!(eventlog_io_r_read_eventlog("", &q_u, &r_u, rdata, 0))) {
81 DEBUG(0, ("eventlog_io_r_read_eventlog: unable to marshall EVENTLOG_R_READ_EVENTLOG.\n"));
82 return False;
85 return True;
88 static bool api_eventlog_clear_eventlog(pipes_struct *p)
90 return proxy_eventlog_call(p, NDR_EVENTLOG_CLEAREVENTLOGW);
94 \pipe\eventlog commands
96 struct api_struct api_eventlog_cmds[] =
98 {"EVENTLOG_OPENEVENTLOG", EVENTLOG_OPENEVENTLOG, api_eventlog_open_eventlog },
99 {"EVENTLOG_CLOSEEVENTLOG", EVENTLOG_CLOSEEVENTLOG, api_eventlog_close_eventlog },
100 {"EVENTLOG_GETNUMRECORDS", EVENTLOG_GETNUMRECORDS, api_eventlog_get_num_records },
101 {"EVENTLOG_GETOLDESTENTRY", EVENTLOG_GETOLDESTENTRY, api_eventlog_get_oldest_entry },
102 {"EVENTLOG_READEVENTLOG", EVENTLOG_READEVENTLOG, api_eventlog_read_eventlog },
103 {"EVENTLOG_CLEAREVENTLOG", EVENTLOG_CLEAREVENTLOG, api_eventlog_clear_eventlog }
106 NTSTATUS rpc_eventlog2_init(void)
108 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
109 "eventlog", "eventlog", &ndr_table_eventlog.syntax_id,
110 api_eventlog_cmds,
111 sizeof(api_eventlog_cmds)/sizeof(struct api_struct));
114 void eventlog2_get_pipe_fns(struct api_struct **fns, int *n_fns)
116 *fns = api_eventlog_cmds;
117 *n_fns = sizeof(api_eventlog_cmds) / sizeof(struct api_struct);