File:  [Public] / libwww / Library / src / HTFWrite.html
Revision 2.1: download - view: text, annotated - select for diffs
Thu Mar 9 18:20:25 1995 UTC (29 years, 2 months ago) by frystyk
Branches: MAIN
CVS tags: without-configure, with-configure, v3/0pre3, v3/0, WindowsNT, HEAD
Library version 3.0beta

<HTML>
<HEAD>
<TITLE>HTFWriter:  File Writer for libwww</TITLE>
<NEXTID N="z4">
</HEAD>
<BODY>

<H1>C File Writer</H1>

<PRE>
/*
**	(c) COPYRIGHT CERN 1994.
**	Please first read the full copyright statement in the file COPYRIGH.
*/
</PRE>

It is useful to have both FWriter and Writer for environments in which
fdopen() doesn't exist for example.<P>

This module is implemented by <A HREF="HTFWrite.c">HTFWrite.c</A>,
and it is a part of the <A
HREF="http://info.cern.ch/hypertext/WWW/Library/User/Guide/Guide.html">
Library of Common Code</A>.


<PRE>
#ifndef HTFWRITE_H
#define HTFWRITE_H

#include "HTStream.h"
#include "HTFormat.h"
</PRE>

<H2>Set up a Stream to a File</H2>

This function puts up a new stream given an open file descripter. If the file
is not to be closed afterwards, then set leave_open = NO.

<PRE>extern HTStream * HTFWriter_new PARAMS((FILE *	fp,
					     BOOL	leave_open));
</PRE>

<H3>Converters</H3>

HTSaveAndCallBack will save to a cache file and call the request->callback
function with the filename as parameter.

<PRE>
#ifndef pyramid
extern HTConverter HTSaveAndExecute, HTSaveLocally, HTSaveAndCallBack,
       HTThroughLine;
#endif
</PRE>

<A NAME="BlackHole"><H2>Black Hole Stream</H2></A>

This stream simply absorbs data without doing anything what so ever.

<PRE>
extern HTStream * HTBlackHole NOPARAMS;
</PRE>


<H2>Get Local File Name</H2>

This function tries really hard to generate a non-existent file name on the
local file system. You can specify the path of the file so that the file name
is generated relatively to this. Two modes of file name generations exist:
It can either generate a hash based file name or take the last part of the URL
and generate a more human readable file name.

<PRE>
extern char *HTFWriter_filename PARAMS((char * 		path,
					char *		url,
				      	 CONST char * 	suffix,
				      	 unsigned int	limit,
	                                 BOOL           flat));
</PRE>

<H2><A
NAME="z3">The Client Cache</A></H2>The cache contains details of temporary
disk files which contain the contents
of remote documents.   There is also
a <A
NAME="z2" HREF="HTAnchor.html#z1">list of cache items for each URL</A>
in its anchor object.
<H3>An item in the cache</H3>
<PRE>typedef struct _HTCacheItem {
    HTParentAnchor *	anchor;
    HTFormat		format;		/* May have many formats per anchor */
    char *		filename;
    time_t		load_time;
    time_t		load_delay;
    int			reference_count;
} HTCacheItem;

</PRE>
<H3>The Cache Itself</H3>There is one global cache. No, it's
not reentrant code then.  If we find
a use for >1 cache then we can change
it. Currently the obvious advantage
is when all things which could gain
from caching use the same one.
<PRE>extern HTList * HTCache;	/* made up of HTCacheItem items */

</PRE>
<H3>The Cache Limit</H3>The cache limit is the number of
files which are kept. Yes, I know,
the amount of disk space wouldbe
more relevant. So this may change.
Currentlyit is present to 100 but
may be changed by the application
by writing into this variable.
<PRE>extern int	HTCacheLimit;

</PRE>
<H3>Clear a cache</H3>
<PRE>extern void HTCacheClear PARAMS((HTList * cache));

</PRE>

</PRE>
<H3>To remove All cache files known to this session</H3>
<PRE>
extern void HTCacheDeleteAll NOPARAMS;
</PRE>

<H3>Stream for writing to cache</H3>Note that HTSaveAndCallBack will
also generate a cache file.

<PRE>
#ifndef pyramid
extern HTConverter HTCacheWriter;
#endif

#endif
</PRE>

End of definition module
</BODY>
</HTML>

Webmaster