Annotation of libwww/Library/src/HTProfil.c, revision 2.6
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.6 ! frystyk 6: ** @(#) $Id: HTProfil.c,v 2.5 1996/08/08 16:41:02 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;
19: PRIVATE HTList * encodings = NULL;
20: PRIVATE BOOL preemptive = NO;
21:
22: /* ------------------------------------------------------------------------- */
23:
24: PUBLIC void HTProfile_delete (void)
25: {
2.4 eric 26: if (!preemptive) HTEventTerminate();
2.1 frystyk 27: if (HTLib_isInitialized()) {
2.6 ! frystyk 28:
! 29: /* Clean up the persistent cache (if any) */
! 30: HTCache_deleteAll();
! 31:
! 32: /* Clean up all the global preferences */
2.1 frystyk 33: HTFormat_deleteAll();
2.6 ! frystyk 34:
! 35: /* Terminate libwww */
2.1 frystyk 36: HTLibTerminate();
37: }
38: }
39:
40: PRIVATE void client_profile (const char * AppName, const char * AppVersion)
41: {
42: /* If the Library is not already initialized then do it */
43: if (!HTLib_isInitialized()) HTLibInit(AppName, AppVersion);
44:
45: if (!converters) converters = HTList_new();
46: if (!encodings) encodings = HTList_new();
47:
48: /* Register the default set of transport protocols */
49: HTTransportInit();
50:
51: /* Register the default set of transport protocols */
52: HTTransportInit();
53:
54: /* Register the default set of BEFORE and AFTER filters */
55: HTNetInit();
2.6 ! frystyk 56:
! 57: /* Enable the persistent cache */
! 58: HTCache_enable(NULL);
2.1 frystyk 59:
60: /* Set up the default set of Authentication schemes */
61: HTAAInit();
62:
63: /* Get any proxy or gateway environment variables */
64: HTProxy_getEnvVar();
65:
66: /* Register the default set of converters */
67: HTConverterInit(converters);
68: HTFormat_setConversion(converters);
69:
70: /* Register the default set of transfer encoders and decoders */
71: HTEncoderInit(encodings);
72: HTFormat_setTransferCoding(encodings);
73:
74: /* Register the default set of MIME header parsers */
75: HTMIMEInit();
76:
77: /* Register the default set of file suffix bindings */
78: HTFileInit();
79:
80: /* Register the default set of Icons for directory listings */
81: HTIconInit(NULL);
82:
83: /* Register the default set of messages and dialog functions */
84: HTAlertInit();
85: HTAlert_setInteractive(YES);
86: }
87:
88: PUBLIC void HTProfile_newClient (const char * AppName, const char * AppVersion)
2.4 eric 89: {
2.5 frystyk 90: /* Do the default setup */
91: client_profile(AppName, AppVersion);
92:
93: /* Set up default event loop */
2.4 eric 94: HTEventInit();
2.1 frystyk 95:
96: /* Register the default set of application protocol modules */
97: HTProtocolInit();
98: }
99:
100: PUBLIC void HTProfile_newPreemptiveClient (const char * AppName,
101: const char * AppVersion)
102: {
2.5 frystyk 103: /* Do the default setup */
2.1 frystyk 104: client_profile(AppName, AppVersion);
105:
106: /* Register the default set of application protocol modules */
107: HTProtocolPreemptiveInit();
108:
109: /* Remember that we are loading preemptively */
110: preemptive = YES;
111: }
112:
113: PRIVATE void robot_profile (const char * AppName, const char * AppVersion)
114: {
115: /* If the Library is not already initialized then do it */
116: if (!HTLib_isInitialized()) HTLibInit(AppName, AppVersion);
117:
118: if (!converters) converters = HTList_new();
119: if (!encodings) encodings = HTList_new();
120:
121: /* Register the default set of transport protocols */
122: HTTransportInit();
123:
124: /* Register the default set of application protocol modules */
125: HTProtocolInit();
126:
127: /* Set max number of sockets we want open simultanously */
128: HTNet_setMaxSocket(6);
129:
130: /* Register some default set of BEFORE and AFTER filters */
131: HTNetCall_addBefore(HTRuleFilter, NULL, 0);
132: HTNetCall_addBefore(HTProxyFilter, NULL, 0);
133: HTNetCall_addAfter(HTLogFilter, NULL, HT_ALL);
134: HTNetCall_addAfter(HTInfoFilter, NULL, HT_ALL);
135:
136: /* Get any proxy or gateway environment variables */
137: HTProxy_getEnvVar();
138:
139: /* Register the default set of converters including the HTML parser */
140: HTConverterInit(converters);
141: HTFormat_setConversion(converters);
142:
143: /* Register the default set of transfer encoders and decoders */
144: HTEncoderInit(encodings);
145: HTFormat_setTransferCoding(encodings);
146:
147: /* Register the default set of MIME header parsers */
148: HTMIMEInit();
149:
150: /* Register the default set of file suffix bindings */
151: HTFileInit();
152:
153: /* Register the default set of Icons for directory listings */
154: HTIconInit(NULL);
155:
156: /* Register some default messages and dialog functions */
157: if (HTAlert_interactive()) {
158: HTAlert_add(HTError_print, HT_A_MESSAGE);
159: HTAlert_add(HTConfirm, HT_A_CONFIRM);
160: HTAlert_add(HTPrompt, HT_A_PROMPT);
161: HTAlert_add(HTPromptPassword, HT_A_SECRET);
162: HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
163: }
164: HTAlert_setInteractive(YES);
165: }
166:
167: PUBLIC void HTProfile_newRobot (const char * AppName, const char * AppVersion)
168: {
2.4 eric 169: /* set up default event loop */
170: HTEventInit();
2.1 frystyk 171: robot_profile(AppName, AppVersion);
172:
173: /* Register the default set of application protocol modules */
174: HTProtocolInit();
175: }
176:
177: PUBLIC void HTProfile_newPreemptiveRobot (const char * AppName,
178: const char * AppVersion)
179: {
180: robot_profile(AppName, AppVersion);
181:
182: /* Register the default set of application protocol modules */
183: HTProtocolPreemptiveInit();
184:
185: /* Remember that we are loading preemptively */
186: preemptive = YES;
187: }
188:
189:
190:
191:
192:
193:
194:
Webmaster