/* ** (c) COPYRIGHT MIT 1995. ** Please first read the full copyright statement in the file COPYRIGH. */
This module is like the generic string utility module but it contains more Web related string utility functions. Examples are functions that return a date string, a Message ID string etc.
This module is implemented by HTWWWStr.c, and it is a part of the W3C Reference Library.
#ifndef HTWWWSTR_H #define HTWWWSTR_H #include "HTUser.h"
This function returns a RFC822 word separated by space, comma, or semi-colons.
pstr
points to a string containing a word separated by white
white space "," ";" or "=". The word can optionally be quoted using
<"> or "<" ">" Comments surrrounded by '(' ')' are filtered out. On exit,
pstr
has been moved to the first delimiter past the field THE
STRING HAS BEEN MUTILATED by a 0 terminator. The function returns a pointer
to the first word or NULL on error
extern char * HTNextField (char** pstr);
The Library provides a default set of read routines that can handle the most
common situations. However, before we start we make following definition
is to make life easier when having a state machine looking for a
<CRLF>
sequence.
typedef enum _HTEOLState { EOL_ERR = -1, EOL_BEGIN = 0, EOL_FCR, EOL_FLF, EOL_DOT, EOL_SCR, EOL_SLF, /* intermediate states */ EOL_END, EOL_FOLD, EOL_LINE } HTEOLState;
Returns a pointer to a static area!
extern const char *HTDateTimeStr (time_t *calendar, BOOL local);
extern BOOL HTDateDirStr (time_t * time, char * str, int len);
Converts a string representation in GMT to a local representation of localtime
time_t
. The local time zone is taken from the
user profile information.
extern time_t HTParseTime (const char * str, HTUserProfile * up);
The message ID string can for example be use as a RFC 822 header. The content is based on the information taken from the user profile which can be supplied by the applciation.
extern const char * HTMessageIdStr (HTUserProfile * up);
In computer-world 1K is 1024 bytes and 1M is 1024K -- however, sprintf() still formats in base-10. Therefore I output only until 999, and then start using the next unit. This doesn't work wrong, it's just a feature. The conversion is done in "str" which must be large enough to contain the result.
extern void HTNumToStr (unsigned long n, char *str, int len);
These are two functions that separate the URL naming syntax from platform dependent file naming schemes. If you are porting the code to a new platform, you probably have to do some translation here.
The URL has already been translated through the rules in get_physical in HTAccess.c and all we need to do now is to map the path to a local representation, for example if must translate '/' to the ones that turn the wrong way ;-) Returns local file (that must be freed by caller) if OK, else NULL.
extern char * HTWWWToLocal (const char * url, const char * base, HTUserProfile * up);
Generates a WWW URL name from a local file name or NULL if error. Returns URL (that must be freed by caller) if OK, else NULL.
extern char * HTLocalToWWW (const char * local);
#endif