  #include "common.h"
 -#include <string.h>
  
++#ifndef HAVE_STRNDUP
++char *strndup(const char *str, size_t len)
++{
++  char *dup = (char *)malloc(len+1);
++  if (dup) {
++    strncpy(dup,str,len);
++    dup[len]= '\0';
++  }
++  return dup;
++}
++#endif
++
  @implementation NGMimeRFC822DateHeaderFieldParser
  
 -static Class CalDateClass = Nil;

     [self logWithFormat:
             @"WARNING: failed to parse RFC822 timezone: '%s' (value='%@')",
 	    bytes, _data];
@@ -444,9 +334,9 @@
   
   /* construct and return */
  finished:  

   /* remove leading chars (skip to first digit, the day of the month) */
   while (length > 0 && (!isdigit(*bytes))) {
     bytes++;
@@ -312,7 +217,7 @@
   if (length == 0) {
     NSLog(@"WARNING(%s): empty value for header field %@ ..",
           __PRETTY_FUNCTION__, _field);
