Annotation of libwww/Library/src/HTFile.html, revision 2.9

2.7       timbl       1: <HTML>
                      2: <HEAD>
2.6       timbl       3: <TITLE>File access in libwww</TITLE>
2.7       timbl       4: <NEXTID N="z4">
                      5: </HEAD>
2.3       timbl       6: <BODY>
2.6       timbl       7: <H1>File Access</H1>These are routines for local file
                      8: access used by WWW browsers and servers.
                      9: Implemented by HTFile.c. <P>
                     10: If the file is not a local file,
                     11: then we pass it on to <A
2.7       timbl      12: NAME="z3" HREF="HTFTP.html">HTFTP</A> in case
2.6       timbl      13: it can be reached by FTP.
2.3       timbl      14: <PRE>#ifndef HTFILE_H
2.1       timbl      15: #define HTFILE_H
                     16: 
                     17: #include "HTFormat.h"
                     18: #include "HTAccess.h"
2.3       timbl      19: #include "HTML.h"              /* SCW */
                     20: 
2.1       timbl      21: 
                     22:  
2.3       timbl      23: </PRE>
                     24: <H2>Controlling globals</H2>These flags control how directories
                     25: and files are represented as hypertext,
                     26: and are typically set by the application
                     27: from command line options, etc.
                     28: <PRE>extern int HTDirAccess;           /* Directory access level */
2.1       timbl      29: 
                     30: #define HT_DIR_FORBID          0       /* Altogether forbidden */
2.3       timbl      31: #define HT_DIR_SELECTIVE       1       /* If HT_DIR_ENABLE_FILE exists */
2.1       timbl      32: #define HT_DIR_OK              2       /* Any accesible directory */
                     33: 
                     34: #define HT_DIR_ENABLE_FILE     ".www_browsable" /* If exists, can browse */
                     35: 
2.3       timbl      36: extern int HTDirReadme;                /* Include readme files in listing? */
                     37:                                        /* Values: */
                     38: #define HT_DIR_README_NONE     0       /* No */
                     39: #define HT_DIR_README_TOP      1       /* Yes, first */
                     40: #define HT_DIR_README_BOTTOM   2       /* Yes, at the end */
2.1       timbl      41: 
                     42: #define HT_DIR_README_FILE             "README"
                     43: 
                     44: 
2.9     ! luotonen   45: PUBLIC BOOL HTMulti PARAMS((HTRequest * req));
        !            46: 
2.3       timbl      47: </PRE>
                     48: <H2>Convert filenames between local and
                     49: WWW formats</H2>
                     50: <PRE>extern char * HTLocalName PARAMS((CONST char * name));
2.1       timbl      51: 
                     52: 
2.3       timbl      53: </PRE>
                     54: <H2>Make a WWW name from a full local
                     55: path name</H2>
                     56: <PRE>extern char * WWW_nameOfFile PARAMS((const char * name));
2.1       timbl      57: 
                     58: 
2.3       timbl      59: </PRE>
                     60: <H2>Generate the name of a cache file</H2>
                     61: <PRE>extern char * HTCacheFileName PARAMS((CONST char * name));
2.1       timbl      62: 
                     63: 
2.3       timbl      64: </PRE>
2.5       timbl      65: <H2>Output directory titles</H2>This is (like the next one) used
                     66: by HTFTP. It is common code to generate
                     67: the title and heading 1 and the parent
                     68: directory link for any anchor.
                     69: <PRE>extern void HTDirTitles PARAMS((
                     70:        HTStructured *  target,
                     71:        HTAnchor *      anchor));
                     72: 
                     73: </PRE>
2.6       timbl      74: <H2>Output a directory entry</H2>This is used by HTFTP.c for example
                     75: -- it is a common routine for generating
                     76: a linked directory entry.
2.4       timbl      77: <PRE>extern void HTDirEntry PARAMS((
                     78:        HTStructured *  target,         /* in which to put the linked text */
                     79:        CONST char *    tail,           /* last part of directory name */
                     80:        CONST char *    entry));        /* name of this entry */
                     81: 
                     82: </PRE>
2.6       timbl      83: <H2><A
2.7       timbl      84: NAME="z1">HTSetSuffix: Define the representation
2.6       timbl      85: for a file suffix</A></H2>This defines a mapping between local
                     86: file suffixes and file content types
                     87: and encodings.
                     88: <H3>On entry,</H3>
                     89: <DL>
                     90: <DT>suffix
                     91: <DD> includes the "." if that is
                     92: important (normally, yes!)
                     93: <DT>representation
                     94: <DD> is MIME-style content-type
                     95: <DT>encoding
                     96: <DD> is MIME-style <A
