<HTML>
<HEAD>
<TITLE>File access in libwww</TITLE>
<NEXTID N="z4">
</HEAD>
<BODY>
<H1>File Access</H1>These are routines for local file
access used by WWW browsers and servers.
Implemented by HTFile.c. <P>
If the file is not a local file,
then we pass it on to <A
NAME="z3" HREF="HTFTP.html">HTFTP</A> in case
it can be reached by FTP.
<PRE>#ifndef HTFILE_H
#define HTFILE_H
#include "HTFormat.h"
#include "HTAccess.h"
#include "HTML.h" /* SCW */
</PRE>
<H2>Controlling globals</H2>These flags control how directories
and files are represented as hypertext,
and are typically set by the application
from command line options, etc.
<PRE>extern int HTDirAccess; /* Directory access level */
#define HT_DIR_FORBID 0 /* Altogether forbidden */
#define HT_DIR_SELECTIVE 1 /* If HT_DIR_ENABLE_FILE exists */
#define HT_DIR_OK 2 /* Any accesible directory */
#define HT_DIR_ENABLE_FILE ".www_browsable" /* If exists, can browse */
extern int HTDirReadme; /* Include readme files in listing? */
/* Values: */
#define HT_DIR_README_NONE 0 /* No */
#define HT_DIR_README_TOP 1 /* Yes, first */
#define HT_DIR_README_BOTTOM 2 /* Yes, at the end */
#define HT_DIR_README_FILE "README"
</PRE>
<H2>Convert filenames between local and
WWW formats</H2>
<PRE>extern char * HTLocalName PARAMS((CONST char * name));
</PRE>
<H2>Make a WWW name from a full local
path name</H2>
<PRE>extern char * WWW_nameOfFile PARAMS((const char * name));
</PRE>
<H2>Generate the name of a cache file</H2>
<PRE>extern char * HTCacheFileName PARAMS((CONST char * name));
</PRE>
<H2>Output directory titles</H2>This is (like the next one) used
by HTFTP. It is common code to generate
the title and heading 1 and the parent
directory link for any anchor.
<PRE>extern void HTDirTitles PARAMS((
HTStructured * target,
HTAnchor * anchor));
</PRE>
<H2>Output a directory entry</H2>This is used by HTFTP.c for example
-- it is a common routine for generating
a linked directory entry.
<PRE>extern void HTDirEntry PARAMS((
HTStructured * target, /* in which to put the linked text */
CONST char * tail, /* last part of directory name */
CONST char * entry)); /* name of this entry */
</PRE>
<H2><A
NAME="z1">HTSetSuffix: Define the representation
for a file suffix</A></H2>This defines a mapping between local
file suffixes and file content types
and encodings.
<H3>On entry,</H3>
<DL>
<DT>suffix
<DD> includes the "." if that is
important (normally, yes!)
<DT>representation
<DD> is MIME-style content-type
<DT>encoding
<DD> is MIME-style <A
NAME="z0" HREF="../../Protocols/rfc1341/5_Content-Transfer-Encoding.html#z0">content-transfer-encoding</A>
(8bit, 7bit, etc)
<DT>quality
<DD> an a priori judgement of
the quality of such files (0.0..1.0)
</DL>
<PRE>/* Example: HTSetSuffix(".ps", "application/postscript", "8bit", 1.0);
**
*/
extern void HTSetSuffix PARAMS((
CONST char * suffix,
CONST char * representation,
CONST char * encoding,
float quality));
</PRE>
<H2>HTFileFormat: Get Representation
and Encoding from file name</H2>
<H3>On exit,</H3>
<DL>
<DT>return
<DD> The represntation it imagines
the file is in
<DT>*pEncoding
<DD> The encoding (binary,
7bit, etc). See <A
NAME="z2" HREF="#z1">HTSetSuffix</A> .
</DL>
<PRE>extern HTFormat HTFileFormat PARAMS((
CONST char * filename,
HTAtom ** pEncoding));
</PRE>
<H2>Determine file value from file name</H2>
<PRE>
extern float HTFileValue PARAMS((
CONST char * filename));
</PRE>
<H2>Determine write access to a file</H2>
<H3>On exit,</H3>
<DL>
<DT>return value
<DD> YES if file can be accessed
and can be written to.
</DL>
<PRE>
</PRE>
<H3>Bugs</H3>Isn't there a quicker way?
<PRE>
extern BOOL HTEditable PARAMS((CONST char * filename));
</PRE>
<H2>Determine a suitable suffix, given
the representation</H2>
<H3>On entry,</H3>
<DL>
<DT>rep
<DD> is the atomized MIME style representation
</DL>
<H3>On exit,</H3>
<DL>
<DT>returns
<DD> a pointer to a suitable suffix
string if one has been found, else
NULL.
</DL>
<PRE>extern CONST char * HTFileSuffix PARAMS((
HTAtom* rep));
</PRE>
<H2>The Protocols</H2>
<PRE>GLOBALREF HTProtocol HTFTP, HTFile;
#endif /* HTFILE_H */
</PRE>end of HTFile</A></BODY>
</HTML>
Webmaster