*** htcommon/URL.h Sun Sep 15 11:16:43 2002 --- htcommon/URL.h.lha Fri Sep 13 22:14:29 2002 *************** *** 69,74 **** --- 69,76 ---- void normalizePath(); void ServerAlias(); void constructURL(); + // Number of slashes following service specifier. eg service("http")=2 + static int slashes(const String &); }; *** htcommon/URL.cc Sun Jan 13 19:13:13 2002 --- htcommon/URL.cc.lha Sat Sep 14 17:41:03 2002 *************** *** 19,24 **** --- 19,25 ---- #endif /* HAVE_CONFIG_H */ #include "URL.h" + #include "QuotedStringList.h" #include "Dictionary.h" #include "HtConfiguration.h" #include "StringMatch.h" *************** *** 37,42 **** --- 38,45 ---- #define NNTP_DEFAULT_PORT 119 + static Dictionary *slashCount = 0; + //***************************************************************************** // URL::URL() // Default Constructor *************** *** 318,324 **** _port = 0; _url = 0; _path = p; ! if (strcmp((char*)_service, "file") == 0) _host = "localhost"; } else --- 321,329 ---- _port = 0; _url = 0; _path = p; ! if (p) // (should also check the slashes are actually there...) ! p += slashes (_service); ! if (strcmp((char*)_service, "file") == 0 || slashes (_service) < 2) _host = "localhost"; } else *************** *** 711,716 **** --- 716,775 ---- } //***************************************************************************** + // int URL::slash(const String &protocol) + // Returns number of slashes folowing the service name for protocol + // + int + URL::slashes(const String &protocol) + { + if (!slashCount) + { + HtConfiguration* config= HtConfiguration::config(); + slashCount = new Dictionary(); + + // count stored as (first character of a string)-1. Better way? + slashCount->Add (String("mailto"), new String("\1")); + slashCount->Add (String("news"), new String("\1")); + slashCount->Add (String("http"), new String("\3")); + slashCount->Add (String("ftp"), new String("\3")); + // file:/// has three, but the last counts as part of the path... + slashCount->Add (String("file"), new String("\3")); + + QuotedStringList qsl(config->Find("external_protocols"), " \t"); + String from; + int i; + int sep,colon; + + for (i = 0; qsl[i]; i += 2) + { + from = qsl[i]; + sep = from.indexOf("->"); + if (sep != -1) + from = from.sub(0, sep); //.get(); // What was "get" for?? + + colon = from.indexOf(":"); + // if service specified as "help:/" or "man:", note trailing slashes + // Default is 2. + if (colon != -1) + { + char count [2]; // count using first char of string... + for (count[0] = '\1'; from[colon+count[0]] == '/'; count[0]++) + ; + count [1] = '\0'; + from = from.sub(0,colon); //.get(); + slashCount->Add (from, new String (count)); + } else + slashCount->Add (from, new String ("\3")); + } + } + + // count stored as first character of a string. Better way? + // Default to two slashes for unknown protocols + String *count = (String *)slashCount->Find(protocol); + return count ? (count->get()[0] - 1) : 2; + } + + //***************************************************************************** // void URL::constructURL() // Constructs the _url member from everything else // Also ensures the port number is correct for the service *************** *** 725,743 **** _url = _service; _url << ":"; ! if (!(strcmp((char*)_service, "news") == 0 || ! strcmp((char*)_service, "mailto") == 0 )) ! _url << "//"; ! if (strcmp((char*)_service, "file") != 0) ! { ! if (_user.length()) ! _url << _user << '@'; ! _url << _host; ! } ! if (_port != DefaultPort() && _port != 0) // Different than the default port ! _url << ':' << _port; _url << _path; } --- 784,808 ---- _url = _service; _url << ":"; ! // Add correct number of slashes after service name ! int i; ! for (i = slashes (_service); i > 0; i--) ! { ! _url << "/"; ! } ! if (slashes (_service) == 2) // services specifying a particular ! { // IP host must begin "service://" ! if (strcmp((char*)_service, "file") != 0) ! { ! if (_user.length()) ! _url << _user << '@'; ! _url << _host; ! } ! if (_port != DefaultPort() && _port != 0) // Different than the default port ! _url << ':' << _port; ! } _url << _path; } *** htdig/ExternalTransport.cc Sun Jan 13 19:13:13 2002 --- htdig/ExternalTransport.cc.lha Fri Sep 13 23:14:27 2002 *************** *** 93,98 **** --- 93,104 ---- to = from.sub(sep+2).get(); from = from.sub(0, sep).get(); } + + // Recognise service specified as "https://" rather than "https" + sep = from.indexOf(":"); + if (sep != -1) + from = from.sub(0, sep).get(); + handlers->Add(from, new String(qsl[i + 1])); toTypes->Add(from, new String(to)); } *** htcommon/defaults.cc Sun Jun 23 23:55:41 2002 --- htcommon/defaults.cc.kurl Sun Sep 15 11:29:45 2002 *************** *** 836,841 **** --- 836,846 ---- The external protocols are specified as pairs of strings, the first being the URL scheme that \ the script can handle while the second is the path to the script itself. If the second is \ quoted, then additional command-line arguments may be given.
\ + If the external protocol does not contain a colon (:), it is assumed \ + to have the standard format \ + \"protocol://[usr[:password]@]address[:port]/path\". \ + If it ends with a colon, then it is assumed to have the simpler format \ + \"protocol:path\".
\ The program takes three command-line parameters, not counting any parameters already given \ in the command string:
\ protocol URL configuration-file
\