VBS URL Parser Class


Topics:

Overview
Enumerations
Data Structures
Functions


Overview

The vbsURL class is used to parse uniform resource locators.


Enumerations

// This following list of URL protocols is a combination
// standard and non-standard URI schemes taken from:
// http://www.w3.org/pub/WWW/Addressing/schemes.html
enum { // Recognized URL protocols
  vbsURL::vbs_Unknown_URL_protocol = 0, // Protocol is not known
  vbsURL::vbs_about,       // Client-Side JavaScript Reference
  vbsURL::vbs_acap,        // ACAP -- Application Configuration Access
  vbsURL::vbs_afp,         // URLs for use with Service Location
  vbsURL::vbs_afs,         // Reserved, per Internet Standard 
  vbsURL::vbs_callto,      // NetMeeting Hyperlink on a Web Page
  vbsURL::vbs_chttp,       // RealPlayer Caching Protocol 
  vbsURL::vbs_cid,         // Content-ID and Message-ID  
  vbsURL::vbs_clsid,       // Identifies OLE/COM classes 
  vbsURL::vbs_data,        // Data: URL scheme
  vbsURL::vbs_file,        // Host-specific file names URL RFC  
  vbsURL::vbs_finger,      // Finger protocol URL
  vbsURL::vbs_ftp,         // File Transfer protocol URL
  vbsURL::vbs_gopher,      // Gopher protocol URL
  vbsURL::vbs_hdl,         // CNRI handle system 
  vbsURL::vbs_http,        // Hypertext Transfer Protocol URL 
  vbsURL::vbs_https,       // HTTP over SSL (Secure Socket Layer)
  vbsURL::vbs_iioploc,     // Interoperable Naming Joint Revised Sub
  vbsURL::vbs_ilu,         // ILU types, string binding handles 
  vbsURL::vbs_imap,        // IMAP URL scheme 
  vbsURL::vbs_ior,         // CORBA interoperable object reference 
  vbsURL::vbs_java,        // Identifies Java classes 
  vbsURL::vbs_javascript,  // Client-Side JavaScript Reference
  vbsURL::vbs_jdbc,        // Used in Java SQL API 
  vbsURL::vbs_ldap,        // An LDAP URL Format
  vbsURL::vbs_lifn,        // BFD -- Bulk File distribution
  vbsURL::vbs_mailto,      // Electronic mail address
  vbsURL::vbs_mid,         // Content-ID and Message-ID 
  vbsURL::vbs_news,        // USENET news
  vbsURL::vbs_nfs,         // NFS URL Scheme
  vbsURL::vbs_nntp,        // USENET news using NNTP access URL
  vbsURL::vbs_path,        // Path spec 
  vbsURL::vbs_pop,         // POP URL Scheme
  vbsURL::vbs_pop3,        // A POP3 URL Interface
  vbsURL::vbs_printer,     // Definition of printer
  vbsURL::vbs_prospero,    // Prospero Directory Service URL
  vbsURL::vbs_res,         // Res Protocol
  vbsURL::vbs_rtsp,        // Real Time Streaming Protocol (RTSP)
  vbsURL::vbs_rvp,         // Rendezvous Protocol
  vbsURL::vbs_rlogin,      // Remote login
  vbsURL::vbs_rwhois,      // The RWhois Uniform Resource Locator
  vbsURL::vbs_rx,          // Remote Execution
  vbsURL::vbs_sdp,         // SDP URL Scheme
  vbsURL::vbs_service,     // Service Templates and service
  vbsURL::vbs_sip,         // SIP URL Scheme
  vbsURL::vbs_shttp,       // Secure http
  vbsURL::vbs_snews,       // NNTP over SSL
  vbsURL::vbs_stanf,       // Stable Network Filenames 
  vbsURL::vbs_telnet,      // Reference to interactive sessions URL RFC 
  vbsURL::vbs_tip,         // Transaction Internet Protocol Version 3.0
  vbsURL::vbs_tn3270,      // Reserved, per Internet Standard 
  vbsURL::vbs_tv,          // Television Broadcasts
  vbsURL::vbs_uuid,        // The UUID addressing scheme
  vbsURL::vbs_wais,        // Wide Area Information Servers URL 
  vbsURL::vbs_whois,       // Distributed directory service
  vbsURL::vbs_whodp        // WhoDP: Widely Hosted Object Data Protocol
};


Data Structures

