File Access

These are routines for local file access used by WWW browsers and servers. Implemented by HTFile.c. This module is a part of the CERN Common WWW Library.

If the file is not a local file, then we pass it on to HTFTP in case it can be reached by FTP. However, as this is very time consuming when requesting a local file that actually doesn't exist, this redirection will be disabled in the next major release, www-bug@info.cern.ch June 1994.

Note: All functions that deal with directory listings etc. have been moved to HTDirBrw Module.

#ifndef HTFILE_H
#define HTFILE_H

#include "HTFormat.h"
#include "HTAccess.h"
#include "HTML.h"		/* SCW */
#include "HTDirBrw.h"

#ifdef SHORT_NAMES
#define HTGetCoD	HTGetContentDescription
#define HTSplFiN	HTSplitFilename
#endif /*SHORT_NAMES*/

Multiformat Handling

Split Filename to suffixes

PUBLIC int HTSplitFilename PARAMS((char *	s_str,
				   char **	s_arr));

Get Content Description According to Suffixes

PUBLIC HTContentDescription * HTGetContentDescription PARAMS((char ** actual,
							      int	  n));

#define MULTI_SUFFIX ".multi"   /* Extension for scanning formats */
#define MAX_SUFF 15		/* Maximum number of suffixes for a file */

Convert filenames between local and WWW formats

extern char * HTLocalName PARAMS((CONST char * name));


Make a WWW name from a full local path name

extern char * WWW_nameOfFile PARAMS((const char * name));


Generate the name of a cache file

extern char * HTCacheFileName PARAMS((CONST char * name));

HTSetSuffix: Define the representation for a file suffix

This defines a mapping between local file suffixes and file content types and encodings.

On entry,

suffix
includes the "." if that is important (normally, yes!)
representation
is MIME-style content-type
encoding
is MIME-style content-transfer-encoding (8bit, 7bit, etc)
language
is MIME-style content-language
quality
an a priori judgement of the quality of such files (0.0..1.0)
/*
** Example:  HTSetSuffix(".ps", "application/postscript", "8bit", NULL, 1.0);
*/

PUBLIC void HTSetSuffix PARAMS((CONST char *	suffix,
			       CONST char *	representation,
			       CONST char *	encoding,
			       CONST char *	language,
			       float		quality));

PUBLIC void HTAddType PARAMS((CONST char *	suffix,
			      CONST char *	representation,
			      CONST char *	encoding,
			      float		quality));

PUBLIC void HTAddEncoding PARAMS((CONST char *	suffix,
				  CONST char *	encoding,
				  float		quality));

PUBLIC void HTAddLanguage PARAMS((CONST char *	suffix,
				  CONST char *	language,
				  float		quality));


HTFileFormat: Get Representation and Encoding from file name

On exit,

return
The represntation it imagines the file is in
*pEncoding
The encoding (binary, 7bit, etc). See HTSetSuffix .
*pLanguage
The language.
extern HTFormat HTFileFormat PARAMS((
		CONST char * 	filename,
		HTAtom ** 	pEncoding,
		HTAtom **	pLanguage));


Determine file value from file name


extern float HTFileValue PARAMS((
		CONST char * filename));


Determine write access to a file

On exit,

return value
YES if file can be accessed and can be written to.

Bugs

Isn't there a quicker way?

extern BOOL HTEditable PARAMS((CONST char * filename));


Determine a suitable suffix, given the representation

On entry,

rep
is the atomized MIME style representation

On exit,

returns
a pointer to a suitable suffix string if one has been found, else NULL.
extern CONST char * HTFileSuffix PARAMS((
		HTAtom* rep)); 



The Protocols

GLOBALREF HTProtocol HTFTP, HTFile;

#endif /* HTFILE_H */

end of HTFile