Annotation of parser3/src/main/pa_globals.C, revision 1.153

1.15      paf         1: /** @file
1.16      paf         2:        Parser: globals.
                      3: 
1.152     paf         4:        Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com)
1.113     paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.133     paf         6: */
1.16      paf         7: 
1.153   ! paf         8: static const char* IDENT_GLOBALS_C="$Date: 2003/01/21 15:51:14 $";
1.1       paf         9: 
1.102     paf        10: #include "pa_config_includes.h"
                     11: 
                     12: #ifdef XML
                     13: #include "libxslt/extensions.h"
                     14: #include "libxslt/xsltutils.h"
1.116     paf        15: extern "C" {
1.102     paf        16: #include "libexslt/exslt.h"
1.116     paf        17: };
1.102     paf        18: #endif
                     19: 
1.1       paf        20: #include "pa_globals.h"
1.32      paf        21: #include "pa_string.h"
                     22: #include "pa_hash.h"
1.42      paf        23: #include "pa_sql_driver_manager.h"
1.77      parser     24: #include "pa_dictionary.h"
1.100     paf        25: #include "pa_stylesheet_manager.h"
1.83      parser     26: #include "pa_sapi.h"
1.90      paf        27: #include "pa_cache_managers.h"
1.95      paf        28: #include "pa_charsets.h"
                     29: #include "pa_charset.h"
1.101     paf        30: #include "pa_threads.h"
1.84      parser     31: 
1.8       paf        32: String *content_type_name;
1.75      parser     33: String *charset_name;
1.8       paf        34: String *body_name;
1.146     paf        35: String *download_name;
1.13      paf        36: String *value_name;
1.14      paf        37: String *expires_name;
                     38: String *path_name;
1.17      paf        39: String *name_name;
                     40: String *size_name;
                     41: String *text_name;
1.8       paf        42: 
1.39      paf        43: String *content_disposition_name;
1.145     paf        44: String *content_disposition_value;
1.39      paf        45: String *content_disposition_filename_name;
                     46: 
1.130     paf        47: String *conf_method_name;
1.1       paf        48: String *auto_method_name;
                     49: 
                     50: String *main_class_name;
                     51: 
1.6       paf        52: String *result_var_name;
1.64      parser     53: String *match_var_name;
1.6       paf        54: 
1.119     paf        55: String *exception_var_name;
                     56: String *exception_type_part_name;
                     57: String *exception_source_part_name;
                     58: String *exception_comment_part_name;
                     59: String *exception_handled_part_name;
                     60: 
1.79      parser     61: String *charsets_name;
1.36      paf        62: String *mime_types_name;
                     63: String *vfile_mime_type_name;
1.63      parser     64: String *origins_mode_name;
1.67      parser     65: 
1.69      parser     66: String *class_path_name;
                     67: 
1.67      parser     68: String *switch_data_name;
                     69: 
1.120     paf        70: String *cache_data_name;
                     71: 
1.70      parser     72: String *sql_limit_name;
                     73: String *sql_offset_name;
                     74: String *sql_default_name;
1.139     paf        75: String *sql_distinct_name;
1.70      parser     76: 
1.95      paf        77: String *charset_UTF8_name;
                     78: 
1.71      parser     79: String *hash_default_element_name;
1.42      paf        80: 
1.141     paf        81: String *http_method_name;
                     82: String *http_timeout_name;
                     83: String *http_headers_name;
1.151     paf        84: String *http_any_status_name;
1.141     paf        85: String *file_status_name;
                     86: 
1.140     paf        87: 
1.124     paf        88: Table *string_match_table_template;
1.123     paf        89: 
1.135     paf        90: Table *date_calendar_table_template;
                     91: 
1.1       paf        92: Hash *untaint_lang_name2enum;
1.140     paf        93: Hash *exif_tag_value2name;
1.1       paf        94: 
1.95      paf        95: Charset *utf8_charset;
1.32      paf        96: 
1.5       paf        97: short hex_value[0x100];
1.111     paf        98: 
                     99: #ifdef XML
                    100: GdomeDOMImplementation *domimpl;
                    101: #endif
