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

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

Webmaster