Utility Functions
Overview
The utility routines come in a couple major categories.
There are the routines that deal with filename suffixes (include
"rbutil.h"):
- There are two functions that return a pointer to the suffix based
upon either a filename or an URL: rbGetFileSuffix() and
rbGetUrlSuffix.
- There are several routines that take a pointer to a suffix and return
a bool if it is the indicated type: rbIsHtmlSuf(),
rbIsHidxSuf(), rbIsHkeySuf(), rbIsTextSuf(),
rbIsImageSuf(), rbIsAudioSuf(), rbIsInfoSuf(), and
rbIsRbSuf().
- There is a routine that takes a pointer to a suffix and returns a
page-type int: rbSuffixToPageType().
- There are two routines that return a page-type int by parsing the
suffix from either a filename or an URL: rbFileNameToPageType()
and rbUrlToPageType().
- You can call rbAddIgnoreSuf() to add a suffix that you want
rbmake to completely ignore. The code already includes such suffixes as
"exe", "zip", "mov", etc.
- Call rbPageTypeIsBinary() if you want to know if the indicated
RB_PAGETYPE_* value contains binary data.
(See the page-type values in the RbFile
class documentation.)
There are some URL-related utilities (include "rburls.h"):
- The rbBuildURL() function takes a (potentially relative) URL
and combines it with the URL for the base page. The resulting URL is a
malloced string with the absolute URL. If the base-page-URL pointer is
NULL, the routine supplies an URL for the current directory as the base
(e.g. "file:///some/path/").
- The rbFreeURL() routine is used to free the memory that was
given to you by rbBuildURL(). It is not portable to use any other
method to free this memory.
- The rbGetUrlFn() function turns a "file://..." URL into a
local filename.
- The rbUrlEscape() function takes a filename and turns any
illegal URI characters into % escapes. The memory returned is allocated
with Mem_alloc().
- The rbUrlUnescape() function takes an URL and turns any %
escapes into normal characters. The memory returned is allocated with
Mem_alloc().
- The rbGetCwdURL() function returns an URL for the current
directory.
- The rbStripCwd() function strips the current-directory's URL
from the start of the supplied URL string IF it is present.