3ec11228d5b7cc74d8f6da17e4bcb39ada84e6c7
angie
  Mon Feb 23 15:11:39 2015 -0800
Use MAXNAMLEN instead of NAME_MAX for portability to BSD-based systems like Mac OS X.  refs #14899

diff --git src/lib/udc.c src/lib/udc.c
index 3789f37..42962f0 100644
--- src/lib/udc.c
+++ src/lib/udc.c
@@ -23,30 +23,31 @@
  * The bitmap file contains time stamp and size data as well as an array with one bit
  * for each block of the file that has been fetched.  Currently the block size is 8K. */
 
 #include <sys/file.h>
 #include "common.h"
 #include "hash.h"
 #include "obscure.h"
 #include "bits.h"
 #include "linefile.h"
 #include "portable.h"
 #include "sig.h"
 #include "net.h"
 #include "cheapcgi.h"
 #include "udc.h"
 #include "hex.h"
+#include <dirent.h>
 #include <openssl/sha.h>
 
 
 #define udcBlockSize (8*1024)
 /* All fetch requests are rounded up to block size. */
 
 #define udcMaxBytesPerRemoteFetch (udcBlockSize * 32)
 /* Very large remote reads are broken down into chunks this size. */
 
 struct connInfo
 /* Socket descriptor and associated info, for keeping net connections open. */
     {
     int socket;                 /* Socket descriptor for data connection (or 0). */
     bits64 offset;		/* Current file offset of socket. */
     int ctrlSocket;             /* (FTP only) Control socket descriptor or 0. */
@@ -776,48 +777,48 @@
 *retProtocol = protocol;
 *retAfterProtocol = afterProtocol;
 *retColon = colon;
 }
 
 void udcParseUrl(char *url, char **retProtocol, char **retAfterProtocol, char **retColon)
 /* Parse the URL into components that udc treats separately.
  * *retAfterProtocol is Q-encoded to keep special chars out of filenames.  
  * Free  *retProtocol and *retAfterProtocol but not *retColon when done. */
 {
 udcParseUrlFull(url, retProtocol, retAfterProtocol, retColon, NULL);
 }
 
 static void addElementToDy(struct dyString *dy, char *name)
 /* add one element of a path to a dyString, hashing it if it's longer 
- * than NAME_MAX */
+ * than MAXNAMLEN */
 {
-if (strlen(name) > NAME_MAX)
+if (strlen(name) > MAXNAMLEN)
     {
     unsigned char hash[SHA_DIGEST_LENGTH];
     char newName[(SHA_DIGEST_LENGTH + 1) * 2];
 
     SHA1((const unsigned char *)name, strlen(name), hash);
     hexBinaryString(hash,  SHA_DIGEST_LENGTH, newName, (SHA_DIGEST_LENGTH + 1) * 2);
     
     dyStringAppend(dy, newName);
     }
 else
     dyStringAppend(dy, name);
 }
 
 static char *longDirHash(char *name)
-/* take a path and hash the elements that are longer than NAME_MAX */
+/* take a path and hash the elements that are longer than MAXNAMLEN */
 {
 struct dyString *dy = newDyString(strlen(name));
 char *ptr = strchr(name, '/');
 
 while(ptr)
     {
     *ptr = 0;
     addElementToDy(dy, name);
 
     dyStringAppend(dy, "/");
 
     name = ptr + 1;
     ptr = strchr(name, '/');
     }