Annotation of libwww/Library/src/HTProfil.c, revision 2.16
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.16 ! frystyk 6: ** @(#) $Id: HTProfil.c,v 2.15 1997/12/16 21:09:25 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:
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 */
65: if (!preemptive) 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.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