1 /*
2  * $LynxId: HTAccess.h,v 1.20 2008/01/03 00:24:16 tom Exp $
3  *					HTAccess:  Access manager for libwww
4  *			ACCESS MANAGER
5  *
6  * This module keeps a list of valid protocol (naming scheme) specifiers with
7  * associated access code.  It allows documents to be loaded given various
8  * combinations of parameters.  New access protocols may be registered at any
9  * time.
10  *
11  * Part of the libwww library .
12  *
13  */
14 #ifndef HTACCESS_H
15 #define HTACCESS_H
16 
17 /*      Definition uses:
18 */
19 #include <HTAnchor.h>
20 #include <HTFormat.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25     extern char *use_this_url_instead;
26 
27     extern int redirection_attempts;
28 
29 /*      Return codes from load routines:
30  *
31  *      These codes may be returned by the protocol modules,
32  *      and by the HTLoad routines.
33  *      In general, positive codes are OK and negative ones are bad.
34  */
35 
36 /*
37 
38 Default Addresses
39 
40    These control the home page selection.  To mess with these for normal browses is asking
41    for user confusion.
42 
43  */
44 #define LOGICAL_DEFAULT "WWW_HOME"	/* Defined to be the home page */
45 
46 #ifndef PERSONAL_DEFAULT
47 #define PERSONAL_DEFAULT "WWW/default.html"	/* in home directory */
48 #endif
49 #ifndef LOCAL_DEFAULT_FILE
50 #define LOCAL_DEFAULT_FILE "/usr/local/lib/WWW/default.html"
51 #endif
52 /*  If one telnets to a www access point,
53     it will look in this file for home page */
54 #ifndef REMOTE_POINTER
55 #define REMOTE_POINTER  "/etc/www-remote.url"	/* can't be file */
56 #endif
57 /* and if that fails it will use this. */
58 #ifndef REMOTE_ADDRESS
59 #define REMOTE_ADDRESS  "http://www.w3.org/remote.html"		/* can't be file */
60 #endif
61 
62 /* If run from telnet daemon and no -l specified, use this file:
63 */
64 #ifndef DEFAULT_LOGFILE
65 #define DEFAULT_LOGFILE "/usr/adm/www-log/www-log"
66 #endif
67 
68 /*      If the home page isn't found, use this file:
69 */
70 #ifndef LAST_RESORT
71 #define LAST_RESORT     "http://www.w3.org/default.html"
72 #endif
73 
74 /*
75 
76 Flags which may be set to control this module
77 
78  */
79 #ifdef NOT
80     extern int HTDiag;		/* Flag: load source as plain text */
81 #endif				/* NOT */
82     extern char *HTClientHost;	/* Name or number of telnetting host */
83     extern FILE *HTlogfile;	/* File to output one-liners to */
84     extern BOOL HTSecure;	/* Disable security holes? */
85     extern BOOL HTPermitRedir;	/* Special flag for getfile() */
86     extern HTStream *HTOutputStream;	/* For non-interactive, set this */
87     extern HTFormat HTOutputFormat;	/* To convert on load, set this */
88 
89 /*	Check for proxy override.			override_proxy()
90  *
91  *	Check the no_proxy environment variable to get the list
92  *	of hosts for which proxy server is not consulted.
93  *
94  *	no_proxy is a comma- or space-separated list of machine
95  *	or domain names, with optional :port part.  If no :port
96  *	part is present, it applies to all ports on that domain.
97  *
98  *  Example:
99  *          no_proxy="cern.ch,some.domain:8001"
100  *
101  *  Use "*" to override all proxy service:
102  *	     no_proxy="*"
103  */
104     extern BOOL override_proxy(const char *addr);
105 
106 /*
107 
108 Load a document from relative name
109 
110   ON ENTRY,
111   relative_name           The relative address of the file to be accessed.
112   here                    The anchor of the object being searched
113 
114   ON EXIT,
115   returns    YES          Success in opening file
116   NO                      Failure
117 
118  */
119     extern BOOL HTLoadRelative(const char *relative_name,
120 			       HTParentAnchor *here);
121 
122 /*
123 
124 Load a document from absolute name
125 
126   ON ENTRY,
127   addr                    The absolute address of the document to be accessed.
128   filter_it               if YES, treat document as HTML
129 
130   ON EXIT,
131   returns YES             Success in opening document
132   NO                      Failure
133 
134  */
135     extern BOOL HTLoadAbsolute(const DocAddress *addr);
136 
137 /*
138 
139 Load a document from absolute name to a stream
140 
141   ON ENTRY,
142   addr                    The absolute address of the document to be accessed.
143   filter_it               if YES, treat document as HTML
144 
145   ON EXIT,
146   returns YES             Success in opening document
147   NO                      Failure
148 
149    Note: This is equivalent to HTLoadDocument
150 
151  */
152     extern BOOL HTLoadToStream(const char *addr, BOOL filter_it,
153 			       HTStream *sink);
154 
155 /*
156 
157 Load if necessary, and select an anchor
158 
159   ON ENTRY,
160   destination                The child or parent anchor to be loaded.
161 
162   ON EXIT,
163   returns YES             Success
164   returns NO              Failure
165 
166  */
167     extern BOOL HTLoadAnchor(HTAnchor * destination);
168 
169 /*
170 
171 Make a stream for Saving object back
172 
173   ON ENTRY,
174   anchor                  is valid anchor which has previously been loaded
175 
176   ON EXIT,
177   returns                 0 if error else a stream to save the object to.
178 
179  */
180     extern HTStream *HTSaveStream(HTParentAnchor *anchor);
181 
182 /*
183 
184 Search
185 
186    Performs a search on word given by the user.  Adds the search words to the end of the
187    current address and attempts to open the new address.
188 
189   ON ENTRY,
190   *keywords               space-separated keyword list or similar search list
191   here                    The anchor of the object being searched
192 
193  */
194     extern BOOL HTSearch(const char *keywords, HTParentAnchor *here);
195 
196 /*
197 
198 Search Given Indexname
199 
200    Performs a keyword search on word given by the user.  Adds the keyword to  the end of
201    the current address and attempts to open the new address.
202 
203   ON ENTRY,
204   *keywords               space-separated keyword list or similar search list
205   *indexname              is name of object search is to be done on.
206 
207  */
208     extern BOOL HTSearchAbsolute(const char *keywords,
209 				 char *indexname);
210 
211 /*
212 
213 Register an access method
214 
215  */
216 
217     typedef struct _HTProtocol {
218 	const char *name;
219 
220 	int (*load) (const char *full_address,
221 		     HTParentAnchor *anchor,
222 		     HTFormat format_out,
223 		     HTStream *sink);
224 
225 	HTStream *(*saveStream) (HTParentAnchor *anchor);
226 
227     } HTProtocol;
228 
229     extern BOOL HTRegisterProtocol(HTProtocol * protocol);
230 
231 /*
232 
233 Generate the anchor for the home page
234 
235  */
236 
237 /*
238 
239    As it involves file access, this should only be done once when the program first runs.
240    This is a default algorithm -- browser don't HAVE to use this.
241 
242  */
243     extern HTParentAnchor *HTHomeAnchor(void);
244 
245 /*
246 
247 Return Host Name
248 
249  */
250     extern const char *HTHostName(void);
251 
252 /*
253 
254 For registering protocols supported by Lynx
255 
256 */
257     extern void LYRegisterLynxProtocols(void);
258 
259     extern void LYUCPushAssumed(HTParentAnchor *anchor);
260     extern int LYUCPopAssumed(void);
261 
262     extern BOOL using_proxy;	/* Are we using an NNTP proxy? */
263 
264 #ifdef __cplusplus
265 }
266 #endif
267 #endif				/* HTACCESS_H */
268