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