View | Details | Raw Unified | Return to bug 1588 | Differences between
and this patch

Collapse All | Expand All

(-)sftp.c (-18 / +20 lines)
Lines 47-64 Link Here
47
#include "sftp-common.h"
47
#include "sftp-common.h"
48
#include "sftp-client.h"
48
#include "sftp-client.h"
49
49
50
#define DEFAULT_COPY_BUFLEN	32768	/* Size of buffer for up/download */
51
#define DEFAULT_NUM_REQUESTS	64	/* # concurrent outstanding requests */
52
50
/* File to read commands from */
53
/* File to read commands from */
51
FILE* infile;
54
FILE* infile;
52
55
53
/* Are we in batchfile mode? */
56
/* Are we in batchfile mode? */
54
int batchmode = 0;
57
int batchmode = 0;
55
58
56
/* Size of buffer used when copying files */
57
size_t copy_buffer_len = 32768;
58
59
/* Number of concurrent outstanding requests */
60
size_t num_requests = 64;
61
62
/* PID of ssh transport process */
59
/* PID of ssh transport process */
63
static pid_t sshpid = -1;
60
static pid_t sshpid = -1;
64
61
Lines 164-170 static const struct CMD cmds[] = { Link Here
164
	{ NULL,			-1}
161
	{ NULL,			-1}
165
};
162
};
166
163
167
int interactive_loop(int fd_in, int fd_out, char *file1, char *file2);
164
int interactive_loop(struct sftp_conn *, char *file1, char *file2);
168
165
169
/* ARGSUSED */
166
/* ARGSUSED */
170
static void
167
static void
Lines 1447-1458 prompt(EditLine *el) Link Here
1447
}
1444
}
1448
1445
1449
int
1446
int
1450
interactive_loop(int fd_in, int fd_out, char *file1, char *file2)
1447
interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
1451
{
1448
{
1452
	char *pwd;
1449
	char *pwd;
1453
	char *dir = NULL;
1450
	char *dir = NULL;
1454
	char cmd[2048];
1451
	char cmd[2048];
1455
	struct sftp_conn *conn;
1456
	int err, interactive;
1452
	int err, interactive;
1457
	EditLine *el = NULL;
1453
	EditLine *el = NULL;
1458
	History *hl = NULL;
1454
	History *hl = NULL;
Lines 1474-1483 interactive_loop(int fd_in, int fd_out, Link Here
1474
		el_source(el, NULL);
1470
		el_source(el, NULL);
1475
	}
1471
	}
1476
1472
1477
	conn = do_init(fd_in, fd_out, copy_buffer_len, num_requests);
1478
	if (conn == NULL)
1479
		fatal("Couldn't initialise connection to server");
1480
1481
	pwd = do_realpath(conn, ".");
1473
	pwd = do_realpath(conn, ".");
1482
	if (pwd == NULL)
1474
	if (pwd == NULL)
1483
		fatal("Need cwd");
1475
		fatal("Need cwd");
Lines 1646-1651 main(int argc, char **argv) Link Here
1646
	arglist args;
1638
	arglist args;
1647
	extern int optind;
1639
	extern int optind;
1648
	extern char *optarg;
1640
	extern char *optarg;
1641
	struct sftp_conn *conn;
1642
	size_t copy_buffer_len = DEFAULT_COPY_BUFLEN;
1643
	size_t num_requests = DEFAULT_NUM_REQUESTS;
1649
1644
1650
	/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
1645
	/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
1651
	sanitise_stdfd();
1646
	sanitise_stdfd();
Lines 1788-1807 main(int argc, char **argv) Link Here
1788
		addargs(&args, "%s", (sftp_server != NULL ?
1783
		addargs(&args, "%s", (sftp_server != NULL ?
1789
		    sftp_server : "sftp"));
1784
		    sftp_server : "sftp"));
1790
1785
1791
		if (!batchmode)
1792
			fprintf(stderr, "Connecting to %s...\n", host);
1793
		connect_to_server(ssh_program, args.list, &in, &out);
1786
		connect_to_server(ssh_program, args.list, &in, &out);
1794
	} else {
1787
	} else {
1795
		args.list = NULL;
1788
		args.list = NULL;
1796
		addargs(&args, "sftp-server");
1789
		addargs(&args, "sftp-server");
1797
1790
1798
		if (!batchmode)
1799
			fprintf(stderr, "Attaching to %s...\n", sftp_direct);
1800
		connect_to_server(sftp_direct, args.list, &in, &out);
1791
		connect_to_server(sftp_direct, args.list, &in, &out);
1801
	}
1792
	}
1802
	freeargs(&args);
1793
	freeargs(&args);
1803
1794
1804
	err = interactive_loop(in, out, file1, file2);
1795
	conn = do_init(in, out, copy_buffer_len, num_requests);
1796
	if (conn == NULL)
1797
		fatal("Couldn't initialise connection to server");
1798
1799
	if (!batchmode) {
1800
		if (sftp_direct == NULL)
1801
			fprintf(stderr, "Connected to %s.\n", host);
1802
		else
1803
			fprintf(stderr, "Attached to %s.\n", sftp_direct);
1804
	}
1805
1806
	err = interactive_loop(conn, file1, file2);
1805
1807
1806
	close(in);
1808
	close(in);
1807
	close(out);
1809
	close(out);

Return to bug 1588