summaryrefslogtreecommitdiff
path: root/imap/src/osdep/tops-20
diff options
context:
space:
mode:
authorEduardo Chappa <echappa@gmx.com>2013-02-03 00:59:38 -0700
committerEduardo Chappa <echappa@gmx.com>2013-02-03 00:59:38 -0700
commit094ca96844842928810f14844413109fc6cdd890 (patch)
treee60efbb980f38ba9308ccb4fb2b77b87bbc115f3 /imap/src/osdep/tops-20
downloadalpine-094ca96844842928810f14844413109fc6cdd890.tar.xz
Initial Alpine Version
Diffstat (limited to 'imap/src/osdep/tops-20')
-rw-r--r--imap/src/osdep/tops-20/build.ctl63
-rw-r--r--imap/src/osdep/tops-20/dummy.h43
-rw-r--r--imap/src/osdep/tops-20/dummyt20.c294
-rw-r--r--imap/src/osdep/tops-20/env_t20.c226
-rw-r--r--imap/src/osdep/tops-20/env_t20.h73
-rw-r--r--imap/src/osdep/tops-20/fs_t20.c62
-rw-r--r--imap/src/osdep/tops-20/ftl_t20.c38
-rw-r--r--imap/src/osdep/tops-20/linkage.c37
-rw-r--r--imap/src/osdep/tops-20/linkage.h36
-rw-r--r--imap/src/osdep/tops-20/log_t20.c80
-rw-r--r--imap/src/osdep/tops-20/nl_t20.c61
-rw-r--r--imap/src/osdep/tops-20/os_t20.c106
-rw-r--r--imap/src/osdep/tops-20/os_t20.h52
-rw-r--r--imap/src/osdep/tops-20/pmatch.c89
-rw-r--r--imap/src/osdep/tops-20/shortsym.h608
-rw-r--r--imap/src/osdep/tops-20/tcp_t20.c365
-rw-r--r--imap/src/osdep/tops-20/tcp_t20.h65
17 files changed, 2298 insertions, 0 deletions
diff --git a/imap/src/osdep/tops-20/build.ctl b/imap/src/osdep/tops-20/build.ctl
new file mode 100644
index 00000000..45a13450
--- /dev/null
+++ b/imap/src/osdep/tops-20/build.ctl
@@ -0,0 +1,63 @@
+! ========================================================================
+! Copyright 1988-2006 University of Washington
+!
+! Licensed under the Apache License, Version 2.0 (the "License");
+! you may not use this file except in compliance with the License.
+! You may obtain a copy of the License at
+!
+! http://www.apache.org/licenses/LICENSE-2.0
+!
+!
+! ========================================================================
+
+! Program: Portable C client build for TOPS-20
+!
+! Author: Mark Crispin
+! Networks and Distributed Computing
+! Computing & Communications
+! University of Washington
+! Administration Building, AG-44
+! Seattle, WA 98195
+! Internet: MRC@CAC.Washington.EDU
+!
+! Date: 11 May 1989
+! Last Edited: 30 August 2006
+
+!
+! Set environment
+@DEFINE SYS: PS:<KCC-6>,SYS:
+!
+! Build c-client library
+!
+@COPY OS_T20.* OSDEP.*
+@CCX -c -m -w=note MAIL.C DUMMYT20.C IMAP4R1.C SMTP.C NNTP.C POP3.C RFC822.C MISC.C OSDEP.C FLSTRING.C SMANAGER.C NEWSRC.C NETMSG.C UTF8.C UTF8AUX.C
+!
+! Build c-client library file. Should use MAKLIB, but MAKLIB barfs on MAIL.REL
+!
+@DELETE CCLINT.REL
+@APPEND MAIL.REL,DUMMYT20.REL,IMAP4R1.REL,SMTP.REL,NNTP.REL,POP3.REL,RFC822.REL,MISC.REL,OSDEP.REL,FLSTRING.REL,SMANAGER.REL,NEWSRC.REL,NETMSG.REL,UTF8.REL,UTF8AUX.REL CCLINT.REL
+!
+! Build MTEST library test program
+!
+@CCX -c -m -w=note MTEST.C
+@LINK
+*/SET:.HIGH.:200000
+*C:LIBCKX.REL
+*MTEST.REL
+*CCLINT.REL
+*MTEST/SAVE
+*/GO
+!
+! Build MAILUTIL
+!
+@CCX -c -m -w=note MAILUTIL.C
+@RENAME MAILUTIL.REL MUTIL.REL
+@LINK
+*/SET:.HIGH.:200000
+*C:LIBCKX.REL
+*MUTIL.REL
+*CCLINT.REL
+*MUTIL/SAVE
+*/GO
+@RESET
+@RENAME MUTIL.EXE MAILUTIL.EXE
diff --git a/imap/src/osdep/tops-20/dummy.h b/imap/src/osdep/tops-20/dummy.h
new file mode 100644
index 00000000..32650e06
--- /dev/null
+++ b/imap/src/osdep/tops-20/dummy.h
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: Dummy routines
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 9 May 1991
+ * Last Edited: 30 August 2006
+ */
+
+/* Exported function prototypes */
+
+void dummy_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents);
+void dummy_list (MAILSTREAM *stream,char *ref,char *pat);
+void dummy_lsub (MAILSTREAM *stream,char *ref,char *pat);
+long scan_contents (DRIVER *dtb,char *name,char *contents,
+ unsigned long csiz,unsigned long fsiz);
+long dummy_scan_contents (char *name,char *contents,unsigned long csiz,
+ unsigned long fsiz);
+long dummy_create (MAILSTREAM *stream,char *mailbox);
+long dummy_create_path (MAILSTREAM *stream,char *path,long dirmode);
+long dummy_delete (MAILSTREAM *stream,char *mailbox);
+long dummy_rename (MAILSTREAM *stream,char *old,char *newname);
+char *dummy_file (char *dst,char *name);
+long dummy_canonicalize (char *tmp,char *ref,char *pat);
diff --git a/imap/src/osdep/tops-20/dummyt20.c b/imap/src/osdep/tops-20/dummyt20.c
new file mode 100644
index 00000000..1117ad45
--- /dev/null
+++ b/imap/src/osdep/tops-20/dummyt20.c
@@ -0,0 +1,294 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: Dummy routines for TOPS-20
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 13 June 1995
+ * Last Edited: 30 August 2006
+ */
+
+
+#include <ctype.h>
+#include <stdio.h>
+#include "mail.h"
+#include "osdep.h"
+#include "dummy.h"
+#include "misc.h"
+
+/* Function prototypes */
+
+DRIVER *dummy_valid (char *name);
+void *dummy_parameters (long function,void *value);
+MAILSTREAM *dummy_open (MAILSTREAM *stream);
+void dummy_close (MAILSTREAM *stream,long options);
+long dummy_ping (MAILSTREAM *stream);
+void dummy_check (MAILSTREAM *stream);
+long dummy_expunge (MAILSTREAM *stream,char *sequence,long options);
+long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options);
+long dummy_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data);
+
+/* Dummy routines */
+
+
+/* Driver dispatch used by MAIL */
+
+DRIVER dummydriver = {
+ "dummy", /* driver name */
+ DR_LOCAL|DR_MAIL, /* driver flags */
+ (DRIVER *) NIL, /* next driver */
+ dummy_valid, /* mailbox is valid for us */
+ dummy_parameters, /* manipulate parameters */
+ dummy_scan, /* scan mailboxes */
+ dummy_list, /* list mailboxes */
+ dummy_lsub, /* list subscribed mailboxes */
+ NIL, /* subscribe to mailbox */
+ NIL, /* unsubscribe from mailbox */
+ dummy_create, /* create mailbox */
+ dummy_delete, /* delete mailbox */
+ dummy_rename, /* rename mailbox */
+ mail_status_default, /* status of mailbox */
+ dummy_open, /* open mailbox */
+ dummy_close, /* close mailbox */
+ NIL, /* fetch message "fast" attributes */
+ NIL, /* fetch message flags */
+ NIL, /* fetch overview */
+ NIL, /* fetch message structure */
+ NIL, /* fetch header */
+ NIL, /* fetch text */
+ NIL, /* fetch message data */
+ NIL, /* unique identifier */
+ NIL, /* message number from UID */
+ NIL, /* modify flags */
+ NIL, /* per-message modify flags */
+ NIL, /* search for message based on criteria */
+ NIL, /* sort messages */
+ NIL, /* thread messages */
+ dummy_ping, /* ping mailbox to see if still alive */
+ dummy_check, /* check for new messages */
+ dummy_expunge, /* expunge deleted messages */
+ dummy_copy, /* copy messages to another mailbox */
+ dummy_append, /* append string message to mailbox */
+ NIL /* garbage collect stream */
+};
+
+
+ /* prototype stream */
+MAILSTREAM dummyproto = {&dummydriver};
+
+/* Dummy validate mailbox
+ * Accepts: mailbox name
+ * Returns: our driver if name is valid, NIL otherwise
+ */
+
+DRIVER *dummy_valid (char *name)
+{
+ /* must be valid local mailbox */
+ return (name && *name && (*name != '{') && !compare_cstring (name,"INBOX")) ?
+ &dummydriver : NIL;
+}
+
+
+/* Dummy manipulate driver parameters
+ * Accepts: function code
+ * function-dependent value
+ * Returns: function-dependent return value
+ */
+
+void *dummy_parameters (long function,void *value)
+{
+ return NIL;
+}
+
+/* Dummy scan mailboxes
+ * Accepts: mail stream
+ * reference
+ * pattern to search
+ * string to scan
+ */
+
+void dummy_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents)
+{
+ /* return silently */
+}
+
+
+/* Dummy list mailboxes
+ * Accepts: mail stream
+ * reference
+ * pattern to search
+ */
+
+void dummy_list (MAILSTREAM *stream,char *ref,char *pat)
+{
+ /* return silently */
+}
+
+
+/* Dummy list subscribed mailboxes
+ * Accepts: mail stream
+ * reference
+ * pattern to search
+ */
+
+void dummy_lsub (MAILSTREAM *stream,char *ref,char *pat)
+{
+ /* return silently */
+}
+
+/* Dummy create mailbox
+ * Accepts: mail stream
+ * mailbox name to create
+ * driver type to use
+ * Returns: T on success, NIL on failure
+ */
+
+long dummy_create (MAILSTREAM *stream,char *mailbox)
+{
+ return NIL; /* always fails */
+}
+
+
+/* Dummy delete mailbox
+ * Accepts: mail stream
+ * mailbox name to delete
+ * Returns: T on success, NIL on failure
+ */
+
+long dummy_delete (MAILSTREAM *stream,char *mailbox)
+{
+ return NIL; /* always fails */
+}
+
+
+/* Mail rename mailbox
+ * Accepts: mail stream
+ * old mailbox name
+ * new mailbox name
+ * Returns: T on success, NIL on failure
+ */
+
+long dummy_rename (MAILSTREAM *stream,char *old,char *newname)
+{
+ return NIL; /* always fails */
+}
+
+/* Dummy open
+ * Accepts: stream to open
+ * Returns: stream on success, NIL on failure
+ */
+
+MAILSTREAM *dummy_open (MAILSTREAM *stream)
+{
+ char tmp[MAILTMPLEN];
+ /* OP_PROTOTYPE call or silence */
+ if (!stream || stream->silent) return NIL;
+ if (compare_cstring (stream->mailbox,"INBOX")) {
+ sprintf (tmp,"Not a mailbox: %s",stream->mailbox);
+ mm_log (tmp,ERROR);
+ return NIL; /* always fails */
+ }
+ if (!stream->silent) { /* only if silence not requested */
+ mail_exists (stream,0); /* say there are 0 messages */
+ mail_recent (stream,0);
+ stream->uid_validity = time (0);
+ }
+ stream->inbox = T; /* note that it's an INBOX */
+ return stream; /* return success */
+}
+
+
+/* Dummy close
+ * Accepts: MAIL stream
+ * options
+ */
+
+void dummy_close (MAILSTREAM *stream,long options)
+{
+ /* return silently */
+}
+
+/* Dummy ping mailbox
+ * Accepts: MAIL stream
+ * Returns: T if stream alive, else NIL
+ * No-op for readonly files, since read/writer can expunge it from under us!
+ */
+
+long dummy_ping (MAILSTREAM *stream)
+{
+ return T;
+}
+
+
+/* Dummy check mailbox
+ * Accepts: MAIL stream
+ * No-op for readonly files, since read/writer can expunge it from under us!
+ */
+
+void dummy_check (MAILSTREAM *stream)
+{
+ dummy_ping (stream); /* invoke ping */
+}
+
+
+/* Dummy expunge mailbox
+ * Accepts: MAIL stream
+ * sequence to expunge if non-NIL
+ * expunge options
+ * Returns: T, always
+ */
+
+long dummy_expunge (MAILSTREAM *stream,char *sequence,long options)
+{
+ return LONGT;
+}
+
+/* Dummy copy message(s)
+ * Accepts: MAIL stream
+ * sequence
+ * destination mailbox
+ * options
+ * Returns: T if copy successful, else NIL
+ */
+
+long dummy_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options)
+{
+ if ((options & CP_UID) ? mail_uid_sequence (stream,sequence) :
+ mail_sequence (stream,sequence)) fatal ("Impossible dummy_copy");
+ return NIL;
+}
+
+
+/* Dummy append message string
+ * Accepts: mail stream
+ * destination mailbox
+ * append callback function
+ * data for callback
+ * Returns: T on success, NIL on failure
+ */
+
+long dummy_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data)
+{
+ char tmp[MAILTMPLEN];
+ sprintf (tmp,"Can't append to %s",mailbox);
+ mm_log (tmp,ERROR); /* pass up error */
+ return NIL; /* always fails */
+}
diff --git a/imap/src/osdep/tops-20/env_t20.c b/imap/src/osdep/tops-20/env_t20.c
new file mode 100644
index 00000000..38403454
--- /dev/null
+++ b/imap/src/osdep/tops-20/env_t20.c
@@ -0,0 +1,226 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: Environment routines -- TOPS-20 version
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 1 August 1988
+ * Last Edited: 30 August 2006
+ */
+
+
+/* Dedication:
+ * This file is dedicated with affection to the TOPS-20 operating system, which
+ * set standards for user and programmer friendliness that have still not been
+ * equaled by more `modern' operating systems.
+ * Wasureru mon ka!!!!
+ */
+
+/* c-client environment parameters */
+
+static char *myUserName = NIL; /* user name */
+static char *myHomeDir = NIL; /* home directory name */
+static char *myLocalHost = NIL; /* local host name */
+static char *myNewsrc = NIL; /* newsrc file name */
+static short no822tztext = NIL; /* disable RFC [2]822 timezone text */
+
+
+#include "pmatch.c" /* include wildcard pattern matcher */
+
+/* Environment manipulate parameters
+ * Accepts: function code
+ * function-dependent value
+ * Returns: function-dependent return value
+ */
+
+void *env_parameters (long function,void *value)
+{
+ void *ret = NIL;
+ switch ((int) function) {
+ case SET_USERNAME:
+ if (myUserName) fs_give ((void **) &myUserName);
+ myUserName = cpystr ((char *) value);
+ case GET_USERNAME:
+ ret = (void *) myUserName;
+ break;
+ case SET_HOMEDIR:
+ if (myHomeDir) fs_give ((void **) &myHomeDir);
+ myHomeDir = cpystr ((char *) value);
+ case GET_HOMEDIR:
+ ret = (void *) myHomeDir;
+ break;
+ case SET_LOCALHOST:
+ if (myLocalHost) fs_give ((void **) &myLocalHost);
+ myLocalHost = cpystr ((char *) value);
+ case GET_LOCALHOST:
+ ret = (void *) myLocalHost;
+ break;
+ case SET_NEWSRC:
+ if (myNewsrc) fs_give ((void **) &myNewsrc);
+ myNewsrc = cpystr ((char *) value);
+ case GET_NEWSRC:
+ ret = (void *) myNewsrc;
+ break;
+ case SET_DISABLE822TZTEXT:
+ no822tztext = value ? T : NIL;
+ case GET_DISABLE822TZTEXT:
+ ret = (void *) (no822tztext ? VOIDT : NIL);
+ break;
+ }
+ return ret;
+}
+
+/* Write current time in RFC 822 format
+ * Accepts: destination string
+ */
+
+void rfc822_date (char *date)
+{
+ char *s;
+ int argblk[4];
+ argblk[1] = (int) (date-1);
+ argblk[2] = -1; /* time now */
+ argblk[3] = OT_822; /* want RFC [2]822 format */
+ jsys (ODTIM,argblk);
+ /* suppress time zone text if desired */
+ if (no822tztext && (s = strstr (date," ("))) *s = NIL;
+}
+
+
+/* Write current time in internal format
+ * Accepts: destination string
+ */
+
+void internal_date (char *date)
+{
+ int argblk[5];
+ argblk[1] = (int) (date-1);
+ argblk[2] = -1; /* time now */
+ argblk[3] = OT_4YR; /* output in 4-digit year format */
+ jsys (ODTIM,argblk);
+ argblk[2] = ' '; /* delimit with space */
+ jsys (BOUT,argblk);
+ argblk[2] = -1; /* time now */
+ argblk[4] = 0; /* no flags */
+ jsys (ODCNV,argblk); /* get time zone */
+ argblk[2] = ((argblk[4] & 077000000) >> 18) * -100;
+ /* add an hour if summer time */
+ if (argblk[4] & IC_ADS) argblk[2] += 100;
+ argblk[3] = 0340005000012;
+ jsys (NOUT,argblk);
+}
+
+/* Return my user name
+ * Accepts: pointer to optional flags
+ * Returns: my user name
+ */
+
+char *myusername_full (unsigned long *flags)
+{
+ if (!myUserName) { /* get user name if don't have it yet */
+ char tmp[MAILTMPLEN];
+ int argblk[5],i;
+ jsys (GJINF,argblk); /* get job poop */
+ if (!(i = argblk[1])) { /* remember user number */
+ if (flags) *flags = MU_NOTLOGGEDIN;
+ return "SYSTEM"; /* not logged in */
+ }
+ argblk[1] = (int) (tmp-1); /* destination */
+ argblk[2] = i; /* user number */
+ jsys (DIRST,argblk); /* get user name string */
+ myUserName = cpystr (tmp); /* copy user name */
+ argblk[1] = 0; /* no flags */
+ argblk[2] = i; /* user number */
+ argblk[3] = 0; /* no stepping */
+ jsys (RCDIR,argblk); /* get home directory */
+ argblk[1] = (int) (tmp-1); /* destination */
+ argblk[2] = argblk[3]; /* home directory number */
+ jsys (DIRST,argblk); /* get home directory string */
+ myHomeDir = cpystr (tmp); /* copy home directory */
+ if (!myNewsrc) { /* set news file name if not defined */
+ sprintf (tmp,"%sNEWSRC",myhomedir ());
+ myNewsrc = cpystr (tmp);
+ }
+ if (flags) *flags = MU_LOGGEDIN;
+ }
+ return myUserName;
+}
+
+/* Return my local host name
+ * Returns: my local host name
+ */
+
+char *mylocalhost ()
+{
+ if (!myLocalHost) { /* initialize if first time */
+ char tmp[MAILTMPLEN];
+ int argblk[5];
+ argblk[1] = _GTHNS; /* convert number to string */
+ argblk[2] = (int) (tmp-1);
+ argblk[3] = -1; /* want local host */
+ if (!jsys (GTHST,argblk)) strcpy (tmp,"LOCAL");
+ myLocalHost = cpystr (tmp);
+ }
+ return myLocalHost;
+}
+
+
+/* Return my home directory name
+ * Returns: my home directory name
+ */
+
+char *myhomedir ()
+{
+ if (!myHomeDir) myusername ();/* initialize if first time */
+ return myHomeDir ? myHomeDir : "";
+}
+
+
+/* Determine default prototype stream to user
+ * Accepts: type (NIL for create, T for append)
+ * Returns: default prototype stream
+ */
+
+MAILSTREAM *default_proto (long type)
+{
+ return NIL; /* no default prototype */
+}
+
+/* Emulator for BSD syslog() routine
+ * Accepts: priority
+ * message
+ * parameters
+ */
+
+void syslog (int priority,const char *message,...)
+{
+}
+
+
+/* Emulator for BSD openlog() routine
+ * Accepts: identity
+ * options
+ * facility
+ */
+
+void openlog (const char *ident,int logopt,int facility)
+{
+}
diff --git a/imap/src/osdep/tops-20/env_t20.h b/imap/src/osdep/tops-20/env_t20.h
new file mode 100644
index 00000000..3031f4ed
--- /dev/null
+++ b/imap/src/osdep/tops-20/env_t20.h
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: TOPS-20 environment routines
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 25 May 1995
+ * Last Edited: 30 August 2006
+ */
+
+
+/* Dedication:
+ * This file is dedicated with affection to the TOPS-20 operating system, which
+ * set standards for user and programmer friendliness that have still not been
+ * equaled by more `modern' operating systems.
+ * Wasureru mon ka!!!!
+ */
+
+
+#define SUBSCRIPTIONFILE(t) sprintf (t,"%s\\SUBSCRIPTIONS.TXT",myhomedir ())
+#define SUBSCRIPTIONTEMP(t) sprintf (t,"%s\\SUBSCRIPTIONS.TMP",myhomedir ())
+
+/* Function prototypes */
+
+#include "env.h"
+
+char *myusername_full (unsigned long *flags);
+#define MU_LOGGEDIN 0
+#define MU_NOTLOGGEDIN 1
+#define MU_ANONYMOUS 2
+#define myusername() \
+ myusername_full (NIL)
+
+
+/* syslog() emulation */
+
+#define LOG_MAIL (2<<3) /* mail system */
+#define LOG_DAEMON (3<<3) /* system daemons */
+#define LOG_AUTH (4<<3) /* security/authorization messages */
+#define LOG_EMERG 0 /* system is unusable */
+#define LOG_ALERT 1 /* action must be taken immediately */
+#define LOG_CRIT 2 /* critical conditions */
+#define LOG_ERR 3 /* error conditions */
+#define LOG_WARNING 4 /* warning conditions */
+#define LOG_NOTICE 5 /* normal but signification condition */
+#define LOG_INFO 6 /* informational */
+#define LOG_DEBUG 7 /* debug-level messages */
+#define LOG_PID 0x01 /* log the pid with each message */
+#define LOG_CONS 0x02 /* log on the console if errors in sending */
+#define LOG_ODELAY 0x04 /* delay open until syslog() is called */
+#define LOG_NDELAY 0x08 /* don't delay open */
+#define LOG_NOWAIT 0x10 /* if forking to log on console, don't wait() */
+
+void openlog (const char *ident,int logopt,int facility);
+void syslog (int priority,const char *message,...);
diff --git a/imap/src/osdep/tops-20/fs_t20.c b/imap/src/osdep/tops-20/fs_t20.c
new file mode 100644
index 00000000..03908328
--- /dev/null
+++ b/imap/src/osdep/tops-20/fs_t20.c
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: Free storage management routines
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 1 August 1988
+ * Last Edited: 30 August 2006
+ */
+
+/* Get a block of free storage
+ * Accepts: size of desired block
+ * Returns: free storage block
+ */
+
+void *fs_get (size_t size)
+{
+ void *block = malloc (size ? size : (size_t) 1);
+ if (!block) fatal ("Out of memory");
+ return (block);
+}
+
+
+/* Resize a block of free storage
+ * Accepts: ** pointer to current block
+ * new size
+ */
+
+void fs_resize (void **block,size_t size)
+{
+ if (!(*block = realloc (*block,size ? size : (size_t) 1)))
+ fatal ("Can't resize memory");
+}
+
+
+/* Return a block of free storage
+ * Accepts: ** pointer to free storage block
+ */
+
+void fs_give (void **block)
+{
+ free (*block);
+ *block = NIL;
+}
diff --git a/imap/src/osdep/tops-20/ftl_t20.c b/imap/src/osdep/tops-20/ftl_t20.c
new file mode 100644
index 00000000..9e65ef55
--- /dev/null
+++ b/imap/src/osdep/tops-20/ftl_t20.c
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: DOS/VMS/TOPS-20 crash management routines
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 1 August 1988
+ * Last Edited: 30 August 2006
+ */
+
+
+/* Report a fatal error
+ * Accepts: string to output
+ */
+
+void fatal (char *string)
+{
+ mm_fatal (string); /* pass up the string */
+ abort (); /* die horribly */
+}
diff --git a/imap/src/osdep/tops-20/linkage.c b/imap/src/osdep/tops-20/linkage.c
new file mode 100644
index 00000000..14490a0c
--- /dev/null
+++ b/imap/src/osdep/tops-20/linkage.c
@@ -0,0 +1,37 @@
+/* ========================================================================
+ * Copyright 1988-2007 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: Default driver linkage
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 13 June 1995
+ * Last Edited: 23 May 2007
+ */
+
+ mail_link (&imapdriver); /* link in the imap driver */
+ mail_link (&nntpdriver); /* link in the nntp driver */
+ mail_link (&pop3driver); /* link in the pop3 driver */
+ mail_link (&dummydriver); /* link in the dummy driver */
+ auth_link (&auth_ext); /* link in the ext authenticator */
+ auth_link (&auth_md5); /* link in the md5 authenticator */
+ auth_link (&auth_pla); /* link in the plain authenticator */
+ auth_link (&auth_log); /* link in the log authenticator */
+ mail_versioncheck (CCLIENTVERSION); /* validate version */
diff --git a/imap/src/osdep/tops-20/linkage.h b/imap/src/osdep/tops-20/linkage.h
new file mode 100644
index 00000000..7e0eccfa
--- /dev/null
+++ b/imap/src/osdep/tops-20/linkage.h
@@ -0,0 +1,36 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: Default driver linkage
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 13 June 1995
+ * Last Edited: 30 August 2006
+ */
+
+extern DRIVER imapdriver;
+extern DRIVER nntpdriver;
+extern DRIVER pop3driver;
+extern DRIVER dummydriver;
+extern AUTHENTICATOR auth_ext;
+extern AUTHENTICATOR auth_log;
+extern AUTHENTICATOR auth_md5;
+extern AUTHENTICATOR auth_pla;
diff --git a/imap/src/osdep/tops-20/log_t20.c b/imap/src/osdep/tops-20/log_t20.c
new file mode 100644
index 00000000..1c744d7f
--- /dev/null
+++ b/imap/src/osdep/tops-20/log_t20.c
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: TOPS-20 server login
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 1 August 1988
+ * Last Edited: 30 August 2006
+ */
+
+
+/* Dedication:
+ * This file is dedicated with affection to the TOPS-20 operating system, which
+ * set standards for user and programmer friendliness that have still not been
+ * equaled by more `modern' operating systems.
+ * Wasureru mon ka!!!!
+ */
+
+/* Server log in
+ * Accepts: user name string
+ * password string
+ * authenticating user name string
+ * argument count
+ * argument vector
+ * Returns: T if password validated, NIL otherwise
+ */
+
+long server_login (char *user,char *pass,char *authuser,int argc,char *argv[])
+{
+ int uid;
+ int argblk[5];
+ if (authuser && *authuser) { /* not available */
+ syslog (LOG_NOTICE|LOG_AUTH,
+ "Login %s failed: invalid authentication ID %s host=%.80s",
+ user,authuser,tcp_clienthost ());
+ sleep (3);
+ return NIL;
+ }
+ argblk[1] = RC_EMO; /* require exact match */
+ argblk[2] = (int) (user-1); /* user name */
+ argblk[3] = 0; /* no stepping */
+ if (!jsys (RCUSR,argblk)) return NIL;
+ uid = argblk[1] = argblk[3]; /* user number */
+ argblk[2] = (int) (pass-1); /* password */
+ argblk[3] = 0; /* no special account */
+ if (!jsys (LOGIN,argblk)) return NIL;
+ return T;
+}
+
+
+/* Authenticated server log in
+ * Accepts: user name string
+ * authenticating user name string
+ * argument count
+ * argument vector
+ * Returns: T if password validated, NIL otherwise
+ */
+
+long authserver_login (char *user,char *authuser,int argc,char *argv[])
+{
+ return NIL; /* how to implement this on TOPS-20??? */
+}
diff --git a/imap/src/osdep/tops-20/nl_t20.c b/imap/src/osdep/tops-20/nl_t20.c
new file mode 100644
index 00000000..47cb7f0a
--- /dev/null
+++ b/imap/src/osdep/tops-20/nl_t20.c
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: Windows/TOPS-20 newline routines
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 1 August 1988
+ * Last Edited: 30 August 2006
+ */
+
+/* Copy string with CRLF newlines
+ * Accepts: destination string
+ * pointer to size of destination string buffer
+ * source string
+ * length of source string
+ * Returns: length of copied string
+ */
+
+unsigned long strcrlfcpy (unsigned char **dst,unsigned long *dstl,
+ unsigned char *src,unsigned long srcl)
+{
+ /* flush destination buffer if too small */
+ if (*dst && (srcl > *dstl)) fs_give ((void **) dst);
+ if (!*dst) { /* make a new buffer if needed */
+ *dst = (char *) fs_get ((size_t) (*dstl = srcl) + 1);
+ if (dstl) *dstl = srcl; /* return new buffer length to main program */
+ }
+ /* copy strings */
+ if (srcl) memcpy (*dst,src,(size_t) srcl);
+ *(*dst + srcl) = '\0'; /* tie off destination */
+ return srcl; /* return length */
+}
+
+
+/* Length of string after strcrlfcpy applied
+ * Accepts: source string
+ * Returns: length of string
+ */
+
+unsigned long strcrlflen (STRING *s)
+{
+ return SIZE (s); /* no-brainer on DOS! */
+}
diff --git a/imap/src/osdep/tops-20/os_t20.c b/imap/src/osdep/tops-20/os_t20.c
new file mode 100644
index 00000000..de0479df
--- /dev/null
+++ b/imap/src/osdep/tops-20/os_t20.c
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: Operating-system dependent routines -- TOPS-20 version
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 1 August 1988
+ * Last Edited: 30 August 2006
+ */
+
+
+/* Dedication:
+ * This file is dedicated with affection to the TOPS-20 operating system, which
+ * set standards for user and programmer friendliness that have still not been
+ * equaled by more `modern' operating systems.
+ * Wasureru mon ka!!!!
+ */
+
+#include "mail.h"
+#include <jsys.h> /* must be before tcp_t20.h */
+#include "tcp_t20.h" /* must be before osdep include tcp.h */
+#include <time.h>
+#include "osdep.h"
+#include <sys/time.h>
+#include "misc.h"
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <ctype.h>
+
+#include "fs_t20.c"
+#include "ftl_t20.c"
+#include "nl_t20.c"
+#include "env_t20.c"
+#include "tcp_t20.c"
+#include "log_t20.c"
+
+#define MD5ENABLE "PS:<SYSTEM>CRAM-MD5.PWD"
+#include "auth_md5.c"
+#include "auth_ext.c"
+#include "auth_pla.c"
+#include "auth_log.c"
+
+/* Emulator for UNIX gethostid() call
+ * Returns: host id
+ */
+
+long gethostid ()
+{
+ int argblk[5];
+#ifndef _APRID
+#define _APRID 28
+#endif
+ argblk[1] = _APRID;
+ jsys (GETAB,argblk);
+ return (long) argblk[1];
+}
+
+
+/* Emulator for UNIX getpass() call
+ * Accepts: prompt
+ * Returns: password
+ */
+
+#define PWDLEN 128 /* used by Linux */
+
+char *getpass (const char *prompt)
+{
+ char *s;
+ static char pwd[PWDLEN];
+ int argblk[5],mode;
+ argblk[1] = (int) (prompt-1); /* prompt user */
+ jsys (PSOUT,argblk);
+ argblk[1] = _PRIIN; /* get current TTY mode */
+ jsys (RFMOD,argblk);
+ mode = argblk[2]; /* save for later */
+ argblk[2] &= ~06000;
+ jsys (SFMOD,argblk);
+ jsys (STPAR,argblk);
+ fgets (pwd,PWDLEN-1,stdin);
+ pwd[PWDLEN-1] = '\0';
+ if (s = strchr (pwd,'\n')) *s = '\0';
+ putchar ('\n');
+ argblk[2] = mode;
+ jsys (SFMOD,argblk);
+ jsys (STPAR,argblk);
+ return pwd;
+}
diff --git a/imap/src/osdep/tops-20/os_t20.h b/imap/src/osdep/tops-20/os_t20.h
new file mode 100644
index 00000000..4c397243
--- /dev/null
+++ b/imap/src/osdep/tops-20/os_t20.h
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * Copyright 1988-2007 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: Operating-system dependent routines -- TOPS-20 version
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 1 August 1988
+ * Last Edited: 30 January 2007
+ */
+
+
+/* Dedication:
+ * This file is dedicated with affection to the TOPS-20 operating system, which
+ * set standards for user and programmer friendliness that have still not been
+ * equaled by more `modern' operating systems.
+ * Wasureru mon ka!!!!
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/file.h>
+#include <unistd.h>
+
+#include "env_t20.h"
+#include "fs.h"
+#include "ftl.h"
+#include "nl.h"
+#include "tcp.h"
+
+long gethostid (void);
+char *getpass (const char *prompt);
+
+#define strtok_r(a,b,c) strtok(a,b)
diff --git a/imap/src/osdep/tops-20/pmatch.c b/imap/src/osdep/tops-20/pmatch.c
new file mode 100644
index 00000000..95a0bb86
--- /dev/null
+++ b/imap/src/osdep/tops-20/pmatch.c
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: IMAP Wildcard Matching Routines (case-independent)
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 15 June 2000
+ * Last Edited: 30 August 2006
+ */
+
+/* Wildcard pattern match
+ * Accepts: base string
+ * pattern string
+ * delimiter character
+ * Returns: T if pattern matches base, else NIL
+ */
+
+long pmatch_full (unsigned char *s,unsigned char *pat,unsigned char delim)
+{
+ switch (*pat) {
+ case '%': /* non-recursive */
+ /* % at end, OK if no inferiors */
+ if (!pat[1]) return (delim && strchr (s,delim)) ? NIL : T;
+ /* scan remainder of string until delimiter */
+ do if (pmatch_full (s,pat+1,delim)) return T;
+ while ((*s != delim) && *s++);
+ break;
+ case '*': /* match 0 or more characters */
+ if (!pat[1]) return T; /* * at end, unconditional match */
+ /* scan remainder of string */
+ do if (pmatch_full (s,pat+1,delim)) return T;
+ while (*s++);
+ break;
+ case '\0': /* end of pattern */
+ return *s ? NIL : T; /* success if also end of base */
+ default: /* match this character */
+ return compare_uchar (*pat,*s) ? NIL : pmatch_full (s+1,pat+1,delim);
+ }
+ return NIL;
+}
+
+/* Directory pattern match
+ * Accepts: base string
+ * pattern string
+ * delimiter character
+ * Returns: T if base is a matching directory of pattern, else NIL
+ */
+
+long dmatch (unsigned char *s,unsigned char *pat,unsigned char delim)
+{
+ switch (*pat) {
+ case '%': /* non-recursive */
+ if (!*s) return T; /* end of base means have a subset match */
+ if (!*++pat) return NIL; /* % at end, no inferiors permitted */
+ /* scan remainder of string until delimiter */
+ do if (dmatch (s,pat,delim)) return T;
+ while ((*s != delim) && *s++);
+ if (*s && !s[1]) return T; /* ends with delimiter, must be subset */
+ return dmatch (s,pat,delim);/* do new scan */
+ case '*': /* match 0 or more characters */
+ return T; /* unconditional match */
+ case '\0': /* end of pattern */
+ break;
+ default: /* match this character */
+ if (*s) return compare_uchar (*pat,*s) ? NIL : dmatch (s+1,pat+1,delim);
+ /* end of base, return if at delimiter */
+ else if (*pat == delim) return T;
+ break;
+ }
+ return NIL;
+}
diff --git a/imap/src/osdep/tops-20/shortsym.h b/imap/src/osdep/tops-20/shortsym.h
new file mode 100644
index 00000000..2bd54649
--- /dev/null
+++ b/imap/src/osdep/tops-20/shortsym.h
@@ -0,0 +1,608 @@
+/* ========================================================================
+ * Copyright 1988-2008 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: Definitions for compilers with 6-letter symbol limits
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 24 May 1995
+ * Last Edited: 1 January 2008
+ */
+
+#define auth_link a_link
+#define auth_log a_log
+#define auth_login_client al_cli
+#define auth_login_server al_ser
+#define auth_ext a_ext
+#define auth_external_client ae_cli
+#define auth_external_server ae_ser
+#define auth_md5 a_md5
+#define auth_md5_valid a5_val
+#define auth_md5_client a5_cli
+#define auth_md5_server a5_ser
+#define auth_pla a_pla
+#define auth_plain_client ap_cli
+#define auth_plain_server ap_ser
+#define authenticate a_auth
+#define authserver_login a_serv
+#define body_encodings bencds
+#define body_types btypes
+#define compare_csizedtext cm_szt
+#define compare_cstring cm_str
+#define compare_uchar cm_uch
+#define compare_ulong cm_uln
+#define default_proto d_prot
+#define dummy_append d_appn
+#define dummy_canonicalize d_cano
+#define dummy_check d_chck
+#define dummy_close d_clos
+#define dummy_copy d_copy
+#define dummy_create d_crea
+#define dummy_create_path d_crep
+#define dummy_delete d_del
+#define dummy_expunge d_exp
+#define dummy_file d_fil
+#define dummy_list d_list
+#define dummy_list_work d_lstw
+#define dummy_listed d_lstd
+#define dummy_lsub d_lsub
+#define dummy_open d_open
+#define dummy_parameters d_parm
+#define dummy_ping d_ping
+#define dummy_rename d_ren
+#define dummy_scan d_scan
+#define dummy_search d_srch
+#define dummy_subscribe d_subs
+#define dummy_valid d_val
+#define env_parameters e_parm
+#define fatal fatal
+#define file_string fl_str
+#define file_string_init fl_ini
+#define file_string_next fl_nxt
+#define file_string_setpos fl_sps
+#define fs_get f_get
+#define fs_give f_give
+#define fs_resize f_rsiz
+#define hash_create h_crea
+#define hash_destory h_dest
+#define hash_index h_indx
+#define hash_lookup h_lkup
+#define hash_add h_add
+#define hash_lookup_and_add h_lad
+#define imap_OK i_OK
+#define imap_acl_work i_aclw
+#define imap_append i_appn
+#define imap_append_single i_apps
+#define imap_anon i_anon
+#define imap_auth i_auth
+#define imap_cache i_cach
+#define imap_cap i_cap
+#define imap_capability i_capa
+#define imap_challenge i_chln
+#define imap_check i_chck
+#define imap_close i_clos
+#define imap_copy i_copy
+#define imap_create i_crea
+#define imap_delete i_del
+#define imap_deleteacl i_dacl
+#define imap_expunge i_expn
+#define imap_fake i_fake
+#define imap_fast i_fast
+#define imap_fetch i_fetc
+#define imap_flag i_flag
+#define imap_flags i_flgs
+#define imap_gc i_gc
+#define imap_gc_body ig_bdy
+#define imap_getacl i_gacl
+#define imap_getquota i_gqot
+#define imap_getquotaroot i_gqtr
+#define imap_host i_host
+#define imap_list i_list
+#define imap_listrights i_lrgh
+#define imap_list_work il_wrk
+#define imap_login i_logn
+#define imap_lsub i_lsub
+#define imap_manage i_man
+#define imap_msgdata i_msgd
+#define imap_msgno i_msgn
+#define imap_myrights i_mrgh
+#define imap_open i_open
+#define imap_parameters i_parm
+#define imap_parse_address ip_adr
+#define imap_parse_adrlist ip_adl
+#define imap_parse_astring ip_ast
+#define imap_parse_body ip_bdy
+#define imap_parse_body_parameter ipb_pa
+#define imap_parse_body_structure ipb_st
+#define imap_parse_capabilities ip_cap
+#define imap_parse_disposition ip_dsp
+#define imap_parse_envelope ip_env
+#define imap_parse_extension ip_ext
+#define imap_parse_flags ip_flg
+#define imap_parse_header ip_hdr
+#define imap_parse_language ip_lng
+#define imap_parse_namespace ip_nam
+#define imap_parse_reply ip_rep
+#define imap_parse_response ip_rsp
+#define imap_parse_string ip_str
+#define imap_parse_stringlist ip_stl
+#define imap_parse_thread ip_thr
+#define imap_parse_unsolicited ip_uns
+#define imap_parse_user_flag ipu_fl
+#define imap_ping i_ping
+#define imap_reform_sequence i_rfrs
+#define imap_rename i_ren
+#define imap_reply i_rep
+#define imap_response i_rspn
+#define imap_scan i_scan
+#define imap_search i_srch
+#define imap_send i_send
+#define imap_send_astring is_ast
+#define imap_send_literal is_lit
+#define imap_send_sdate iss_da
+#define imap_send_slist iss_sl
+#define imap_send_spgm iss_pg
+#define imap_send_spgm_trim iss_pt
+#define imap_send_sset iss_st
+#define imap_send_sset_work iss_sw
+#define imap_setacl i_sacl
+#define imap_setquota i_sqot
+#define imap_sort i_sort
+#define imap_sout i_sout
+#define imap_soutr i_sotr
+#define imap_status i_stat
+#define imap_structure i_stru
+#define imap_subscribe i_sub
+#define imap_thread i_thrd
+#define imap_thread_work i_thrw
+#define imap_uid i_uid
+#define imap_unsubscribe i_uns
+#define imap_valid i_val
+#define internal_date in_dat
+#define mail_append_full m_appn
+#define mail_append_multiple m_appm
+#define mail_append_set m_apps
+#define mail_auth m_auth
+#define mail_body m_body
+#define mail_cdate m_cdat
+#define mail_check m_chck
+#define mail_close_full m_clos
+#define mail_copy_full m_copy
+#define mail_create m_crea
+#define mail_criteria m_crit
+#define mail_criteria_date mc_dat
+#define mail_criteria_string mc_str
+#define mail_date m_date
+#define mail_debug m_dbug
+#define mail_delete m_del
+#define mail_dlog m_dlog
+#define mail_elt m_elt
+#define mail_exists m_exst
+#define mail_expunge_full m_expn
+#define mail_expunged m_expd
+#define mail_fetch_body fs_bdy
+#define mail_fetch_fast mf_fst
+#define mail_fetch_flags mf_flg
+#define mail_fetch_header mf_hdr
+#define mail_fetch_message mf_msg
+#define mail_fetch_mime mf_mim
+#define mail_fetch_overview mf_ovr
+#define mail_fetch_overview_sequence mf_ovs
+#define mail_fetch_overview_default mf_ovd
+#define mail_fetch_structure mf_str
+#define mail_fetch_text mf_txt
+#define mail_fetch_text_return mf_txr
+#define mail_fetch_string_return mf_tsr
+#define mail_fetchfrom mf_frm
+#define mail_fetchsubject mf_sub
+#define mail_filter m_filt
+#define mail_flag m_flag
+#define mail_free_acl mr_acl
+#define mail_free_address mr_add
+#define mail_free_body mr_bdy
+#define mail_free_body_data mrb_da
+#define mail_free_body_parameter mrb_pr
+#define mail_free_body_part mrb_pt
+#define mail_free_cache mr_cac
+#define mail_free_elt mr_elt
+#define mail_free_envelope mr_env
+#define mail_free_handle mr_han
+#define mail_free_namespace mr_nsp
+#define mail_free_quotalist mr_qtl
+#define mail_free_searchheader mrs_hd
+#define mail_free_searchor mrs_or
+#define mail_free_searchpgm mrs_pg
+#define mail_free_searchpgmlist mrs_pl
+#define mail_free_searchset mrs_st
+#define mail_free_sortpgm mr_spg
+#define mail_free_stringlist mr_sls
+#define mail_free_threadnode mr_thn
+#define mail_gc m_gc
+#define mail_gc_msg m_gcm
+#define mail_gc_body m_gcb
+#define mail_initbody m_ibdy
+#define mail_link m_link
+#define mail_list m_list
+#define mail_lock m_lock
+#define mail_longdate ml_lda
+#define mail_lookup_auth m_laut
+#define mail_lookup_auth_name m_latn
+#define mail_lsub m_lsub
+#define mail_makehandle m_mhdl
+#define mail_match_lines m_mlns
+#define mail_msgno m_msgn
+#define mail_newacl mn_acl
+#define mail_newaddr mn_add
+#define mail_newbody mn_bdy
+#define mail_newbody_parameter mnb_pr
+#define mail_newbody_part mnb_pt
+#define mail_newbody_message_part mnb_mp
+#define mail_new_cache_elt mn_elt
+#define mail_newenvelope mn_env
+#define mail_newmsg mn_msg
+#define mail_newquotalist mn_qtl
+#define mail_newsearchheader mns_hd
+#define mail_newsearchor mns_or
+#define mail_newsearchpgm mns_pg
+#define mail_newsearchpgmlist mns_pl
+#define mail_newsearchset mns_st
+#define mail_newsortpgm mn_spg
+#define mail_newstringlist mn_sls
+#define mail_newthreadnode mn_thr
+#define mail_nodebug m_ndbg
+#define mail_open m_open
+#define mail_parameters m_parm
+#define mail_parse_date mp_dat
+#define mail_parse_flags mp_flg
+#define mail_parse_set mp_set
+#define mail_partial_body mpt_bd
+#define mail_partial_text mpt_tx
+#define mail_ping m_ping
+#define mail_read m_read
+#define mail_recent m_rcent
+#define mail_rename m_ren
+#define mail_scan m_scan
+#define mail_search_addr ms_adr
+#define mail_search_body ms_bdy
+#define mail_search_default ms_def
+#define mail_search_full m_srch
+#define mail_search_gets ms_gts
+#define mail_search_header ms_hdr
+#define mail_search_header_text ms_hdt
+#define mail_search_keyword ms_key
+#define mail_search_msg ms_msg
+#define mail_search_string ms_str
+#define mail_search_string_work ms_stw
+#define mail_search_text ms_txt
+#define mail_sequence m_seq
+#define mail_shortdate m_shtd
+#define mail_skip_fwd msk_fw
+#define mail_skip_re msk_re
+#define mail_sort ml_srt
+#define mail_sort_cache ms_csh
+#define mail_sort_compare ms_cmp
+#define mail_sort_loadcache ms_lcs
+#define mail_sort_msgs ms_mgs
+#define mail_status m_stat
+#define mail_status_default m_stad
+#define mail_stream m_strm
+#define mail_string m_strg
+#define mail_string_init mt_ini
+#define mail_string_next mt_nxt
+#define mail_string_setpos mt_sps
+#define mail_strip_subject mst_sb
+#define mail_strip_subject_wsp mst_ws
+#define mail_strip_subject_blob mst_bl
+#define mail_subscribe m_sub
+#define mail_thread m_thr
+#define mail_threadlist mt_lst
+#define mail_thread_c2node mt_c2n
+#define mail_thread_check_child mt_ckc
+#define mail_thread_compare_date mtc_da
+#define mail_thread_loadcache mt_ldc
+#define mail_thread_msgs mt_mgs
+#define mail_thread_orderedsubject mt_osb
+#define mail_thread_parse_msgid mtp_mi
+#define mail_thread_parse_references mtp_rf
+#define mail_thread_prune_dummy mt_prd
+#define mail_thread_references mt_ref
+#define mail_thread_sort mt_srt
+#define mail_uid m_uid
+#define mail_uid_sequence mu_seq
+#define mail_unlock m_unl
+#define mail_unsubscribe m_uns
+#define mail_usable_network_stream m_usns
+#define mail_utf7_valid m_ut7v
+#define mail_valid m_val
+#define mail_valid_net mv_net
+#define mail_valid_net_parse mvn_pr
+#define mail_valid_net_parse_work mvn_pw
+#define mail_versioncheck m_vers
+#define mailboxfile mbxfil
+#define md5_init m5_ini
+#define md5_update m5_upd
+#define md5_final m5_fin
+#define mime2_decode m2_dec
+#define mime2_text m2_txt
+#define mime2_token m2_tok
+#define mm_cache mm_cac
+#define mm_critical mm_crt
+#define mm_diskerror mm_dse
+#define mm_dlog mm_dlg
+#define mm_exists mm_exs
+#define mm_expunged mm_exp
+#define mm_fatal mm_ftl
+#define mm_flags mm_flg
+#define mm_list mm_lst
+#define mm_log mm_log
+#define mm_login mm_lgi
+#define mm_lsub mm_lsb
+#define mm_mailbox mm_mbx
+#define mm_nocritical mm_ncr
+#define mm_notify mm_not
+#define mm_searched mm_src
+#define myhomedir myhome
+#define mylocalhost myhost
+#define myusername_full myuser
+#define net_aopen nt_aop
+#define net_close nt_cls
+#define net_getbuffer nt_gtb
+#define net_getdata nt_gtd
+#define net_getline nt_gtl
+#define net_host nt_hst
+#define net_localhost nt_lhs
+#define net_open nt_opn
+#define net_port nt_prt
+#define net_sout nt_sot
+#define net_soutr nt_str
+#define netmsg_read nm_rea
+#define netmsg_slurp nm_slr
+#define netmsg_slurp_text nm_slt
+#define newsrc_check_uid nsc_ui
+#define newsrc_create ns_crea
+#define newsrc_error ns_err
+#define newsrc_lsub ns_lsub
+#define newsrc_newmessages ns_nms
+#define newsrc_newstate ns_nst
+#define newsrc_read ns_rea
+#define newsrc_status ns_sta
+#define newsrc_update ns_upd
+#define newsrc_write ns_wri
+#define newsrc_write_error ns_wer
+#define nntp_append n_appn
+#define nntp_canonicalize n_cano
+#define nntp_check n_chck
+#define nntp_close n_clos
+#define nntp_copy n_copy
+#define nntp_create n_crea
+#define nntp_delete n_del
+#define nntp_expunge n_expn
+#define nntp_fake n_fake
+#define nntp_fetchfast nf_fst
+#define nntp_fetchflags nf_flg
+#define nntp_fetchmessage nf_msg
+#define nntp_flagmsg n_fmsg
+#define nntp_gc n_gc
+#define nntp_getmap n_gmap
+#define nntp_header n_head
+#define nntp_isvalid n_isvl
+#define nntp_list n_list
+#define nntp_lsub n_lsub
+#define nntp_mail n_mail
+#define nntp_mclose n_mcls
+#define nntp_mopen n_mopn
+#define nntp_open_full n_open
+#define nntp_over n_ovr
+#define nntp_overview n_over
+#define nntp_parameters n_parm
+#define nntp_parsestructure n_pars
+#define nntp_parse_overview n_povr
+#define nntp_ping n_ping
+#define nntp_rename n_ren
+#define nntp_reply n_repl
+#define nntp_scan n_scan
+#define nntp_search n_srch
+#define nntp_search_msg ns_msg
+#define nntp_send n_send
+#define nntp_send_auth ns_aut
+#define nntp_send_auth_work ns_atw
+#define nntp_send_work n_sndw
+#define nntp_sort n_sort
+#define nntp_sort_loadcache ns_lcs
+#define nntp_soutr n_sout
+#define nntp_status n_stat
+#define nntp_subscribe n_sub
+#define nntp_text n_text
+#define nntp_text_slurp nt_slp
+#define nntp_thread n_thrd
+#define nntp_unsubscribe n_uns
+#define nntp_valid n_val
+#define pop3_append p_appn
+#define pop3_auth p_auth
+#define pop3_cache p_cach
+#define pop3_challenge p_chal
+#define pop3_check p_chck
+#define pop3_close p_clos
+#define pop3_copy p_copy
+#define pop3_create p_crea
+#define pop3_delete p_del
+#define pop3_expunge p_exp
+#define pop3_fake p_fake
+#define pop3_fetchfast pf_fst
+#define pop3_fetchflags pf_flg
+#define pop3_fetchmessage pf_msg
+#define pop3_gc p_gc
+#define pop3_list p_list
+#define pop3_lsub p_lsub
+#define pop3_open p_open
+#define pop3_parameters p_parm
+#define pop3_parsestructure p_pars
+#define pop3_ping p_ping
+#define pop3_rename p_ren
+#define pop3_reply p_rep
+#define pop3_response p_resp
+#define pop3_scan p_scan
+#define pop3_send p_send
+#define pop3_send_num ps_num
+#define pop3_status p_stat
+#define pop3_subscribe p_sub
+#define pop3_unsubscribe p_uns
+#define pop3_valid p_val
+#define rfc822_8bit r
+#define rfc822_address r_addr
+#define rfc822_address_line ra_lin
+#define rfc822_base64 r_b64
+#define rfc822_binary r_bin
+#define rfc822_cat r_cat
+#define rfc822_contents r_cont
+#define rfc822_cpy r_cpy
+#define rfc822_cpy_adr rc_adr
+#define rfc822_date r_date
+#define rfc822_default_subtype rd_sub
+#define rfc822_encode_body_7bit reb_7b
+#define rfc822_encode_body_8bit reb_8b
+#define rfc822_header r_head
+#define rfc822_header_line rh_lin
+#define rfc822_output r_out
+#define rfc822_output_address ro_adr
+#define rfc822_output_address_line roa_ln
+#define rfc822_output_address_list roa_li
+#define rfc822_output_body ro_bdy
+#define rfc822_output_body_header rob_hd
+#define rfc822_output_full ro_ful
+#define rfc822_output_flush ro_flu
+#define rfc822_output_header ro_hdr
+#define rfc822_output_header_line roh_ln
+#define rfc822_output_cat ro_cat
+#define rfc822_output_parameter ro_par
+#define rfc822_output_stringlist ro_stl
+#define rfc822_output_text ro_txt
+#define rfc822_parse_address rp_adr
+#define rfc822_parse_addrspec rp_ads
+#define rfc822_parse_adrlist rp_adl
+#define rfc822_parse_content rp_cnt
+#define rfc822_parse_content_header rpc_hd
+#define rfc822_parse_group rp_grp
+#define rfc822_parse_mailbox rp_mbx
+#define rfc822_parse_msg_full rp_msg
+#define rfc822_parse_parameter rp_par
+#define rfc822_parse_phrase rp_phr
+#define rfc822_parse_routeaddr rp_rte
+#define rfc822_parse_word rp_wrd
+#define rfc822_phraseonly r_poly
+#define rfc822_qprint r_qpnt
+#define rfc822_quote r_quot
+#define rfc822_skip_comment rs_cmt
+#define rfc822_skipws rs_ws
+#define rfc822_timezone r_tz
+#define rfc822_write_address_full rw_adr
+#define rfc822_write_body_header rwbh_8
+#define server_input_wait s_iwat
+#define server_login s_log
+#define server_init s_init
+#define sm_read sm_rd
+#define sm_subscribe sm_sub
+#define sm_unsubscribe sm_uns
+#define smtp_auth s_auth
+#define smtp_challenge s_chal
+#define smtp_close s_clos
+#define smtp_ehlo s_ehlo
+#define smtp_fake s_fake
+#define smtp_mail s_mail
+#define smtp_open_full s_open
+#define smtp_rcpt s_rcpt
+#define smtp_reply s_repl
+#define smtp_response s_resp
+#define smtp_send s_send
+#define smtp_send_auth ss_aut
+#define smtp_send_auth_work ss_atw
+#define smtp_send_work ss_wrk
+#define smtp_soutr s_str
+#define strcrlfcpy sc_cpy
+#define strcrlflen sc_len
+#define tcp_aopen t_aopn
+#define tcp_canonical t_cnon
+#define tcp_clientaddr t_cadr
+#define tcp_clienthost t_chst
+#define tcp_clientport t_cprt
+#define tcp_close t_clos
+#define tcp_getbuffer tg_buf
+#define tcp_getdata tg_dat
+#define tcp_getline tg_lin
+#define tcp_host t_host
+#define tcp_localhost t_lhst
+#define tcp_open t_open
+#define tcp_parameters t_parameters
+#define tcp_port t_port
+#define tcp_remotehost t_rhst
+#define tcp_serveraddr t_sadr
+#define tcp_serverhost t_shst
+#define tcp_serverport t_sprt
+#define tcp_sout t_sout
+#define tcp_soutr t_str
+#define textcpy txcopy
+#define textcpystring txcpst
+#define textcpyoffstring txcpos
+#define ucs4_cs_get u4_csg
+#define ucs4_decompose u4_dcm
+#define ucs4_decompose_recursive u4_dcr
+#define ucs4_rmapbuf u4r_bf
+#define ucs4_rmaplen u4r_ln
+#define ucs4_rmaptext u4r_tx
+#define ucs4_titlecase u4_tcs
+#define ucs4_width u4_wid
+#define utf8_badcharset u8_bcs
+#define utf8_charset u8_chs
+#define utf8_cstext u8_cst
+#define utf8_cstocstext u8_cct
+#define utf8_from_mutf7 u8fmu7
+#define utf8_get u8_get
+#define utf8_get_raw u8_gtr
+#define utf8_iso2022text u8_i22
+#define utf8_mime2text u8_mi2
+#define utf8_put u8_put
+#define utf8_rmap u8_rmp
+#define utf8_rmap_cs u8r_cs
+#define utf8_rmap_gen u8r_gn
+#define utf8_rmapsize u8r_sz
+#define utf8_rmaptext u8r_tx
+#define utf8_script u8_scr
+#define utf8_searchpgm u8_spg
+#define utf8_size u8_siz
+#define utf8_stringlist u8_lst
+#define utf8_text u8_txt
+#define utf8_text_2022 u8t_22
+#define utf8_text_8859_1 u8t_we
+#define utf8_text_1byte0 u8t_10
+#define utf8_text_1byte u8t_1b
+#define utf8_text_1byte8 u8t_18
+#define utf8_text_cs ut8_cs
+#define utf8_text_euc u8t_eu
+#define utf8_text_dbyte u8t_db
+#define utf8_text_dbyte2 u8t_d2
+#define utf8_text_sjis u8t_sj
+#define utf8_text_ucs2 u8t_u2
+#define utf8_text_ucs4 ut8_u4
+#define utf8_text_utf7 ut8_u7
+#define utf8_text_utf8 ut8_u8
+#define utf8_text_utf16 ut8_16
+#define utf8_to_mutf7 u8tmu7
+#define utf8_validate u8_val
+#define utf8_textwidth u8_twd
diff --git a/imap/src/osdep/tops-20/tcp_t20.c b/imap/src/osdep/tops-20/tcp_t20.c
new file mode 100644
index 00000000..7b2a2580
--- /dev/null
+++ b/imap/src/osdep/tops-20/tcp_t20.c
@@ -0,0 +1,365 @@
+/* ========================================================================
+ * Copyright 1988-2008 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: TOPS-20 TCP/IP routines
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 1 August 1988
+ * Last Edited: 13 January 2008
+ */
+
+
+/* Dedication:
+ * This file is dedicated with affection to the TOPS-20 operating system, which
+ * set standards for user and programmer friendliness that have still not been
+ * equaled by more `modern' operating systems.
+ * Wasureru mon ka!!!!
+ */
+
+static char *tcp_getline_work (TCPSTREAM *stream,unsigned long *size,
+ long *contd);
+
+/* TCP/IP manipulate parameters
+ * Accepts: function code
+ * function-dependent value
+ * Returns: function-dependent return value
+ */
+
+void *tcp_parameters (long function,void *value)
+{
+ return NIL;
+}
+
+/* TCP/IP open
+ * Accepts: host name
+ * contact service name
+ * contact port number
+ * Returns: TCP stream if success else NIL
+ */
+
+TCPSTREAM *tcp_open (char *host,char *service,unsigned long port)
+{
+ char *s,tmp[MAILTMPLEN];
+ TCPSTREAM *stream = NIL;
+ int argblk[5],jfn;
+ unsigned long i,j,k,l;
+ char file[MAILTMPLEN];
+ port &= 0xffff; /* erase flags */
+ /* domain literal? */
+ if (host[0] == '[' && host[strlen (host)-1] == ']') {
+ if (((i = strtoul (s = host+1,&s,10)) <= 255) && *s++ == '.' &&
+ ((j = strtoul (s,&s,10)) <= 255) && *s++ == '.' &&
+ ((k = strtoul (s,&s,10)) <= 255) && *s++ == '.' &&
+ ((l = strtoul (s,&s,10)) <= 255) && *s++ == ']' && !*s) {
+ argblk[3] = (i << 24) + (j << 16) + (k << 8) + l;
+ sprintf (tmp,"[%lu.%lu.%lu.%lu]",i,j,k,l);
+ }
+ else {
+ sprintf (tmp,"Bad format domain-literal: %.80s",host);
+ mm_log (tmp,ERROR);
+ return NIL;
+ }
+ }
+ else { /* host name */
+ argblk[1] = _GTHPN; /* get IP address and primary name */
+ argblk[2] = (int) (host-1); /* pointer to host */
+ argblk[4] = (int) (tmp-1);
+ if (!jsys (GTHST,argblk)) { /* first try DEC's domain way */
+ argblk[1] = _GTHPN; /* get IP address and primary name */
+ argblk[2] = (int) (host-1);
+ argblk[4] = (int) (tmp-1);
+ if (!jsys (GTDOM,argblk)){/* try the CHIVES domain way */
+ argblk[1] = _GTHSN; /* failed, do the host table then */
+ if (!jsys (GTHST,argblk)) {
+ sprintf (tmp,"No such host as %s",host);
+ mm_log (tmp,ERROR);
+ return NIL;
+ }
+ argblk[1] = _GTHNS; /* convert number to string */
+ argblk[2] = (int) (tmp-1);
+ /* get the official name */
+ if (!jsys (GTHST,argblk)) strcpy (tmp,host);
+ }
+ }
+ }
+
+ sprintf (file,"TCP:.%o-%d;PERSIST:30;CONNECTION:ACTIVE",argblk[3],port);
+ argblk[1] = GJ_SHT; /* short form GTJFN% */
+ argblk[2] = (int) (file-1); /* pointer to file name */
+ /* get JFN for TCP: file */
+ if (!jsys (GTJFN,argblk)) fatal ("Unable to create TCP JFN");
+ jfn = argblk[1]; /* note JFN for later */
+ /* want 8-bit bidirectional I/O */
+ argblk[2] = OF_RD|OF_WR|(FLD (8,monsym("OF%BSZ")));
+ if (!jsys (OPENF,argblk)) {
+ sprintf (file,"Can't connect to %s,%d server",tmp,port);
+ mm_log (file,ERROR);
+ return NIL;
+ }
+ /* create TCP/IP stream */
+ stream = (TCPSTREAM *) fs_get (sizeof (TCPSTREAM));
+ stream->host = cpystr (tmp); /* copy official host name */
+ argblk[1] = _GTHNS; /* convert number to string */
+ argblk[2] = (int) (tmp-1);
+ argblk[3] = -1; /* want local host */
+ if (!jsys (GTHST,argblk)) strcpy (tmp,"LOCAL");
+ stream->localhost = cpystr (tmp);
+ stream->port = port; /* save port number */
+ stream->jfn = jfn; /* init JFN */
+ return stream;
+}
+
+/* TCP/IP authenticated open
+ * Accepts: NETMBX specifier
+ * service name
+ * returned user name buffer
+ * Returns: TCP/IP stream if success else NIL
+ */
+
+TCPSTREAM *tcp_aopen (NETMBX *mb,char *service,char *usrbuf)
+{
+ return NIL;
+}
+
+/* TCP receive line
+ * Accepts: TCP stream
+ * Returns: text line string or NIL if failure
+ */
+
+char *tcp_getline (TCPSTREAM *stream)
+{
+ unsigned long n,contd;
+ char *ret = tcp_getline_work (stream,&n,&contd);
+ if (ret && contd) { /* got a line needing continuation? */
+ STRINGLIST *stl = mail_newstringlist ();
+ STRINGLIST *stc = stl;
+ do { /* collect additional lines */
+ stc->text.data = (unsigned char *) ret;
+ stc->text.size = n;
+ stc = stc->next = mail_newstringlist ();
+ ret = tcp_getline_work (stream,&n,&contd);
+ } while (ret && contd);
+ if (ret) { /* stash final part of line on list */
+ stc->text.data = (unsigned char *) ret;
+ stc->text.size = n;
+ /* determine how large a buffer we need */
+ for (n = 0, stc = stl; stc; stc = stc->next) n += stc->text.size;
+ ret = fs_get (n + 1); /* copy parts into buffer */
+ for (n = 0, stc = stl; stc; n += stc->text.size, stc = stc->next)
+ memcpy (ret + n,stc->text.data,stc->text.size);
+ ret[n] = '\0';
+ }
+ mail_free_stringlist (&stl);/* either way, done with list */
+ }
+ return ret;
+}
+
+/* TCP receive line or partial line
+ * Accepts: TCP stream
+ * pointer to return size
+ * pointer to return continuation flag
+ * Returns: text line string, size and continuation flag, or NIL if failure
+ */
+
+static char *tcp_getline_work (TCPSTREAM *stream,unsigned long *size,
+ long *contd)
+{
+ int argblk[5];
+ unsigned long n,m;
+ char *ret,*stp,*st;
+ *contd = NIL; /* assume no continuation */
+ argblk[1] = stream->jfn; /* read from TCP */
+ /* pointer to buffer */
+ argblk[2] = (int) (stream->ibuf - 1);
+ argblk[3] = BUFLEN; /* max number of bytes to read */
+ argblk[4] = '\012'; /* terminate on LF */
+ if (!jsys (SIN,argblk)) return NIL;
+ n = BUFLEN - argblk[3]; /* number of bytes read */
+ /* got a complete line? */
+ if ((stream->ibuf[n - 2] == '\015') && (stream->ibuf[n - 1] == '\012')) {
+ memcpy ((ret = (char *) fs_get (n)),stream->ibuf,*size = n - 2);
+ ret[n - 2] = '\0'; /* tie off string with null */
+ return ret;
+ }
+ /* copy partial string */
+ memcpy ((ret = (char *) fs_get (n)),stream->ibuf,*size = n);
+ /* special case of newline broken by buffer */
+ if ((stream->ibuf[n - 1] == '\015') && jsys (BIN,argblk) &&
+ (argblk[2] == '\012')) { /* was it? */
+ ret[n - 1] = '\0'; /* tie off string with null */
+ }
+ /* otherwise back up */
+ else if (!jsys (BKJFN,argblk)) fs_give ((void **) &ret);
+ else *contd = LONGT; /* continuation needed */
+ return ret;
+}
+
+/* TCP/IP receive buffer
+ * Accepts: TCP/IP stream
+ * size in bytes
+ * buffer to read into
+ * Returns: T if success, NIL otherwise
+ */
+
+long tcp_getbuffer (TCPSTREAM *stream,unsigned long size,char *buffer)
+{
+ int argblk[5];
+ argblk[1] = stream->jfn; /* read from TCP */
+ argblk[2] = (int) (buffer-1); /* pointer to buffer */
+ argblk[3] = -size; /* number of bytes to read */
+ if (!jsys (SIN,argblk)) return NIL;
+ buffer[size] = '\0'; /* tie off text */
+ return T;
+}
+
+
+/* TCP/IP send string as record
+ * Accepts: TCP/IP stream
+ * string pointer
+ * Returns: T if success else NIL
+ */
+
+long tcp_soutr (TCPSTREAM *stream,char *string)
+{
+ int argblk[5];
+ argblk[1] = stream->jfn; /* write to TCP */
+ argblk[2] = (int) (string-1); /* pointer to buffer */
+ argblk[3] = 0; /* write until NUL */
+ if (!jsys (SOUTR,argblk)) return NIL;
+ return T;
+}
+
+
+/* TCP/IP send string
+ * Accepts: TCP/IP stream
+ * string pointer
+ * byte count
+ * Returns: T if success else NIL
+ */
+
+long tcp_sout (TCPSTREAM *stream,char *string,unsigned long size)
+{
+ int argblk[5];
+ argblk[1] = stream->jfn; /* write to TCP */
+ argblk[2] = (int) (string-1); /* pointer to buffer */
+ argblk[3] = -size; /* write this many bytes */
+ if (!jsys (SOUTR,argblk)) return NIL;
+ return T;
+}
+
+/* TCP/IP close
+ * Accepts: TCP/IP stream
+ */
+
+void tcp_close (TCPSTREAM *stream)
+{
+ int argblk[5];
+ argblk[1] = stream->jfn; /* close TCP */
+ jsys (CLOSF,argblk);
+ /* flush host names */
+ fs_give ((void **) &stream->host);
+ fs_give ((void **) &stream->localhost);
+ fs_give ((void **) &stream); /* flush the stream */
+}
+
+
+/* TCP/IP return host for this stream
+ * Accepts: TCP/IP stream
+ * Returns: host name for this stream
+ */
+
+char *tcp_host (TCPSTREAM *stream)
+{
+ return stream->host; /* return host name */
+}
+
+
+/* TCP/IP return remote host for this stream
+ * Accepts: TCP/IP stream
+ * Returns: host name for this stream
+ */
+
+char *tcp_remotehost (TCPSTREAM *stream)
+{
+ return stream->host; /* return host name */
+}
+
+
+/* TCP/IP return port for this stream
+ * Accepts: TCP/IP stream
+ * Returns: port number for this stream
+ */
+
+unsigned long tcp_port (TCPSTREAM *stream)
+{
+ return stream->port; /* return port number */
+}
+
+
+/* TCP/IP return local host for this stream
+ * Accepts: TCP/IP stream
+ * Returns: local host name for this stream
+ */
+
+char *tcp_localhost (TCPSTREAM *stream)
+{
+ return stream->localhost; /* return local host name */
+}
+
+/* TCP/IP return canonical form of host name
+ * Accepts: host name
+ * Returns: canonical form of host name
+ */
+
+char *tcp_canonical (char *name)
+{
+ int argblk[5];
+ static char tmp[MAILTMPLEN];
+ /* look like domain literal? */
+ if (name[0] == '[' && name[strlen (name) - 1] == ']') return name;
+ argblk[1] = _GTHPN; /* get IP address and primary name */
+ argblk[2] = (int) (name-1); /* pointer to host */
+ argblk[4] = (int) (tmp-1); /* pointer to return destination */
+ if (!jsys (GTHST,argblk)) { /* first try DEC's domain way */
+ argblk[1] = _GTHPN; /* get IP address and primary name */
+ argblk[2] = (int) (name-1);
+ argblk[4] = (int) (tmp-1);
+ if (!jsys (GTDOM,argblk)) { /* try the CHIVES domain way */
+ argblk[1] = _GTHSN; /* failed, do the host table then */
+ if (!jsys (GTHST,argblk)) return name;
+ argblk[1] = _GTHNS; /* convert number to string */
+ argblk[2] = (int) (tmp-1);
+ /* get the official name */
+ if (!jsys (GTHST,argblk)) return name;
+ }
+ }
+ return tmp;
+}
+
+
+/* TCP/IP get client host name (server calls only)
+ * Returns: client host name
+ */
+
+char *tcp_clienthost ()
+{
+ return "UNKNOWN";
+}
diff --git a/imap/src/osdep/tops-20/tcp_t20.h b/imap/src/osdep/tops-20/tcp_t20.h
new file mode 100644
index 00000000..291465cf
--- /dev/null
+++ b/imap/src/osdep/tops-20/tcp_t20.h
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * Copyright 1988-2006 University of Washington
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *
+ * ========================================================================
+ */
+
+/*
+ * Program: TOPS-20 TCP/IP routines
+ *
+ * Author: Mark Crispin
+ * Networks and Distributed Computing
+ * Computing & Communications
+ * University of Washington
+ * Administration Building, AG-44
+ * Seattle, WA 98195
+ * Internet: MRC@CAC.Washington.EDU
+ *
+ * Date: 1 August 1988
+ * Last Edited: 30 August 2006
+ */
+
+
+/* Dedication:
+ * This file is dedicated with affection to the TOPS-20 operating system, which
+ * set standards for user and programmer friendliness that have still not been
+ * equaled by more `modern' operating systems.
+ * Wasureru mon ka!!!!
+ */
+
+/* TCP input buffer */
+
+#define BUFLEN 8192
+
+/* TCP I/O stream (must be before osdep.h is included) */
+
+#define TCPSTREAM struct tcp_stream
+TCPSTREAM {
+ char *host; /* host name */
+ unsigned long port; /* port number */
+ char *localhost; /* local host name */
+ int jfn; /* jfn for connection */
+ char ibuf[BUFLEN]; /* input buffer */
+};
+
+
+/* All of these should be in JSYS.H, but just in case... */
+
+#ifndef _GTHPN
+#define _GTHPN 12
+#endif
+
+#ifndef _GTDPN
+#define _GTDPN 12
+#endif
+
+#ifndef GTDOM
+#define GTDOM (FLD (1,JSYS_CLASS) | 501
+#endif