~vcs-imports/samba/main

« back to all changes in this revision

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

  • Committer: jerry
  • Date: 2006-07-14 21:48:39 UTC
  • Revision ID: vcs-imports@canonical.com-20060714214839-586d8c489a8fcead
gutting trunk to move to svn:externals

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 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
 
                err = smbc_list_print_jobs(url,print_list_fn);
93
 
 
94
 
                if ( err < 0 )
95
 
                        err = 1;
96
 
 
97
 
                else
98
 
                        err = 0;
99
 
 
100
 
        }
101
 
 
102
 
        return err;
103
 
 
104
 
}
105