5 #include <libsmbclient.h>
7 #define MAX_BUFF_SIZE 255
8 char g_workgroup
[MAX_BUFF_SIZE
];
9 char g_username
[MAX_BUFF_SIZE
];
10 char g_password
[MAX_BUFF_SIZE
];
11 char g_server
[MAX_BUFF_SIZE
];
12 char g_share
[MAX_BUFF_SIZE
];
14 char g_print_user
[MAX_BUFF_SIZE
];
15 char g_print_name
[MAX_BUFF_SIZE
];
16 unsigned int g_print_id
;
17 unsigned int g_print_priority
;
18 unsigned int g_print_size
;
21 static void auth_fn(const char *server
, const char *share
, char *workgroup
, int wgmaxlen
,
22 char *username
, int unmaxlen
, char *password
, int pwmaxlen
)
25 strncpy(workgroup
, g_workgroup
, wgmaxlen
- 1);
27 strncpy(username
, g_username
, unmaxlen
- 1);
29 strncpy(password
, g_password
, pwmaxlen
- 1);
31 strcpy(g_server
, server
);
32 strcpy(g_share
, share
);
36 static void print_list_fn(struct print_job_info
*pji
)
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
);
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); */
50 int main(int argc
, char** argv
)
55 char url
[MAX_BUFF_SIZE
];
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
);
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]));
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); */
82 smbc_init(auth_fn
, 0);
84 fd
= smbc_open(url
,O_RDWR
| O_CREAT
, 0666);
85 smbc_write(fd
, message
, msg_len
);
90 smbc_print_file(url
,argv
[6]);
91 smbc_list_print_jobs(argv
[6],print_list_fn
);
94 if (( (g_print_size
> 0) && (g_print_size
> 0) && (strcasecmp(g_username
,g_print_user
)==0) ))
95 /* && (strlen(g_print_name) > 0) )) */