delineation between smb and msrpc more marked. smbd now constructs
[kai/samba.git] / source3 / rpc_parse / parse_at.c
1 /* 
2  *  Unix SMB/Netbios implementation.
3  *  Version 2.1.
4  *  RPC parsing 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.
8  *  
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.
13  *  
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.
18  *  
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.
22  */
23
24 #include "includes.h"
25
26 extern int DEBUGLEVEL;
27
28 /*******************************************************************
29  make_at_q_add_job
30  ********************************************************************/
31 BOOL make_at_q_add_job(AT_Q_ADD_JOB *q_a, char *server,
32                         AT_JOB_INFO *info, char *command)
33 {
34         DEBUG(5,("make_at_q_add_job\n"));
35
36         make_buf_unistr2(&(q_a->uni_srv_name), &(q_a->ptr_srv_name), server);
37         memcpy(&(q_a->info), info, sizeof(q_a->info));
38         make_unistr2(&(q_a->command), command, strlen(command)+1);
39
40         return True;
41 }
42
43 /*******************************************************************
44 reads or writes a AT_JOB_INFO structure.
45 ********************************************************************/
46 BOOL at_io_job_info(char *desc, AT_JOB_INFO *info, prs_struct *ps, int depth)
47 {
48         if (info == NULL) return False;
49
50         prs_debug(ps, depth, desc, "at_io_job_info");
51         depth++;
52
53         prs_align(ps);
54
55         prs_uint32("time", ps, depth, &(info->time));
56         prs_uint32("monthdays", ps, depth, &(info->monthdays));
57         prs_uint8("weekdays", ps, depth, &(info->weekdays));
58         prs_uint8("flags", ps, depth, &(info->flags));
59         prs_align(ps);
60
61         prs_uint32("ptr_command", ps, depth, &(info->ptr_command));
62
63         return True;
64 }
65
66 /*******************************************************************
67 reads or writes a AT_Q_ADD_JOB structure.
68 ********************************************************************/
69 BOOL at_io_q_add_job(char *desc, AT_Q_ADD_JOB *q_a, prs_struct *ps, int depth)
70 {
71         if (q_a == NULL) return False;
72
73         prs_debug(ps, depth, desc, "at_q_add_job");
74         depth++;
75
76         prs_align(ps);
77         prs_uint32("ptr_srv_name", ps, depth, &(q_a->ptr_srv_name));
78         smb_io_unistr2("", &(q_a->uni_srv_name), q_a->ptr_srv_name, ps, depth); 
79         at_io_job_info("", &(q_a->info), ps, depth);
80         smb_io_unistr2("", &(q_a->command), q_a->info.ptr_command, ps, depth);
81
82         return True;
83 }
84
85 /*******************************************************************
86 reads or writes a AT_R_ADD_JOB structure.
87 ********************************************************************/
88 BOOL at_io_r_add_job(char *desc, AT_R_ADD_JOB *r_a, prs_struct *ps, int depth)
89 {
90         if (r_a == NULL) return False;
91
92         prs_debug(ps, depth, desc, "at_r_add_job");
93         depth++;
94
95         prs_align(ps);
96         prs_uint32("jobid", ps, depth, &(r_a->jobid));
97         prs_uint32("status", ps, depth, &(r_a->status));
98
99         return True;
100 }
101
102 /*******************************************************************
103  make_at_q_del_job
104  ********************************************************************/
105 BOOL make_at_q_del_job(AT_Q_DEL_JOB *q_a, char *server, uint32 min_jobid,
106                        uint32 max_jobid)
107 {
108         DEBUG(5,("make_at_q_del_job\n"));
109
110         make_buf_unistr2(&(q_a->uni_srv_name), &(q_a->ptr_srv_name), server);
111         q_a->min_jobid = min_jobid;
112         q_a->max_jobid = max_jobid;
113
114         return True;
115 }
116
117 /*******************************************************************
118 reads or writes a AT_Q_DEL_JOB structure.
119 ********************************************************************/
120 BOOL at_io_q_del_job(char *desc, AT_Q_DEL_JOB *q_d, prs_struct *ps, int depth)
121 {
122         if (q_d == NULL) return False;
123
124         prs_debug(ps, depth, desc, "at_q_del_job");
125         depth++;
126
127         prs_align(ps);
128
129         prs_uint32("ptr_srv_name", ps, depth, &(q_d->ptr_srv_name));
130         smb_io_unistr2("", &(q_d->uni_srv_name), q_d->ptr_srv_name, ps, depth); 
131         prs_align(ps);
132         prs_uint32("min_jobid", ps, depth, &(q_d->min_jobid));
133         prs_uint32("max_jobid", ps, depth, &(q_d->max_jobid));
134
135         return True;
136 }
137
138 /*******************************************************************
139 reads or writes a AT_R_DEL_JOB structure.
140 ********************************************************************/
141 BOOL at_io_r_del_job(char *desc, AT_R_DEL_JOB *r_d, prs_struct *ps, int depth)
142 {
143         if (r_d == NULL) return False;
144
145         prs_debug(ps, depth, desc, "at_r_del_job");
146         depth++;
147
148         prs_align(ps);
149         prs_uint32("status", ps, depth, &(r_d->status));
150
151         return True;
152 }
153
154 /*******************************************************************
155  make_at_q_enum_jobs
156  ********************************************************************/
157 BOOL make_at_q_enum_jobs(AT_Q_ENUM_JOBS *q_e, char *server)
158 {
159         DEBUG(5,("make_at_q_enum_jobs\n"));
160
161         make_buf_unistr2(&(q_e->uni_srv_name), &(q_e->ptr_srv_name), server);
162         q_e->unknown0 = 0;
163         q_e->unknown1 = 0;
164         q_e->max_len = 0xffff;
165         q_e->ptr_resume = 1;
166         q_e->hnd_resume = 0;
167
168         return True;
169 }
170
171 /*******************************************************************
172 reads or writes a AT_Q_ENUM_JOBS structure.
173 ********************************************************************/
174 BOOL at_io_q_enum_jobs(char *desc, AT_Q_ENUM_JOBS *q_e, prs_struct *ps, int depth)
175 {
176         if (q_e == NULL) return False;
177
178         prs_debug(ps, depth, desc, "at_q_enum_jobs");
179         depth++;
180
181         prs_align(ps);
182         prs_uint32("ptr_srv_name", ps, depth, &(q_e->ptr_srv_name));
183         smb_io_unistr2("", &(q_e->uni_srv_name), q_e->ptr_srv_name, ps, depth); 
184         prs_align(ps);
185         prs_uint32("unknown0", ps, depth, &(q_e->unknown0));
186         prs_uint32("unknown1", ps, depth, &(q_e->unknown1));
187         prs_uint32("max_len" , ps, depth, &(q_e->max_len ));
188
189         prs_uint32("ptr_resume", ps, depth, &(q_e->ptr_resume));
190         prs_uint32("hnd_resume", ps, depth, &(q_e->hnd_resume));
191
192         return True;
193 }
194
195 /*******************************************************************
196 reads or writes a AT_R_ENUM_JOBS structure.
197 ********************************************************************/
198 BOOL at_io_r_enum_jobs(char *desc, AT_R_ENUM_JOBS *r_e, prs_struct *ps, int depth)
199 {
200         if (r_e == NULL) return False;
201
202         prs_debug(ps, depth, desc, "at_r_enum_jobs");
203         depth++;
204
205         prs_align(ps);
206         prs_uint32("num_entries", ps, depth, &(r_e->num_entries));
207         prs_uint32("ptr_entries", ps, depth, &(r_e->ptr_entries));
208
209         if (r_e->ptr_entries != 0)
210         {
211                 int i;
212
213                 prs_uint32("num_entries2", ps, depth, &(r_e->num_entries2));
214                 if (r_e->num_entries2 != r_e->num_entries)
215                 {
216                         /* RPC fault */
217                         return False;
218                 }
219
220                 SMB_ASSERT_ARRAY(r_e->info, r_e->num_entries2);
221
222                 for (i = 0; i < r_e->num_entries2; i++)
223                 {
224                         prs_uint32("jobid", ps, depth, &(r_e->info[i].jobid));
225                         at_io_job_info("", &(r_e->info[i].info), ps, depth);
226                 }
227
228                 for (i = 0; i < r_e->num_entries2; i++)
229                 {
230                         smb_io_unistr2("", &(r_e->command[i]),
231                                  r_e->info[i].info.ptr_command, ps, depth);
232                 }
233         }
234
235         prs_align(ps);
236         prs_uint32("total_entries", ps, depth, &(r_e->total_entries));
237         prs_uint32("ptr_resume"   , ps, depth, &(r_e->ptr_resume   ));
238         prs_uint32("hnd_resume"   , ps, depth, &(r_e->hnd_resume   ));
239
240         prs_uint32("status", ps, depth, &(r_e->status));
241
242         return True;
243 }
244
245 /*******************************************************************
246  make_at_q_query_job
247  ********************************************************************/
248 BOOL make_at_q_query_job(AT_Q_QUERY_JOB *q_q, char *server, uint32 jobid)
249 {
250         DEBUG(5,("make_at_q_query_job\n"));
251
252         make_buf_unistr2(&(q_q->uni_srv_name), &(q_q->ptr_srv_name), server);
253         q_q->jobid = jobid;
254
255         return True;
256 }
257
258 /*******************************************************************
259 reads or writes a AT_Q_QUERY_JOB structure.
260 ********************************************************************/
261 BOOL at_io_q_query_job(char *desc, AT_Q_QUERY_JOB *q_q, prs_struct *ps, int depth)
262 {
263         if (q_q == NULL) return False;
264
265         prs_debug(ps, depth, desc, "at_q_query_job");
266         depth++;
267
268         prs_align(ps);
269         prs_uint32("ptr_srv_name", ps, depth, &(q_q->ptr_srv_name));
270         smb_io_unistr2("", &(q_q->uni_srv_name), q_q->ptr_srv_name, ps, depth); 
271         prs_align(ps);
272         prs_uint32("jobid", ps, depth, &(q_q->jobid));
273
274         return True;
275 }
276
277 /*******************************************************************
278 reads or writes a AT_R_QUERY_JOB structure.
279 ********************************************************************/
280 BOOL at_io_r_query_job(char *desc, AT_R_QUERY_JOB *r_q, prs_struct *ps, int depth)
281 {
282         if (r_q == NULL) return False;
283
284         prs_debug(ps, depth, desc, "at_r_query_job");
285         depth++;
286
287         prs_align(ps);
288         prs_uint32("ptr_info", ps, depth, &(r_q->ptr_info));
289         if (r_q->ptr_info != 0)
290         {
291                 at_io_job_info("", &(r_q->info), ps, depth);
292                 smb_io_unistr2("", &(r_q->command), r_q->info.ptr_command, ps, depth);
293         }
294
295         prs_align(ps);
296         prs_uint32("status", ps, depth, &(r_q->status));
297
298         return True;
299 }