+/*
+ * Timeout intervals for retrying connections
+ * to hosts that don't accept PORT cmds. This
+ * is a kludge, but given the problems with TCP...
+ */
+#define SWAITMAX 90 /* wait at most 90 seconds */
+#define SWAITINT 5 /* interval between retries */
+
+int swaitmax = SWAITMAX;
+int swaitint = SWAITINT;
+
+#ifdef SETPROCTITLE
+char **Argv = NULL; /* pointer to argument vector */
+char *LastArgv = NULL; /* end of argv */
+char proctitle[BUFSIZ]; /* initial part of title */
+#endif /* SETPROCTITLE */
+
+#define MAXLINE 256
+
+#define LOGCMD(cmd, file) \
+ if (logging > 1) \
+ syslog(LOG_INFO,"%s %s%s", cmd, \
+ *(file) == '/' ? "" : curdir(), file);
+#define LOGCMD2(cmd, file1, file2) \
+ if (logging > 1) \
+ syslog(LOG_INFO,"%s %s%s %s%s", cmd, \
+ *(file1) == '/' ? "" : curdir(), file1, \
+ *(file2) == '/' ? "" : curdir(), file2);
+#define LOGBYTES(cmd, file, cnt) \
+ if (logging > 1) { \
+ if (cnt == (off_t)-1) \
+ syslog(LOG_INFO,"%s %s%s", cmd, \
+ *(file) == '/' ? "" : curdir(), file); \
+ else \
+ syslog(LOG_INFO, "%s %s%s = %qd bytes", \
+ cmd, (*(file) == '/') ? "" : curdir(), file, cnt); \
+ }
+
+static void ack __P((char *));
+static void myoob __P((int));
+static int checkuser __P((char *));
+static FILE *dataconn __P((char *, off_t, char *));
+static void dolog __P((struct sockaddr_in *));
+static char *curdir __P((void));
+static void end_login __P((void));
+static FILE *getdatasock __P((char *));
+static char *gunique __P((char *));
+static void lostconn __P((int));
+static int receive_data __P((FILE *, FILE *));
+static void send_data __P((FILE *, FILE *, off_t));
+static struct passwd *
+ sgetpwnam __P((char *));
+static char *sgetsave __P((char *));
+
+static char *
+curdir()
+{
+ static char path[MAXPATHLEN+1+1]; /* path + '/' + '\0' */
+
+ if (getcwd(path, sizeof(path)-2) == NULL)
+ return ("");
+ if (path[1] != '\0') /* special case for root dir. */
+ strcat(path, "/");
+ /* For guest account, skip / since it's chrooted */
+ return (guest ? path+1 : path);
+}