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