*/
#include "includes.h"
+#include "system/filesys.h"
+#include "system/passwd.h"
+#include "libsmb/libsmb.h"
/*
* Starting with CUPS 1.3, Kerberos support is provided by cupsd including
* Setup the SAMBA server state...
*/
- setup_logging("smbspool", True);
+ setup_logging("smbspool", DEBUG_STDOUT);
lp_set_in_client(True); /* Make sure that we tell lp_load we are */
/* Start the SMB connection */
*need_auth = false;
nt_status = cli_start_connection(&cli, myname, server, NULL, port,
- Undefined, flags, NULL);
+ Undefined, flags);
if (!NT_STATUS_IS_OK(nt_status)) {
fprintf(stderr, "ERROR: Connection failed: %s\n", nt_errstr(nt_status));
return NULL;
return NULL;
}
- if (!cli_send_tconX(cli, share, "?????", password, strlen(password) + 1)) {
- fprintf(stderr, "ERROR: Tree connect failed (%s)\n", cli_errstr(cli));
+ nt_status = cli_tcon_andx(cli, share, "?????", password,
+ strlen(password) + 1);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ fprintf(stderr, "ERROR: Tree connect failed (%s)\n",
+ nt_errstr(nt_status));
- if (get_exit_code(cli, cli_nt_error(cli)) == 2) {
+ if (get_exit_code(cli, nt_status) == 2) {
*need_auth = true;
}
/*
* Get the names and addresses of the client and server...
*/
- myname = talloc_get_myname(talloc_tos());
+ myname = get_myname(talloc_tos());
if (!myname) {
return NULL;
}
char *title, /* I - Title/job name */
FILE * fp)
{ /* I - File to print */
- int fnum; /* File number */
+ uint16_t fnum; /* File number */
int nbytes, /* Number of bytes read */
tbytes; /* Total bytes read */
char buffer[8192], /* Buffer for copy */
*ptr; /* Pointer into title */
+ NTSTATUS nt_status;
/*
* Open the printer device...
*/
- fnum = cli_open(cli, title, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
- if (fnum == -1) {
+ nt_status = cli_open(cli, title, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE,
+ &fnum);
+ if (!NT_STATUS_IS_OK(nt_status)) {
fprintf(stderr, "ERROR: %s opening remote spool %s\n",
- cli_errstr(cli), title);
- return (get_exit_code(cli, cli_nt_error(cli)));
+ nt_errstr(nt_status), title);
+ return get_exit_code(cli, nt_status);
}
/*
tbytes = 0;
while ((nbytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
- if (cli_write(cli, fnum, 0, buffer, tbytes, nbytes) != nbytes) {
- int status = get_exit_code(cli, cli_nt_error(cli));
-
- fprintf(stderr, "ERROR: Error writing spool: %s\n", cli_errstr(cli));
- fprintf(stderr, "DEBUG: Returning status %d...\n", status);
+ NTSTATUS status;
+
+ status = cli_writeall(cli, fnum, 0, (uint8_t *)buffer,
+ tbytes, nbytes, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ int ret = get_exit_code(cli, status);
+ fprintf(stderr, "ERROR: Error writing spool: %s\n",
+ nt_errstr(status));
+ fprintf(stderr, "DEBUG: Returning status %d...\n",
+ ret);
cli_close(cli, fnum);
- return (status);
+ return (ret);
}
tbytes += nbytes;
}
- if (!cli_close(cli, fnum)) {
+ nt_status = cli_close(cli, fnum);
+ if (!NT_STATUS_IS_OK(nt_status)) {
fprintf(stderr, "ERROR: %s closing remote spool %s\n",
- cli_errstr(cli), title);
- return (get_exit_code(cli, cli_nt_error(cli)));
+ nt_errstr(nt_status), title);
+ return get_exit_code(cli, nt_status);
} else {
return (0);
}