int main(int argc, char **argv) { // Avoid SEGV if ( ! g_log.init( "foo.log" ) ) { fprintf (stderr,"db: Log file init failed.\n" ); exit( 1 ); } // init our table for doing zobrist hashing if ( ! hashinit() ) { log("db: Failed to init hashtable." ); exit(1); } // . hashinit() calls srand() w/ a fixed number // . let's mix it up again srand ( time(NULL) ); UCProps props = 0; g_ucProps.setValue(0, &props); // Download data from: // ftp://ftp.unicode.org/Public/UNIDATA/ loadUnidataProps("UNIDATA/DerivedNormalizationProps.txt", handleDerivedNormalizationProps); loadUnidataProps("UNIDATA/UnicodeData.txt", handleUnicodeData); decomposeHangul(); // set up algorithmic hangul decomps printf("%d canonical deompositions\n", g_canonicalDecompCount); printf("%d code points excluded\n", g_excludeCount); loadUnidataProps("UNIDATA/DerivedCoreProperties.txt", handleDerivedCoreProps); loadUnidataProps("UNIDATA/PropList.txt", handlePropList); loadUnidataProps("UNIDATA/Scripts.txt", handleScripts); printf("lower case map size: %lu\n", g_ucLowerMap.getSize()); saveUnicodeTable(&g_ucLowerMap, "ucdata/lowermap.dat"); printf("upper case map size: %lu\n", g_ucUpperMap.getSize()); saveUnicodeTable(&g_ucUpperMap, "ucdata/uppermap.dat"); printf("properties size: %lu\n", g_ucProps.getSize()); saveUnicodeTable(&g_ucProps, "ucdata/properties.dat"); printf("scripts size: %lu\n", g_ucScripts.getSize()); saveUnicodeTable(&g_ucScripts, "ucdata/scripts.dat"); // JAB: we now have Kompatible and Canonical decompositions saveKDecompTable(); g_mem.printMem(); if (loadUnicodeTable(&g_ucUpperMap,"ucdata/uppermap.dat") && loadUnicodeTable(&g_ucLowerMap,"ucdata/lowermap.dat") && loadUnicodeTable(&g_ucProps,"ucdata/properties.dat") && loadUnicodeTable(&g_ucScripts,"ucdata/scripts.dat") && // JAB: we now have Kompatible and Canonical decompositions loadDecompTables()){ printf("tables reloaded successfully\n\n"); printf("lower case map size: %lu\n", g_ucLowerMap.getSize()); printf("upper case map size: %lu\n", g_ucUpperMap.getSize()); printf("properties size: %lu\n", g_ucProps.getSize()); printf("scripts size: %lu\n", g_ucScripts.getSize()); printf("Kompat Decomp size: %lu\n", g_ucKDIndex.getSize()); exit(0); } }
bool ucInit(char *path, bool verifyFiles){ char file[384]; if (path == NULL) path = "./"; // Might want to move this out of ucInit someday // but right now it's the only thing that uses .so files (?) char gbLibDir[512]; snprintf(gbLibDir, 512, "%s/lib",path); // i don't think this is used any more because we don't have it! //log(LOG_INIT, "ucinit: Setting LD_RUN_PATH to \"%s\"",gbLibDir); if (setenv("LD_RUN_PATH", gbLibDir, 1)){ log(LOG_INIT, "Failed to set LD_RUN_PATH"); } //char *ldpath = getenv("LD_RUN_PATH"); // i don't think this is used any more because we don't have it! //log(LOG_DEBUG, "ucinit: LD_RUN_PATH: %s\n", ldpath); strcpy(file, path); strcat(file, "/ucdata/uppermap.dat"); if (!loadUnicodeTable(&g_ucUpperMap,file, VERIFY_UNICODE_CHECKSUMS, CHKSUM_UPPERMAP)) goto failed; strcpy(file, path); strcat(file, "/ucdata/lowermap.dat"); if (!loadUnicodeTable(&g_ucLowerMap,file, VERIFY_UNICODE_CHECKSUMS, CHKSUM_LOWERMAP)) goto failed; strcpy(file, path); strcat(file, "/ucdata/properties.dat"); if (!loadUnicodeTable(&g_ucProps, file, VERIFY_UNICODE_CHECKSUMS, CHKSUM_PROPERTIES)) goto failed; strcpy(file, path); strcat(file, "/ucdata/combiningclass.dat"); if (!loadUnicodeTable(&g_ucCombiningClass, file, VERIFY_UNICODE_CHECKSUMS, CHKSUM_COMBININGCLASS)) goto failed; strcpy(file, path); strcat(file, "/ucdata/scripts.dat"); if (!loadUnicodeTable(&g_ucScripts, file, VERIFY_UNICODE_CHECKSUMS, CHKSUM_SCRIPTS)) goto failed; // MDW: do we need this for converting from X to utf8? or for // the is_alnum(), etc. functions? if (!loadDecompTables(path) || !initCompositionTable()) goto failed; //s_convTable.set(1024); if ( ! s_convTable.set(4,sizeof(iconv_t),1024,NULL,0,false,0,"cnvtbl")) goto failed; // dont use these files anymore if (verifyFiles){ if (!openIconvDescriptors()) return log(LOG_WARN, "uni: unable to open all iconv descriptors"); } return true; failed: return log(LOG_WARN, "uni: unable to load all property tables"); }