~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_1.c

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 call_back_flag;
 
22
int print_queue_empty;
 
23
 
 
24
void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen, 
 
25
                char *username, int unmaxlen, char *password, int pwmaxlen)
 
26
{
 
27
 
 
28
        strncpy(workgroup, g_workgroup, wgmaxlen - 1);
 
29
 
 
30
        strncpy(username, g_username, unmaxlen - 1);
 
31
 
 
32
        strncpy(password, g_password, pwmaxlen - 1);
 
33
 
 
34
        strcpy(g_server, server);
 
35
        strcpy(g_share, share);
 
36
 
 
37
}
 
38
 
 
39
void print_list_fn_2(struct print_job_info *pji)
 
40
{
 
41
        print_queue_empty = 0;
 
42
        g_print_id = pji->id;
 
43
}
 
44
 
 
45
void print_list_fn(struct print_job_info *pji)
 
46
{
 
47
 
 
48
        call_back_flag = 1;
 
49
 
 
50
        g_print_id = pji->id;
 
51
        g_print_priority = pji->priority;
 
52
        g_print_size = pji->size;
 
53
        strcpy(g_print_user,pji->user);
 
54
        strcpy(g_print_name,pji->name);
 
55
 
 
56
        /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
 
57
                                  pji->id, pji->priority, pji->size, pji->user, pji->name); */
 
58
        
 
59
}
 
60
 
 
61
int main(int argc, char** argv)
 
62
{
 
63
 
 
64
        int err = -1;
 
65
        char url[MAX_BUFF_SIZE];
 
66
 
 
67
        bzero(g_workgroup,MAX_BUFF_SIZE);
 
68
        bzero(url,MAX_BUFF_SIZE);
 
69
        bzero(g_print_user,MAX_BUFF_SIZE);
 
70
        bzero(g_print_name,MAX_BUFF_SIZE);
 
71
 
 
72
        g_print_id = 0;
 
73
        g_print_priority = 0;
 
74
        g_print_size = 0;
 
75
        call_back_flag = 0;
 
76
        print_queue_empty = 0;
 
77
 
 
78
        if ( argc == 5 )
 
79
        {
 
80
                
 
81
                strncpy(g_workgroup,argv[1],strlen(argv[1]));
 
82
                strncpy(g_username,argv[2],strlen(argv[2]));
 
83
                strncpy(g_password,argv[3],strlen(argv[3]));
 
84
                strncpy(url,argv[4],strlen(argv[4]));
 
85
 
 
86
                smbc_init(auth_fn, 0);
 
87
 
 
88
                while ( ! print_queue_empty ) /* Wait until the queue is empty */
 
89
                {
 
90
                        sleep(1);
 
91
                        print_queue_empty = 1;
 
92
                        smbc_list_print_jobs(url,print_list_fn_2);
 
93
                }
 
94
 
 
95
                smbc_list_print_jobs(url,print_list_fn);
 
96
 
 
97
                if ( call_back_flag )
 
98
 
 
99
                        err = 0;
 
100
 
 
101
                else
 
102
                        err = 1;
 
103
                
 
104
        }
 
105
 
 
106
        return err;
 
107
 
 
108
}
 
109