diff -Nur htdig-3.1.5.orig/htdig/Document.cc htdig-3.1.5.cmg/htdig/Document.cc --- htdig-3.1.5.orig/htdig/Document.cc Thu Feb 24 20:29:10 2000 +++ htdig-3.1.5.cmg/htdig/Document.cc Tue May 29 07:47:24 2001 @@ -28,6 +28,37 @@ typedef SIG_PF SIGNAL_HANDLER; #endif + +//***************************************************************************** +// Quick local hack for htdig to recognize mail files +// This is a utility function for the search options below +// returns 1 if file is \d+, 0 otherwise + +int my_isnum(char *str) { + char *p; + + p = strrchr(str, '/'); + + if(p == NULL) + p = str; + else if (*p == '/') + { + if (*(p+1) != '\0') + p = p+1; + else + return 0; // the has nothing after / which makes no sense. + } + + + for(p; *p != '\0'; p++) { + if(!isdigit(*p)) + return 0; // not a digit - bail + } + // yup it was a number + return 1; +} + + //***************************************************************************** // Document::Document(char *u) // Initialize with the given url as the location for this document. @@ -609,18 +640,24 @@ // the server's mime.types file). // (...and handle a select few other types for now...) char *ext = strrchr(*filename, '.'); - if (ext == NULL) - return Document_not_local; - if ((mystrcasecmp(ext, ".html") == 0) || (mystrcasecmp(ext, ".htm") == 0)) - contentType = "text/html"; - else if ((mystrcasecmp(ext, ".txt") == 0) || (mystrcasecmp(ext, ".asc") == 0)) - contentType = "text/plain"; - else if ((mystrcasecmp(ext, ".pdf") == 0)) - contentType = "application/pdf"; - else if ((mystrcasecmp(ext, ".ps") == 0) || (mystrcasecmp(ext, ".eps") == 0)) - contentType = "application/postscript"; - else - return Document_not_local; + + if (ext == NULL) { + if (my_isnum(*filename)) + contentType = "text/plain"; + else + return Document_not_local; + } else { + if ((mystrcasecmp(ext, ".html") == 0) || (mystrcasecmp(ext, ".htm") == 0)) + contentType = "text/html"; + else if ((mystrcasecmp(ext, ".txt") == 0) || (mystrcasecmp(ext, ".asc") == 0)) + contentType = "text/plain"; + else if ((mystrcasecmp(ext, ".pdf") == 0)) + contentType = "application/pdf"; + else if ((mystrcasecmp(ext, ".ps") == 0) || (mystrcasecmp(ext, ".eps") == 0)) + contentType = "application/postscript"; + else + return Document_not_local; + } // Open it FILE *f = fopen(*filename, "r");