2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Marcin Krzysztof Porwit 2005.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define DBGC_CLASS DBGC_RPC_SRV
26 static BOOL
api_eventlog_open_eventlog(pipes_struct
*p
)
28 EVENTLOG_Q_OPEN_EVENTLOG q_u
;
29 EVENTLOG_R_OPEN_EVENTLOG r_u
;
30 prs_struct
*data
= &p
->in_data
.data
;
31 prs_struct
*rdata
= &p
->out_data
.rdata
;
36 if (!(eventlog_io_q_open_eventlog("", &q_u
, data
, 0))) {
37 DEBUG(0, ("eventlog_io_q_open_eventlog: unable to unmarshall EVENTLOG_Q_OPEN_EVENTLOG.\n"));
41 r_u
.status
= _eventlog_open_eventlog(p
, &q_u
, &r_u
);
43 if (!(eventlog_io_r_open_eventlog("", &r_u
, rdata
, 0))) {
44 DEBUG(0, ("eventlog_io_r_open_eventlog: unable to marshall EVENTLOG_R_OPEN_EVENTLOG.\n"));
51 static BOOL
api_eventlog_close_eventlog(pipes_struct
*p
)
53 EVENTLOG_Q_CLOSE_EVENTLOG q_u
;
54 EVENTLOG_R_CLOSE_EVENTLOG r_u
;
55 prs_struct
*data
= &p
->in_data
.data
;
56 prs_struct
*rdata
= &p
->out_data
.rdata
;
61 if (!(eventlog_io_q_close_eventlog("", &q_u
, data
, 0))) {
62 DEBUG(0, ("eventlog_io_q_close_eventlog: unable to unmarshall EVENTLOG_Q_CLOSE_EVENTLOG.\n"));
66 r_u
.status
= _eventlog_close_eventlog(p
, &q_u
, &r_u
);
68 if (!(eventlog_io_r_close_eventlog("", &r_u
, rdata
, 0))) {
69 DEBUG(0, ("eventlog_io_r_close_eventlog: unable to marshall EVENTLOG_R_CLOSE_EVENTLOG.\n"));
76 static BOOL
api_eventlog_get_num_records(pipes_struct
*p
)
78 EVENTLOG_Q_GET_NUM_RECORDS q_u
;
79 EVENTLOG_R_GET_NUM_RECORDS r_u
;
80 prs_struct
*data
= &p
->in_data
.data
;
81 prs_struct
*rdata
= &p
->out_data
.rdata
;
86 if (!(eventlog_io_q_get_num_records("", &q_u
, data
, 0))) {
87 DEBUG(0, ("eventlog_io_q_get_num_records: unable to unmarshall EVENTLOG_Q_GET_NUM_RECORDS.\n"));
91 r_u
.status
= _eventlog_get_num_records(p
, &q_u
, &r_u
);
93 if (!(eventlog_io_r_get_num_records("", &r_u
, rdata
, 0))) {
94 DEBUG(0, ("eventlog_io_r_get_num_records: unable to marshall EVENTLOG_R_GET_NUM_RECORDS.\n"));
101 static BOOL
api_eventlog_get_oldest_entry(pipes_struct
*p
)
103 EVENTLOG_Q_GET_OLDEST_ENTRY q_u
;
104 EVENTLOG_R_GET_OLDEST_ENTRY r_u
;
105 prs_struct
*data
= &p
->in_data
.data
;
106 prs_struct
*rdata
= &p
->out_data
.rdata
;
111 if (!(eventlog_io_q_get_oldest_entry("", &q_u
, data
, 0))) {
112 DEBUG(0, ("eventlog_io_q_get_oldest_entry: unable to unmarshall EVENTLOG_Q_GET_OLDEST_ENTRY.\n"));
116 r_u
.status
= _eventlog_get_oldest_entry(p
, &q_u
, &r_u
);
118 if (!(eventlog_io_r_get_oldest_entry("", &r_u
, rdata
, 0))) {
119 DEBUG(0, ("eventlog_io_r_get_oldest_entry: unable to marshall EVENTLOG_R_GET_OLDEST_ENTRY.\n"));
126 static BOOL
api_eventlog_read_eventlog(pipes_struct
*p
)
128 EVENTLOG_Q_READ_EVENTLOG q_u
;
129 EVENTLOG_R_READ_EVENTLOG r_u
;
130 prs_struct
*data
= &p
->in_data
.data
;
131 prs_struct
*rdata
= &p
->out_data
.rdata
;
136 if (!(eventlog_io_q_read_eventlog("", &q_u
, data
, 0))) {
137 DEBUG(0, ("eventlog_io_q_read_eventlog: unable to unmarshall EVENTLOG_Q_READ_EVENTLOG.\n"));
141 r_u
.status
= _eventlog_read_eventlog(p
, &q_u
, &r_u
);
143 if (!(eventlog_io_r_read_eventlog("", &q_u
, &r_u
, rdata
, 0))) {
144 DEBUG(0, ("eventlog_io_r_read_eventlog: unable to marshall EVENTLOG_R_READ_EVENTLOG.\n"));
151 static BOOL
api_eventlog_clear_eventlog(pipes_struct
*p
)
153 EVENTLOG_Q_CLEAR_EVENTLOG q_u
;
154 EVENTLOG_R_CLEAR_EVENTLOG r_u
;
155 prs_struct
*data
= &p
->in_data
.data
;
156 prs_struct
*rdata
= &p
->out_data
.rdata
;
161 if (!(eventlog_io_q_clear_eventlog("", &q_u
, data
, 0))) {
162 DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to unmarshall EVENTLOG_Q_CLEAR_EVENTLOG.\n"));
166 r_u
.status
= _eventlog_clear_eventlog(p
, &q_u
, &r_u
);
168 if (!(eventlog_io_r_clear_eventlog("", &r_u
, rdata
, 0))) {
169 DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to marshall EVENTLOG_Q_CLEAR_EVENTLOG.\n"));
177 \pipe\eventlog commands
179 struct api_struct api_eventlog_cmds
[] =
181 {"EVENTLOG_OPENEVENTLOG", EVENTLOG_OPENEVENTLOG
, api_eventlog_open_eventlog
},
182 {"EVENTLOG_CLOSEEVENTLOG", EVENTLOG_CLOSEEVENTLOG
, api_eventlog_close_eventlog
},
183 {"EVENTLOG_GETNUMRECORDS", EVENTLOG_GETNUMRECORDS
, api_eventlog_get_num_records
},
184 {"EVENTLOG_GETOLDESTENTRY", EVENTLOG_GETOLDESTENTRY
, api_eventlog_get_oldest_entry
},
185 {"EVENTLOG_READEVENTLOG", EVENTLOG_READEVENTLOG
, api_eventlog_read_eventlog
},
186 {"EVENTLOG_CLEAREVENTLOG", EVENTLOG_CLEAREVENTLOG
, api_eventlog_clear_eventlog
}
189 NTSTATUS
rpc_eventlog_init(void)
191 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION
,
192 "eventlog", "eventlog", api_eventlog_cmds
,
193 sizeof(api_eventlog_cmds
)/sizeof(struct api_struct
));
196 void eventlog_get_pipe_fns(struct api_struct
**fns
, int *n_fns
)
198 *fns
= api_eventlog_cmds
;
199 *n_fns
= sizeof(api_eventlog_cmds
) / sizeof(struct api_struct
);