Annotation of libwww/Library/src/HTProfil.c, revision 2.28
2.1 frystyk 1: /*
2: ** APPLICATION PROFILES INITALIZATION
3: **
4: ** (c) COPYRIGHT MIT 1995.
5: ** Please first read the full copyright statement in the file COPYRIGH.
2.28 ! frystyk 6: ** @(#) $Id: HTProfil.c,v 2.27 1999/03/30 22:31:58 frystyk Exp $
2.1 frystyk 7: **
8: ** Defines a set of application profiles
9: */
10:
11: /* Library include files */
2.18 frystyk 12: #include "wwwsys.h"
2.1 frystyk 13: #include "WWWUtil.h"
14: #include "WWWCore.h"
2.6 frystyk 15: #include "WWWCache.h"
2.25 frystyk 16: #include "WWWStream.h"
2.27 frystyk 17: #include "HTInit.h"
2.1 frystyk 18: #include "HTProfil.h" /* Implemented here */
19:
20: PRIVATE HTList * converters = NULL;
2.13 frystyk 21: PRIVATE HTList * transfer_encodings = NULL;
22: PRIVATE HTList * content_encodings = NULL;
2.1 frystyk 23: PRIVATE BOOL preemptive = NO;
24:
25: /* ------------------------------------------------------------------------- */
26:
27: PUBLIC void HTProfile_delete (void)
28: {
2.4 eric 29: if (!preemptive) HTEventTerminate();
2.1 frystyk 30: if (HTLib_isInitialized()) {
2.6 frystyk 31:
2.28 ! frystyk 32: /* Clean up SSL */
! 33: #ifdef HT_SSL
! 34: HTSSLhttps_terminate();
! 35: #endif
! 36:
2.6 frystyk 37: /* Clean up the persistent cache (if any) */
2.7 frystyk 38: HTCacheTerminate();
2.6 frystyk 39:
40: /* Clean up all the global preferences */
2.1 frystyk 41: HTFormat_deleteAll();
2.24 frystyk 42:
2.25 frystyk 43: /* The following lists have been cleaned up by HTFormat_deleteAll */
44: transfer_encodings = 0;
45: content_encodings = 0;
46: converters = 0;
47:
48: /* Remove bindings between suffixes, media types */
49: HTBind_deleteAll();
2.6 frystyk 50:
51: /* Terminate libwww */
2.1 frystyk 52: HTLibTerminate();
53: }
54: }
55:
2.7 frystyk 56: PRIVATE void client_profile (const char * AppName, const char * AppVersion,
2.21 frystyk 57: BOOL preemptive, BOOL cache, BOOL HTMLParser)
2.1 frystyk 58: {
59: /* If the Library is not already initialized then do it */
60: if (!HTLib_isInitialized()) HTLibInit(AppName, AppVersion);
61:
2.16 frystyk 62: /* Register the default set of messages and dialog functions */
63: HTAlertInit();
64: HTAlert_setInteractive(YES);
65:
2.1 frystyk 66: if (!converters) converters = HTList_new();
2.13 frystyk 67: if (!transfer_encodings) transfer_encodings = HTList_new();
68: if (!content_encodings) content_encodings = HTList_new();
2.1 frystyk 69:
70: /* Register the default set of transport protocols */
71: HTTransportInit();
72:
2.7 frystyk 73: /* Register the default set of application protocol modules */
74: if (preemptive)
75: HTProtocolPreemptiveInit();
76: else
77: HTProtocolInit();
78:
2.25 frystyk 79: /* Initialize suffix bindings for local files */
80: HTBind_init();
81:
2.19 frystyk 82: /* Set max number of sockets we want open simultanously */
2.23 frystyk 83: HTNet_setMaxSocket(32);
2.19 frystyk 84:
2.14 frystyk 85: /* The persistent cache does not work in preemptive mode */
2.17 frystyk 86: if (cache) HTCacheInit(NULL, 20);
2.1 frystyk 87:
88: /* Register the default set of BEFORE and AFTER filters */
89: HTNetInit();
2.6 frystyk 90:
2.1 frystyk 91: /* Set up the default set of Authentication schemes */
92: HTAAInit();
2.28 ! frystyk 93:
! 94: #ifdef HT_SSL
! 95: HTSSLhttps_init(preemptive);
! 96: #endif
2.1 frystyk 97:
98: /* Get any proxy or gateway environment variables */
99: HTProxy_getEnvVar();
100:
101: /* Register the default set of converters */
102: HTConverterInit(converters);
2.21 frystyk 103:
104: /* Register the default libwww HTML parser */
105: if (HTMLParser) HTMLInit(converters);
106:
107: /* Set the convertes as global converters for all requests */
2.1 frystyk 108: HTFormat_setConversion(converters);
109:
110: /* Register the default set of transfer encoders and decoders */
2.13 frystyk 111: HTTransferEncoderInit(transfer_encodings);
112: HTFormat_setTransferCoding(transfer_encodings);
2.1 frystyk 113:
2.13 frystyk 114: /* Register the default set of content encoders and decoders */
115: HTContentEncoderInit(content_encodings);
116: if (HTList_count(content_encodings) > 0)
117: HTFormat_setContentCoding(content_encodings);
118: else {
119: HTList_delete(content_encodings);
120: content_encodings = NULL;
121: }
122:
2.1 frystyk 123: /* Register the default set of MIME header parsers */
124: HTMIMEInit();
125:
126: /* Register the default set of file suffix bindings */
127: HTFileInit();
128:
129: /* Register the default set of Icons for directory listings */
130: HTIconInit(NULL);
131: }
132:
133: PUBLIC void HTProfile_newClient (const char * AppName, const char * AppVersion)
2.4 eric 134: {
2.5 frystyk 135: /* Do the default setup */
2.21 frystyk 136: client_profile(AppName, AppVersion, NO, YES, NO);
137:
138: /* Set up default event loop */
139: HTEventInit();
140: }
141:
142: PUBLIC void HTProfile_newHTMLClient (const char * AppName, const char * AppVersion)
143: {
144: /* Do the default setup */
145: client_profile(AppName, AppVersion, NO, YES, YES);
2.5 frystyk 146:
147: /* Set up default event loop */
2.4 eric 148: HTEventInit();
2.1 frystyk 149: }
150:
151: PUBLIC void HTProfile_newPreemptiveClient (const char * AppName,
152: const char * AppVersion)
153: {
2.5 frystyk 154: /* Do the default setup */
2.21 frystyk 155: client_profile(AppName, AppVersion, YES, NO, NO);
2.1 frystyk 156:
2.26 frystyk 157: /* On windows we need the initialization anyway */
158: #ifdef WWW_WIN_ASYNC
159: HTEventInit();
160: #else
2.1 frystyk 161: /* Remember that we are loading preemptively */
162: preemptive = YES;
2.26 frystyk 163: #endif
164:
2.17 frystyk 165: }
166:
167: PUBLIC void HTProfile_newNoCacheClient (const char * AppName,
168: const char * AppVersion)
169: {
170: /* Do the default setup */
2.21 frystyk 171: client_profile(AppName, AppVersion, NO, NO, NO);
172:
173: /* Set up default event loop */
174: HTEventInit();
175: }
176:
177: PUBLIC void HTProfile_newHTMLNoCacheClient (const char * AppName,
178: const char * AppVersion)
179: {
180: /* Do the default setup */
181: client_profile(AppName, AppVersion, NO, NO, YES);
2.17 frystyk 182:
183: /* Set up default event loop */
184: HTEventInit();
2.1 frystyk 185: }
186:
187: PRIVATE void robot_profile (const char * AppName, const char * AppVersion)
188: {
189: /* If the Library is not already initialized then do it */
190: if (!HTLib_isInitialized()) HTLibInit(AppName, AppVersion);
191:
192: if (!converters) converters = HTList_new();
2.13 frystyk 193: if (!transfer_encodings) transfer_encodings = HTList_new();
194: if (!content_encodings) content_encodings = HTList_new();
2.1 frystyk 195:
196: /* Register the default set of transport protocols */
197: HTTransportInit();
198:
199: /* Register the default set of application protocol modules */
200: HTProtocolInit();
2.25 frystyk 201:
202: /* Initialize suffix bindings for local files */
203: HTBind_init();
2.1 frystyk 204:
205: /* Set max number of sockets we want open simultanously */
2.23 frystyk 206: HTNet_setMaxSocket(32);
2.1 frystyk 207:
208: /* Register some default set of BEFORE and AFTER filters */
2.10 frystyk 209: HTNet_addBefore(HTRuleFilter, NULL, NULL, HT_FILTER_MIDDLE);
210: HTNet_addBefore(HTProxyFilter, NULL, NULL, HT_FILTER_MIDDLE);
211: HTNet_addAfter(HTInfoFilter, NULL, NULL, HT_ALL, HT_FILTER_LATE);
2.1 frystyk 212:
213: /* Get any proxy or gateway environment variables */
214: HTProxy_getEnvVar();
215:
216: /* Register the default set of converters including the HTML parser */
217: HTConverterInit(converters);
2.21 frystyk 218: HTMLInit(converters);
219:
220: /* Set the convertes as global converters for all requests */
2.1 frystyk 221: HTFormat_setConversion(converters);
2.13 frystyk 222:
2.1 frystyk 223: /* Register the default set of transfer encoders and decoders */
2.13 frystyk 224: HTTransferEncoderInit(transfer_encodings);
225: HTFormat_setTransferCoding(transfer_encodings);
2.1 frystyk 226:
2.13 frystyk 227: /* Register the default set of content encoders and decoders */
228: HTContentEncoderInit(content_encodings);
229: if (HTList_count(content_encodings) > 0)
230: HTFormat_setContentCoding(content_encodings);
231: else {
232: HTList_delete(content_encodings);
233: content_encodings = NULL;
234: }
235:
2.1 frystyk 236: /* Register the default set of MIME header parsers */
237: HTMIMEInit();
238:
239: /* Register the default set of file suffix bindings */
240: HTFileInit();
241:
242: /* Register the default set of Icons for directory listings */
243: HTIconInit(NULL);
244:
245: /* Register some default messages and dialog functions */
246: if (HTAlert_interactive()) {
247: HTAlert_add(HTError_print, HT_A_MESSAGE);
248: HTAlert_add(HTConfirm, HT_A_CONFIRM);
249: HTAlert_add(HTPrompt, HT_A_PROMPT);
250: HTAlert_add(HTPromptPassword, HT_A_SECRET);
251: HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
252: }
253: HTAlert_setInteractive(YES);
254: }
255:
256: PUBLIC void HTProfile_newRobot (const char * AppName, const char * AppVersion)
257: {
2.4 eric 258: /* set up default event loop */
259: HTEventInit();
2.1 frystyk 260: robot_profile(AppName, AppVersion);
261:
262: /* Register the default set of application protocol modules */
263: HTProtocolInit();
264: }
265:
266: PUBLIC void HTProfile_newPreemptiveRobot (const char * AppName,
267: const char * AppVersion)
268: {
269: robot_profile(AppName, AppVersion);
270:
271: /* Register the default set of application protocol modules */
272: HTProtocolPreemptiveInit();
273:
274: /* Remember that we are loading preemptively */
275: preemptive = YES;
276: }
277:
278:
279:
280:
281:
282:
283:
Webmaster