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

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.29    ! frystyk     6: **     @(#) $Id: HTProfil.c,v 2.28 1999/04/04 00:14:38 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.25      frystyk    16: #include "WWWStream.h"
2.27      frystyk    17: #include "HTInit.h"
2.1       frystyk    18: #include "HTProfil.h"                                   /* Implemented here */
                     19: 
                     20: PRIVATE HTList * converters = NULL;
2.13      frystyk    21: PRIVATE HTList * transfer_encodings = NULL;
                     22: PRIVATE HTList * content_encodings = NULL;
2.1       frystyk    23: PRIVATE BOOL preemptive = NO;
                     24: 
                     25: /* ------------------------------------------------------------------------- */
                     26: 
                     27: PUBLIC void HTProfile_delete (void)
                     28: {
2.4       eric       29:     if (!preemptive) HTEventTerminate();
2.1       frystyk    30:     if (HTLib_isInitialized()) {
2.6       frystyk    31: 
                     32:        /* Clean up the persistent cache (if any) */
2.7       frystyk    33:        HTCacheTerminate();
2.6       frystyk    34: 
                     35:        /* Clean up all the global preferences */
2.1       frystyk    36:        HTFormat_deleteAll();
2.24      frystyk    37: 
2.25      frystyk    38:        /* The following lists have been cleaned up by HTFormat_deleteAll */
                     39:        transfer_encodings = 0;
                     40:        content_encodings = 0;
                     41:        converters = 0;
                     42: 
                     43:        /* Remove bindings between suffixes, media types */
                     44:        HTBind_deleteAll();
2.6       frystyk    45: 
                     46:        /* Terminate libwww */
2.1       frystyk    47:        HTLibTerminate();
                     48:     }
                     49: }
                     50: 
2.7       frystyk    51: PRIVATE void client_profile (const char * AppName, const char * AppVersion,
2.21      frystyk    52:                             BOOL preemptive, BOOL cache, BOOL HTMLParser)
2.1       frystyk    53: {
                     54:     /* If the Library is not already initialized then do it */
                     55:     if (!HTLib_isInitialized()) HTLibInit(AppName, AppVersion);
                     56: 
2.16      frystyk    57:     /* Register the default set of messages and dialog functions */
                     58:     HTAlertInit();
                     59:     HTAlert_setInteractive(YES);
                     60: 
2.1       frystyk    61:     if (!converters) converters = HTList_new();
2.13      frystyk    62:     if (!transfer_encodings) transfer_encodings = HTList_new();
                     63:     if (!content_encodings) content_encodings = HTList_new();
2.1       frystyk    64: 
                     65:     /* Register the default set of transport protocols */
                     66:     HTTransportInit();
                     67: 
2.7       frystyk    68:     /* Register the default set of application protocol modules */
                     69:     if (preemptive)
                     70:        HTProtocolPreemptiveInit();
                     71:     else
                     72:        HTProtocolInit();
                     73: 
2.25      frystyk    74:     /* Initialize suffix bindings for local files */
                     75:     HTBind_init();
                     76: 
2.19      frystyk    77:     /* Set max number of sockets we want open simultanously */ 
2.23      frystyk    78:     HTNet_setMaxSocket(32);
2.19      frystyk    79: 
2.14      frystyk    80:     /* The persistent cache does not work in preemptive mode */
2.17      frystyk    81:     if (cache) HTCacheInit(NULL, 20);
2.1       frystyk    82: 
                     83:     /* Register the default set of BEFORE and AFTER filters */
                     84:     HTNetInit();
2.6       frystyk    85: 
2.1       frystyk    86:     /* Set up the default set of Authentication schemes */
                     87:     HTAAInit();
                     88: 
                     89:     /* Get any proxy or gateway environment variables */
                     90:     HTProxy_getEnvVar();
                     91: 
                     92:     /* Register the default set of converters */
                     93:     HTConverterInit(converters);
2.21      frystyk    94: 
                     95:     /* Register the default libwww HTML parser */
                     96:     if (HTMLParser) HTMLInit(converters);
                     97: 
                     98:     /* Set the convertes as global converters for all requests */
2.1       frystyk    99:     HTFormat_setConversion(converters);
                    100: 
                    101:     /* Register the default set of transfer encoders and decoders */
2.13      frystyk   102:     HTTransferEncoderInit(transfer_encodings);
                    103:     HTFormat_setTransferCoding(transfer_encodings);
2.1       frystyk   104: 
2.13      frystyk   105:     /* Register the default set of content encoders and decoders */
                    106:     HTContentEncoderInit(content_encodings);
                    107:     if (HTList_count(content_encodings) > 0)
                    108:        HTFormat_setContentCoding(content_encodings);
                    109:     else {
                    110:        HTList_delete(content_encodings);
                    111:        content_encodings = NULL;
                    112:     }
                    113: 
2.1       frystyk   114:     /* Register the default set of MIME header parsers */
                    115:     HTMIMEInit();
                    116: 
                    117:     /* Register the default set of file suffix bindings */
                    118:     HTFileInit();
                    119: 
                    120:     /* Register the default set of Icons for directory listings */
                    121:     HTIconInit(NULL);
                    122: }
                    123: 
                    124: PUBLIC void HTProfile_newClient (const char * AppName, const char * AppVersion)
2.4       eric      125: {
2.5       frystyk   126:     /* Do the default setup */
2.21      frystyk   127:     client_profile(AppName, AppVersion, NO, YES, NO);
                    128: 
                    129:     /* Set up default event loop */
                    130:     HTEventInit();
                    131: }
                    132: 
                    133: PUBLIC void HTProfile_newHTMLClient (const char * AppName, const char * AppVersion)
                    134: {
                    135:     /* Do the default setup */
                    136:     client_profile(AppName, AppVersion, NO, YES, YES);
2.5       frystyk   137: 
                    138:     /* Set up default event loop */
2.4       eric      139:     HTEventInit();
2.1       frystyk   140: }
                    141: 
                    142: PUBLIC void HTProfile_newPreemptiveClient (const char * AppName,
                    143:                                           const char * AppVersion)
                    144: {
2.5       frystyk   145:     /* Do the default setup */
2.21      frystyk   146:     client_profile(AppName, AppVersion, YES, NO, NO);
2.1       frystyk   147: 
2.26      frystyk   148:     /* On windows we need the initialization anyway */
                    149: #ifdef WWW_WIN_ASYNC
                    150:     HTEventInit();
                    151: #else
2.1       frystyk   152:     /* Remember that we are loading preemptively */
                    153:     preemptive = YES;
2.26      frystyk   154: #endif
                    155: 
2.17      frystyk   156: }
                    157: 
                    158: PUBLIC void HTProfile_newNoCacheClient (const char * AppName,
                    159:                                        const char * AppVersion)
                    160: {
                    161:     /* Do the default setup */
2.21      frystyk   162:     client_profile(AppName, AppVersion, NO, NO, NO);
                    163: 
                    164:     /* Set up default event loop */
                    165:     HTEventInit();
                    166: }
                    167: 
                    168: PUBLIC void HTProfile_newHTMLNoCacheClient (const char * AppName,
                    169:                                            const char * AppVersion)
                    170: {
                    171:     /* Do the default setup */
                    172:     client_profile(AppName, AppVersion, NO, NO, YES);
2.17      frystyk   173: 
                    174:     /* Set up default event loop */
                    175:     HTEventInit();
2.1       frystyk   176: }
                    177: 
                    178: PRIVATE void robot_profile (const char * AppName, const char * AppVersion)
                    179: {
                    180:     /* If the Library is not already initialized then do it */
                    181:     if (!HTLib_isInitialized()) HTLibInit(AppName, AppVersion);
                    182: 
                    183:     if (!converters) converters = HTList_new();
2.13      frystyk   184:     if (!transfer_encodings) transfer_encodings = HTList_new();
                    185:     if (!content_encodings) content_encodings = HTList_new();
2.1       frystyk   186: 
                    187:     /* Register the default set of transport protocols */
                    188:     HTTransportInit();
                    189: 
                    190:     /* Register the default set of application protocol modules */
                    191:     HTProtocolInit();
2.25      frystyk   192: 
                    193:     /* Initialize suffix bindings for local files */
                    194:     HTBind_init();
2.1       frystyk   195: 
                    196:     /* Set max number of sockets we want open simultanously */ 
2.23      frystyk   197:     HTNet_setMaxSocket(32);
2.1       frystyk   198: 
                    199:     /* Register some default set of BEFORE and AFTER filters */
2.10      frystyk   200:     HTNet_addBefore(HTRuleFilter, NULL, NULL, HT_FILTER_MIDDLE); 
                    201:     HTNet_addBefore(HTProxyFilter, NULL, NULL, HT_FILTER_MIDDLE); 
                    202:     HTNet_addAfter(HTInfoFilter, NULL, NULL, HT_ALL, HT_FILTER_LATE); 
2.1       frystyk   203: 
                    204:     /* Get any proxy or gateway environment variables */
                    205:     HTProxy_getEnvVar();
                    206: 
                    207:     /* Register the default set of converters including the HTML parser */
                    208:     HTConverterInit(converters);
2.21      frystyk   209:     HTMLInit(converters);
                    210: 
                    211:     /* Set the convertes as global converters for all requests */
2.1       frystyk   212:     HTFormat_setConversion(converters);
2.13      frystyk   213: 
2.1       frystyk   214:     /* Register the default set of transfer encoders and decoders */
2.13      frystyk   215:     HTTransferEncoderInit(transfer_encodings);
                    216:     HTFormat_setTransferCoding(transfer_encodings);
2.1       frystyk   217: 
2.13      frystyk   218:     /* Register the default set of content encoders and decoders */
                    219:     HTContentEncoderInit(content_encodings);
                    220:     if (HTList_count(content_encodings) > 0)
                    221:        HTFormat_setContentCoding(content_encodings);
                    222:     else {
                    223:        HTList_delete(content_encodings);
                    224:        content_encodings = NULL;
                    225:     }
                    226: 
2.1       frystyk   227:     /* Register the default set of MIME header parsers */
                    228:     HTMIMEInit();
                    229: 
                    230:     /* Register the default set of file suffix bindings */
                    231:     HTFileInit();
                    232: 
                    233:     /* Register the default set of Icons for directory listings */
                    234:     HTIconInit(NULL);
                    235: 
                    236:     /* Register some default messages and dialog functions */
                    237:     if (HTAlert_interactive()) {
                    238:        HTAlert_add(HTError_print, HT_A_MESSAGE);
                    239:        HTAlert_add(HTConfirm, HT_A_CONFIRM);
                    240:        HTAlert_add(HTPrompt, HT_A_PROMPT);
                    241:        HTAlert_add(HTPromptPassword, HT_A_SECRET);
                    242:        HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
                    243:     }
                    244:     HTAlert_setInteractive(YES);
                    245: }
                    246: 
                    247: PUBLIC void HTProfile_newRobot (const char * AppName, const char * AppVersion)
                    248: {    
2.4       eric      249:   /* set up default event loop */
                    250:     HTEventInit();
2.1       frystyk   251:     robot_profile(AppName, AppVersion);
                    252: 
                    253:     /* Register the default set of application protocol modules */
                    254:     HTProtocolInit();
                    255: }
                    256: 
                    257: PUBLIC void HTProfile_newPreemptiveRobot (const char * AppName,
                    258:                                          const char * AppVersion)
                    259: {
                    260:     robot_profile(AppName, AppVersion);
                    261: 
                    262:     /* Register the default set of application protocol modules */
                    263:     HTProtocolPreemptiveInit();
                    264: 
                    265:     /* Remember that we are loading preemptively */
                    266:     preemptive = YES;
                    267: }
                    268: 
                    269: 
                    270: 
                    271: 
                    272: 
                    273: 
                    274: 

Webmaster