diff --git a/poppler/Makefile.am b/poppler/Makefile.am index 05c5db1..f7d7c69 100644 --- a/poppler/Makefile.am +++ b/poppler/Makefile.am @@ -329,3 +329,19 @@ libpoppler_la_SOURCES = \ EXTRA_DIST = gen-unicode-tables.py \ GlobalParamsWin.cc + +if BUILD_WITH_WIN32_FONTCONFIGURATION + +bin_PROGRAMS = \ + Win32DetectGS + +Win32DetectGS_SOURCES = \ + Win32DetectGS.cc + +Win32DetectGS_CXXFLAGS = \ + -I$(top_srcdir)/goo + +Win32DetectGS_LDADD = \ + -L$(top_builddir)/goo -lgoo + +endif diff --git a/poppler/Win32DetectGS.cc b/poppler/Win32DetectGS.cc new file mode 100644 index 0000000..d5541c9 --- /dev/null +++ b/poppler/Win32DetectGS.cc @@ -0,0 +1,93 @@ +#ifndef PACKAGE_NAME +#include +#endif + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include +#include "goo/gmem.h" +#include "goo/GooString.h" +#include "goo/GooList.h" +#include "goo/GooHash.h" +#include "goo/gfile.h" + +int main(int argc, char** argv) { + HKEY regSoftware; + GooList* gsFontDirs = new GooList(gTrue); + + + if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ, ®Software)) { + return 1; + } + + char swName[1024]; + DWORD swNameLen = sizeof(swName); + FILETIME mTime; + for (int swIdx = 0; ERROR_SUCCESS == RegEnumKeyEx(regSoftware, swIdx, swName, &swNameLen, NULL, NULL, NULL, &mTime) ; swIdx ++, swNameLen = sizeof(swName) ) { + char swNameUpper[1024]; + memcpy(swNameUpper, swName, swNameLen); + CharUpperBuff(swNameUpper, swNameLen); + if (!strstr(swNameUpper, "GHOSTSCRIPT")) { + continue; + } + + + char parent[1024]; + HKEY regGSVers; + snprintf(parent, sizeof(parent), "SOFTWARE\\%s", swName); + if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, parent, 0, KEY_READ, ®GSVers)) { + continue; + } + + + LONG err; + char verName[1024]; + DWORD verNameLen = sizeof(verName); + for (int verIdx = 0; ERROR_SUCCESS == ( err = RegEnumKeyEx(regGSVers, verIdx, verName, &verNameLen, NULL, NULL, NULL, &mTime) ); verIdx ++, verNameLen = sizeof(verName)) { + + snprintf(parent, sizeof(parent), "SOFTWARE\\%s\\%s", swName, verName); + printf("Check the registry data for '%s'\n", parent); + + HKEY regGSData; + if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, parent, 0, KEY_READ, ®GSData)) { + continue; + } + + char gsDataName[1024]; + char gsDataValue[1024]; + DWORD gsDataType; + DWORD gsDataNameLen = sizeof(gsDataName); + DWORD gsDataValueLen = sizeof(gsDataValue); + + for (int idx = 0; ERROR_SUCCESS == ( err = RegEnumValue(regGSData, idx, gsDataName, &gsDataNameLen, NULL, &gsDataType, (BYTE*)gsDataValue, &gsDataValueLen) ); idx ++, gsDataNameLen = sizeof(gsDataName), gsDataValueLen = sizeof(gsDataValue) ) { + if (gsDataType != REG_SZ) { + continue; + } else if (memcmp(gsDataName, "GS_LIB", sizeof("GS_LIB"))) { + continue; + } + + char *p0, *p1; + for (p0 = gsDataValue; ; p0 = p1 + 1) { + p1 = strchr(p0, ';'); + if (!p1) + break; + + *p1 = '\0'; + gsFontDirs->append(new GooString(p0)); + } + } + RegCloseKey(regGSData); + } + RegCloseKey(regGSVers); + } + RegCloseKey(regSoftware); + + for (int i = 0; i < gsFontDirs->getLength(); i++) { + printf("gsFontDirs[%d]\t%s\n", i, ((GooString*)(gsFontDirs->get(i)))->getCString()); + } + + deleteGooList(gsFontDirs,GooString); + return 0; +}