JSM: Protocol module return values should be a named type, possibly an enumeration. Data types used in the public functions HTList * HTConverter * HTRequest * HTFormat HTStream HTProtocol HTRuleOp HTParentAnchor HTAnchor HTEventCallBack * SOCKFD HTThreadAction HTEncoding * HTLanguage * HTContentDescription * HTChildAnchor * HTLinkType * HyperDoc * HTCharset HTLevel HTCte HText * HTStructured * HTStyle * HTStyleSheet * HTNesting * HTHrefNode * HTIconNode * HTDirLineInput HTConverter HTTag * SGML_dtd * HTNetInfo * SockA * HTAtom * HTAssocList * HTBTree * HTBTElement * ============================ Public functions void HTSetPresentation(HTList *conversions, CONST char *representation, CONST char *command, CONST char *test_command, double quality, double secs, double secs_per_byte) Register a presenter globally. void HTSetConversion(HTList *conversions, CONST char *rep_in, CONST char *rep_out, HTConverter *converter, double quality, double secs, double secs_per_byte) Register a converter globally. void HTFormatInit(HTList * conversions) Set up default global presenters and converters. void HTAcceptEncoding(HTList * list, CONST char * enc, double quality) Register an encoding void HTAcceptCharset(HTList * list, CONST char * charset, double quality) Register a charset void HTAcceptLanguage(HTList * list, CONST char * lang, double quality) Register a language void HTFormatDelete(HTRequest * request) Remove local preferences. void HTDisposeConversions() Remove global preferences. BOOL HTRank(HTList * possibilities, HTList * accepted_content_types, HTList * accepted_content_languages, HTList * accepted_content_encodings) Rearranges the list "possibilities" into descending preference. Entries are pruned from the list if they are unacceptable bad. The boolean returned indicates whether any possibilities remain. HTStream * HTStreamStack(HTFormat rep_in, HTFormat rep_out, HTStream *output_stream, HTRequest *request, BOOL guess) Sets up the conversion. It takes a stream into which the output should be sent in the final format, builds the conversion stack, and returns a stream into which the data in the input format should be fed. double HTStackValue(HTList * conversions, HTFormat format_in, HTFormat format_out, double initial_value, long int length) Returns the cost of the conversion stack HTStreamStack would create. BOOL HTRegisterProtocol(HTProtocol * protocol) void HTDisposeProtocols() BOOL HTProtocolBlocking(HTRequest *request) Returns YES if the Library is run in NON-INTERACTIVE MODE. Otherwise reports on the ability to support blocking mode for this request? int HTAddRule(HTRuleOp op, CONST char *pattern, CONST char *equiv) Add a configuration management rule. JSM -- should return VOID and always succeed? int HTClearRules() Clear all configuration management rules. JSM -- should return VOID and always succeed char *HTTranslate(CONST char *required) Translate the input string by the configuration management rules. The result is a newly allocated string (which the user expected to free), possibly a copy of the input string. int HTSetConfiguration (CONST char *config) Load one line of configuration information. Returns 0 for OK, < 0 for syntax error in configuration information. int HTLoadRules(CONST char * filename) Load configuration management rules from a file. Returns 0 for OK, non-0 for error. int HTLoadRelative(CONST char *relative_name, HTParentAnchor *here, HTRequest *request) Load a document from relative URL. Returns a protocol module value. int HTLoadAbsolute(CONST char *addr, HTRequest *request) Load a document from absolute URL. Returns a protocol module value. int HTLoadToStream(CONST char *addr, BOOL filter, HTRequest *request) Load a document from absolute name to a stream. Returns a protocol module value. int HTLoadAnchor(HTAnchor *a, HTRequest *request) Load a document from anchor. Returns a protocol module value. int HTLoadAnchorRecursive(HTAnchor *a, HTRequest *request) JSM: I don't understand this description. The recursive function keeps the error stack in the request structure so that no information is lost having more than one call. int HTLoad(HTRequest *request, BOOL keep_error_stack) JSM: I don't understand this description. Load a document which has an address AND a matching anchor. BOOL HTLoadTerminate(HTRequest * request, int status) Terminates loading which was initiated by HTLoad. JSM: what's the status for? int HTSearch(CONST char *keywords, HTParentAnchor *here, HTRequest *request) Search for specified "keywords" using relative URL. JSM: what CONSTitutes a keyword? Case sensitive? int HTSearchAbsolute(CONST char *keywords, CONST char *indexname, HTRequest *request) Search using absolute URL. JSM: what's the indexname for, as well as above questions. BOOL HTEventRegister(HTEventCallBack * user_socket) BOOL HTEventUnregister(HTEventCallBack * user_socket) void HTEventCleanup() void HTEventThread_new(void *) int HTEventThread_clear(void *) void HTEventThreadState(SOCKFD, HTThreadAction) HTEventState HTEventRequestTerminate(HTRequest *request, int status) int HTEventLoop(HTRequest *homerequest, HTParentAnchor *homeanchor, CONST char *homekeywords) JSM: this looks like the old event interface. BOOL HTBind_init() Initializes bindings of filename suffixes to language, encoding type, etc. Also initializes separator character in filenames to ".". BOOL HTBind_deleteAll() Delete all filename suffix bindings. Called by HTLibTerminate(). void HTBind_setCaseSensitive(BOOL sensitive) Should the search for suffixes be case sensitive or not? The default value is case sensitive. CONST char *HTBind_getDelimiters() Get set of suffix delimiters. void HTBind_setDelimiters(CONST char * new_suffixes) Change the set of suffix delimiters. BOOL HTBind_setBinding(CONST char *suffix, CONST char *representation, CONST char *encoding, CONST char *language, double value) A "super" method for binding information to a file suffix. Any of the string values can be NULL. If filename suffix is already defined its previous definition is overridden or modified. =================================================(cont'd by AHL 6/23/95) BOOL HTBind_setType(CONST char *suffix, CONST char *encoding, double value) Set up content type Bindings Associated from a given File Suffix BOOL HTBind_setEncoding(CONST char *suffix, CONST char *encoding, double value) Set up content type Bindings Associated from a given Content encoding. BOOL HTBind_setLanguage(CONST char *suffix, CONST char *language, double value) Set up content type Bindings Associated from a given language. char *HTBind_getSuffix(HTParentAnchor *anchor) Use the set of bindings to find a suitable suffix (or index) for a certain combination of language, media type and encoding given in the anchor. Returns a pointer to a suitable suffix string that must be freed by the caller. If more than one suffix is found they are all concatenated. If no suffix is found, NULL is returned. BOOL HTBind_getBindings(HTParentAnchor *anchor) Use the set of bindings to find the combination of language, media type and encoding of a given anchor. If more than one suffix is found they are all searched. The last suffix has highest priority, the first one lowest. Returns the anchor object with the representations found. BOOL HTBind_getFormat(CONST char *filename, HTFormat *format, HTEncoding *encoding, HTLanguage *language, double *quality) Use the set of bindings to find the combination of language, media type and encoding of a given file. If more than one suffix is found they are all searched. The last suffix has highest priority, the first one lowest. HTContentDescription *HTBind_getDescription(char *file) Use the set of bindings to find the combination of language, media type and encoding of a given. ========================================================== (done 6/26/95) (HTAnchor) HTAnchor *HTAnchor_findAddress(CONST char *address) Return a reference (link) which is found in a document, and might not be already loaded. The parent anchor returned can either be created on the spot or be found in the hash table. HTChildAnchor *HTAnchor_findChild(HTParentAnchor *parent, CONST char *tag) Find/Create a Child Anchor for a new child anchor being edited into an existing document. The parent anchor must already exist but the child returned can either be created on the spot or is already in the hash table. The tag is the part that's after the '#' sign in a URI. HTChildAnchor *HTAnchor_findChildAndLink (HTParentAnchor *parent, CONST char *tag, CONST char *href, HTLinkType *ltype) Find a child anchor anchor with a given parent and possibly a tag, and (if passed) link this child to the URI given in the href. As we really want typed links to the caller should also indicate what the type of the link is (see HTTP spec for more information). The link is relative to the address of the parent anchor. BOOL HTAnchor_delete(HTParentAnchor *me) All outgoing links from parent and children are deleted, and this anchor is removed from the sources list of all its targets. We also delete the targets. If this anchor's source list is empty, we delete it and its children. BOOL HTAnchor_deleteAll(HTList *objects) Deletes all anchors and return a list of all the HyperDocs found while doing it. The application may keep its own list of HyperDocs, but this function returns it anyway. It is always for the application to delete any HyperDocs. BOOL HTAnchor_link(HTAnchor *source, HTAnchor *destination, HTLinkType *type) A single anchor may have many outgoing links of which the default is the main link. If one already exists then this new link is simply added to the list. HTAnchor *HTAnchor_followMainLink(HTAnchor *me) Find the anchor which is the main target of this anchor. HTAnchor *HTAnchor_followTypedLink(HTAnchor *me, HTLinkType *type) Return the anchor following a given typed link. BOOL HTAnchor_makeMainLink(HTAnchor *me, HTLink *movingLink) Make an outgoing link the default Main target. void HTAnchor_makeLastChild(HTChildAnchor *me) Move a child anchor to the head of the list of its siblings. This is to ensure that an anchor which might have already existed is put in the correct order as we load the document. *AHL: ?? Is the last child the head of the list ?? HTParentAnchor *HTAnchor_parent(HTAnchor *me) Given an anchor returns the parent anchor. BOOL HTAnchor_hasChildren(HTParentAnchor *me) Given an anchor, it returns whether or not it contains anchors within. void HTAnchor_setDocument(HTParentAnchor *me, HyperDoc *doc) Assign a HyperDoc to an Anchor HyperDoc *HTAnchor_document(HTParentAnchor *me) Return the HyperDoc of an anchor (if any) char *HTAnchor_address(HTAnchor *me) Returns the full URI of the anchor, child or parent as a malloc'd string to be freed by the caller as when th eanchor was created. char *HTAnchor_physical(HTParentAnchor *me) Returns the physical address after we haved looked for proxies etc. void HTAnchor_setPhysical(HTParentAnchor *me, char *protocol) Set a physical address to an anchor. void HTAnchor_clearIndex(HTParentAnchor *me) void HTAnchor_setIndex(HTParentAnchor *me) BOOL HTAnchor_isIndex(HTParentAnchor *me) Is the Anchor searchable? - Search functions. void *HTAnchor_protocol(HTParentAnchor *me) Gets the necessary protocol associated with anchor. void HTAnchor_setProtocol(HTParentAnchor *me, void *protocol) Sets the protocol associated with anchor. CONST char *HTAnchor_title(HTParentAnchor *me) Returns the title of anchor. void HTAnchor_setTitle(HTParentAnchor *me, CONST char *title) Set the title for anchor void HTAnchor_appendTitle(HTParentAnchor *me, CONST char *title) Append to the title of an anchor. HTFormat HTAnchor_format(HTParentAnchor *me) Get content type. void HTAnchor_setFormat(HTParentAnchor *me, HTFormat form) Set content type. HTCharset HTAnchor_charset(HTParentAnchor *me) Get character set parameter to the content-type. void HTAnchor_setCharset(HTParentAnchor *me, HTCharset charset) Set character set parameter to the content-type. HTLevel HTAnchor_level(HTParentAnchor *me) Get level parameter to the content-type. void HTAnchor_setLevel(HTParentAnchor *me, HTLevel level) Set level parameter to the content-type. HTLanguage HTAnchor_language(HTParentAnchor *me) Get language of an anchor. void HTAnchor_setLanguage(HTParentAnchor *me, HTLanguage language) set language of an anchor HTEncoding HTAnchor_encoding(HTParentAnchor *me) Get content encoding void HTAnchor_setEncoding(HTParentAnchor *me, HTEncoding encoding) Set content encoding. HTCte HTAnchor_cte(HTParentAnchor *me) Get content transfer encoding void HTAnchor_setCte(HTParentAnchor *me, HTCte cte) Set content transfer encoding. long int HTAnchor_length(HTParentAnchor *me) Get anchor content length void HTAnchor_setLength(HTParentAnchor *me, long int length) set anchor content length. int HTAnchor_methods(HTParentAnchor *me) get anchor methods void HTAnchor_setMethods(HTParentAnchor *me, int methodset) set anchor methods void HTAnchor_appendMethods(HTParentAnchor *me, int methodset) append to anchor methods. CONST char * HTAnchor_version(HTParentAnchor *me) Get anchor version void HTAnchor_setVersion(HTParentAnchor *me, CONST char *version) Set anchor version CONST char * HTAnchor_derived(HTParentAnchor *me) Get the location from where the anchor was derived. void HTAnchor_setDerived(HTParentAnchor *me, CONST char *derived_from) Set the derivation of the anchor. HTList * HTAnchor_Extra(HTParentAnchor *me) void HTAnchor_addExtra(HTParentAnchor *me, CONST char *header) BOOL HTAnchor_headerParsed(HTParentAnchor *me) Status of Header Parsing. These are primarily for internal use void HTAnchor_setHeaderParsed(HTParentAnchor *me) Status of Header Parsing. These are primarily for internal use void HTAnchor_clearHeader(HTParentAnchor *me) Clear the Header information. ================================================== (AHL: done 6/26/95) (HTRequest) HTRequest * HTRequest_new() Create blank request void HTRequest_delete(HTRequest * req) Delete request structure. Also frees conversion list hanging from req->conversions. void HTRequest_clear(HTRequest * req) Clear a request structure so that it can be reused. The only thing that differs from using free/new is that the list of conversions is kept. ================================================== (AHL: done 6/26/95) (HTLog) BOOL HTLog_enable(CONST char * filename, BOOL local) Open the log file and start doing log. The time used in the log file is either GMT or local dependent on local. BOOL HTLog_disable() Disable the log. BOOL HTLog_request(HTRequest * request) This functions logs the result of a request. ================================================== (AHL: done 6/26/95) (HTCache) BOOL HTCache_enable(CONST char * cache_root) Enable Cache. If cache_root is NULL then reuse old value or use HT_CACHE_ROOT. An empty string will make '/' as cache root. BOOL HTCache_disable() Turns off the cache. Note that the cache can be disabled and enabled at any time. The cache root is kept and can be reused during the execution. BOOL HTCache_isEnabled() Checks if cache is enabled. BOOL HTCache_setRoot(CONST char * cache_root) Set Cache Root directory. CONST char *HTCache_getRoot() Get Cache Root void HTCache_freeRoot() For cleaning up memory. This is done by the Library function HTLibTerminate() void HTCacheClear(HTList * cache) Can clear a list of cache items. void HTCacheDeleteAll() To remove All cache files known to this session ================================================== (AHL: done 6/26/95) (HTProxy) BOOL HTProxy_setProxy(CONST char *access,CONST char *proxy) A proxy server is registered with a corresponding access method, for example http, ftp etc. The `proxy' parameter should be a fully valid name, like http://proxy.w3.org:8001 but domain name is not required. If an entry exists for this access then delete it and use the new one. BOOL HTProxy_deleteProxy() Deletes all proxies. This is automatically done in HTLibTerminate() BOOL HTProxy_setNoProxy(CONST char *host, CONST char *access, unsigned port) The noproxy list is a list of host names and domain names where we don't contact a proxy even though a proxy is in fact registered for this particular access method . When registering a noproxy item, you can specify a specific port for this access method in which case it isvalid only for requests to this port. If `port' is '0' then it applies to all ports and if `access' is NULL then it applies to to all access methods. BOOL HTProxy_deleteNoProxy() The remove function removes all entries in the list. This is automatically done in HTLibTerminate() char * HTProxy_getProxy(CONST char * url) This function evaluates the lists of registered proxies and if one is found for the actual access method and it is not registered in the `noproxy' list, then a URL containing the host to be contacted is returned to the caller. BOOL HTProxy_setGateway(CONST char *access, CONST char *gate) A gateway is registered with a corresponding access method, for example http, ftp etc. The `gate' parameter should be a fully valid name, like http://gateway.w3.org:8001 but domain name is not required. If an entry exists for this access then delete it and use the new one. BOOL HTProxy_deleteGateway() The remove function removes all registered proxies. This is automatically done in HTLibTerminate() char * HTProxy_getGateway(CONST char * url) This function evaluates the lists of registered gateways and if one is found for the actual access method then it is returned and must be freed by the caller. void HTProxy_getEnvVar() This function maintains backwards compatibility with the old environment variables and searches for the most common values: http, ftp, news, wais, and gopher ================================================== (AHL: done 6/26/95) (HTAlert) BOOL HTConfirm(CONST char * Msg) This function prompts the user for a confirmation on the message passed as a parameter. If the user reacts in the affirmative, returns TRUE, returns FALSE otherwise. char * HTPrompt(CONST char * Msg, CONST char * deflt) Prompt for answer and get text back. Reply text is either NULL on error or a dynamic string which the caller must free. char * HTPromptPassword(CONST char * Msg) Prompt for password without echoing the reply. Reply text is either NULL on error or a dynamic string which the caller must free. void HTPromptUsernameAndPassword(CONST char *Msg, char **username, char **password) This is just a composite function using HTPrompt and HTPromptPassword. The strings returned must be freed by caller. void HTAlert(CONST char * Msg) This function simply puts out the message passed. void HTProgress(CONST char * Msg) This function can be used to indicate the current status of a certain action. void HTErrorMsg(HTRequest * request) This function outputs the content of the error_stack to standard output ================================================== (AHL: done 6/26/95) (HTParse) char *HTParse(CONST char *aName, CONST char *relatedName, int wanted) Parse a URI relative to another URI char *HTRelative(CONST char *aName, CONST char *relatedName) This function creates and returns a string which gives an expression of one address as related to another. Where there is no relation, an absolute address is returned. char *HTSimplify(char **filename) Canonicalize the Path Part of a URI. A URI is allowed to contain the seqeunce xxx/../ which may be replaced by "" , and the seqeunce "/./" which may be replaced by "/". Simplification helps us recognize duplicate URIs. char *HTCanon(char **filename, char *host) Canonicalize the DNS part of a URI This function expands the host name of the URI from a local name to a full domain name and converts the host name to lower case. The advantage by doing this is that we only have one entry in the host case and one entry in the document cache. BOOL HTCleanTelnetString(char *str) Prevent Security Holes. In many telnet like protocols, it can be very dangerous to allow a full ASCII character set to be in a URI. Therefore we have to strip them out. ================================================== (AHL: done 6/27/95) (HTEscape) char * HTEscape(CONST char * str, unsigned char mask) This funtion takes a string containing any sequence of ASCII characters, and returns a malloced string containing the same information but with all "unacceptable" characters represented in the form %xy where x and y are two hex digits. char * HTUnEscape( char * str) This function takes a pointer to a string in which characters may have been encoded in %xy form, where xy is the acsii hex code for character 16x+y. The string is converted in place, as it will never grow. ================================================== (AHL: done 6/27/95) (HText) HText *HText_new(HTParentAnchor *anchor) HText *HText_new2(HTParentAnchor *anchor, HTStream *output_stream) HText *HText_new3(HTRequest *request, HTStream *output_stream, HTStructured *structure) There are several methods depending on how much you want to specify. The output stream is used with objects which need to output the hypertext to a stream. The structure is for objects which need to refer to the structure which is kep by the creating stream. void HText_free(HText *me) Free hypertext object void HText_beginAppend(HText *text) void HText_endAppend(HText * text) These are used by a parser to build the text in an object HText_beginAppend must be called, then any combination of other append calls, then HText_endAppend. This allows optimised handling using buffers and caches which are flushed at the end. void HText_setStyle(HText *text, HTStyle *style) Set the style for future text void HText_appendCharacter(HText *text, char ch) Add one character void HText_appendText(HText *text, CONST char *str) Add a zero-terminated string void HText_appendParagraph(HText *text) New Paragraph void HText_appendLineBreak(HText *text) Add new line break void HText_appendHorizontalRule(HText *text) add horizontal ruler??? void HText_beginAnchor(HText *text, HTChildAnchor *anc) void HText_endAnchor(HText *text) The anchor object is created and passed to HText_beginAnchor. The senstive text is added to the text object, and then HText_endAnchor is called. Anchors may not be nested. void HText_setNextId(HText *text, CONST char *s) The string must be of the form aaannnnn where aaa is the prefix for automatically generated ids, normally "z", and nnnn is the next unused number. If not present, defaults to z0. An editor should pick up both the a and n bits, and increment n when generating ids. This ensures that old ids are not reused, even if the elements using them have been deleted from the document. void HText_appendImage(HText *text, HTChildAnchor *anc, CONST char *alternative_text, CONST char *alignment, BOOL isMap) Append an inline image. The image is handled by the creation of an anchor whose destination is the image document to be included. The semantics is the intended inline display of the image. void HText_appendObject(HText *text, int element_number, CONST BOOL *present, CONST char * CONST * value) Append an object which does its own work. The SGML parameters are passed untouched. Currently this is only used for empty elements. Extensions could be (1) to pass CDATA contents as well as any attributes and (2) to pass the whole structured stream until the compound object has parsed itself. void HText_unimplemented(HText *text) If the parser realises that it has incompletely parsed an object, then it can call this to flag it to the object. This will for example prevent editing or writing back. void HText_dump(HText * me) Dump diagnostics to stderr HTParentAnchor * HText_nodeAnchor(HText * me) Return the anchor associated with this node BOOL HText_select(HText * text) Brings text to front and highlights. BOOL HText_selectAnchor(HText *text, HTChildAnchor *anchor) Brings anchor to front and highlights. void HText_applyStyle(HText * me, HTStyle *style) Apply style to selection. - for editing programs void HText_updateStyle(HText * me, HTStyle *style) Update selection with style. - for editing programs HTStyle * HText_selectionStyle(HText * me, HTStyleSheet* sheet) Returns style of selected text. - for editing programs. void HText_replaceSel(HText * me, CONST char *aString, HTStyle* aStyle) Paste in styled text - for editing programs. void HTextApplyToSimilar(HText * me, HTStyle *style) Apply this style to the selection and all similarly formatted text (style recovery only) void HTextSelectUnstyled(HText * me, HTStyleSheet *sheet) Select the first unstyled run. (style recovery only) void HText_unlinkSelection(HText * me) HTAnchor *HText_referenceSelected(HText * me) HTAnchor *HText_linkSelTo(HText * me, HTAnchor* anchor) Anchor handling - for editing programs. ================================================== (AHL: done 6/27/95) (HTStyle) HTStyle * HTStyleModify(HTStyle * style, HTNesting* nesting, int element_number) This routine is passed the style for a particular SGML nesting state, and the element number of a new element within that state. The routine returns a suitable style for text within the new element. It is passed a pointer to the nesting state so that it can link the style back to the nesting state for later manipulation of the SGML nesting tree. HTStyle * HTStyleNew() HTStyle* HTStyleNewNamed(CONST char * name) HTStyle * HTStyleFree(HTStyle * self) HTStyle * HTStyleRead(HTStyle * self, HTStream * stream) HTStyle * HTStyleWrite(HTStyle * self, HTStream * stream) Style Functions HTStyleSheet * HTStyleSheetNew() HTStyleSheet * HTStyleSheetFree(HTStyleSheet * self) HTStyle * HTStyleNamed(HTStyleSheet * self, CONST char * name) HTStyle * HTStyleMatching(HTStyleSheet *self, HTStyle * style) HTStyleSheet * HTStyleSheetAddStyle(HTStyleSheet * self, HTStyle * style) HTStyleSheet * HTStyleSheetRemoveStyle(HTStyleSheet * self, HTStyle * style) HTStyleSheet * HTStyleSheetRead(HTStyleSheet * self, HTStream * stream) HTStyleSheet * HTStyleSheetWrite(HTStyleSheet * self, HTStream * stream) Style Sheet Functions ================================================== (AHL: done 6/27/95) (HTHistory) void HTHistory_record(HTAnchor * destination) Record the jump to an anchor HTAnchor * HTHistory_back(HTAnchor * cur_anch) Go back in history (find the last visited node) HTAnchor * HTHistory_forward(HTAnchor * cur_anch) Go forward in history (find the last visited node) if exists. HTAnchor * HTHistory_backtrack() ????????? BOOL HTHistory_canBacktrack() Can History go back to last node? HTAnchor * HTHistory_moveBy(int offset) Take the n-th child's link after or before the one we took to get here. Positive offset means go towards most recently added children. BOOL HTHistory_canMoveBy(int offset) Check if it's possible to move such. HTAnchor * HTHistory_read(int number) Read numbered visited anchor (1 is the oldest) HTAnchor * HTHistory_recall(int number) This reads the anchor and stores it again in the list, except if last. int HTHistory_count() This is needed in order to check the validity of certain commands for menus, etc. (not needed for now. Use canBacktrack, etc.) void HTHistory_leavingFrom(HTAnchor * anchor) Change last history entry. Sometimes we load a node by one anchor but leave by a different one, and it is the one we left from which we want to remember. ================================================== (AHL: done 6/27/95) (HTIcon) char * HTIcon_alt_string(char * alt, BOOL brackets) Generates the alt-tag void HTAddIcon(char * url, char * alt, char * type_templ) General icon binding. Use this icon if content-type or encoding matches template. void HTAddHref(char * url, char * type_templ) Called from HTConfig.c to build the list of all the AddHref's void HTAddUnknownIcon(char * url, char * alt) Icon for which no other icon can be used. void HTAddBlankIcon(char * url, char * alt) Invisible icon for the listing header field to make it aligned with the rest of the listing (this doesn't have to be blank) void HTAddParentIcon(char * url, char * alt) Icon to use for parent directory. void HTAddDirIcon(char * url, char * alt) Icon to use for a directory HTIconNode * HTGetIcon(mode_t mode, HTFormat content_type, HTEncoding content_encoding) returns the icon corresponding to content_type or content_encoding. HTHrefNode * HTGetHref( char * filename) returns the HrefNode to get the URL for presentation of a file (indexing) void HTStdIconInit(CONST char * url_prefix) The function HTStdIconInit(url_prefix) can be used to initialize a standard icon set ================================================== (AHL: done 6/28/95) (HTBrowse) int HTBrowseDirectory(HTRequest *req, char *directory) Functions for directory browsing on local UNIX system int HTFTPBrowseDirectory(HTRequest *req, char *directory, HTDirLineInput input) Functions for directory browsing from other sources This function fills out the EntryInfo file structure. ================================================== (AHL: done 6/28/95) (HTStream) HTStream * HTWriter_new(SOCKFD soc, BOOL leave_open) Opens a new socket writer HTStream * HTWriter_newNoClose(SOCKFD soc) Opens a new socket writer that does not close HTStream * HTASCIIWriter(SOCKFD soc) Write ASCII to socket? HTStream * HTBlackHole() This stream simply absorbs data without doing anything what so ever. HTStream * HTFWriter_new(FILE *fp, BOOL leave_open) This function puts up a new stream given an open file descripter. If the file is not to be closed afterwards, then set leave_open = NO BOOL HTTmp_setRoot(CONST char * tmp_root) Sets destination for temporary files. CONST char * HTTmp_getRoot() Gets destination for the files. void HTTmp_freeRoot() The HTTmp_freeRoot is called by the HTLibTerminate function. Probably does not need to be tested. HTConverter HTSaveAndExecute, HTSaveLocally, HTSaveAndCallBack, HTThroughLine;HTCacheWriter; Five converters. Note that HTSaveAndCallBack will also generate a cache file. HTTag * SGMLFindTag(CONST SGML_dtd* dtd, CONST char * string) Find a Tag by Name. Returns a pointer to the tag within the DTD. int SGMLFindAttribute(HTTag* tag, CONST char * string) Find a Attribute by Name. Returns the number of the atribute or -1 if failure. HTStream *SGML_new(CONST SGML_dtd *dtd, HTStructured *target) Create an SGML parser HTStream * HTTee(HTStream* s1, HTStream* s2) The Tee stream just writes everything you put into it into two other streams. One use (the only use?!) is for taking a cached copy on disk while loading the main copy, without having to wait for the disk copy to be finished and reread it. HTStructured* HTML_new(HTRequest *request, void *param, HTFormat input_format, HTFormat output_format, HTStream *output_stream) A structured stream to parse HTML When this routine is called, the request structure may contain a childAnchor value. In that case it is the responsability of this module to select the anchor. void HTML_reopen(HTStructured * me) Reopening an existing HTML object allows it to be retained (for example by the styled text object) after the structured stream has been closed. HTConverter HTMLToPlain, HTMLToC, HTMLPresent, HTMLToTeX; Converters void HTMLUseCharacterSet(HTMLCharacterSet i) Selecting internal character set representations int HTLoadError(HTRequest *req, int number, CONST char *message) The error message should be marked as an error so that it can be reloaded later. This implementation just throws up an error message and leaves the document unloaded. void HTRegenInit() void HTRegenCharacter(char c, HTNesting * nesting, HTStructured * target) void HTNestingChange (HTStructured * s, HTNesting * old, HTNesting * newnest, HTChildAnchor * info, CONST char * aName) HTNesting * HTMLCommonality (HTNesting * s1, HTNesting * s2) HTNesting * HTNestElement (HTNesting * p, int ele) void * HTStyleForNesting(HTNesting * n) HTNesting * HTMLAncestor (HTNesting * old, int depth) HTNesting * CopyBranch (HTNesting * old, HTNesting * newnest, int depth) HTNesting * HTInsertLevel (HTNesting * old, int element_number, int level) HTNesting * HTDeleteLevel (HTNesting * old, int level) int HTMLElementNumber(HTNesting * s) int HTMLLevel (HTNesting * s) HTNesting * HTMLAncestor (HTNesting * old, int depth) Nesting functions. These functions were new with HTML2.c. They allow the tree of SGML nesting states to be manipulated, and SGML regenerated from the style sequence. HTStructured * HTMLGenerator(HTStream * output) This module converts structed stream into stream. That is, given a stream to write to, it will give you a structured stream too. HTStructured * HTTeXGenerator(HTStream * output) This module converts a structured stream from HTML into LaTeX format. void HTStartAnchor (HTStructured * targetstream, CONST char * name, CONST char * href) Start anchor element void HTMLPutImg (HTStructured *obj, CONST char *src, CONST char *alt, CONST char *align) Put image element void HTNextID (HTStructured * targetStream, CONST char * s) Specify next ID to be used HTConverter HTMIMEConvert, HTNetMIME; Converters HTConverter HTWSRCConvert; WAIS converter char * HTDeSlash (CONST char * str) HTDeSlash takes out the invlaid characters in a URL path ELEMENT by converting them into hex-escaped characters. char * HTEnSlash (CONST char * str) Opposite of HTDeSlash. HTConverter HTPlainPresent; Plain text converter. HTStream * HTGuess_new (HTRequest * req, void * param, HTFormat input_format, HTFormat output_format, HTStream * output_stream) This stream is a one that reads first a chunk of stuff, tries to figure out the format, and calls HTStreamStack(). This is a kind of lazy-evaluation of HTStreamStack(). ================================================== (AHL: done 6/29/95) (HTTCP) int HTDoConnect (HTNetInfo *net, char *url, u_short default_port, u_long *addr, BOOL use_cur) This makes an active connect to the specified host. int HTDoAccept (HTNetInfo *net) This function makes a non-blocking accept on a port and polls every second until MAX_ACCEPT_POLL is reached. void HTTCPAddrWeights (char * host, time_t deltatime) Recalculating the Time-Weights on Multihomed Hosts. On every connect to a multihomed host, the average connect time is updated exponentially for all the entries. void HTTCPCacheRemoveAll(); Cleanup the Memory. This function is called from HTLibTerminate(). CONST char * HTErrnoString(int errnum) Return error message corresponding to errno number given. int HTInetStatus(int errnum, char * where) We need to pass the error number as a parameter as we on some platforms get different codes from sockets and local file access. unsigned int HTCardinal(int * pstatus, char ** pp, unsigned int max_value) Parse a Cardinal Value CONST char * HTInetString(struct sockaddr_in * sin) Produce a string for an internet address. This function is equivalent to the BSD system call inet_ntoa in that it converts a numeric 32-bit IP-address to a dotted-notation decimal string. The pointer returned points to static memory which must be copied if it is to be kept. int HTParseInet(struct sockaddr_in * sin, CONST char * str, BOOL use_cur) This function finds the address of a specified host and fills out the sockaddr structure. str points to a string with a node name or number, with optional trailing colon and port number. sin points to the binary internet or decnet address field. char * HTGetHostBySock (int soc) Name of a Machine on the Other Side of a Socket int HTGetHostByName(char *host, SockA *sin, BOOL use_cur) This function gets the address of the host and puts it in to the socket structure. It maintains its own cache of connections so that the communication to the Domain Name Server is minimized. CONST char * HTGetHostName; This function returns a CONET char pointer to a static location containing the name of this host or NULL if not available. void HTSetHostName (char * host) This function overwrites any other value of current host name. This might be set by the user to change the value in the ID value parsed to a news host when posting. The change doesn't influence the Mail Address as they are stored in two different locations. If, however, the change is done before the first call to HTGetMailAddress() then this function will use the new host and domain name. void HTFreeHostName; Cleanup Memory. Called from HTLibTerminate(). CONST char *HTGetDomainName; This function rerturns the domain name part of the host name as returned by HTGetHostName() function. CONST char * HTGetMailAddress; This functions returns a char pointer to a static location containing the mail address of the current user. The static location is different from the one of the current host name so different values can be assigned. The default value is @hostname where hostname is as returned by HTGetHostName(). void HTSetMailAddress (char * address) This function overwrites any other value of current mail address. This might be set by the user to change the value in the From field in the HTTP Protocol. void HTFreeMailAddress NO; Free Memory. Called by HTLibTerminate(). void HTSetSignal NO; This is only necessary to compile on a few platforms and only if the application does not have its own signal handling. It is required on Solaris 2.3 (and other SVR4 platforms?) due to a bug in the TCP kernel. When a connect() is tried to a illegal port, solaris gives a SIGPIPE signal instead of returning Connection refused. ================================================== (AHL: done 6/29/95) (HTString) #define StrAllocCopy(dest, src) HTSACopy (&(dest), src) #define StrAllocCat(dest, src) HTSACat (&(dest), src) char * HTSACopy PARAMS ((char **dest, CONST char *src)); char * HTSACat PARAMS ((char **dest, CONST char *src)); These two functions are dynamic versions of strcpy and strcat. They use malloc for allocating space for the string. If StrAllocCopy is called with a non-NULL dest, then this is freed before the new value is assigned so that only the last string created has to be freed by the user. If StrAllocCat is called with a NULL pointer as destination then it is equivalent to StrAllocCopy. int strcasecomp (CONST char *a, CONST char *b) String comparison. int strncasecomp (CONST char *a, CONST char *b, int n) Case-insensitive String Comparison char * strcasestr (char * s1, char * s2) This works like strstr() but is not case-sensitive. char * HTStrip (char * s) Strip whitespace off a string. Return value points to first non-white character, or to '/0' if none. All trailing white space is OVERWRITTEN with zero. char * HTNextField (char** pstr) This function returns a RFC822 word separated by space, comma, or semi-colons. CONST char *HTDateTimeStr (time_t *calendar, BOOL local) RFC1123 Date/Time Stamp String long HTGetTimeZoneOffset NO; Calculates the offset from GMT in seconds. This is called from HTLibInit(). time_t HTParseTime (CONST char * str) Converts a string representation in GMT to a local representation of localtime time_t. CONST char *HTMessageIdStr NO; Unique Message-ID String ================================================== (AHL: done 6/29/95) (HTAtom) #define HTAtom_name(a) (a) Get Content of an Atom HTAtom * HTAtom_for (CONST char * string) This function returns a representative value (an atom) such that it will always (within one run of the program) return the same value for the same given string. Case sensitive. HTAtom * HTAtom_caseFor (CONST char * string) Same as above but not case sensitive. HTList * HTAtom_templateMatches (CONST char * templ) Returns a list of atoms which matches the template given. It is especially made for MIME-types so that for example a template like text returns a list of all MIME-types of type text. void HTAtom_deleteAll() Cleanup Memory. In order to cleanup memory, call this function. This is done automaticly from HTLibTerminate(). ================================================== (AHL: done 6/29/95) (HTList) HTList * HTList_new NO; Create a new list. void HTList_delete (HTList *me) Delete a list. BOOL HTList_addObject (HTList *me, void *newObject) Add object to start of list. BOOL HTList_removeObject (HTList *me, void *oldObject) Remove object. void * HTList_removeLastObject (HTList *me) Removes last object. void * HTList_removeFirstObject (HTList *me) Removes first object #define HTList_isEmpty(me) (me ? me->next == NULL : YES) Returns True or false if list is empty int HTList_count (HTList *me) Gets length of list int HTList_indexOf (HTList *me, void *object) #define HTList_lastObject(me) \ (me && me->next ? me->next->object : NULL) Gets last object. void * HTList_objectAt (HTList *me, int position) Gets object at given location. #define HTList_nextObject(me) (me && (me = me->next) ? me->object : NULL) Fast macro to traverse the list. Call it first with copy of list header: it returns the first object and increments the passed list pointer. Call it with the same variable until it returns NULL. #define HTList_free(x) FREE(x) Free the memory from a list. ================================================== (AHL: done 6/29/95) (HTAssoc) HTAssocList *HTAssocList_new NO; Creates a new associated list. void HTAssocList_delete (HTAssocList * alist) Deletes an associated list. void HTAssocList_add (HTAssocList * alist, CONST char * name, CONST char * value) Add a new member to the list. char *HTAssocList_lookup (HTAssocList * alist, CONST char * name) Lookup a member of the list. ================================================== (AHL: done 6/29/95) (HTBTree) HTBTree * HTBTree_new (HTComparer comp) Create a binary tree given its discrimination routine void HTBTree_free (HTBTree* tree) Free storage of the tree but not of the objects void HTBTreeAndObject_free (HTBTree* tree) Free storage of the tree and of the objects void HTBTree_add (HTBTree * tree, void * object) Add an object to a binary tree #define HTBTree_object(element) (element) Find user object for element HTBTElement * HTBTree_next(HTBTree* tree, HTBTElement * ele) Find next element in depth-first order ================================================== (AHL: done 6/29/95)