// Structure containing info on a URL. 
struct vbsURLInfo
{
  // URL information
  vbString url;	            // Unchanged URL 
  vbString proto;	    // URL protocol 
  vbString host;            // Extracted hostname 
  vbString path, dir, file; // Path, as well as directory and file 
  vbString user, passwd;    // Username and password 
  vbsURLInfo *proxy;        // The exact string to pass to proxy server 
  vbString local;           // The local filename of the URL document
  vbString referer;	    // Source that requested URI was obtained
  int port;                 // Port number
  int proto_type;           // Enumerated value representing a protocol  
  char ftp_type;            // FTP type

  // Members used by HTTP clients
  vbString parent_directory; // This resource's parent directory
  vbString local_file;       // This resource's parent directory
};


Functions

vbsURL::vbsURL()
vbsURL::~vbsURL()
vbsURL::CleanUserName()
vbsURL::GetPortNumber()
vbsURL::GetProtocolString()
vbsURL::GetProtocolType()
vbsURL::HasFile()
vbsURL::HasProtocol()
vbsURL::ParseDirectory()
vbsURL::ParseHostName()
vbsURL::ParsePortNumber()
vbsURL::ParseProtocol()
vbsURL::ParseURL()
vbsURL::ParseUserName()
vbsURL::ProcessFTPType()

vbsURL::vbsURL() - Default class constructor.

vbsURL::~vbsURL() - Class destructor.

int vbsURL::CleanUserName(const vbString &url, vbString &clean_url) - Public member function used to remove the username and password string from a URL and pass back a clean URL in the "clean_url" variable. Returns false if the URL does not contain a username or password.

int vbsURL::GetPortNumber(const vbString &url, int &port) - Public member function used to obtain a port number according to the protocol specified in the URL. If the port number cannot be determined or is not known this function will return false and set the port number to port 80.

char *vbsURL::GetProtocolString(int protocol) - Public member function that returns a null terminated string corresponding to the specified protocol. The "protocol" variable must equal one of the integer constants defined in the URL protocol enumeration.

int vbsURL::GetProtocolType(const vbString &protocol) - Public member function used to identify the specified protocol string and tag it with one of the integer constant defined in the URL protocol enumeration.

int vbsURL::HasFile(const vbString &path, vbString &dir, vbString &file) - Public member function that returns true if the path has a file associated with it. The directory and file name will be passed back in the "dir" and "file" variables.

int vbsURL::HasFile(const vbString &path) - Public member function that returns true if the path has a file associated with it.

int vbsURL::HasProtocol(const vbString &url) - Public member function that returns a protocol type defined in the URL protocol enumeration if the URL begins with a protocol.

int vbsURL::ParseDirectory(vbsURLInfo &u) - Public member function used to build the directory and filename components of the path specified in the vbsURLInfo object. Returns true if the path has a file associated with it.

int vbsURL::ParseDirectory(const vbString &url, vbString &path, vbString &dir,vbString &file) - Public member function Public member function used to build the directory and filename components of the path specified in the vbsURLInfo object. Returns true if the path has a file associated with it. . The path, directory, and file name will be passed back in the "path", "dir", and "file" variables.

int vbsURL::ParseHostName(const vbString &url, vbString &host,int remove_port_number = 1) - Public member function used to parse the hostname from a URL. If the "remove_port_number variable is true the port number will be removed from the host name if a port number was specified. Returns true if a valid hostname was found in the string containing the URL.

int vbsURL::ParsePortNumber(const vbString &url, int &port) - Public member function used to parse a port number from a URL and pass back the value in the "port" variable. Returns true if a port number was found.

int vbsURL::ParseProtocol(const vbString &url, vbString &proto_name, int &proto_type) - Public member function used to parse the protocol string in the specified URL. Passes back the protocol name in the "proto_name" variable and a protocol type defined in the URL protocol enumeration. Returns false if no protocol is found in the URL.

int vbsURL::ParseURL(const vbString &url, vbsURLInfo &u, int strict = 0) - Public member function used to extract the specified URL in the following format:

URL protocol://username:password@hostname:port/path/filename

Extracts the hostname terminated with a forward slash or colon. Extracts the port number terminated with forward slash, or selects the protocol if no port number is specified. The directory name equals everything after the hostname. The URL information will be passed back in the "u" variable. Returns false if any errors occur during the parsing operation. If the "strict" variable is true this function will return false if an unknown protocol is specified in the URL.

int vbsURL::ParseURL(const char *url, vbsURLInfo &u, int strict = 0) - Public member function used to parse the specified URL.

int vbsURL::ParseUserName(const vbString &url, vbString &user, vbString &passwd,vbString &clean_url) -Public member function used to find the optional username and password within the URL, as per RFC1738. Returns false if the URL does not contain a username or password. Passes back a URL without the username and password information in the "clean_url" variable.

void vbsURL::ProcessFTPType(const vbString &url, char &ftp_type) - Public member function used to determine the FTP type.


End Of Document