6 #include <libsmbclient.h>
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];
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;
22 int print_queue_empty;
24 static void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
25 char *username, int unmaxlen, char *password, int pwmaxlen)
28 strncpy(workgroup, g_workgroup, wgmaxlen - 1);
30 strncpy(username, g_username, unmaxlen - 1);
32 strncpy(password, g_password, pwmaxlen - 1);
34 strcpy(g_server, server);
35 strcpy(g_share, share);
39 static void print_list_fn_2(struct print_job_info *pji)
41 print_queue_empty = 0;
45 static void print_list_fn(struct print_job_info *pji)
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);
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); */
61 int main(int argc, char** argv)
65 char url[MAX_BUFF_SIZE];
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);
76 print_queue_empty = 0;
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]));
86 smbc_init(auth_fn, 0);
88 while ( ! print_queue_empty ) /* Wait until the queue is empty */
91 print_queue_empty = 1;
92 smbc_list_print_jobs(url,print_list_fn_2);
95 smbc_list_print_jobs(url,print_list_fn);