2 * Unix SMB/Netbios implementation.
4 * RPC client routines: scheduler service
5 * Copyright (C) Matthew Chapman 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 add a job to the scheduler
30 ****************************************************************************/
31 BOOL at_add_job(struct cli_state *cli, uint16 fnum,
32 char *server_name, AT_JOB_INFO *info, char *command,
40 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
41 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
43 /* create and send a MSRPC command with api AT_ADD_JOB */
45 DEBUG(4,("Scheduler Add Job\n"));
47 /* store the parameters */
48 make_at_q_add_job(&q_a, server_name, info, command);
50 /* turn parameters into data stream */
51 at_io_q_add_job("", &q_a, &buf, 0);
53 /* send the data on \PIPE\ */
54 if (rpc_api_pipe_req(cli, fnum, AT_ADD_JOB, &buf, &rbuf))
58 at_io_r_add_job("", &r_a, &rbuf, 0);
61 if (p && r_a.status != 0)
63 /* report error code */
64 DEBUG(0,("AT_R_ADD_JOB: %s\n", get_nt_error_msg(r_a.status)));
80 /****************************************************************************
82 ****************************************************************************/
83 BOOL at_del_job(struct cli_state *cli, uint16 fnum,
84 char *server_name, uint32 min_jobid, uint32 max_jobid)
91 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
92 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
94 /* create and send a MSRPC command with api AT_DEL_JOB */
96 DEBUG(4,("Scheduler Delete Job\n"));
98 /* store the parameters */
99 make_at_q_del_job(&q_d, server_name, min_jobid, max_jobid);
101 /* turn parameters into data stream */
102 at_io_q_del_job("", &q_d, &buf, 0);
104 /* send the data on \PIPE\ */
105 if (rpc_api_pipe_req(cli, fnum, AT_DEL_JOB, &buf, &rbuf))
109 at_io_r_del_job("", &r_d, &rbuf, 0);
110 p = rbuf.offset != 0;
112 if (p && r_d.status != 0)
114 /* report error code */
115 DEBUG(0,("AT_R_DEL_JOB: %s\n", get_nt_error_msg(r_d.status)));
126 /****************************************************************************
127 enumerate scheduled jobs
128 ****************************************************************************/
129 BOOL at_enum_jobs(struct cli_state *cli, uint16 fnum,
130 char *server_name, uint32 *num_jobs,
131 AT_ENUM_INFO *jobs, fstring *commands)
138 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
139 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
141 /* create and send a MSRPC command with api AT_DEL_JOB */
143 DEBUG(4,("Scheduler Enumerate Jobs\n"));
145 /* store the parameters */
146 make_at_q_enum_jobs(&q_e, server_name);
148 /* turn parameters into data stream */
149 at_io_q_enum_jobs("", &q_e, &buf, 0);
151 /* send the data on \PIPE\ */
152 if (rpc_api_pipe_req(cli, fnum, AT_ENUM_JOBS, &buf, &rbuf))
156 at_io_r_enum_jobs("", &r_e, &rbuf, 0);
157 p = rbuf.offset != 0;
159 if (p && r_e.status != 0)
161 /* report error code */
162 DEBUG(0,("AT_R_ENUM_JOBS: %s\n", get_nt_error_msg(r_e.status)));
170 *num_jobs = r_e.num_entries;
171 memcpy(jobs, &r_e.info, r_e.num_entries * sizeof(AT_ENUM_INFO));
173 for (i = 0; i < r_e.num_entries; i++)
175 unistr2_to_ascii(commands[i], &r_e.command[i],
176 sizeof(commands[i]));
187 /****************************************************************************
188 query job information
189 ****************************************************************************/
190 BOOL at_query_job(struct cli_state *cli, uint16 fnum, char *server_name,
191 uint32 jobid, AT_JOB_INFO *job, fstring command)
198 prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
199 prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
201 /* create and send a MSRPC command with api AT_QUERY_JOB */
203 DEBUG(4,("Scheduler Query Job\n"));
205 /* store the parameters */
206 make_at_q_query_job(&q_q, server_name, jobid);
208 /* turn parameters into data stream */
209 at_io_q_query_job("", &q_q, &buf, 0);
211 /* send the data on \PIPE\ */
212 if (rpc_api_pipe_req(cli, fnum, AT_QUERY_JOB, &buf, &rbuf))
216 at_io_r_query_job("", &r_q, &rbuf, 0);
217 p = rbuf.offset != 0;
219 if (p && r_q.status != 0)
221 /* report error code */
222 DEBUG(0,("AT_R_QUERY_JOB: %s\n", get_nt_error_msg(r_q.status)));
228 memcpy(job, &r_q.info, sizeof(AT_JOB_INFO));
229 unistr2_to_ascii(command, &r_q.command,