• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/samba-3.0.13/testsuite/libsmbclient/src/list_print_jobs/
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <errno.h>
5#include <libsmbclient.h>
6
7#define	MAX_BUFF_SIZE	255
8char g_workgroup[MAX_BUFF_SIZE];
9char g_username[MAX_BUFF_SIZE];
10char g_password[MAX_BUFF_SIZE];
11char g_server[MAX_BUFF_SIZE];
12char g_share[MAX_BUFF_SIZE];
13
14char g_print_user[MAX_BUFF_SIZE];
15char g_print_name[MAX_BUFF_SIZE];
16unsigned int g_print_id;
17unsigned int g_print_priority;
18unsigned int g_print_size;
19
20
21void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
22		char *username, int unmaxlen, char *password, int pwmaxlen)
23{
24
25	strncpy(workgroup, g_workgroup, wgmaxlen - 1);
26
27	strncpy(username, g_username, unmaxlen - 1);
28
29	strncpy(password, g_password, pwmaxlen - 1);
30
31	strcpy(g_server, server);
32	strcpy(g_share, share);
33
34}
35
36void print_list_fn(struct print_job_info *pji)
37{
38
39	g_print_id = pji->id;
40	g_print_priority = pji->priority;
41	g_print_size = pji->size;
42	strcpy(g_print_user,pji->user);
43	strcpy(g_print_name,pji->name);
44
45	/* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
46		          pji->id, pji->priority, pji->size, pji->user, pji->name); */
47
48}
49
50int main(int argc, char** argv)
51{
52	int err = -1;
53	int fd = 0;
54	int msg_len = 0;
55	char url[MAX_BUFF_SIZE];
56	char* message;
57
58	bzero(g_workgroup,MAX_BUFF_SIZE);
59	bzero(url,MAX_BUFF_SIZE);
60	bzero(g_print_user,MAX_BUFF_SIZE);
61	bzero(g_print_name,MAX_BUFF_SIZE);
62
63	g_print_id = 0;
64	g_print_priority = 0;
65	g_print_size = 0;
66
67	if ( argc == 7 )
68	{
69
70		strncpy(g_workgroup,argv[1],strlen(argv[1]));
71		strncpy(g_username,argv[2],strlen(argv[2]));
72		strncpy(g_password,argv[3],strlen(argv[3]));
73		strncpy(url,argv[4],strlen(argv[4]));
74
75		msg_len = strlen(argv[5])+1;
76		message = malloc(msg_len);
77		message[msg_len - 1] = 0;
78		strncpy(message,argv[5],msg_len);
79		/* printf("Message: %s\n",message); */
80		/* printf("Message len: %i\n",msg_len); */
81
82		smbc_init(auth_fn, 0);
83		smbc_unlink(url);
84		fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
85		smbc_write(fd, message, msg_len);
86		smbc_close(fd);
87
88		free(message);
89		smbc_print_file(url,argv[6]);
90		err = smbc_list_print_jobs(argv[6],print_list_fn);
91
92		if ( err < 0 )
93			err = 1;
94
95		else
96			err = 0;
97
98	}
99
100	return err;
101
102}
103
104