1.5       paf       102: 
                    103: static void setup_hex_value() {
1.68      parser    104:        memset(hex_value, 0, sizeof(hex_value));
1.5       paf       105:        hex_value['0'] = 0;     
                    106:        hex_value['1'] = 1;     
                    107:        hex_value['2'] = 2;     
                    108:        hex_value['3'] = 3;     
                    109:        hex_value['4'] = 4;     
                    110:        hex_value['5'] = 5;     
                    111:        hex_value['6'] = 6;     
                    112:        hex_value['7'] = 7;     
                    113:        hex_value['8'] = 8;     
                    114:        hex_value['9'] = 9;
                    115:        hex_value['A'] = 10;
                    116:        hex_value['B'] = 11;
                    117:        hex_value['C'] = 12;
                    118:        hex_value['D'] = 13;
                    119:        hex_value['E'] = 14;
                    120:        hex_value['F'] = 15;
                    121:        hex_value['a'] = 10;
                    122:        hex_value['b'] = 11;
                    123:        hex_value['c'] = 12;
                    124:        hex_value['d'] = 13;
                    125:        hex_value['e'] = 14;
                    126:        hex_value['f'] = 15;
                    127: }
1.1       paf       128: 
1.99      paf       129: #ifdef XML
1.101     paf       130: 
                    131: const int MAX_CONCURRENT_XML_GENERIC_ERROR_THREADS=10;
                    132: 
                    133: struct XML_Generic_error_info {
                    134:        pa_thread_t thread_id;
                    135:        char *message;
                    136: } xml_generic_error_infos[MAX_CONCURRENT_XML_GENERIC_ERROR_THREADS];
                    137: 
                    138: XML_Generic_error_info *xml_generic_error_info(pa_thread_t thread_id) {
                    139:        for(int i=0; i<MAX_CONCURRENT_XML_GENERIC_ERROR_THREADS; i++) {
                    140:                XML_Generic_error_info *p=xml_generic_error_infos+i;
                    141:                if(p->thread_id==thread_id)
                    142:                        return p;
                    143:        }
                    144:        return 0;
                    145: }
                    146: 
1.99      paf       147: static void
1.101     paf       148: xmlParserGenericErrorFunc(void *ctx, const char *msg, ...) { 
                    149:     pa_thread_t thread_id=pa_get_thread_id();
                    150: 
                    151:        // infinitely looking for free slot to fill it
                    152:        while(true) {
                    153:                SYNCHRONIZED;  // find+fill blocked
                    154: 
                    155:                // first try to get existing for this thread_id
                    156:                XML_Generic_error_info *p=xml_generic_error_info(thread_id);
                    157:                if(!p) { // occupy empty one
                    158:                        p=xml_generic_error_info(0);
                    159:                        if(!p) // wait for empty for it to appear
                    160:                                continue;
                    161:                }
                    162: 
1.102     paf       163:                p->thread_id=thread_id;
1.101     paf       164:                size_t offset=p->message?strlen(p->message):0;
                    165:                p->message=(char *)realloc(p->message, offset+MAX_STRING);
                    166:                if(!p->message)
                    167:                        SAPI::die(
                    168:                                "out of memory in 'xmlParserGenericErrorFunc', failed to reallocate to %u bytes", 
                    169:                                offset+MAX_STRING);
                    170:                
                    171:                va_list args;
                    172:                va_start(args, msg);
                    173:                vsnprintf(p->message+offset, MAX_STRING, msg, args);
                    174:                va_end(args);
                    175: 
                    176:                break;
                    177:        }
                    178: }
                    179: 
1.102     paf       180: bool xmlHaveGenericErrors() {
                    181:     pa_thread_t thread_id=pa_get_thread_id();
                    182: 
                    183:        SYNCHRONIZED;  // find blocked
                    184: 
                    185:        return xml_generic_error_info(thread_id)!=0;
                    186: }
                    187: 
