Move the "rid_name" typedef to the only place where it might be used
[Samba.git] / source3 / rpc_server / srv_eventlog.c
blob973be28040adf2490b056757c1b4cefd33e80fae
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"
22 #include "librpc/gen_ndr/srv_eventlog.h"
24 #undef DBGC_CLASS
25 #define DBGC_CLASS DBGC_RPC_SRV
27 static bool proxy_eventlog_call(pipes_struct *p, uint8 opnum)
29 struct api_struct *fns;
30 int n_fns;
32 eventlog_get_pipe_fns(&fns, &n_fns);
34 if (opnum >= n_fns)
35 return False;
37 if (fns[opnum].opnum != opnum) {
38 smb_panic("EVENTLOG function table not sorted\n");
41 return fns[opnum].fn(p);
44 static bool api_eventlog_open_eventlog(pipes_struct *p)
46 return proxy_eventlog_call(p, NDR_EVENTLOG_OPENEVENTLOGW);
49 static bool api_eventlog_close_eventlog(pipes_struct *p)
51 return proxy_eventlog_call( p, NDR_EVENTLOG_CLOSEEVENTLOG );
54 static bool api_eventlog_get_num_records(pipes_struct *p)
56 return proxy_eventlog_call(p, NDR_EVENTLOG_GETNUMRECORDS);
59 static bool api_eventlog_get_oldest_entry(pipes_struct *p)
61 return proxy_eventlog_call(p, NDR_EVENTLOG_GETOLDESTRECORD);
64 static bool api_eventlog_read_eventlog(pipes_struct *p)
66 EVENTLOG_Q_READ_EVENTLOG q_u;
67 EVENTLOG_R_READ_EVENTLOG r_u;
68 prs_struct *data = &p->in_data.data;
69 prs_struct *rdata = &p->out_data.rdata;
71 ZERO_STRUCT(q_u);
72 ZERO_STRUCT(r_u);
74 if (!(eventlog_io_q_read_eventlog("", &q_u, data, 0))) {
75 DEBUG(0, ("eventlog_io_q_read_eventlog: unable to unmarshall EVENTLOG_Q_READ_EVENTLOG.\n"));
76 return False;
79 r_u.status = _eventlog_read_eventlog(p, &q_u, &r_u);
81 if (!(eventlog_io_r_read_eventlog("", &q_u, &r_u, rdata, 0))) {
82 DEBUG(0, ("eventlog_io_r_read_eventlog: unable to marshall EVENTLOG_R_READ_EVENTLOG.\n"));
83 return False;
86 return True;
89 static bool api_eventlog_clear_eventlog(pipes_struct *p)
91 return proxy_eventlog_call(p, NDR_EVENTLOG_CLEAREVENTLOGW);
95 \pipe\eventlog commands
97 struct api_struct api_eventlog_cmds[] =
99 {"EVENTLOG_OPENEVENTLOG", EVENTLOG_OPENEVENTLOG, api_eventlog_open_eventlog },
100 {"EVENTLOG_CLOSEEVENTLOG", EVENTLOG_CLOSEEVENTLOG, api_eventlog_close_eventlog },
101 {"EVENTLOG_GETNUMRECORDS", EVENTLOG_GETNUMRECORDS, api_eventlog_get_num_records },
102 {"EVENTLOG_GETOLDESTENTRY", EVENTLOG_GETOLDESTENTRY, api_eventlog_get_oldest_entry },
103 {"EVENTLOG_READEVENTLOG", EVENTLOG_READEVENTLOG, api_eventlog_read_eventlog },
104 {"EVENTLOG_CLEAREVENTLOG", EVENTLOG_CLEAREVENTLOG, api_eventlog_clear_eventlog }
107 NTSTATUS rpc_eventlog2_init(void)
109 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
110 "eventlog", "eventlog", &ndr_table_eventlog.syntax_id,
111 api_eventlog_cmds,
112 sizeof(api_eventlog_cmds)/sizeof(struct api_struct));
115 void eventlog2_get_pipe_fns(struct api_struct **fns, int *n_fns)
117 *fns = api_eventlog_cmds;
118 *n_fns = sizeof(api_eventlog_cmds) / sizeof(struct api_struct);