import HEAD into svn+ssh://svn.samba.org/home/svn/samba/trunk
[metze/old/v3-2-winbind-ndr.git] / testsuite / libsmbclient / src / list_print_jobs / list_print_jobs_5.c
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <errno.h>
6 #include <libsmbclient.h>
7
8 #define MAX_BUFF_SIZE   255
9 char g_workgroup[MAX_BUFF_SIZE];
10 char g_username[MAX_BUFF_SIZE];
11 char g_password[MAX_BUFF_SIZE];
12 char g_server[MAX_BUFF_SIZE];
13 char g_share[MAX_BUFF_SIZE];
14
15 char g_print_user[MAX_BUFF_SIZE];
16 char g_print_name[MAX_BUFF_SIZE];
17 unsigned int g_print_id;
18 unsigned int g_print_priority;
19 unsigned int g_print_size;
20
21 int print_queue_empty;
22
23 void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen, 
24                 char *username, int unmaxlen, char *password, int pwmaxlen)
25 {
26
27         strncpy(workgroup, g_workgroup, wgmaxlen - 1);
28
29         strncpy(username, g_username, unmaxlen - 1);
30
31         strncpy(password, g_password, pwmaxlen - 1);
32
33         strcpy(g_server, server);
34         strcpy(g_share, share);
35
36 }
37
38 void print_list_fn_2(struct print_job_info *pji)
39 {
40         print_queue_empty = 0;
41         g_print_id = pji->id;
42 }
43
44 void print_list_fn(struct print_job_info *pji)
45 {
46
47         g_print_id = pji->id;
48         g_print_priority = pji->priority;
49         g_print_size = pji->size;
50         strcpy(g_print_user,pji->user);
51         strcpy(g_print_name,pji->name);
52
53         /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
54                                   pji->id, pji->priority, pji->size, pji->user, pji->name); */
55         
56 }
57
58 int main(int argc, char** argv)
59 {
60
61         int err = -1;
62         char url[MAX_BUFF_SIZE];
63
64         bzero(g_workgroup,MAX_BUFF_SIZE);
65         bzero(url,MAX_BUFF_SIZE);
66         bzero(g_print_user,MAX_BUFF_SIZE);
67         bzero(g_print_name,MAX_BUFF_SIZE);
68
69         g_print_id = 0;
70         g_print_priority = 0;
71         g_print_size = 0;
72
73         print_queue_empty = 0;
74
75         if ( argc == 5 )
76         {
77                 
78                 strncpy(g_workgroup,argv[1],strlen(argv[1]));
79                 strncpy(g_username,argv[2],strlen(argv[2]));
80                 strncpy(g_password,argv[3],strlen(argv[3]));
81                 strncpy(url,argv[4],strlen(argv[4]));
82
83                 smbc_init(auth_fn, 0);
84
85                 while ( ! print_queue_empty ) /* Wait until the queue is empty */
86                 {
87                         sleep(1);
88                         print_queue_empty = 1;
89                         smbc_list_print_jobs(url,print_list_fn_2);
90                 }
91
92                 smbc_list_print_jobs(url,print_list_fn);
93
94                 err = errno;
95
96         }
97
98         return err;
99
100 }
101