svn commit: samba r9605 - in branches/SOC/SAMBA_3_0/source/client: .
kalim at samba.org
kalim at samba.org
Thu Aug 25 02:55:55 GMT 2005
Author: kalim
Date: 2005-08-25 02:55:54 +0000 (Thu, 25 Aug 2005)
New Revision: 9605
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9605
Log:
Wrote the core of the 'put' command and enabled cmd_put.
-Kalim
Modified:
branches/SOC/SAMBA_3_0/source/client/client.c
Changeset:
Modified: branches/SOC/SAMBA_3_0/source/client/client.c
===================================================================
--- branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-25 02:33:08 UTC (rev 9604)
+++ branches/SOC/SAMBA_3_0/source/client/client.c 2005-08-25 02:55:54 UTC (rev 9605)
@@ -933,6 +933,7 @@
if (newhandle)
close(handle);
smbc_close(fnum);
+ SAFE_FREE(data);
return 1;
}
while (1) {
@@ -944,6 +945,7 @@
if (newhandle)
close(handle);
smbc_close(fnum);
+ SAFE_FREE(data);
return 1;
}
if (n == 0)
@@ -1315,33 +1317,27 @@
int maxwrite = io_bufsize;
int rc = 0;
struct timeval tp_start;
- struct cli_state *targetcli;
- pstring targetname;
+ struct stat stat;
- if ( !cli_resolve_path( "", cli, rname, &targetcli, targetname ) ) {
- d_printf("Failed to open %s: %s\n", rname, cli_errstr(cli));
- return 1;
- }
-
GetTimeOfDay(&tp_start);
if (reput) {
- fnum = cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE);
- if (fnum >= 0) {
- if (!cli_qfileinfo(targetcli, fnum, NULL, &start, NULL, NULL, NULL, NULL, NULL) &&
- !cli_getattrE(targetcli, fnum, NULL, &start, NULL, NULL, NULL)) {
- d_printf("getattrib: %s\n",cli_errstr(cli));
- return 1;
- }
- }
+ fnum = smbc_open(rname, O_RDWR|O_CREAT, 0644);
+ if (fnum < 0)
+ {
+ d_printf("%s opening remote file %s\n", strerror(errno), rname);
+ return 1;
+ }
+ if (smbc_fstat(fnum, &stat) < 0)
+ {
+ d_printf("%s trying to stat remote file %s\n", strerror(errno), rname);
+ smbc_close(fnum);
+ return 1;
+ }
+ start = stat.st_size;
} else {
- fnum = cli_open(targetcli, targetname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
+ fnum = smbc_creat(rname, 0644);
}
-
- if (fnum == -1) {
- d_printf("%s opening remote file %s\n",cli_errstr(targetcli),rname);
- return 1;
- }
/* allow files to be piped into smbclient
jdblair 24.jun.98
@@ -1356,6 +1352,8 @@
if (f && reput) {
if (x_tseek(f, start, SEEK_SET) == -1) {
d_printf("Error seeking local file\n");
+ smbc_close(fnum);
+ x_fclose(f);
return 1;
}
}
@@ -1363,17 +1361,30 @@
if (!f) {
d_printf("Error opening local file %s\n",lname);
+ smbc_close(fnum);
return 1;
}
- DEBUG(1,("putting file %s as %s ",lname,
- rname));
+ DEBUG(1,("putting file %s as %s ",lname,rname));
buf = (char *)SMB_MALLOC(maxwrite);
if (!buf) {
d_printf("ERROR: Not enough memory!\n");
+ smbc_close(fnum);
+ if (f != x_stdin)
+ x_fclose(f);
return 1;
}
+
+ if (smbc_lseek(fnum, start, SEEK_SET) < 0)
+ {
+ d_printf("%s trying to lseek remote file %s\n", strerror(errno), rname);
+ if (f != x_stdin)
+ x_fclose(f);
+ smbc_close(fnum);
+ SAFE_FREE(buf);
+ return 1;
+ }
while (!x_feof(f)) {
int n = maxwrite;
int ret;
@@ -1387,10 +1398,10 @@
break;
}
- ret = cli_write(targetcli, fnum, 0, buf, nread + start, n);
+ ret = smbc_write(fnum, buf, n);
if (n != ret) {
- d_printf("Error writing file: %s\n", cli_errstr(cli));
+ d_printf("Error writing file: %s\n", strerror(errno));
rc = 1;
break;
}
@@ -1398,9 +1409,10 @@
nread += n;
}
- if (!cli_close(targetcli, fnum)) {
- d_printf("%s closing remote file %s\n",cli_errstr(cli),rname);
- x_fclose(f);
+ if (smbc_close(fnum) < 0) {
+ d_printf("%s closing remote file %s\n",strerror(errno),rname);
+ if (f != x_stdin)
+ x_fclose(f);
SAFE_FREE(buf);
return 1;
}
@@ -1447,8 +1459,9 @@
pstring buf;
char *p=buf;
- pstrcpy(rname,cur_dir);
- pstrcat(rname,"/");
+ pstrcpy(rname, "smb:");
+ pstrcat(rname, service);
+ pstrcat(rname, cur_dir);
if (!next_token_nr(NULL,p,NULL,sizeof(buf))) {
d_printf("put <filename>\n");
@@ -1461,8 +1474,6 @@
else
pstrcat(rname,lname);
- dos_clean_name(rname);
-
{
SMB_STRUCT_STAT st;
/* allow '-' to represent stdin
@@ -1474,6 +1485,7 @@
}
}
+ /*d_printf("lname: %s, rname: %s\n", lname, rname);*/
return do_put(rname, lname, False);
}
@@ -2899,7 +2911,7 @@
/* {"open",cmd_open,"<mask> open a file",{COMPL_REMOTE,COMPL_NONE}}, */
/* {"print",cmd_print,"<file name> print a file",{COMPL_NONE,COMPL_NONE}}, */
{"prompt",cmd_prompt,"toggle prompting for filenames for mget and mput",{COMPL_NONE,COMPL_NONE}},
-/* {"put",cmd_put,"<local name> [remote name] put a file",{COMPL_LOCAL,COMPL_REMOTE}}, */
+ {"put",cmd_put,"<local name> [remote name] put a file",{COMPL_LOCAL,COMPL_REMOTE}},
{"pwd",cmd_pwd,"show current remote directory (same as 'cd' with no args)",{COMPL_NONE,COMPL_NONE}},
{"q",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
/* {"queue",cmd_queue,"show the print queue",{COMPL_NONE,COMPL_NONE}}, */
@@ -3326,7 +3338,7 @@
if (*base_directory) {
rc = do_cd(base_directory);
if (rc) {
- /*cli_cm_shutdown();*/
+ cli_cm_shutdown();
return rc;
}
}
More information about the samba-cvs
mailing list