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

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

Webmaster