diff options
author | Eduardo Chappa <echappa@gmx.com> | 2013-02-03 00:59:38 -0700 |
---|---|---|
committer | Eduardo Chappa <echappa@gmx.com> | 2013-02-03 00:59:38 -0700 |
commit | 094ca96844842928810f14844413109fc6cdd890 (patch) | |
tree | e60efbb980f38ba9308ccb4fb2b77b87bbc115f3 /imap/src/osdep/mac | |
download | alpine-094ca96844842928810f14844413109fc6cdd890.tar.xz |
Initial Alpine Version
Diffstat (limited to 'imap/src/osdep/mac')
-rw-r--r-- | imap/src/osdep/mac/dummy.h | 43 | ||||
-rw-r--r-- | imap/src/osdep/mac/dummymac.c | 295 | ||||
-rw-r--r-- | imap/src/osdep/mac/env_mac.c | 236 | ||||
-rw-r--r-- | imap/src/osdep/mac/env_mac.h | 58 | ||||
-rw-r--r-- | imap/src/osdep/mac/fs_mac.c | 62 | ||||
-rw-r--r-- | imap/src/osdep/mac/ftl_mac.c | 39 | ||||
-rw-r--r-- | imap/src/osdep/mac/linkage.c | 37 | ||||
-rw-r--r-- | imap/src/osdep/mac/linkage.h | 36 | ||||
-rw-r--r-- | imap/src/osdep/mac/mtest.sit.hqx | 171 | ||||
-rw-r--r-- | imap/src/osdep/mac/nl_mac.c | 74 | ||||
-rw-r--r-- | imap/src/osdep/mac/os_mac.c | 82 | ||||
-rw-r--r-- | imap/src/osdep/mac/os_mac.h | 69 | ||||
-rw-r--r-- | imap/src/osdep/mac/osdep.h | 29 | ||||
-rw-r--r-- | imap/src/osdep/mac/pmatch.c | 89 | ||||
-rw-r--r-- | imap/src/osdep/mac/tcp_mac.c | 557 | ||||
-rw-r--r-- | imap/src/osdep/mac/tcp_mac.h | 49 |
16 files changed, 1926 insertions, 0 deletions
diff --git a/imap/src/osdep/mac/dummy.h b/imap/src/osdep/mac/dummy.h new file mode 100644 index 00000000..32650e06 --- /dev/null +++ b/imap/src/osdep/mac/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/mac/dummymac.c b/imap/src/osdep/mac/dummymac.c new file mode 100644 index 00000000..a0d6d0d2 --- /dev/null +++ b/imap/src/osdep/mac/dummymac.c @@ -0,0 +1,295 @@ +/* ======================================================================== + * 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 Mac + * + * 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 1993 + * 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) +{ + char tmp[MAILTMPLEN]; + /* 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/mac/env_mac.c b/imap/src/osdep/mac/env_mac.c new file mode 100644 index 00000000..d0a88df7 --- /dev/null +++ b/imap/src/osdep/mac/env_mac.c @@ -0,0 +1,236 @@ +/* ======================================================================== + * 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: Mac 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: 26 January 1992 + * Last Edited: 30 August 2006 + */ + + +static char *myHomeDir = NIL; /* home directory name */ +static char *myLocalHost = NIL; /* local host name */ +static char *myNewsrc = NIL; /* newsrc file name */ + +#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; + char tmp[MAILTMPLEN]; + switch ((int) function) { + case SET_HOMEDIR: + if (myHomeDir) fs_give ((void **) &myHomeDir); + myHomeDir = cpystr ((char *) value); + case GET_HOMEDIR: + /* set home directory if not defined */ + if (!myHomeDir) myHomeDir = cpystr (""); + ret = (void *) myHomeDir; + break; + case SET_LOCALHOST: + myLocalHost = cpystr ((char *) value); + case GET_LOCALHOST: + ret = (void *) myLocalHost ? myLocalHost : "random-mac"; + break; + case SET_NEWSRC: + if (myNewsrc) fs_give ((void **) &myNewsrc); + myNewsrc = cpystr ((char *) value); + case GET_NEWSRC: + if (!myNewsrc) { /* set news file name if not defined */ + sprintf (tmp,"%s:News State",myhomedir ()); + myNewsrc = cpystr (tmp); + } + ret = (void *) myNewsrc; + break; + } + return ret; +} + +/* Write current time + * Accepts: destination string + * format of date and time + * + * This depends upon the ReadLocation() call in System 7 and the + * user properly setting his location/timezone in the Map control + * panel. + * Nothing is done about the gmtFlags.dlsDelta byte yet, since I + * don't know how it's supposed to work. + */ + +static void do_date (char *date,char *fmt) +{ + long tz,tzm; + time_t ti = time (0); + struct tm *t = localtime (&ti); + MachineLocation loc; + ReadLocation (&loc); /* get location/timezone poop */ + /* get sign-extended time zone */ + tz = (loc.gmtFlags.gmtDelta & 0x00ffffff) | + ((loc.gmtFlags.gmtDelta & 0x00800000) ? 0xff000000 : 0); + tz /= 60; /* get timezone in minutes */ + tzm = tz % 60; /* get minutes from the hour */ + /* output time */ + strftime (date,MAILTMPLEN,fmt,t); + /* now output time zone */ + sprintf (date += strlen (date),"%+03ld%02ld",tz/60,tzm >= 0 ? tzm : -tzm); +} + + +/* Write current time in RFC 822 format + * Accepts: destination string + */ + +void rfc822_date (char *date) +{ + do_date (date,"%a, %d %b %Y %H:%M:%S "); +} + + +/* Write current time in internal format + * Accepts: destination string + */ + +void internal_date (char *date) +{ + do_date (date,"%2d-%b-%Y %H:%M:%S "); +} + +/* Return my local host name + * Returns: my local host name + */ + +char *mylocalhost (void) +{ + return (char *) mail_parameters (NIL,GET_LOCALHOST,NIL); +} + + +/* Return my home directory name + * Returns: my home directory name + */ + +char *myhomedir () +{ + return (char *) mail_parameters (NIL,GET_HOMEDIR,NIL); +} + + +/* Determine default prototype stream to user + * Accepts: type (NIL for create, T for append) + * Returns: default prototype stream + */ + +MAILSTREAM *default_proto (long type) +{ + extern MAILSTREAM dummyproto; + return &dummyproto; /* return default driver's prototype */ +} + +/* Block until event satisfied + * Called as: while (wait_condition && wait ()); + * Returns T if OK, NIL if user wants to abort + * + * Allows user to run a desk accessory, select a different window, or go + * to another application while waiting for the event to finish. COMMAND/. + * will abort the wait. + * Assumes the Apple menu has the apple character as its first character, + * and that the main program has disabled all other menus. + */ + +long wait () +{ + EventRecord event; + WindowPtr window; + MenuInfo **m; + long r; + Str255 tmp; + /* wait for an event */ + WaitNextEvent (everyEvent,&event,(long) 6,NIL); + switch (event.what) { /* got one -- what is it? */ + case mouseDown: /* mouse clicked */ + switch (FindWindow (event.where,&window)) { + case inMenuBar: /* menu bar item? */ + /* yes, interesting event? */ + if (r = MenuSelect (event.where)) { + /* round-about test for Apple menu */ + if ((*(m = GetMHandle (HiWord (r))))->menuData[1] == appleMark) { + /* get desk accessory name */ + GetItem (m,LoWord (r),tmp); + OpenDeskAcc (tmp); /* fire it up */ + SetPort (window); /* put us back at our window */ + } + else SysBeep (60); /* the fool forgot to disable it! */ + } + HiliteMenu (0); /* unhighlight it */ + break; + case inContent: /* some window was selected */ + if (window != FrontWindow ()) SelectWindow (window); + break; + default: /* ignore all others */ + break; + } + break; + case keyDown: /* key hit - if COMMAND/. then punt */ + if ((event.modifiers & cmdKey) && (event.message & charCodeMask) == '.') + return NIL; + break; + default: /* ignore all others */ + break; + } + return T; /* try wait test again */ +} + +/* Return random number + */ + +long random () +{ + return (long) rand () << 16 + rand (); +} + + +/* 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/mac/env_mac.h b/imap/src/osdep/mac/env_mac.h new file mode 100644 index 00000000..4a5a8c97 --- /dev/null +++ b/imap/src/osdep/mac/env_mac.h @@ -0,0 +1,58 @@ +/* ======================================================================== + * 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: Macintosh 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 + */ + + +#define SUBSCRIPTIONFILE(t) sprintf (t,"%s:Mailbox List",myhomedir ()) +#define SUBSCRIPTIONTEMP(t) sprintf (t,"%s:Mailbox List Temp",myhomedir ()) + +/* Function prototypes */ + +#include "env.h" + + +/* 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/mac/fs_mac.c b/imap/src/osdep/mac/fs_mac.c new file mode 100644 index 00000000..03908328 --- /dev/null +++ b/imap/src/osdep/mac/fs_mac.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/mac/ftl_mac.c b/imap/src/osdep/mac/ftl_mac.c new file mode 100644 index 00000000..782381b8 --- /dev/null +++ b/imap/src/osdep/mac/ftl_mac.c @@ -0,0 +1,39 @@ +/* ======================================================================== + * 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: Mac 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: 26 January 1992 + * Last Edited: 30 August 2006 + */ + +/* Report a fatal error + * Accepts: string to output + */ + +void fatal (char *string) +{ + mm_fatal (string); /* pass up the string */ + /* nuke the resolver */ + if (resolveropen) CloseResolver (); + abort (); /* die horribly */ +} diff --git a/imap/src/osdep/mac/linkage.c b/imap/src/osdep/mac/linkage.c new file mode 100644 index 00000000..14490a0c --- /dev/null +++ b/imap/src/osdep/mac/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/mac/linkage.h b/imap/src/osdep/mac/linkage.h new file mode 100644 index 00000000..7e0eccfa --- /dev/null +++ b/imap/src/osdep/mac/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/mac/mtest.sit.hqx b/imap/src/osdep/mac/mtest.sit.hqx new file mode 100644 index 00000000..4089c44f --- /dev/null +++ b/imap/src/osdep/mac/mtest.sit.hqx @@ -0,0 +1,171 @@ +(This file must be converted with BinHex 4.0) +:#@edCA0d,R0TG!"6594%8dP8)3#3""l`!!!"4[4p8dP8)3!#!!!Hm(*-BA8#bJ# +3!aB"#Jd!$'edCA0d,VNZFR0bB`#3%j@,!*!8"h-!N!6rN!4bFh*M8P0&4!%!TFk +UMDPEIVJ!!"f3!!#3"JEY!*!%`hJ!N!KIY3c!q+l(4rK4`['9YjP(D"GY*FH1(-X +cXLBR0(,Fbb2([#i[,dqCK"rKGS3@iEFb3JQeji4&VeZ[1Tp``PGTPS4GCi46F[` +)*dr*J*-T2h+-c2N46VMfC-$*Vi46-Z(N'*P4`L5F(#G2#5GiGT&MK"*'9LD!erG +CjLAcHUq9(@&*RN@fj0Ne))``F[c)XC9`B,`kD)!("P!!B+%+X!"Ij9MdF'6TDbk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&Md@Mh0K'A94F1 +aF$0Z,XqLDlNaF1$Vb#S4Ui0,Si#Ji5H4$`Vm2`!5FJ!!!3#3!`%8!*!$&!#3!c) +U9*!(+LVX!!!U+P53#Z`!!#T8N!-*EA4PFh3ZFfPd!J#3!e0*9%46593K!3!!T!) +-!*!$!3!!8dP84&0*9#%"!!#N!J`!N"+`fEpN!!!Hm!!!!8C892q3"953!q`!N!4 +8N!Er9*!&l!!!+P53"Iq3!e53!q`!N!-U9*!+l1`!N!-Ul&53"qcX!*!&l!$X9*! +$l*!$!*!+l*!$!*!,!3#3!rq3#J#3#"!!+!!@!48#!3#3"J-!N!-"!*!$!43!N!- +8!*!$-J&20H`KbJ#3!a`!-J!!8f9dC`#3!`S!!2rr!*!%!8pi(2'-: diff --git a/imap/src/osdep/mac/nl_mac.c b/imap/src/osdep/mac/nl_mac.c new file mode 100644 index 00000000..6c42cd08 --- /dev/null +++ b/imap/src/osdep/mac/nl_mac.c @@ -0,0 +1,74 @@ +/* ======================================================================== + * 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: Mac 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: 26 January 1992 + * 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) +{ + long i,j; + unsigned char c,*d = src; + if (*dst) { /* destination provided? */ + if ((i = srcl * 2) > *dstl) /* calculate worst-case situation */ + for (i = j = srcl; j; --j) if (*d++ == '\015') i++; + /* flush destination buffer if too small */ + if (i > *dstl) fs_give ((void **) dst); + } + /* make a new buffer if needed */ + if (!*dst) *dst = (char *) fs_get ((*dstl = i) + 1); + d = *dst; /* destination string */ + if (srcl) do { /* copy string */ + c = *d++ = *src++; /* copy character */ + /* append line feed to bare CR */ + if ((c == '\015') && (*src != '\012')) *d++ = '\012'; + } while (--srcl); + *d = '\0'; /* tie off destination */ + return d - *dst; /* return length */ +} + + +/* Length of string after strcrlfcpy applied + * Accepts: source string + * Returns: length of string + */ + +unsigned long strcrlflen (STRING *s) +{ + unsigned long pos = GETPOS (s); + unsigned long i = SIZE (s); + unsigned long j = i; + while (j--) if ((SNX (s) == '\015') && ((CHR (s) != '\012') || !j)) i++; + SETPOS (s,pos); /* restore old position */ + return i; +} diff --git a/imap/src/osdep/mac/os_mac.c b/imap/src/osdep/mac/os_mac.c new file mode 100644 index 00000000..156eb5c3 --- /dev/null +++ b/imap/src/osdep/mac/os_mac.c @@ -0,0 +1,82 @@ +/* ======================================================================== + * 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 -- Macintosh 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: 26 January 1992 + * Last Edited: 30 August 2006 + */ + + +/* This is a totally new operating-system dependent module for the Macintosh, + * written using THINK C on my Mac PowerBook-100 in my free time. + * Unlike earlier efforts, this version requires no external TCP library. It + * also takes advantage of the Map panel in System 7 for the timezone. + */ + +/* PPC cretins broke the MachineLocation struct */ + +#define gmtFlags u + +#include <limits.h> +#include <time.h> +#include <stdio.h> +#include <fcntl.h> +#define tcp_port MacTCP_port +#include <MacTCPCommonTypes.h> +#include <AddressXlation.h> +#include <TCPPB.h> +#include <Desk.h> +#include <Devices.h> +#include <Errors.h> +#include <Files.h> +#include <Fonts.h> +#include <Menus.h> +#include <Script.h> +#include <ToolUtils.h> +#include <Windows.h> +#undef tcp_port + +#include "tcp_mac.h" /* must be before osdep.h */ +#include "mail.h" +#include "osdep.h" +#include "misc.h" + +static short TCPdriver = 0; /* MacTCP's reference number */ +short resolveropen = 0; /* TCP's resolver open */ + + +#include "env_mac.c" +#include "fs_mac.c" +#include "ftl_mac.c" +#include "nl_mac.c" +#include "tcp_mac.c" + +#define open(a,b,c) open (a,b) +#define server_login(user,pass,authuser,argc,argv) NIL +#define authserver_login(user,authuser,argc,argv) NIL +#define myusername() "" /* dummy definition to prevent build errors */ +#define MD5ENABLE "" + +#include "auth_md5.c" +#include "auth_pla.c" +#include "auth_log.c" diff --git a/imap/src/osdep/mac/os_mac.h b/imap/src/osdep/mac/os_mac.h new file mode 100644 index 00000000..5cdad642 --- /dev/null +++ b/imap/src/osdep/mac/os_mac.h @@ -0,0 +1,69 @@ +/* ======================================================================== + * 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 -- Macintosh 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: 26 January 1992 + * Last Edited: 30 August 2006 + */ + + +/* This is a totally new operating-system dependent module for the Macintosh, + * written using THINK C on my Mac PowerBook-100 in my free time. + * Unlike earlier efforts, this version requires no external TCP library. It + * also takes advantage of the Map panel in System 7 for the timezone. + */ + +#include <stdlib.h> +#include <string.h> +#include <types.h> +#include <unix.h> +#ifndef noErr +#include <Desk.h> +#include <Devices.h> +#include <Errors.h> +#include <Events.h> +#include <Fonts.h> +#include <Memory.h> +#include <Menus.h> +#include <ToolUtils.h> +#include <Windows.h> +#endif + +#define L_SET SEEK_SET +#define L_INCR SEEK_CUR +#define L_XTND SEEK_END + +extern short resolveropen; /* make this global so caller can sniff */ + +#include "env_mac.h" +#include "fs.h" +#include "ftl.h" +#include "nl.h" +#include "tcp.h" + +#define TCPDRIVER "\p.IPP" + +#define gethostid clock + +long wait (void); +long random (void); diff --git a/imap/src/osdep/mac/osdep.h b/imap/src/osdep/mac/osdep.h new file mode 100644 index 00000000..9755c565 --- /dev/null +++ b/imap/src/osdep/mac/osdep.h @@ -0,0 +1,29 @@ +/* ======================================================================== + * 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 -- Macintosh 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: 13 June 1995 + * Last Edited: 30 August 2006 + */ + +#include "os_mac.h" diff --git a/imap/src/osdep/mac/pmatch.c b/imap/src/osdep/mac/pmatch.c new file mode 100644 index 00000000..95a0bb86 --- /dev/null +++ b/imap/src/osdep/mac/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/mac/tcp_mac.c b/imap/src/osdep/mac/tcp_mac.c new file mode 100644 index 00000000..8d39d4f3 --- /dev/null +++ b/imap/src/osdep/mac/tcp_mac.c @@ -0,0 +1,557 @@ +/* ======================================================================== + * 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: Macintosh 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: 26 January 1992 + * Last Edited: 13 January 2008 + */ + + +/* This is a totally new operating-system dependent module for the Macintosh, + * written using THINK C on my Mac PowerBook-100 in my free time. + * Unlike earlier efforts, this version requires no external TCP library. It + * also takes advantage of the Map panel in System 7 for the timezone. + */ + +static tcptimeout_t tmoh = NIL; /* TCP timeout handler routine */ +static long ttmo_open = 75; /* TCP timeouts, in seconds */ +static long ttmo_read = 0; +static long ttmo_write = 0; +static long ttmo_close = 0; + +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) +{ + void *ret = NIL; + switch ((int) function) { + case SET_TIMEOUT: + tmoh = (tcptimeout_t) value; + case GET_TIMEOUT: + ret = (void *) tmoh; + break; + case SET_OPENTIMEOUT: + ttmo_open = (long) value; + case GET_OPENTIMEOUT: + ret = (void *) ttmo_open; + break; + case SET_READTIMEOUT: + ttmo_read = (long) value; + case GET_READTIMEOUT: + ret = (void *) ttmo_read; + break; + case SET_WRITETIMEOUT: + ttmo_write = (long) value; + case GET_WRITETIMEOUT: + ret = (void *) ttmo_write; + break; + case SET_CLOSETIMEOUT: + ttmo_close = (long) value; + case GET_CLOSETIMEOUT: + ret = (void *) ttmo_close; + break; + } + return ret; +} + +/* 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) +{ + TCPSTREAM *stream; + struct hostInfo hst; + struct TCPCreatePB *createpb; + struct TCPOpenPB *openpb; + char *s; + unsigned long i,j,k,l; + char tmp[MAILTMPLEN]; + port &= 0xffff; /* erase flags */ + /* init MacTCP */ + if (!TCPdriver && OpenDriver (TCPDRIVER,&TCPdriver)) { + mm_log ("Can't init MacTCP",ERROR); + return NIL; + } + if (!resolveropen && OpenResolver (NIL)) { + mm_log ("Can't init domain resolver",ERROR); + return NIL; + } + resolveropen = T; /* note resolver open now */ + /* 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) { + hst.addr[0] = (i << 24) + (j << 16) + (k << 8) + l; + hst.addr[1] = 0; /* only one address to try! */ + sprintf (hst.cname,"[%ld.%ld.%ld.%ld]",i,j,k,l); + } + else { + sprintf (tmp,"Bad format domain-literal: %.80s",host); + mm_log (tmp,ERROR); + return NIL; + } + } + + else { /* look up host name */ + if (!tcp_dns_upp) tcp_dns_upp = NewResultProc (tcp_dns_result); + if (StrToAddr (host,&hst,tcp_dns_upp,NIL)) { + while (hst.rtnCode == cacheFault && wait ()); + /* kludge around MacTCP bug */ + if (hst.rtnCode == outOfMemory) { + mm_log ("Re-initializing domain resolver",WARN); + CloseResolver (); /* bop it on the head and try again */ + OpenResolver (NIL); /* note this will leak 12K */ + StrToAddr (host,&hst,tcp_dns_upp,NIL); + while (hst.rtnCode == cacheFault && wait ()); + } + if (hst.rtnCode) { /* still have error status? */ + switch (hst.rtnCode) { /* analyze return */ + case nameSyntaxErr: + s = "Syntax error in name"; + break; + case noResultProc: + s = "No result procedure"; + break; + case noNameServer: + s = "No name server found"; + break; + case authNameErr: + s = "Host does not exist"; + break; + case noAnsErr: + s = "No name servers responding"; + break; + case dnrErr: + s = "Name server returned an error"; + break; + case outOfMemory: + s = "Not enough memory to resolve name"; + break; + case notOpenErr: + s = "Driver not open"; + break; + default: + s = NIL; + break; + } + if (s) sprintf (tmp,"%s: %.80s",s,host); + else sprintf (tmp,"Unknown resolver error (%ld): %.80s", + hst.rtnCode,host); + mm_log (tmp,ERROR); + return NIL; + } + } + } + + /* create local TCP/IP stream */ + stream = (TCPSTREAM *) fs_get (sizeof (TCPSTREAM)); + stream->ictr = 0; /* initialize input */ + stream->pb.ioCRefNum = TCPdriver; + createpb = &stream->pb.csParam.create; + openpb = &stream->pb.csParam.open; + stream->pb.csCode = TCPCreate;/* create a TCP stream */ + /* set up buffer for TCP */ + createpb->rcvBuffLen = 4*BUFLEN; + createpb->rcvBuff = fs_get (createpb->rcvBuffLen); + createpb->notifyProc = NIL; /* no special notify procedure */ + createpb->userDataPtr = NIL; + if (PBControlSync ((ParmBlkPtr) &stream->pb)) + fatal ("Can't create TCP stream"); + /* open TCP connection */ + stream->pb.csCode = TCPActiveOpen; + openpb->ulpTimeoutValue = (int) ttmo_open; + openpb->ulpTimeoutAction = T; + openpb->validityFlags = timeoutValue|timeoutAction; + /* remote host (should try all) */ + openpb->remoteHost = hst.addr[0]; + openpb->remotePort = port; /* caller specified remote port */ + openpb->localPort = 0; /* generate a local port */ + openpb->tosFlags = 0; /* no special TOS */ + openpb->precedence = 0; /* no special precedence */ + openpb->dontFrag = 0; /* allow fragmentation */ + openpb->timeToLive = 255; /* standards say 60, UNIX uses 255 */ + openpb->security = 0; /* no special security */ + openpb->optionCnt = 0; /* no IP options */ + openpb->options[0] = 0; + openpb->userDataPtr = NIL; /* no special data pointer */ + PBControlAsync ((ParmBlkPtr) &stream->pb); + while (stream->pb.ioResult == inProgress && wait ()); + if (stream->pb.ioResult) { /* got back error status? */ + sprintf (tmp,"Can't connect to %.80s,%ld",hst.cname,port); + mm_log (tmp,ERROR); + /* nuke the buffer */ + stream->pb.csCode = TCPRelease; + createpb->userDataPtr = NIL; + if (PBControlSync ((ParmBlkPtr) &stream->pb)) fatal ("TCPRelease lossage"); + /* free its buffer */ + fs_give ((void **) &createpb->rcvBuff); + fs_give ((void **) &stream);/* and the local stream */ + return NIL; + } + + /* copy host names for later use */ + stream->host = cpystr (hst.cname); + /* tie off trailing dot */ + stream->host[strlen (stream->host) - 1] = '\0'; + /* the open gave us our address */ + i = (openpb->localHost >> 24) & 0xff; + j = (openpb->localHost >> 16) & 0xff; + k = (openpb->localHost >> 8) & 0xff; + l = openpb->localHost & 0xff; + sprintf (tmp,"[%ld.%ld.%ld.%ld]",i,j,k,l); + stream->localhost = cpystr (tmp); + if (!myLocalHost) myLocalHost = cpystr (tmp); + stream->port = port; /* copy port number */ + return stream; +} + + +/* Called when have return from DNS + * Accepts: host info pointer + * user data pointer + */ + +ResultUPP tcp_dns_upp = NIL; + +pascal void tcp_dns_result (struct hostInfo *hostInfoPtr,char *userDataPtr) +{ + /* dummy routine */ +} + +/* 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; /* no authenticated opens on Mac */ +} + +/* 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) +{ + unsigned long n; + char *s,*ret,c,d; + *contd = NIL; /* assume no continuation */ + /* make sure have data */ + if (!tcp_getdata (stream)) return NIL; + for (s = stream->iptr, n = 0, c = '\0'; stream->ictr--; n++, c = d) { + d = *stream->iptr++; /* slurp another character */ + if ((c == '\015') && (d == '\012')) { + ret = (char *) fs_get (n--); + memcpy (ret,s,*size = n); /* copy into a free storage string */ + ret[n] = '\0'; /* tie off string with null */ + return ret; + } + } + /* copy partial string from buffer */ + memcpy ((ret = (char *) fs_get (n)),s,*size = n); + /* get more data from the net */ + if (!tcp_getdata (stream)) fs_give ((void **) &ret); + /* special case of newline broken by buffer */ + else if ((c == '\015') && (*stream->iptr == '\012')) { + stream->iptr++; /* eat the line feed */ + stream->ictr--; + ret[*size = --n] = '\0'; /* tie off string with null */ + } + 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) +{ + unsigned long n; + char *bufptr = buffer; + while (size > 0) { /* until request satisfied */ + if (!tcp_getdata (stream)) return NIL; + n = min (size,stream->ictr);/* number of bytes to transfer */ + /* do the copy */ + memcpy (bufptr,stream->iptr,n); + bufptr += n; /* update pointer */ + stream->iptr +=n; + size -= n; /* update # of bytes to do */ + stream->ictr -=n; + } + bufptr[0] = '\0'; /* tie off string */ + return T; +} + + +/* TCP/IP receive data + * Accepts: TCP/IP stream + * Returns: T if success, NIL otherwise + */ + +long tcp_getdata (TCPSTREAM *stream) +{ + time_t t = time (0); + struct TCPReceivePB *receivepb = &stream->pb.csParam.receive; + struct TCPAbortPB *abortpb = &stream->pb.csParam.abort; + while (stream->ictr < 1) { /* if nothing in the buffer */ + time_t tl = time (0); + stream->pb.csCode = TCPRcv; /* receive TCP data */ + receivepb->commandTimeoutValue = (int) ttmo_read; + receivepb->rcvBuff = stream->ibuf; + receivepb->rcvBuffLen = BUFLEN; + receivepb->secondTimeStamp = 0; + receivepb->userDataPtr = NIL; + PBControlAsync ((ParmBlkPtr) &stream->pb); + while (stream->pb.ioResult == inProgress && wait ()); + if (stream->pb.ioResult) { /* punt if got an error */ + time_t tc = time (0); + if ((stream->pb.ioResult == commandTimeout) && tmoh && + ((*tmoh) (tc - t,tc - tl, stream->host))) continue; + /* nuke connection */ + stream->pb.csCode = TCPAbort; + abortpb->userDataPtr = NIL; + PBControlSync ((ParmBlkPtr) &stream->pb); + return NIL; + } + stream->iptr = stream->ibuf;/* point at TCP buffer */ + stream->ictr = receivepb->rcvBuffLen; + } + 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) +{ + return tcp_sout (stream,string,(unsigned long) strlen (string)); +} + + +/* 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) +{ + struct TCPSendPB *sendpb = &stream->pb.csParam.send; + struct TCPAbortPB *abortpb = &stream->pb.csParam.abort; + struct { + unsigned short length; + Ptr buffer; + unsigned short trailer; + } wds; + while (wds.length = (size > (unsigned long) 32768) ? 32768 : size) { + wds.buffer = string; /* buffer */ + wds.trailer = 0; /* tie off buffer */ + size -= wds.length; /* this many words will be output */ + string += wds.length; + stream->pb.csCode = TCPSend;/* send TCP data */ + sendpb->ulpTimeoutValue = (int) ttmo_write; + sendpb->ulpTimeoutAction = 0; + sendpb->validityFlags = timeoutValue|timeoutAction; + sendpb->pushFlag = T; /* send the data now */ + sendpb->urgentFlag = NIL; /* non-urgent data */ + sendpb->wdsPtr = (Ptr) &wds; + sendpb->userDataPtr = NIL; + PBControlAsync ((ParmBlkPtr) &stream->pb); + while (stream->pb.ioResult == inProgress && wait ()); + if (stream->pb.ioResult) { /* punt if got an error */ + /* nuke connection */ + stream->pb.csCode =TCPAbort; + abortpb->userDataPtr = NIL; + PBControlSync ((ParmBlkPtr) &stream->pb); + return NIL; + } + } + return T; /* success */ +} + +/* TCP/IP close + * Accepts: TCP/IP stream + */ + +void tcp_close (TCPSTREAM *stream) +{ + struct TCPClosePB *closepb = &stream->pb.csParam.close; + struct TCPCreatePB *createpb = &stream->pb.csParam.create; + stream->pb.csCode = TCPClose; /* close TCP stream */ + closepb->ulpTimeoutValue = (int) ttmo_close; + closepb->ulpTimeoutAction = 0; + closepb->validityFlags = timeoutValue|timeoutAction; + closepb->userDataPtr = NIL; + PBControlAsync ((ParmBlkPtr) &stream->pb); + while (stream->pb.ioResult == inProgress && wait ()); + stream->pb.csCode =TCPRelease;/* flush the buffers */ + createpb->userDataPtr = NIL; + if (PBControlSync ((ParmBlkPtr) &stream->pb)) fatal ("TCPRelease lossage"); + /* free its buffer */ + fs_give ((void **) &createpb->rcvBuff); + /* 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 i; + struct hostInfo hst; + /* look like domain literal? */ + if (name[0] == '[' && name[i = (strlen (name))-1] == ']') return name; + if (StrToAddr (name,&hst,tcp_dns_upp,NIL)) { + while (hst.rtnCode == cacheFault && wait ()); + /* kludge around MacTCP bug */ + if (hst.rtnCode == outOfMemory) { + mm_log ("Re-initializing domain resolver",WARN); + CloseResolver (); /* bop it on the head and try again */ + OpenResolver (NIL); /* note this will leak 12K */ + StrToAddr (name,&hst,tcp_dns_upp,NIL); + while (hst.rtnCode == cacheFault && wait ()); + } + /* still have error status? */ + if (hst.rtnCode) return name; + } + return hst.cname; /* success */ +} + + +/* TCP/IP get client host name (server calls only) + * Returns: client host name + */ + +char *tcp_clienthost () +{ + return "UNKNOWN"; +} diff --git a/imap/src/osdep/mac/tcp_mac.h b/imap/src/osdep/mac/tcp_mac.h new file mode 100644 index 00000000..7e9b4a72 --- /dev/null +++ b/imap/src/osdep/mac/tcp_mac.h @@ -0,0 +1,49 @@ +/* ======================================================================== + * 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: Macintosh 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: 26 January 1992 + * Last Edited: 30 August 2006 + */ + + +/* TCP input buffer */ + +#define BUFLEN (size_t) 8192 /* TCP input buffer */ + + +/* TCP I/O stream */ + +#define TCPSTREAM struct tcp_stream +TCPSTREAM { + char *host; /* host name */ + unsigned long port; /* port number */ + char *localhost; /* local host name */ + struct TCPiopb pb; /* MacTCP parameter block */ + long ictr; /* input counter */ + char *iptr; /* input pointer */ + char ibuf[BUFLEN]; /* input buffer */ +}; + +extern ResultUPP tcp_dns_upp; +pascal void tcp_dns_result (struct hostInfo *hostInfoPtr,char *userDataPtr); |