2 * Unix SMB/Netbios implementation.
4 * RPC client routines: scheduler service
5 * Copyright (C) Jean Francois Micouleau 1998-1999,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
7 * Copyright (C) Andrew Tridgell 1992-1999.
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 2 of the License, or
12 * (at your option) any later version.
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.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 extern int DEBUGLEVEL;
28 /****************************************************************************
29 ****************************************************************************/
30 BOOL event_open(const char* srv_name, const char *log, POLICY_HND *hnd)
36 BOOL valid_pol = False;
38 struct cli_connection *con = NULL;
40 if (!cli_connection_init(srv_name, PIPE_EVENTLOG, &con))
45 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
46 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
48 /* store the parameters */
49 make_eventlog_q_open(&q, log, NULL);
51 /* turn parameters into data stream */
52 eventlog_io_q_open("", &q, &buf, 0);
54 /* send the data on \PIPE\ */
55 if (rpc_con_pipe_req(con, EVENTLOG_OPEN, &buf, &rbuf))
59 eventlog_io_r_open("", &r, &rbuf, 0);
62 if (p && r.status != 0)
64 /* report error code */
65 DEBUG(0,("event_open: %s\n", get_nt_error_msg(r.status)));
72 memcpy(hnd->data, r.pol.data, sizeof(hnd->data));
73 valid_pol = register_policy_hnd(hnd) &&
74 set_policy_con(hnd, con,
75 cli_connection_unlink);
85 /****************************************************************************
86 ****************************************************************************/
87 BOOL event_close( POLICY_HND *hnd)
94 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
95 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
97 /* store the parameters */
98 make_eventlog_q_close(&q, hnd);
100 /* turn parameters into data stream */
101 eventlog_io_q_close("", &q, &buf, 0);
103 /* send the data on \PIPE\ */
104 if (rpc_hnd_pipe_req(hnd, EVENTLOG_CLOSE, &buf, &rbuf))
108 eventlog_io_r_close("", &r, &rbuf, 0);
109 p = rbuf.offset != 0;
111 if (p && r.status != 0)
113 /* report error code */
114 DEBUG(0,("event_close: %s\n", get_nt_error_msg(r.status)));
123 close_policy_hnd(hnd);
128 /****************************************************************************
129 ****************************************************************************/
130 BOOL event_numofeventlogrec( POLICY_HND *hnd, uint32 *number)
134 EVENTLOG_Q_NUMOFEVENTLOGREC q;
137 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
138 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
140 /* store the parameters */
141 make_eventlog_q_numofeventlogrec(&q, hnd);
143 /* turn parameters into data stream */
144 eventlog_io_q_numofeventlogrec("", &q, &buf, 0);
146 /* send the data on \PIPE\ */
147 if (rpc_hnd_pipe_req(hnd, EVENTLOG_NUMOFEVENTLOGRECORDS, &buf, &rbuf))
149 EVENTLOG_R_NUMOFEVENTLOGREC r;
151 eventlog_io_r_numofeventlogrec("", &r, &rbuf, 0);
152 p = rbuf.offset != 0;
154 if (p && r.status != 0)
156 /* report error code */
157 DEBUG(0,("event_close: %s\n", get_nt_error_msg(r.status)));
173 /****************************************************************************
174 ****************************************************************************/
175 BOOL event_readeventlog(POLICY_HND *hnd,
176 uint32 number, uint32 flags, uint32 offset,
177 uint32 *number_of_bytes, EVENTLOGRECORD *ev)
181 EVENTLOG_Q_READEVENTLOG q;
182 EVENTLOG_R_READEVENTLOG r;
185 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
186 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
188 /* store the parameters */
189 make_eventlog_q_readeventlog(&q, hnd, flags, offset, *number_of_bytes);
191 /* turn parameters into data stream */
192 eventlog_io_q_readeventlog("", &q, &buf, 0);
194 /* send the data on \PIPE\ */
195 if (rpc_hnd_pipe_req(hnd, EVENTLOG_READEVENTLOG, &buf, &rbuf))
198 eventlog_io_r_readeventlog("", &r, &rbuf, 0);
199 p = rbuf.offset != 0;
203 *number_of_bytes=r.real_size;