2.7       timbl      97: NAME="z0" HREF="../../Protocols/rfc1341/5_Content-Transfer-Encoding.html#z0">content-transfer-encoding</A>
2.6       timbl      98: (8bit, 7bit, etc)
2.8       luotonen   99: <DT>language
                    100: <DD>is MIME-style content-language
2.6       timbl     101: <DT>quality
                    102: <DD> an a priori judgement of
                    103: the quality of such files (0.0..1.0)
                    104: </DL>
                    105: 
2.8       luotonen  106: <PRE>
                    107: /*
                    108: ** Example:  HTSetSuffix(".ps", "application/postscript", "8bit", NULL, 1.0);
2.1       timbl     109: */
                    110: 
2.8       luotonen  111: PUBLIC void HTSetSuffix PARAMS((CONST char *   suffix,
                    112:                               CONST char *     representation,
                    113:                               CONST char *     encoding,
                    114:                               CONST char *     language,
                    115:                               float            quality));
                    116: 
                    117: PUBLIC void HTAddType PARAMS((CONST char *     suffix,
                    118:                              CONST char *      representation,
                    119:                              CONST char *      encoding,
                    120:                              float             quality));
                    121: 
                    122: PUBLIC void HTAddEncoding PARAMS((CONST char * suffix,
                    123:                                  CONST char *  encoding,
                    124:                                  float         quality));
                    125: 
                    126: PUBLIC void HTAddLanguage PARAMS((CONST char * suffix,
                    127:                                  CONST char *  language,
                    128:                                  float         quality));
                    129: 
2.1       timbl     130: 
2.3       timbl     131: </PRE>
2.6       timbl     132: <H2>HTFileFormat: Get Representation
                    133: and Encoding from file name</H2>
                    134: <H3>On exit,</H3>
                    135: <DL>
                    136: <DT>return
2.7       timbl     137: <DD> The represntation it imagines
2.6       timbl     138: the file is in
                    139: <DT>*pEncoding
2.7       timbl     140: <DD> The encoding (binary,
                    141: 7bit, etc). See <A
                    142: NAME="z2" HREF="#z1">HTSetSuffix</A> .
2.6       timbl     143: </DL>
2.3       timbl     144: 
2.6       timbl     145: <PRE>extern HTFormat HTFileFormat PARAMS((
                    146:                CONST char *    filename,
                    147:                HTAtom **       pEncoding));
2.3       timbl     148: 
                    149: 
                    150: </PRE>
2.6       timbl     151: <H2>Determine file value from file name</H2>
2.3       timbl     152: <PRE>
                    153: 
                    154: extern float HTFileValue PARAMS((
                    155:                CONST char * filename));
2.1       timbl     156: 
                    157: 
2.3       timbl     158: </PRE>
                    159: <H2>Determine write access to a file</H2>
                    160: <H3>On exit,</H3>
                    161: <DL>
                    162: <DT>return value
                    163: <DD> YES if file can be accessed
                    164: and can be written to.
                    165: </DL>
2.1       timbl     166: 
2.3       timbl     167: <PRE>
                    168: </PRE>
                    169: <H3>Bugs</H3>Isn't there a quicker way?
                    170: <PRE>
2.1       timbl     171: 
2.3       timbl     172: extern BOOL HTEditable PARAMS((CONST char * filename));
2.1       timbl     173: 
                    174: 
2.3       timbl     175: </PRE>
                    176: <H2>Determine a suitable suffix, given
                    177: the representation</H2>
                    178: <H3>On entry,</H3>
                    179: <DL>
                    180: <DT>rep
                    181: <DD> is the atomized MIME style representation
                    182: </DL>
                    183: 
                    184: <H3>On exit,</H3>
                    185: <DL>
                    186: <DT>returns
                    187: <DD> a pointer to a suitable suffix
                    188: string if one has been found, else
                    189: NULL.
                    190: </DL>
2.1       timbl     191: 
2.3       timbl     192: <PRE>extern CONST char * HTFileSuffix PARAMS((
                    193:                HTAtom* rep)); 
2.1       timbl     194: 
                    195: 
                    196: 
2.3       timbl     197: </PRE>
                    198: <H2>The Protocols</H2>
2.7       timbl     199: <PRE>GLOBALREF HTProtocol HTFTP, HTFile;
2.1       timbl     200: 
                    201: #endif /* HTFILE_H */
2.3       timbl     202: 
2.7       timbl     203: </PRE>end of HTFile</A></BODY>
                    204: </HTML>

Webmaster