1.101     paf       188: const char *xmlGenericErrors() {
                    189:     pa_thread_t thread_id=pa_get_thread_id();
                    190: 
                    191:        SYNCHRONIZED;  // find+free blocked
                    192: 
                    193:        XML_Generic_error_info *p=xml_generic_error_info(thread_id);
                    194:        if(!p) // no errors for our thread_id registered
                    195:                return 0;
                    196: 
                    197:        const char *result=p->message;
                    198: 
                    199:        // free slot up 
                    200:        memset(p, 0, sizeof(*p));
                    201: 
                    202:        // it is up to caller to free it
                    203:        return result;
1.99      paf       204: }
1.110     paf       205: 
                    206: /**
                    207:  * xmlFileMatchWithLocalhostEqDocumentRoot:
                    208:  * filename:  the URI for matching
                    209:  *
                    210:  * check if the URI matches an HTTP one
                    211:  *
                    212:  * Returns 1 if matches, 0 otherwise
                    213:  */
                    214: static int
                    215: xmlFileMatchLocalhost(const char *filename) {
                    216:     if (!strncmp(filename, "http://localhost", 16))
                    217:        return(1);
                    218:     return(0);
                    219: }
                    220: 
                    221: 
                    222: /**
                    223:  * xmlFileOpenHttpLocalhost :
                    224:  * filename:  the URI for matching
                    225:  *
                    226:  * http://localhost/abc -> $ENV{DOCUMENT_ROOT}/abc | ./abc
                    227:  *
                    228:  * input from FILE *, supports compressed input
                    229:  * if filename is " " then the standard input is used
                    230:  *
                    231:  * Returns an I/O context or NULL in case of error
                    232:  */
                    233: static void *
                    234: xmlFileOpenLocalhost (const char *filename) {
                    235:     FILE *fd;
                    236:     const char* documentRoot;
                    237:     char path[1000];
                    238: 
                    239:        path[0]=0;
                    240:        strcat(path, (documentRoot=getenv("DOCUMENT_ROOT"))?documentRoot:".");
                    241:        strcat(path, &filename[16]);
                    242: 
                    243: #ifdef WIN32
                    244:     fd = fopen(path, "rb");
                    245: #else
                    246:     fd = fopen(path, "r");
                    247: #endif /* WIN32 */
                    248:     return((void *) fd);
                    249: }
                    250: 
1.150     paf       251: /**
                    252:  * xmlFileRead:
                    253:  * @context:  the I/O context
                    254:  * @buffer:  where to drop data
                    255:  * @len:  number of bytes to write
                    256:  *
                    257:  * Read @len bytes to @buffer from the I/O channel.
                    258:  *
                    259:  * Returns the number of bytes written
                    260:  */
                    261: static int
                    262: pa_xmlFileRead (void * context, char * buffer, int len) {
                    263:     return(fread(&buffer[0], 1,  len, (FILE *) context));
                    264: }
                    265: 
                    266: /**
                    267:  * xmlFileClose:
                    268:  * @context:  the I/O context
                    269:  *
                    270:  * Close an I/O channel
                    271:  */
                    272: static int
                    273: pa_xmlFileClose (void * context) {
                    274:     return ( ( fclose((FILE *) context) == EOF ) ? -1 : 0 );
                    275: }
                    276: 
1.99      paf       277: #endif
                    278: 
1.83      parser    279: void pa_globals_destroy(void *) {
                    280:        try {
1.96      paf       281: #ifdef XML
                    282:                GdomeException exc;
                    283:                gdome_di_unref (domimpl, &exc);
                    284: #endif
1.93      paf       285:                if(cache_managers)
                    286:                        cache_managers->~Cache_managers();
1.95      paf       287: 
                    288:                charsets->~Charsets();
1.83      parser    289:                
                    290:        } catch(const Exception& e) {
                    291:                SAPI::die("pa_globals_destroy failed: %s", e.comment());
                    292:        }
                    293: }
                    294: 
