Annotation of libwww/Library/src/HTProfil.c, revision 2.18
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.18 ! frystyk 6: ** @(#) $Id: HTProfil.c,v 2.17 1998/03/25 15:10:00 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.17 frystyk 42: BOOL preemptive, BOOL cache)
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.14 frystyk 64: /* The persistent cache does not work in preemptive mode */
2.17 frystyk 65: if (cache) HTCacheInit(NULL, 20);
2.1 frystyk 66:
67: /* Register the default set of BEFORE and AFTER filters */
68: HTNetInit();
2.6 frystyk 69:
2.1 frystyk 70: /* Set up the default set of Authentication schemes */
71: HTAAInit();
72:
73: /* Get any proxy or gateway environment variables */
74: HTProxy_getEnvVar();
75:
76: /* Register the default set of converters */
77: HTConverterInit(converters);
78: HTFormat_setConversion(converters);
79:
80: /* Register the default set of transfer encoders and decoders */
2.13 frystyk 81: HTTransferEncoderInit(transfer_encodings);
82: HTFormat_setTransferCoding(transfer_encodings);
2.1 frystyk 83:
2.13 frystyk 84: /* Register the default set of content encoders and decoders */
85: HTContentEncoderInit(content_encodings);
86: if (HTList_count(content_encodings) > 0)
87: HTFormat_setContentCoding(content_encodings);
88: else {
89: HTList_delete(content_encodings);
90: content_encodings = NULL;
91: }
92:
2.1 frystyk 93: /* Register the default set of MIME header parsers */
94: HTMIMEInit();
95:
96: /* Register the default set of file suffix bindings */
97: HTFileInit();
98:
99: /* Register the default set of Icons for directory listings */
100: HTIconInit(NULL);
101: }
102:
103: PUBLIC void HTProfile_newClient (const char * AppName, const char * AppVersion)
2.4 eric 104: {
2.5 frystyk 105: /* Do the default setup */
2.17 frystyk 106: client_profile(AppName, AppVersion, NO, YES);
2.5 frystyk 107:
108: /* Set up default event loop */
2.4 eric 109: HTEventInit();
2.1 frystyk 110: }
111:
112: PUBLIC void HTProfile_newPreemptiveClient (const char * AppName,
113: const char * AppVersion)
114: {
2.5 frystyk 115: /* Do the default setup */
2.17 frystyk 116: client_profile(AppName, AppVersion, YES, NO);
2.1 frystyk 117:
118: /* Remember that we are loading preemptively */
119: preemptive = YES;
2.17 frystyk 120: }
121:
122: PUBLIC void HTProfile_newNoCacheClient (const char * AppName,
123: const char * AppVersion)
124: {
125: /* Do the default setup */
126: client_profile(AppName, AppVersion, NO, NO);
127:
128: /* Set up default event loop */
129: HTEventInit();
2.1 frystyk 130: }
131:
132: PRIVATE void robot_profile (const char * AppName, const char * AppVersion)
133: {
134: /* If the Library is not already initialized then do it */
135: if (!HTLib_isInitialized()) HTLibInit(AppName, AppVersion);
136:
137: if (!converters) converters = HTList_new();
2.13 frystyk 138: if (!transfer_encodings) transfer_encodings = HTList_new();
139: if (!content_encodings) content_encodings = HTList_new();
2.1 frystyk 140:
141: /* Register the default set of transport protocols */
142: HTTransportInit();
143:
144: /* Register the default set of application protocol modules */
145: HTProtocolInit();
146:
147: /* Set max number of sockets we want open simultanously */
148: HTNet_setMaxSocket(6);
149:
150: /* Register some default set of BEFORE and AFTER filters */
2.10 frystyk 151: HTNet_addBefore(HTRuleFilter, NULL, NULL, HT_FILTER_MIDDLE);
152: HTNet_addBefore(HTProxyFilter, NULL, NULL, HT_FILTER_MIDDLE);
153: HTNet_addAfter(HTInfoFilter, NULL, NULL, HT_ALL, HT_FILTER_LATE);
2.1 frystyk 154:
155: /* Get any proxy or gateway environment variables */
156: HTProxy_getEnvVar();
157:
158: /* Register the default set of converters including the HTML parser */
159: HTConverterInit(converters);
160: HTFormat_setConversion(converters);
161:
2.13 frystyk 162:
2.1 frystyk 163: /* Register the default set of transfer encoders and decoders */
2.13 frystyk 164: HTTransferEncoderInit(transfer_encodings);
165: HTFormat_setTransferCoding(transfer_encodings);
2.1 frystyk 166:
2.13 frystyk 167: /* Register the default set of content encoders and decoders */
168: HTContentEncoderInit(content_encodings);
169: if (HTList_count(content_encodings) > 0)
170: HTFormat_setContentCoding(content_encodings);
171: else {
172: HTList_delete(content_encodings);
173: content_encodings = NULL;
174: }
175:
2.1 frystyk 176: /* Register the default set of MIME header parsers */
177: HTMIMEInit();
178:
179: /* Register the default set of file suffix bindings */
180: HTFileInit();
181:
182: /* Register the default set of Icons for directory listings */
183: HTIconInit(NULL);
184:
185: /* Register some default messages and dialog functions */
186: if (HTAlert_interactive()) {
187: HTAlert_add(HTError_print, HT_A_MESSAGE);
188: HTAlert_add(HTConfirm, HT_A_CONFIRM);
189: HTAlert_add(HTPrompt, HT_A_PROMPT);
190: HTAlert_add(HTPromptPassword, HT_A_SECRET);
191: HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
192: }
193: HTAlert_setInteractive(YES);
194: }
195:
196: PUBLIC void HTProfile_newRobot (const char * AppName, const char * AppVersion)
197: {
2.4 eric 198: /* set up default event loop */
199: HTEventInit();
2.1 frystyk 200: robot_profile(AppName, AppVersion);
201:
202: /* Register the default set of application protocol modules */
203: HTProtocolInit();
204: }
205:
206: PUBLIC void HTProfile_newPreemptiveRobot (const char * AppName,
207: const char * AppVersion)
208: {
209: robot_profile(AppName, AppVersion);
210:
211: /* Register the default set of application protocol modules */
212: HTProtocolPreemptiveInit();
213:
214: /* Remember that we are loading preemptively */
215: preemptive = YES;
216: }
217:
218:
219:
220:
221:
222:
223:
Webmaster