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