1.108     paf       295: /// @test hint on one should call this for each thread xmlSubstituteEntitiesDefault(1);
1.27      paf       296: void pa_globals_init(Pool& pool) {
1.83      parser    297:        pool.register_cleanup(pa_globals_destroy, 0);
                    298: 
1.32      paf       299:        #undef NEW
                    300:        #define NEW new(pool)
                    301: 
1.5       paf       302:        // hex value
                    303:        setup_hex_value();
                    304: 
1.1       paf       305:        // names
1.32      paf       306:        content_type_name=NEW String(pool, CONTENT_TYPE_NAME);
1.75      parser    307:        charset_name=NEW String(pool, CHARSET_NAME);
1.32      paf       308:        body_name=NEW String(pool, BODY_NAME);
1.146     paf       309:        download_name=NEW String(pool, DOWNLOAD_NAME);
1.32      paf       310:        value_name=NEW String(pool, VALUE_NAME);
                    311:        expires_name=NEW String(pool, EXPIRES_NAME);
                    312:        path_name=NEW String(pool, PATH_NAME);
                    313:        name_name=NEW String(pool, NAME_NAME);
                    314:        size_name=NEW String(pool, SIZE_NAME);
                    315:        text_name=NEW String(pool, TEXT_NAME);
                    316: 
1.39      paf       317:        content_disposition_name=NEW String(pool, CONTENT_DISPOSITION_NAME);
1.145     paf       318:        content_disposition_value=NEW String(pool, CONTENT_DISPOSITION_VALUE);
1.39      paf       319:        content_disposition_filename_name=NEW String(pool, CONTENT_DISPOSITION_FILENAME_NAME);
1.32      paf       320: 
1.130     paf       321:        conf_method_name=NEW String(pool, CONF_METHOD_NAME);
1.32      paf       322:        auto_method_name=NEW String(pool, AUTO_METHOD_NAME);
                    323: 
                    324:        main_class_name=NEW String(pool, MAIN_CLASS_NAME);
1.6       paf       325: 
1.32      paf       326:        result_var_name=NEW String(pool, RESULT_VAR_NAME);
1.64      parser    327:        match_var_name=NEW String(pool, MATCH_VAR_NAME);
1.6       paf       328: 
1.119     paf       329:        exception_var_name=NEW String(pool, EXCEPTION_VAR_NAME);
                    330:        exception_type_part_name=NEW String(pool, EXCEPTION_TYPE_PART_NAME);
                    331:        exception_source_part_name=NEW String(pool, EXCEPTION_SOURCE_PART_NAME);
                    332:        exception_comment_part_name=NEW String(pool, EXCEPTION_COMMENT_PART_NAME);
                    333:        exception_handled_part_name=NEW String(pool, EXCEPTION_HANDLED_PART_NAME);
1.4       paf       334: 
1.79      parser    335:        charsets_name=NEW String(pool, CHARSETS_NAME);
1.36      paf       336:        mime_types_name=NEW String(pool, MIME_TYPES_NAME);
1.63      parser    337:        origins_mode_name=NEW String(pool, ORIGINS_MODE_NAME);
1.69      parser    338: 
                    339:        class_path_name=NEW String(pool, CLASS_PATH_NAME);
1.66      parser    340: 
                    341:        //^switch ^case
                    342:        switch_data_name=NEW String(pool, SWITCH_DATA_NAME);
1.120     paf       343: 
                    344:        //^cache
                    345:        cache_data_name=NEW String(pool, CACHE_DATA_NAME);
1.70      parser    346: 
                    347:        // sql
                    348:        sql_limit_name=NEW String(pool, SQL_LIMIT_NAME);
                    349:        sql_offset_name=NEW String(pool, SQL_OFFSET_NAME);
                    350:        sql_default_name=NEW String(pool, SQL_DEFAULT_NAME);
1.139     paf       351:        sql_distinct_name=NEW String(pool, SQL_DISTINCT_NAME);
1.71      parser    352: 
1.95      paf       353:        // charsets
                    354:        charset_UTF8_name=NEW String(pool, CHARSET_UTF8_NAME);
                    355: 
1.71      parser    356:        // hash
                    357:        hash_default_element_name=NEW String(pool, HASH_DEFAULT_ELEMENT_NAME);
1.70      parser    358: 
1.141     paf       359:        // http
                    360:        http_method_name=NEW String(pool, HTTP_METHOD_NAME);
                    361:        http_timeout_name=NEW String(pool, HTTP_TIMEOUT_NAME);
                    362:        http_headers_name=NEW String(pool, HTTP_HEADERS_NAME);
1.151     paf       363:        http_any_status_name=NEW String(pool, HTTP_ANY_STATUS_NAME);
1.141     paf       364:        file_status_name=NEW String(pool, FILE_STATUS_NAME);
                    365: 
                    366:        
1.1       paf       367:        // hashes
1.32      paf       368:        untaint_lang_name2enum=NEW Hash(pool);
1.87      paf       369:        #define ULN(cstr, LANG) \
1.144     paf       370:                untaint_lang_name2enum->put(*NEW String(pool, cstr), (int)String::UL_##LANG);
1.87      paf       371:        ULN("as-is", AS_IS);
1.147     paf       372:        ULN("optimized-as-is", AS_IS|String::UL_OPTIMIZE_BIT);
1.87      paf       373:        ULN("file-spec", FILE_SPEC);
                    374:        ULN("http-header", HTTP_HEADER);
                    375:        ULN("mail-header", MAIL_HEADER);
                    376:        ULN("uri", URI);
                    377:        ULN("table", TABLE);
                    378:        ULN("sql", SQL);
                    379:        ULN("js", JS);
                    380:        ULN("xml", XML);
1.148     paf       381:        ULN("optimized-xml", XML|String::UL_OPTIMIZE_BIT);
1.87      paf       382:        ULN("html", HTML);
1.92      paf       383:        ULN("optimized-html", HTML|String::UL_OPTIMIZE_BIT);
1.140     paf       384: 
                    385:        // image JPEG Exif
                    386:        exif_tag_value2name=NEW Hash(pool);
                    387:        #define EXIF_TAG(tag, name) \
                    388:                { \
                    389:                        char *buf=(char *)malloc(MAX_NUMBER); \
                    390:                        snprintf(buf, MAX_NUMBER, "%u", tag); \
1.142     paf       391:                        exif_tag_value2name->put(*NEW String(pool, buf), (void *)#name); \
1.140     paf       392:                }
                    393:        // Tags used by IFD0 (main image)
                    394:        EXIF_TAG(0x010e,        ImageDescription);
                    395:        EXIF_TAG(0x010f,        Make);
                    396:        EXIF_TAG(0x0110,        Model);
                    397:        EXIF_TAG(0x0112,        Orientation);
                    398:        EXIF_TAG(0x011a,        XResolution);
                    399:        EXIF_TAG(0x011b,        YResolution);
                    400:        EXIF_TAG(0x0128,        ResolutionUnit);
                    401:        EXIF_TAG(0x0131,        Software);
                    402:        EXIF_TAG(0x0132,        DateTime);
                    403:        EXIF_TAG(0x013e,        WhitePoint);
                    404:        EXIF_TAG(0x013f,        PrimaryChromaticities);
                    405:        EXIF_TAG(0x0211,        YCbCrCoefficients);
                    406:        EXIF_TAG(0x0213,        YCbCrPositioning);
                    407:        EXIF_TAG(0x0214,        ReferenceBlackWhite);
                    408:        EXIF_TAG(0x8298,        Copyright);
                    409:        EXIF_TAG(0x8769,        ExifOffset);
                    410:        // Tags used by Exif SubIFD
                    411:        EXIF_TAG(0x829a,        ExposureTime);
                    412:        EXIF_TAG(0x829d,        FNumber);
                    413:        EXIF_TAG(0x8822,        ExposureProgram);
                    414:        EXIF_TAG(0x8827,        ISOSpeedRatings);
                    415:        EXIF_TAG(0x9000,        ExifVersion);
                    416:        EXIF_TAG(0x9003,        DateTimeOriginal);
                    417:        EXIF_TAG(0x9004,        DateTimeDigitized);
                    418:        EXIF_TAG(0x9101,        ComponentsConfiguration);
                    419:        EXIF_TAG(0x9102,        CompressedBitsPerPixel);
                    420:        EXIF_TAG(0x9201,        ShutterSpeedValue);
                    421:        EXIF_TAG(0x9202,        ApertureValue);
                    422:        EXIF_TAG(0x9203,        BrightnessValue);
                    423:        EXIF_TAG(0x9204,        ExposureBiasValue);
                    424:        EXIF_TAG(0x9205,        MaxApertureValue);
                    425:        EXIF_TAG(0x9206,        SubjectDistance);
                    426:        EXIF_TAG(0x9207,        MeteringMode);
                    427:        EXIF_TAG(0x9208,        LightSource);
                    428:        EXIF_TAG(0x9209,        Flash);
                    429:        EXIF_TAG(0x920a,        FocalLength);
                    430:        EXIF_TAG(0x927c,        MakerNote);
                    431:        EXIF_TAG(0x9286,        UserComment);
                    432:        EXIF_TAG(0x9290,        SubsecTime);
                    433:        EXIF_TAG(0x9291,        SubsecTimeOriginal);
                    434:        EXIF_TAG(0x9292,        SubsecTimeDigitized);
                    435:        EXIF_TAG(0xa000,        FlashPixVersion);
                    436:        EXIF_TAG(0xa001,        ColorSpace);
                    437:        EXIF_TAG(0xa002,        ExifImageWidth);
                    438:        EXIF_TAG(0xa003,        ExifImageHeight);
                    439:        EXIF_TAG(0xa004,        RelatedSoundFile);
                    440:        EXIF_TAG(0xa005,        ExifInteroperabilityOffset);
                    441:        EXIF_TAG(0xa20e,        FocalPlaneXResolution);
                    442:        EXIF_TAG(0xa20f,        FocalPlaneYResolution);
                    443:        EXIF_TAG(0xa210,        FocalPlaneResolutionUnit);
                    444:        EXIF_TAG(0xa215,        ExposureIndex);
                    445:        EXIF_TAG(0xa217,        SensingMethod);
                    446:        EXIF_TAG(0xa300,        FileSource);
                    447:        EXIF_TAG(0xa301,        SceneType);
                    448:        EXIF_TAG(0xa302,        CFAPattern);
                    449:        // Misc Tags
                    450:        EXIF_TAG(0x00fe,        NewSubfileType);
                    451:        EXIF_TAG(0x00ff,        SubfileType);
                    452:        EXIF_TAG(0x012d,        TransferFunction);
                    453:        EXIF_TAG(0x013b,        Artist);
                    454:        EXIF_TAG(0x013d,        Predictor);
                    455:        EXIF_TAG(0x0142,        TileWidth);
                    456:        EXIF_TAG(0x0143,        TileLength);
                    457:        EXIF_TAG(0x0144,        TileOffsets);
                    458:        EXIF_TAG(0x0145,        TileByteCounts);
                    459:        EXIF_TAG(0x014a,        SubIFDs);
                    460:        EXIF_TAG(0x015b,        JPEGTables);
                    461:        EXIF_TAG(0x828d,        CFARepeatPatternDim);
                    462:        EXIF_TAG(0x828e,        CFAPattern);
                    463:        EXIF_TAG(0x828f,        BatteryLevel);
                    464:        EXIF_TAG(0x83bb,        IPTC/NAA);
                    465:        EXIF_TAG(0x8773,        InterColorProfile);
                    466:        EXIF_TAG(0x8824,        SpectralSensitivity);
                    467:        EXIF_TAG(0x8825,        GPSInfo);
                    468:        EXIF_TAG(0x8828,        OECF);
                    469:        EXIF_TAG(0x8829,        Interlace);
                    470:        EXIF_TAG(0x882a,        TimeZoneOffset);
                    471:        EXIF_TAG(0x882b,        SelfTimerMode);
                    472:        EXIF_TAG(0x920b,        FlashEnergy);
                    473:        EXIF_TAG(0x920c,        SpatialFrequencyResponse);
                    474:        EXIF_TAG(0x920d,        Noise);
                    475:        EXIF_TAG(0x9211,        ImageNumber);
                    476:        EXIF_TAG(0x9212,        SecurityClassification);
                    477:        EXIF_TAG(0x9213,        ImageHistory);
                    478:        EXIF_TAG(0x9214,        SubjectLocation);
                    479:        EXIF_TAG(0x9215,        ExposureIndex);
                    480:        EXIF_TAG(0x9216,        TIFF/EPStandardID);
                    481:        EXIF_TAG(0xa20b,        FlashEnergy);
                    482:        EXIF_TAG(0xa20c,        SpatialFrequencyResponse);
                    483:        EXIF_TAG(0xa214,        SubjectLocation);
1.123     paf       484: 
1.135     paf       485:        // string_match_table_template
                    486:        {
                    487:                Array *columns=NEW Array(pool);
                    488:                *columns+=NEW String(pool, STRING_PRE_MATCH_NAME);
                    489:                *columns+=NEW String(pool, STRING_MATCH_NAME);
                    490:                *columns+=NEW String(pool, STRING_POST_MATCH_NAME);
1.123     paf       491:                for(int i=1; i<=MAX_STRING_MATCH_TABLE_COLUMNS; i++) {
1.125     paf       492:                        char *column=(char *)pool.malloc(MAX_NUMBER);
1.123     paf       493:                        snprintf(column, MAX_NUMBER, "%d", i);
1.135     paf       494:                        *columns+=NEW String(pool, column); // .i column name
                    495:                }
                    496:                string_match_table_template=NEW Table(pool, 0, columns);
                    497:        }
                    498: 
                    499:        // date_calendar_table_template
                    500:        {
                    501:                Array *columns=NEW Array(pool);
                    502:                for(int i=0; i<=6; i++) {
                    503:                        char *column=(char *)pool.malloc(MAX_NUMBER);
                    504:                        snprintf(column, MAX_NUMBER, "%d", i);
                    505:                        *columns+=NEW String(pool, column); // .i column name
1.123     paf       506:                }
1.135     paf       507:                *columns+=NEW String(pool, DATE_CALENDAR_WEEKNO_NAME);
1.137     paf       508:                *columns+=NEW String(pool, DATE_CALENDAR_WEEKYEAR_NAME);
1.135     paf       509:                date_calendar_table_template=NEW Table(pool, 0, columns);
1.123     paf       510:        }
1.1       paf       511: 
1.95      paf       512:        // charsets
                    513:        charsets=NEW Charsets(pool);
                    514:        charsets->put(*charset_UTF8_name, 
                    515:                utf8_charset=NEW Charset(pool, *charset_UTF8_name, 0/*no file=system*/));
1.88      paf       516: 
1.101     paf       517: 
1.88      paf       518:        // Status registration, must be initialized before all registrants
1.90      paf       519:        cache_managers=NEW Cache_managers(pool);
1.42      paf       520: 
1.73      parser    521:        // SQL driver manager
1.90      paf       522:        cache_managers->put(*NEW String(pool, "sql"), 
                    523:                SQL_driver_manager=NEW SQL_Driver_manager(pool));
1.74      parser    524: 
1.76      parser    525: #ifdef XML
1.96      paf       526:        // initializing xml libs
                    527: 
                    528:        /* First I get a DOMImplementation reference */
                    529:        domimpl = gdome_di_mkref ();
                    530:     /*
                    531:      * Register the EXSLT extensions and the test module
                    532:      */
                    533:     exsltRegisterAll();
                    534:     xsltRegisterTestModule();
                    535:     xmlDefaultSAXHandlerInit();
                    536:     /*
                    537:      * disable CDATA from being built in the document tree
                    538:      */
1.101     paf       539:     // never added yet  xmlDefaultSAXHandler.cdataBlock = NULL;
1.99      paf       540: 
                    541:        /*
                    542:         * Initialization function for the XML parser.
                    543:         * This is not reentrant. Call once before processing in case of
                    544:         * use in multithreaded programs.
                    545:        */
                    546:        xmlInitParser();
1.107     paf       547: 
                    548:        // 1. this is needed for proper parsing of stylesheets
                    549:        // there were a situation where honest entity ruined innocent xpath compilation
                    550:        // doc says "you sould turn it on on stylesheet load" without deepening into details
                    551:        // 2. when dom tree with entites goes under transform text nodes 
                    552:        // got [erroreosly] cut on first entity occurance
1.109     paf       553:        // --
1.107     paf       554:        // that is why this is:
                    555:        xmlSubstituteEntitiesDefault(1);
1.100     paf       556:        
                    557:        // Bit in the loadsubset context field to tell to do ID/REFs lookups 
                    558:        xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS;
                    559:        // Bit in the loadsubset context field to tell to do complete the elements attributes lists 
                    560:        // with the ones defaulted from the DTDs 
1.138     paf       561:     xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
                    562: 
                    563:        // validate each document after load/create (?)
                    564:        //xmlDoValidityCheckingDefaultValue = 1;
1.99      paf       565: 
1.104     paf       566: //regretfully this not only replaces entities on parse, but also on generate   xmlSubstituteEntitiesDefault(1);
1.105     paf       567:        // never switched this on xmlIndentTreeOutput=1;
1.104     paf       568: 
1.101     paf       569:        memset(xml_generic_error_infos, 0, sizeof(xml_generic_error_infos));
                    570:        xmlSetGenericErrorFunc(0, xmlParserGenericErrorFunc);
1.102     paf       571:        xsltSetGenericErrorFunc(0, xmlParserGenericErrorFunc);
1.105     paf       572: //     FILE *f=fopen("y:\\xslt.log", "wt");
                    573: //     xsltSetGenericDebugFunc(f/*stderr*/, 0);
1.110     paf       574: 
                    575:        // http://localhost/abc -> $ENV{DOCUMENT_ROOT}/abc | ./abc
                    576:        xmlRegisterInputCallbacks(
                    577:                xmlFileMatchLocalhost, xmlFileOpenLocalhost,
1.150     paf       578:                pa_xmlFileRead, pa_xmlFileClose);
1.96      paf       579: 
                    580:        // XSLT stylesheet manager
1.90      paf       581:        cache_managers->put(*NEW String(pool, "stylesheet"), 
                    582:                stylesheet_manager=NEW Stylesheet_manager(pool));
1.76      parser    583: #endif
1.1       paf       584: }
1.76      parser    585: 
                    586: #if defined(XML) && defined(_MSC_VER)
1.153   ! paf       587: #      define GNOME_LIBS "../../../../win32xml/win32/gnome"
1.131     paf       588: #      pragma comment(lib, GNOME_LIBS "/glib/lib/libglib-1.3-11.lib")
1.76      parser    589: #      ifdef _DEBUG
1.131     paf       590: #              pragma comment(lib, GNOME_LIBS "/libxml2-x.x.x/win32/dsp/libxml2_so_debug/libxml2.lib")
                    591: #              pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libexslt_so_debug/libexslt.lib")
                    592: #              pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libxslt_so_debug/libxslt.lib")
                    593: #              pragma comment(lib, GNOME_LIBS "/gdome2-x.x.x/win32/dsp/Debug/libgdome.lib")
1.76      parser    594: #      else
1.131     paf       595: #              pragma comment(lib, GNOME_LIBS "/libxml2-x.x.x/win32/dsp/libxml2_so_release/libxml2.lib")
                    596: #              pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libexslt_so_release/libexslt.lib")
                    597: #              pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libxslt_so_release/libxslt.lib")
                    598: #              pragma comment(lib, GNOME_LIBS "/gdome2-x.x.x/win32/dsp/Release/libgdome.lib")
1.85      paf       599: #      endif
                    600: #endif

E-mail: