📄 htparse.h
字号:
/* W3C Sample Code Library libwww URI Management! URI Management!*//*** (c) COPYRIGHT MIT 1995.** Please first read the full copyright statement in the file COPYRIGH.*//*This module contains code to parse URIs and various related things such as: o Parse a URI for tokens o Canonicalization of URIs o Search a URI for illegal characters in order to prevent security holes This module is implemented by HTParse.c, and it isa part of the W3C Sample CodeLibrary.*/#ifndef HTPARSE_H#define HTPARSE_H#include "HTEscape.h"/*. Parsing URIs.These functions can be used to get information in a URI.( Parse a URI relative to another URI)This returns those parts of a name which are given (and requested) substitutingbits from the related name where necessary. The aName argumentis the (possibly relative) URI to be parsed, the relatedNameis the URI which the aName is to be parsed relative to. Passingan empty string means that the aName is an absolute URI. Thefollowing are flag bits which may be OR'ed together to form a number to givethe 'wanted' argument to HTParse. As an example we have the URL:"/TheProject.html#news"*/#define PARSE_ACCESS 16 /* Access scheme, e.g. "HTTP" */#define PARSE_HOST 8 /* Host name, e.g. "www.w3.org" */#define PARSE_PATH 4 /* URL Path, e.g. "pub/WWW/TheProject.html" */#define PARSE_VIEW 2 /* Fragment identifier, e.g. "news" */#define PARSE_FRAGMENT PARSE_VIEW#define PARSE_ANCHOR PARSE_VIEW#define PARSE_PUNCTUATION 1 /* Include delimiters, e.g, "/" and ":" */#define PARSE_ALL 31/*where the format of a URI is as follows: "ACCESS :// HOST / PATH #ANCHOR"PUNCTUATION means any delimiter like '/', ':', '#' between thetokens above. The string returned by the function must be freed by the caller.*/extern char * HTParse (const char * aName, const char * relatedName, int wanted);/*( Create a Relative (Partial) URI)This function creates and returns a string which gives an expression of oneaddress as related to another. Where there is no relation, an absolute addressis retured. On entry, Both names must be absolute, fully qualified names of nodes (no anchor bits) On exit, The return result points to a newly allocated name which, if parsed by HTParse relative to relatedName, will yield aName. The caller is responsible for freeing the resulting name later.*/extern char * HTRelative (const char * aName, const char *relatedName);/*. Is a URL Relative or Absolute?.Search the URL and determine whether it is a relative or absolute URL. Wecheck to see if there is a ":" before any "/", "?", and "#". If this is thecase then we say it is absolute. Otherwise we say it is relative.*/extern BOOL HTURL_isAbsolute (const char * url);/*. URL Canonicalization.Canonicalization of URIs is a difficult job, but it saves a lot of down loadsand double entries in the cache if we do a good job. A URI is allowed tocontain the seqeunce xxx/../ which may be replaced by "" , and the seqeunce"/./" which may be replaced by "/". Simplification helps us recognize duplicateURIs. Thus, the following transformations are done: o /etc/junk/../fred becomes /etc/fred o /etc/junk/./fred becomes /etc/junk/fred but we should NOT change o http://fred.xxx.edu/../.. or o ../../albert.html In the same manner, the following prefixed are preserved: o ./<etc> o //<etc> In order to avoid empty URIs the following URIs become: o /fred/.. becomes /fred/.. o /fred/././.. becomes /fred/.. o /fred/.././junk/.././ becomes /fred/.. If more than one set of `://' is found (several proxies in cascade) thenonly the part after the last `://' is simplified.*/extern char *HTSimplify (char **filename);/*. Prevent Security Holes.In many telnet like protocols, it can be very dangerous to allow a full ASCIIcharacter set to be in a URI. Therefore we have to strip them out.HTCleanTelnetString() makes sure that the given string doesn'tcontain characters that could cause security holes, such as newlines in ftp,gopher, news or telnet URLs; more specifically: allows everything betweenhexadesimal ASCII 20-7E, and also A0-FE, inclusive. str the string that is *modified* if necessary. The string will be truncated at the first illegal character that is encountered. returns YES, if the string was modified. NO, otherwise.*/extern BOOL HTCleanTelnetString (char * str);/**/#endif /* HTPARSE_H *//* @(#) $Id: HTParse.html,v 2.39 2000/08/04 08:10:53 kahan Exp $*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -