Hutil is the basic package that gets you going with libht. In it, you find the commands for reading and outputing pages, the basic movement commands, and some utility functions for dealing with life as a cgi script.
- htelm * htreadfile (char * file)
- htelm * htreadurl (char * url, int * sts, char * type)
- void htdumpfile ()
- void htdumptree ()
- void htrelease ()
- htelm * htaddelm (char * txt)
- htelm * htpaddelm (htelm * h, htelm **pend, unsigned char * txt)
- htelm * htgototag (char * tag)
- htelm * htpgototag (htelm * h, char * tag)
- htelm * htgotomark (char * mark)
- htelm * htpgotomark (htelm * h, char * mark)
- htelm * htgotoline (int line)
- htelm * htpgotoline (htelm * h, int line)
- void htprintf (char * fmt, ...)
- void hthrdprintf (char * fmt, ...)
- void htfprintf (char * fmt, ...)
- void htflush ()
- void htpprintf (htelm * h, char * fmt, ...)
- htelm * htgetcur ()
- void hteof ()
- void htrewind ()
- void hterase ()
- char ** split (char * str, char sep)
- void chop (char * str)
- void trim (char * str)
- void unwebify (char * word, char * bf)
- int parseurl (char * url, URL * base, URL * base)
- char * canonicalurl (URL * u)
- htelm * htreadfile (char * file)
- htreadfile is the basic function which inserts HTML templates into the page currently being worked on. It is inserted a the current insertion point, and the insertion point is moved to the end of the file that is read in. htreadfile returns a pointer to the first element read in, 0 if an error occurred.
- htelm * htreadurl (char * url, int * sts, char * type)
- htreadurl is similar to htreadfile(), but it contacts the httpd at url and parses the contents. You may optionally receive the transfer status and the MIME encapsulation type if you supply these parameters.
Note: htreadurl is somewhat simple minded: it currently only deals with text/html and text/plain well. There should be a better interface for sucking up other types, but that is beyond the scope of its current implementation. More sophisticated URL readers can be built with fopenurl() and parseurl (), etc.- void htdumpfile ()
- htdumpfile dumps the current page to the standard output. normally, this is the last thing you do before exiting your CGI program.
- void htdumptree ()
- An internal debugging function which dumps out the internal tree representation of the page.
- void htrelease ()
- Release all storage associated with the current page.
- htelm * htaddelm (char * txt)
- add a string of text including markup tags at the current insertion point.
Note: You can not have partial markup tags in the string. This is because the parser is stateless. If have this sort of situation, consider using htfprintf().
- htelm * htpaddelm (htelm * h, htelm **pend, unsigned char * txt)
- Similar to htaddelm, but adds at a specified point, and updates a pointer to the last element.
- htelm * htgototag (char * tag)
- Goto the tage specified in "tag". This can be an real tag, or a psuedo markup tag.
- htelm * htpgototag (htelm * h, char * tag)
- Similar to htgototag, but start scanning at the specificed location.
- htelm * htgotomark (char * mark)
- Markers are implemented with the
<$mark marker>pseudotag in the template documents. To move to the mark, you specify the character string containing the marker
- htelm * htpgotomark (htelm * h, char * mark)
- Similar to htgotomark, but starts at location h.
Note: htpgotomark will not traverse "up" the tree, it only considers the subtree starting at h. If you don't understand this, you probably should be using htgotomark.
- htelm * htgotoline (int line)
- Goto the given line number. These line numbers are somewhat approximate for markup items (they signify the beginning line number of the tag), though they should be accurate for text.
Note: no attempt at all is made to keep the line numbers valid after inserting tags and text.
- htelm * htpgotoline (htelm * h, int line)
- Similar to htgotoline, but start scanning at h rather than the current document.
- void htprintf (char * fmt, ...)
- htprintf works identically to printf(3), except the output is inserted into the current document, at the current insertion point.
Note: You can not have partial markup tags in the string. This is because the parser is stateless. If have this sort of situation, consider using htfprintf().
- void hthrdprintf (char * fmt, ...)
- After calling preHTML(), hthdrprintf can be used to insert MIME headers in the document. Each line must be terminated by a single newline. The final newline-newline pair is taken care of for you.
- void htfprintf (char * fmt, ...)
- htfprintf is similar to htprintf(), but it buffers all of the data until a corresponding htflush(). The reason for this seeming braindamage is because the underlying parser is stateless, so things like:
htprintf ("<foo name=bar "); ... htprintf (">\n");will cause problems. You can pretty much add text with impugnity, the only restriction being available memory.Note: If you want an entire HTML container to be treated as syntactical unit, you must submit it to the parser as a unit. Normally this isn't a problem since big glumps 'o HTML are normally stored in templates rather than hard wired in code. If you expect inserted text to work properly with, say, the forms functions you will need to htfprintf() the entire glump before flushing it.
- void htflush ()
- Flush the proceeds from any built up htfprintf's.
- void htpprintf (htelm * h, char * fmt, ...)
- Similar to htprinf, but inserts at h instead of the current insertion point.
- htelm * htgetcur ()
- get the current insertion point.
- void hteof ()
- goto the end of the current document.
- void htrewind ()
- goto the beginning of the current document.
- void hterase ()
- trash the current document, and start over.
- char ** split (char * str, char sep)
- similiar to the perl(1) split. returns a null terminated vector of pointers to strings. All storage is malloc(3)'d, including the strings.
- void chop (char * str)
- like the perl(1) chop: chop off the last character of string "str".
- void trim (char * str)
- trim trailing whitespace cruft on string "str".
- void unwebify (char * word, char * bf)
- translate a HTML encoded string into string buffer "bf". bf must be buffer of at least strlen(word) length long.
Why doesn't webify() exist Mike? Huh? Huh?