Annotation of libwww/Library/src/HTProfil.c, revision 2.8

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

Webmaster