Annotation of libwww/Library/src/HTProfil.c, revision 2.13
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.13 ! frystyk 6: ** @(#) $Id: HTProfil.c,v 2.12 1997/01/23 19:49:59 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:
60: /* Enable the persistent cache */
2.12 frystyk 61: 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(HTLogFilter, NULL, NULL, HT_ALL, HT_FILTER_LATE);
144: HTNet_addAfter(HTInfoFilter, NULL, NULL, HT_ALL, HT_FILTER_LATE);
2.1 frystyk 145:
146: /* Get any proxy or gateway environment variables */
147: HTProxy_getEnvVar();
148:
149: /* Register the default set of converters including the HTML parser */
150: HTConverterInit(converters);
151: HTFormat_setConversion(converters);
152:
2.13 ! frystyk 153:
2.1 frystyk 154: /* Register the default set of transfer encoders and decoders */
2.13 ! frystyk 155: HTTransferEncoderInit(transfer_encodings);
! 156: HTFormat_setTransferCoding(transfer_encodings);
2.1 frystyk 157:
2.13 ! frystyk 158: /* Register the default set of content encoders and decoders */
! 159: HTContentEncoderInit(content_encodings);
! 160: if (HTList_count(content_encodings) > 0)
! 161: HTFormat_setContentCoding(content_encodings);
! 162: else {
! 163: HTList_delete(content_encodings);
! 164: content_encodings = NULL;
! 165: }
! 166:
2.1 frystyk 167: /* Register the default set of MIME header parsers */
168: HTMIMEInit();
169:
170: /* Register the default set of file suffix bindings */
171: HTFileInit();
172:
173: /* Register the default set of Icons for directory listings */
174: HTIconInit(NULL);
175:
176: /* Register some default messages and dialog functions */
177: if (HTAlert_interactive()) {
178: HTAlert_add(HTError_print, HT_A_MESSAGE);
179: HTAlert_add(HTConfirm, HT_A_CONFIRM);
180: HTAlert_add(HTPrompt, HT_A_PROMPT);
181: HTAlert_add(HTPromptPassword, HT_A_SECRET);
182: HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
183: }
184: HTAlert_setInteractive(YES);
185: }
186:
187: PUBLIC void HTProfile_newRobot (const char * AppName, const char * AppVersion)
188: {
2.4 eric 189: /* set up default event loop */
190: HTEventInit();
2.1 frystyk 191: robot_profile(AppName, AppVersion);
192:
193: /* Register the default set of application protocol modules */
194: HTProtocolInit();
195: }
196:
197: PUBLIC void HTProfile_newPreemptiveRobot (const char * AppName,
198: const char * AppVersion)
199: {
200: robot_profile(AppName, AppVersion);
201:
202: /* Register the default set of application protocol modules */
203: HTProtocolPreemptiveInit();
204:
205: /* Remember that we are loading preemptively */
206: preemptive = YES;
207: }
208:
209:
210:
211:
212:
213:
214:
Webmaster