-/* handling the cleanup when a transfer is interrupted is tricky when
- --partial is selected. We need to ensure that the partial file is
- kept if any real data has been transferred */
-int cleanup_got_literal=0;
+extern int am_server;
+extern int am_daemon;
+extern int io_error;
+extern int keep_partial;
+extern int got_xfer_error;
+extern int output_needs_newline;
+extern char *partial_dir;
+extern char *logfile_name;
+
+#ifdef HAVE_SIGACTION
+static struct sigaction sigact;
+#endif
+
+/**
+ * Close all open sockets and files, allowing a (somewhat) graceful
+ * shutdown() of socket connections. This eliminates the abortive
+ * TCP RST sent by a Winsock-based system when the close() occurs.
+ **/
+void close_all(void)
+{
+#ifdef SHUTDOWN_ALL_SOCKETS
+ int max_fd;
+ int fd;
+ int ret;
+ STRUCT_STAT st;
+
+ max_fd = sysconf(_SC_OPEN_MAX) - 1;
+ for (fd = max_fd; fd >= 0; fd--) {
+ if ((ret = do_fstat(fd, &st)) == 0) {
+ if (is_a_socket(fd))
+ ret = shutdown(fd, 2);
+ ret = close(fd);
+ }
+ }
+#endif
+}
+
+/**
+ * @file cleanup.c
+ *
+ * Code for handling interrupted transfers. Depending on the @c
+ * --partial option, we may either delete the temporary file, or go
+ * ahead and overwrite the destination. This second behaviour only
+ * occurs if we've sent literal data and therefore hopefully made
+ * progress on the transfer.
+ **/
+
+/**
+ * Set to True once literal data has been sent across the link for the
+ * current file. (????)
+ *
+ * Handling the cleanup when a transfer is interrupted is tricky when
+ * --partial is selected. We need to ensure that the partial file is
+ * kept if any real data has been transferred.
+ **/
+int cleanup_got_literal = 0;