imapext-2007

diff src/osdep/os2/unixnt.h @ 0:ada5e610ab86

imap-2007e
author yuuji@gentei.org
date Mon, 14 Sep 2009 15:17:45 +0900
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/osdep/os2/unixnt.h	Mon Sep 14 15:17:45 2009 +0900
     1.3 @@ -0,0 +1,161 @@
     1.4 +/* ========================================================================
     1.5 + * Copyright 1988-2006 University of Washington
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *     http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * 
    1.14 + * ========================================================================
    1.15 + */
    1.16 +
    1.17 +/*
    1.18 + * Program:	UNIX mail routines
    1.19 + *
    1.20 + * Author:	Mark Crispin
    1.21 + *		Networks and Distributed Computing
    1.22 + *		Computing & Communications
    1.23 + *		University of Washington
    1.24 + *		Administration Building, AG-44
    1.25 + *		Seattle, WA  98195
    1.26 + *		Internet: MRC@CAC.Washington.EDU
    1.27 + *
    1.28 + * Date:	20 December 1989
    1.29 + * Last Edited:	30 August 2006
    1.30 + */
    1.31 +
    1.32 +
    1.33 +/*				DEDICATION
    1.34 + *
    1.35 + *  This file is dedicated to my dog, Unix, also known as Yun-chan and
    1.36 + * Unix J. Terwilliker Jehosophat Aloysius Monstrosity Animal Beast.  Unix
    1.37 + * passed away at the age of 11 1/2 on September 14, 1996, 12:18 PM PDT, after
    1.38 + * a two-month bout with cirrhosis of the liver.
    1.39 + *
    1.40 + *  He was a dear friend, and I miss him terribly.
    1.41 + *
    1.42 + *  Lift a leg, Yunie.  Luv ya forever!!!!
    1.43 + */
    1.44 +
    1.45 +/* Validate line
    1.46 + * Accepts: pointer to candidate string to validate as a From header
    1.47 + *	    return pointer to end of date/time field
    1.48 + *	    return pointer to offset from t of time (hours of ``mmm dd hh:mm'')
    1.49 + *	    return pointer to offset from t of time zone (if non-zero)
    1.50 + * Returns: t,ti,zn set if valid From string, else ti is NIL
    1.51 + */
    1.52 +
    1.53 +#define VALID(s,x,ti,zn) {						\
    1.54 +  ti = 0;								\
    1.55 +  if ((*s == 'F') && (s[1] == 'r') && (s[2] == 'o') && (s[3] == 'm') &&	\
    1.56 +      (s[4] == ' ')) {							\
    1.57 +    for (x = s + 5; *x && *x != '\012'; x++);				\
    1.58 +    if (*x) {								\
    1.59 +      if (x[-1] == '\015') --x;						\
    1.60 +      if (x - s >= 41) {						\
    1.61 +	for (zn = -1; x[zn] != ' '; zn--);				\
    1.62 +	if ((x[zn-1] == 'm') && (x[zn-2] == 'o') && (x[zn-3] == 'r') &&	\
    1.63 +	    (x[zn-4] == 'f') && (x[zn-5] == ' ') && (x[zn-6] == 'e') &&	\
    1.64 +	    (x[zn-7] == 't') && (x[zn-8] == 'o') && (x[zn-9] == 'm') &&	\
    1.65 +	    (x[zn-10] == 'e') && (x[zn-11] == 'r') && (x[zn-12] == ' '))\
    1.66 +	  x += zn - 12;							\
    1.67 +      }									\
    1.68 +      if (x - s >= 27) {						\
    1.69 +	if (x[-5] == ' ') {						\
    1.70 +	  if (x[-8] == ':') zn = 0,ti = -5;				\
    1.71 +	  else if (x[-9] == ' ') ti = zn = -9;				\
    1.72 +	  else if ((x[-11] == ' ') && ((x[-10]=='+') || (x[-10]=='-')))	\
    1.73 +	    ti = zn = -11;						\
    1.74 +	}								\
    1.75 +	else if (x[-4] == ' ') {					\
    1.76 +	  if (x[-9] == ' ') zn = -4,ti = -9;				\
    1.77 +	}								\
    1.78 +	else if (x[-6] == ' ') {					\
    1.79 +	  if ((x[-11] == ' ') && ((x[-5] == '+') || (x[-5] == '-')))	\
    1.80 +	    zn = -6,ti = -11;						\
    1.81 +	}								\
    1.82 +	if (ti && !((x[ti - 3] == ':') &&				\
    1.83 +		    (x[ti -= ((x[ti - 6] == ':') ? 9 : 6)] == ' ') &&	\
    1.84 +		    (x[ti - 3] == ' ') && (x[ti - 7] == ' ') &&		\
    1.85 +		    (x[ti - 11] == ' '))) ti = 0;			\
    1.86 +      }									\
    1.87 +    }									\
    1.88 +  }									\
    1.89 +}
    1.90 +
    1.91 +/* You are not expected to understand this macro, but read the next page if
    1.92 + * you are not faint of heart.
    1.93 + *
    1.94 + * Known formats to the VALID macro are:
    1.95 + *		From user Wed Dec  2 05:53 1992
    1.96 + * BSD		From user Wed Dec  2 05:53:22 1992
    1.97 + * SysV		From user Wed Dec  2 05:53 PST 1992
    1.98 + * rn		From user Wed Dec  2 05:53:22 PST 1992
    1.99 + *		From user Wed Dec  2 05:53 -0700 1992
   1.100 + * emacs	From user Wed Dec  2 05:53:22 -0700 1992
   1.101 + *		From user Wed Dec  2 05:53 1992 PST
   1.102 + *		From user Wed Dec  2 05:53:22 1992 PST
   1.103 + *		From user Wed Dec  2 05:53 1992 -0700
   1.104 + * Solaris	From user Wed Dec  2 05:53:22 1992 -0700
   1.105 + *
   1.106 + * Plus all of the above with `` remote from xxx'' after it. Thank you very
   1.107 + * much, smail and Solaris, for making my life considerably more complicated.
   1.108 + */
   1.109 +
   1.110 +/*
   1.111 + * What?  You want to understand the VALID macro anyway?  Alright, since you
   1.112 + * insist.  Actually, it isn't really all that difficult, provided that you
   1.113 + * take it step by step.
   1.114 + *
   1.115 + * Line 1	Initializes the return ti value to failure (0);
   1.116 + * Lines 2-3	Validates that the 1st-5th characters are ``From ''.
   1.117 + * Lines 4-6	Validates that there is an end of line and points x at it.
   1.118 + * Lines 7-14	First checks to see if the line is at least 41 characters long.
   1.119 + *		If so, it scans backwards to find the rightmost space.  From
   1.120 + *		that point, it scans backwards to see if the string matches
   1.121 + *		`` remote from''.  If so, it sets x to point to the space at
   1.122 + *		the start of the string.
   1.123 + * Line 15	Makes sure that there are at least 27 characters in the line.
   1.124 + * Lines 16-21	Checks if the date/time ends with the year (there is a space
   1.125 + *		five characters back).  If there is a colon three characters
   1.126 + *		further back, there is no timezone field, so zn is set to 0
   1.127 + *		and ti is set in front of the year.  Otherwise, there must
   1.128 + *		either to be a space four characters back for a three-letter
   1.129 + *		timezone, or a space six characters back followed by a + or -
   1.130 + *		for a numeric timezone; in either case, zn and ti become the
   1.131 + *		offset of the space immediately before it.
   1.132 + * Lines 22-24	Are the failure case for line 14.  If there is a space four
   1.133 + *		characters back, it is a three-letter timezone; there must be a
   1.134 + *		space for the year nine characters back.  zn is the zone
   1.135 + *		offset; ti is the offset of the space.
   1.136 + * Lines 25-28	Are the failure case for line 20.  If there is a space six
   1.137 + *		characters back, it is a numeric timezone; there must be a
   1.138 + *		space eleven characters back and a + or - five characters back.
   1.139 + *		zn is the zone offset; ti is the offset of the space.
   1.140 + * Line 29-32	If ti is valid, make sure that the string before ti is of the
   1.141 + *		form www mmm dd hh:mm or www mmm dd hh:mm:ss, otherwise
   1.142 + *		invalidate ti.  There must be a colon three characters back
   1.143 + *		and a space six or nine	characters back (depending upon
   1.144 + *		whether or not the character six characters back is a colon).
   1.145 + *		There must be a space three characters further back (in front
   1.146 + *		of the day), one seven characters back (in front of the month),
   1.147 + *		and one eleven characters back (in front of the day of week).
   1.148 + *		ti is set to be the offset of the space before the time.
   1.149 + *
   1.150 + * Why a macro?  It gets invoked a *lot* in a tight loop.  On some of the
   1.151 + * newer pipelined machines it is faster being open-coded than it would be if
   1.152 + * subroutines are called.
   1.153 + *
   1.154 + * Why does it scan backwards from the end of the line, instead of doing the
   1.155 + * much easier forward scan?  There is no deterministic way to parse the
   1.156 + * ``user'' field, because it may contain unquoted spaces!  Yes, I tested it to
   1.157 + * see if unquoted spaces were possible.  They are, and I've encountered enough
   1.158 + * evil mail to be totally unwilling to trust that ``it will never happen''.
   1.159 + */
   1.160 +
   1.161 +/* Build parameters */
   1.162 +
   1.163 +#define KODRETRY 15		/* kiss-of-death retry in seconds */
   1.164 +#define LOCKTIMEOUT 5		/* lock timeout in minutes */

UW-IMAP'd extensions by yuuji