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