first pass at updating head branch to be to be the same as the SAMBA_2_0 branch
[nivanova/samba-autobuild/.git] / source3 / rpcclient / display_spool.c
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    Samba utility functions
5    Copyright (C) Andrew Tridgell 1992-1999
6    Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful, 
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24
25 /****************************************************************************
26 printer info level 0 display function
27 ****************************************************************************/
28 void display_print_info_0(FILE *out_hnd, enum action_type action, 
29                 PRINTER_INFO_0 *const i0)
30 {
31         if (i0 == NULL)
32         {
33                 return;
34         }
35
36         switch (action)
37         {
38                 case ACTION_HEADER:
39                 {
40                         report(out_hnd, "Printer Info Level 0:\n");
41
42                         break;
43                 }
44                 case ACTION_ENUMERATE:
45                 {
46                         fstring name;
47                         fstring serv;
48
49                         unistr_to_ascii(name, i0->printername.buffer, sizeof(name)-1);
50                         unistr_to_ascii(serv, i0->servername .buffer, sizeof(serv)-1);
51
52                         report(out_hnd, "\tprinter name:\t%s\n", name);
53                         report(out_hnd, "\tserver name:\t%s\n", serv);
54                         report(out_hnd, "\t[Other info not displayed]\n");
55
56                         break;
57                 }
58                 case ACTION_FOOTER:
59                 {
60                         report(out_hnd, "\n");
61                         break;
62                 }
63         }
64
65 }
66
67 /****************************************************************************
68 printer info level 1 display function
69 ****************************************************************************/
70 void display_print_info_1(FILE *out_hnd, enum action_type action, 
71                 PRINTER_INFO_1 *const i1)
72 {
73         if (i1 == NULL)
74         {
75                 return;
76         }
77
78         switch (action)
79         {
80                 case ACTION_HEADER:
81                 {
82                         report(out_hnd, "Printer Info Level 1:\n");
83
84                         break;
85                 }
86                 case ACTION_ENUMERATE:
87                 {
88                         fstring desc;
89                         fstring name;
90                         fstring comm;
91
92                         unistr_to_ascii(desc, i1->description.buffer, sizeof(desc)-1);
93                         unistr_to_ascii(name, i1->name       .buffer, sizeof(name)-1);
94                         unistr_to_ascii(comm, i1->comment    .buffer, sizeof(comm)-1);
95
96                         report(out_hnd, "\tflags:\t%d\n", i1->flags);
97                         report(out_hnd, "\tname:\t%s\n", name);
98                         report(out_hnd, "\tdescription:\t%s\n", desc);
99                         report(out_hnd, "\tcomment:\t%s\n", comm);
100
101                         break;
102                 }
103                 case ACTION_FOOTER:
104                 {
105                         report(out_hnd, "\n");
106                         break;
107                 }
108         }
109
110 }
111
112 /****************************************************************************
113 connection info level 0 container display function
114 ****************************************************************************/
115 void display_printer_info_0_ctr(FILE *out_hnd, enum action_type action, 
116                                 uint32 count, PRINTER_INFO_0 *const *const ctr)
117 {
118         if (ctr == NULL)
119         {
120                 report(out_hnd, "display_printer_info_0_ctr: unavailable due to an internal error\n");
121                 return;
122         }
123
124         switch (action)
125         {
126                 case ACTION_HEADER:
127                 {
128                         break;
129                 }
130                 case ACTION_ENUMERATE:
131                 {
132                         int i;
133
134                         for (i = 0; i < count; i++)
135                         {
136                                 display_print_info_0(out_hnd, ACTION_HEADER   , ctr[i]);
137                                 display_print_info_0(out_hnd, ACTION_ENUMERATE, ctr[i]);
138                                 display_print_info_0(out_hnd, ACTION_FOOTER   , ctr[i]);
139                         }
140                         break;
141                 }
142                 case ACTION_FOOTER:
143                 {
144                         break;
145                 }
146         }
147 }
148
149 /****************************************************************************
150 connection info level 1 container display function
151 ****************************************************************************/
152 void display_printer_info_1_ctr(FILE *out_hnd, enum action_type action, 
153                                 uint32 count, PRINTER_INFO_1 *const *const ctr)
154 {
155         if (ctr == NULL)
156         {
157                 report(out_hnd, "display_printer_info_1_ctr: unavailable due to an internal error\n");
158                 return;
159         }
160
161         switch (action)
162         {
163                 case ACTION_HEADER:
164                 {
165                         break;
166                 }
167                 case ACTION_ENUMERATE:
168                 {
169                         int i;
170
171                         for (i = 0; i < count; i++)
172                         {
173                                 display_print_info_1(out_hnd, ACTION_HEADER   , ctr[i]);
174                                 display_print_info_1(out_hnd, ACTION_ENUMERATE, ctr[i]);
175                                 display_print_info_1(out_hnd, ACTION_FOOTER   , ctr[i]);
176                         }
177                         break;
178                 }
179                 case ACTION_FOOTER:
180                 {
181                         break;
182                 }
183         }
184 }
185
186 /****************************************************************************
187 connection info container display function
188 ****************************************************************************/
189 void display_printer_info_ctr(FILE *out_hnd, enum action_type action, 
190                                 uint32 level, uint32 count,
191                                 void *const *const ctr)
192 {
193         if (ctr == NULL)
194         {
195                 report(out_hnd, "display_printer_info_ctr: unavailable due to an internal error\n");
196                 return;
197         }
198
199         switch (level)
200         {
201                 case 0:
202                 {
203                         display_printer_info_0_ctr(out_hnd, action, 
204                                            count, (PRINTER_INFO_0*const*const)ctr);
205                         break;
206                 }
207                 case 1:
208                 {
209                         display_printer_info_1_ctr(out_hnd, action, 
210                                            count, (PRINTER_INFO_1*const*const)ctr);
211                         break;
212                 }
213                 default:
214                 {
215                         report(out_hnd, "display_printer_info_ctr: Unknown Info Level\n");
216                         break;
217                 }
218         }
219 }
220
221 /****************************************************************************
222 job info level 2 display function
223 ****************************************************************************/
224 void display_job_info_2(FILE *out_hnd, enum action_type action, 
225                 JOB_INFO_2 *const i2)
226 {
227         if (i2 == NULL)
228         {
229                 return;
230         }
231
232         switch (action)
233         {
234                 case ACTION_HEADER:
235                 {
236                         report(out_hnd, "Job Info Level 2:\n");
237
238                         break;
239                 }
240                 case ACTION_ENUMERATE:
241                 {
242                         fstring tmp;
243
244                         report(out_hnd, "\tjob id:\t%d\n", i2->jobid);
245                         unistr_to_ascii(tmp, i2->printername.buffer, sizeof(tmp)-1);
246                         report(out_hnd, "\tprinter name:\t%s\n", tmp);
247                         unistr_to_ascii(tmp, i2->machinename.buffer, sizeof(tmp)-1);
248                         report(out_hnd, "\tmachine name:\t%s\n", tmp);
249                         unistr_to_ascii(tmp, i2->username.buffer, sizeof(tmp)-1);
250                         report(out_hnd, "\tusername:\t%s\n", tmp);
251                         unistr_to_ascii(tmp, i2->document.buffer, sizeof(tmp)-1);
252                         report(out_hnd, "\tdocument:\t%s\n", tmp);
253                         unistr_to_ascii(tmp, i2->notifyname.buffer, sizeof(tmp)-1);
254                         report(out_hnd, "\tnotify name:\t%s\n", tmp);
255                         unistr_to_ascii(tmp, i2->datatype.buffer, sizeof(tmp)-1);
256                         report(out_hnd, "\tdata type:\t%s\n", tmp);
257                         unistr_to_ascii(tmp, i2->printprocessor.buffer, sizeof(tmp)-1);
258                         report(out_hnd, "\tprint processor:\t%s\n", tmp);
259                         unistr_to_ascii(tmp, i2->parameters.buffer, sizeof(tmp)-1);
260                         report(out_hnd, "\tparameters:\t%s\n", tmp);
261                         unistr_to_ascii(tmp, i2->drivername.buffer, sizeof(tmp)-1);
262                         report(out_hnd, "\tdriver name:\t%s\n", tmp);
263                         report(out_hnd, "\tDevice Mode:\tNOT DISPLAYED YET\n");
264 /*
265                         DEVICEMODE *devmode;
266 */
267                         unistr_to_ascii(tmp, i2->text_status.buffer, sizeof(tmp)-1);
268                         report(out_hnd, "\ttext status:\t%s\n", tmp);
269                 /*      SEC_DESC sec_desc;*/
270                         report(out_hnd, "\tstatus:\t%d\n", i2->status);
271                         report(out_hnd, "\tpriority:\t%d\n", i2->priority);
272                         report(out_hnd, "\tposition:\t%d\n", i2->position);
273                         report(out_hnd, "\tstarttime:\t%d\n", i2->starttime);
274                         report(out_hnd, "\tuntiltime:\t%d\n", i2->untiltime);
275                         report(out_hnd, "\ttotalpages:\t%d\n", i2->totalpages);
276                         report(out_hnd, "\tsize:\t%d\n", i2->size);
277 /*
278                         SYSTEMTIME submitted;
279 */
280                         report(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n");
281                         report(out_hnd, "\ttimeelapsed:\t%d\n", i2->timeelapsed);
282                         report(out_hnd, "\tpagesprinted:\t%d\n", i2->pagesprinted);
283                 }
284                 case ACTION_FOOTER:
285                 {
286                         report(out_hnd, "\n");
287                         break;
288                 }
289         }
290
291 }
292
293 /****************************************************************************
294 job info level 1 display function
295 ****************************************************************************/
296 void display_job_info_1(FILE *out_hnd, enum action_type action, 
297                 JOB_INFO_1 *const i1)
298 {
299         if (i1 == NULL)
300         {
301                 return;
302         }
303
304         switch (action)
305         {
306                 case ACTION_HEADER:
307                 {
308                         report(out_hnd, "Job Info Level 1:\n");
309
310                         break;
311                 }
312                 case ACTION_ENUMERATE:
313                 {
314                         fstring tmp;
315
316                         report(out_hnd, "\tjob id:\t%d\n", i1->jobid);
317                         unistr_to_ascii(tmp, i1->printername.buffer, sizeof(tmp)-1);
318                         report(out_hnd, "\tprinter name:\t%s\n", tmp);
319                         unistr_to_ascii(tmp, i1->machinename.buffer, sizeof(tmp)-1);
320                         report(out_hnd, "\tmachine name:\t%s\n", tmp);
321                         unistr_to_ascii(tmp, i1->username.buffer, sizeof(tmp)-1);
322                         report(out_hnd, "\tusername:\t%s\n", tmp);
323                         unistr_to_ascii(tmp, i1->document.buffer, sizeof(tmp)-1);
324                         report(out_hnd, "\tdocument:\t%s\n", tmp);
325                         unistr_to_ascii(tmp, i1->datatype.buffer, sizeof(tmp)-1);
326                         report(out_hnd, "\tdata type:\t%s\n", tmp);
327                         unistr_to_ascii(tmp, i1->text_status.buffer, sizeof(tmp)-1);
328                         report(out_hnd, "\ttext status:\t%s\n", tmp);
329                         report(out_hnd, "\tstatus:\t%d\n", i1->status);
330                         report(out_hnd, "\tpriority:\t%d\n", i1->priority);
331                         report(out_hnd, "\tposition:\t%d\n", i1->position);
332                         report(out_hnd, "\ttotalpages:\t%d\n", i1->totalpages);
333 /*
334                         SYSTEMTIME submitted;
335 */
336                         report(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n");
337                         report(out_hnd, "\tpagesprinted:\t%d\n", i1->pagesprinted);
338
339                         break;
340                 }
341                 case ACTION_FOOTER:
342                 {
343                         report(out_hnd, "\n");
344                         break;
345                 }
346         }
347
348 }
349
350 /****************************************************************************
351 connection info level 2 container display function
352 ****************************************************************************/
353 void display_job_info_2_ctr(FILE *out_hnd, enum action_type action, 
354                                 uint32 count, JOB_INFO_2 *const *const ctr)
355 {
356         if (ctr == NULL)
357         {
358                 report(out_hnd, "display_job_info_2_ctr: unavailable due to an internal error\n");
359                 return;
360         }
361
362         switch (action)
363         {
364                 case ACTION_HEADER:
365                 {
366                         break;
367                 }
368                 case ACTION_ENUMERATE:
369                 {
370                         int i;
371
372                         for (i = 0; i < count; i++)
373                         {
374                                 display_job_info_2(out_hnd, ACTION_HEADER   , ctr[i]);
375                                 display_job_info_2(out_hnd, ACTION_ENUMERATE, ctr[i]);
376                                 display_job_info_2(out_hnd, ACTION_FOOTER   , ctr[i]);
377                         }
378                         break;
379                 }
380                 case ACTION_FOOTER:
381                 {
382                         break;
383                 }
384         }
385 }
386
387 /****************************************************************************
388 connection info level 1 container display function
389 ****************************************************************************/
390 void display_job_info_1_ctr(FILE *out_hnd, enum action_type action, 
391                                 uint32 count, JOB_INFO_1 *const *const ctr)
392 {
393         if (ctr == NULL)
394         {
395                 report(out_hnd, "display_job_info_1_ctr: unavailable due to an internal error\n");
396                 return;
397         }
398
399         switch (action)
400         {
401                 case ACTION_HEADER:
402                 {
403                         break;
404                 }
405                 case ACTION_ENUMERATE:
406                 {
407                         int i;
408
409                         for (i = 0; i < count; i++)
410                         {
411                                 display_job_info_1(out_hnd, ACTION_HEADER   , ctr[i]);
412                                 display_job_info_1(out_hnd, ACTION_ENUMERATE, ctr[i]);
413                                 display_job_info_1(out_hnd, ACTION_FOOTER   , ctr[i]);
414                         }
415                         break;
416                 }
417                 case ACTION_FOOTER:
418                 {
419                         break;
420                 }
421         }
422 }
423
424 /****************************************************************************
425 connection info container display function
426 ****************************************************************************/
427 void display_job_info_ctr(FILE *out_hnd, enum action_type action, 
428                                 uint32 level, uint32 count,
429                                 void *const *const ctr)
430 {
431         if (ctr == NULL)
432         {
433                 report(out_hnd, "display_job_info_ctr: unavailable due to an internal error\n");
434                 return;
435         }
436
437         switch (level)
438         {
439                 case 1:
440                 {
441                         display_job_info_1_ctr(out_hnd, action, 
442                                            count, (JOB_INFO_1*const*const)ctr);
443                         break;
444                 }
445                 case 2:
446                 {
447                         display_job_info_2_ctr(out_hnd, action, 
448                                            count, (JOB_INFO_2*const*const)ctr);
449                         break;
450                 }
451                 default:
452                 {
453                         report(out_hnd, "display_job_info_ctr: Unknown Info Level\n");
454                         break;
455                 }
456         }
457 }