2 * uxsftp.c: the Unix-specific parts of PSFTP and PSCP.
\r
5 #include <sys/time.h>
\r
6 #include <sys/types.h>
\r
14 * In PSFTP our selects are synchronous, so these functions are
\r
17 int uxsel_input_add(int fd, int rwx) { return 0; }
\r
18 void uxsel_input_remove(int id) { }
\r
20 char *x_get_default(const char *key)
\r
22 return NULL; /* this is a stub */
\r
25 void platform_get_x11_auth(char *display, int *protocol,
\r
26 unsigned char *data, int *datalen)
\r
28 /* Do nothing, therefore no auth. */
\r
32 * Default settings that are specific to PSFTP.
\r
34 char *platform_default_s(const char *name)
\r
39 int platform_default_i(const char *name, int def)
\r
44 FontSpec platform_default_fontspec(const char *name)
\r
51 Filename platform_default_filename(const char *name)
\r
54 if (!strcmp(name, "LogFileName"))
\r
55 strcpy(ret.path, "putty.log");
\r
62 * Stubs for the GUI feedback mechanism in Windows PSCP.
\r
64 void gui_update_stats(char *name, unsigned long size,
\r
65 int percentage, unsigned long elapsed,
\r
66 unsigned long done, unsigned long eta,
\r
67 unsigned long ratebs) {}
\r
68 void gui_send_errcount(int list, int errs) {}
\r
69 void gui_send_char(int is_stderr, int c) {}
\r
70 void gui_enable(char *arg) {}
\r
74 * Set local current directory. Returns NULL on success, or else an
\r
75 * error message which must be freed after printing.
\r
77 char *psftp_lcd(char *dir)
\r
80 return dupprintf("%s: chdir: %s", dir, strerror(errno));
\r
86 * Get local current directory. Returns a string which must be
\r
89 char *psftp_getcwd(void)
\r
94 buffer = snewn(size, char);
\r
96 ret = getcwd(buffer, size);
\r
99 if (errno != ERANGE) {
\r
101 return dupprintf("[cwd unavailable: %s]", strerror(errno));
\r
104 * Otherwise, ERANGE was returned, meaning the buffer
\r
105 * wasn't big enough.
\r
107 size = size * 3 / 2;
\r
108 buffer = sresize(buffer, size, char);
\r
113 * Wait for some network data and process it.
\r
115 int ssh_sftp_loop_iteration(void)
\r
117 fd_set rset, wset, xset;
\r
118 int i, fdcount, fdsize, *fdlist;
\r
119 int fd, fdstate, rwx, ret, maxfd;
\r
122 fdcount = fdsize = 0;
\r
124 /* Count the currently active fds. */
\r
126 for (fd = first_fd(&fdstate, &rwx); fd >= 0;
\r
127 fd = next_fd(&fdstate, &rwx)) i++;
\r
130 return -1; /* doom */
\r
132 /* Expand the fdlist buffer if necessary. */
\r
135 fdlist = sresize(fdlist, fdsize, int);
\r
144 * Add all currently open fds to the select sets, and store
\r
145 * them in fdlist as well.
\r
148 for (fd = first_fd(&fdstate, &rwx); fd >= 0;
\r
149 fd = next_fd(&fdstate, &rwx)) {
\r
150 fdlist[fdcount++] = fd;
\r
152 FD_SET_MAX(fd, maxfd, rset);
\r
154 FD_SET_MAX(fd, maxfd, wset);
\r
156 FD_SET_MAX(fd, maxfd, xset);
\r
160 ret = select(maxfd, &rset, &wset, &xset, NULL);
\r
161 } while (ret < 0 && errno == EINTR);
\r
168 for (i = 0; i < fdcount; i++) {
\r
171 * We must process exceptional notifications before
\r
172 * ordinary readability ones, or we may go straight
\r
173 * past the urgent marker.
\r
175 if (FD_ISSET(fd, &xset))
\r
176 select_result(fd, 4);
\r
177 if (FD_ISSET(fd, &rset))
\r
178 select_result(fd, 1);
\r
179 if (FD_ISSET(fd, &wset))
\r
180 select_result(fd, 2);
\r
189 * Main program: do platform-specific initialisation and then call
\r
192 int main(int argc, char *argv[])
\r
195 return psftp_main(argc, argv);
\r