File: HTFWriter.html

package info (click to toggle)
cern-httpd 3.0A-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 5,392 kB
  • ctags: 6,554
  • sloc: ansic: 37,902; makefile: 1,746; perl: 535; csh: 167; sh: 143
file content (123 lines) | stat: -rw-r--r-- 3,157 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<HTML>
<HEAD>
<TITLE>HTFWriter:  File Writer for libwww</TITLE>
<NEXTID N="z4">
</HEAD>
<BODY>
<H1>C File Writer</H1>It is useful to have both FWriter
and Writer for environments in which
fdopen() doesn't exist for example.<P>
Part of <A
NAME="z1" HREF="Overview.html">libwww</A> . Implemented by <A
NAME="z0" HREF="HTFWriter.c">HTFWriter.c</A>
<PRE>
#ifndef HTFWRITE_H
#define HTFWRITE_H

#include "HTStream.h"
#include &lt;stdio.h>
#include "HTFormat.h"

#ifdef SHORT_NAMES
#define	HTFWriter_new	HTFWnew
#endif
</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>

<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));
</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>