Example #1
0
BOOL write_cidfmap(const char *gspath, const char *cidpath)
{
    char fontpath[MAXSTR];
    char buf[4*MAXSTR];
    STARTUPINFO siStartInfo;
    PROCESS_INFORMATION piProcInfo;

    get_font_path(fontpath, sizeof(fontpath)-1);

    strcpy(buf, "\042");
    strcat(buf, gspath);
    strcat(buf, "\\bin\\gswin32c.exe\042 -q -dBATCH \042-sFONTDIR=");
    strcat(buf, fontpath);
    strcat(buf, "\042 \042");
    strcat(buf, "-sCIDFMAP=");
    strcat(buf, cidpath);
    strcat(buf, "\042 \042");
    strcat(buf, gspath);
    strcat(buf, "\\lib\\mkcidfm.ps\042");

    siStartInfo.cb = sizeof(STARTUPINFO);
    siStartInfo.lpReserved = NULL;
    siStartInfo.lpDesktop = NULL;
    siStartInfo.lpTitle = NULL;  /* use executable name as title */
    siStartInfo.dwX = siStartInfo.dwY = CW_USEDEFAULT;		/* ignored */
    siStartInfo.dwXSize = siStartInfo.dwYSize = CW_USEDEFAULT;	/* ignored */
    siStartInfo.dwXCountChars = 80;
    siStartInfo.dwYCountChars = 25;
    siStartInfo.dwFillAttribute = 0;			/* ignored */
    siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
    siStartInfo.wShowWindow = SW_HIDE;
    siStartInfo.cbReserved2 = 0;
    siStartInfo.lpReserved2 = NULL;
    siStartInfo.hStdInput = NULL;
    siStartInfo.hStdOutput = NULL;
    siStartInfo.hStdError = NULL;

    /* Create the child process. */
    if (!CreateProcess(NULL,
        (char *)buf,  /* command line                       */
        NULL,          /* process security attributes        */
        NULL,          /* primary thread security attributes */
        FALSE,         /* handles are not inherited          */
        0,             /* creation flags                     */
        NULL,          /* environment                        */
        NULL,          /* use parent's current directory     */
        &siStartInfo,  /* STARTUPINFO pointer                */
        &piProcInfo))  /* receives PROCESS_INFORMATION  */
	    return FALSE;

    /* We don't care if ghostscript fails, so just return */

    CloseHandle(piProcInfo.hProcess);
    CloseHandle(piProcInfo.hThread);

    return TRUE;
}
Example #2
0
static bool init_font(struct ft2_source *srcdata)
{
	FT_Long index;
	const char *path = get_font_path(srcdata->font_name, srcdata->font_size,
			srcdata->font_style, srcdata->font_flags, &index);
	if (!path)
		return false;

	if (srcdata->font_face != NULL) {
		FT_Done_Face(srcdata->font_face);
		srcdata->font_face = NULL;
	}

	return FT_New_Face(ft2_lib, path, index, &srcdata->font_face) == 0;
}
Example #3
0
BOOL
install_prog()
{
	char *regkey1 = "GPL Ghostscript";
	char regkey2[16];
	char szDLL[MAXSTR];
	char szLIB[MAXSTR+MAXSTR];
	char szProgram[MAXSTR];
	char szArguments[MAXSTR];
	char szDescription[MAXSTR];
	char szDotVersion[MAXSTR];
	char szPlatformSuffix[MAXSTR];
	const char *pSuffix = "";
	
	if (g_bQuit)
		return FALSE;
	
	cinst.SetMessageFunction(gs_addmess);
	cinst.SetTargetDir(g_szTargetDir);
	cinst.SetTargetGroup(g_szTargetGroup);
	cinst.SetAllUsers(g_bAllUsers);
	if (!cinst.Init(g_szSourceDir, "filelist.txt"))
		return FALSE;
	
	// Get GS version number
	gs_addmess("Installing Program...\n");
	int nGSversion = 0;
	const char *p = cinst.GetMainDir();
	while (*p && !isdigit(*p))	// skip over "gs" prefix
		p++;
	if (strlen(p) == 4)
		nGSversion = (p[0]-'0')*100 + (p[2]-'0')*10 + (p[3]-'0');
	else if (strlen(p) == 3)
		nGSversion = (p[0]-'0')*100 + (p[2]-'0')*10;
        strncpy(szDotVersion, p, sizeof(szDotVersion));
	strncpy(regkey2, szDotVersion, sizeof(regkey2));
	
	// copy files
	if (!cinst.InstallFiles(g_bNoCopy, &g_bQuit)) {
		gs_addmess("Program install failed\n");
		return FALSE;
	}
	
	if (g_bQuit)
		return FALSE;
	
	// write registry entries
	gs_addmess("Updating Registry\n");
	if (!cinst.UpdateRegistryBegin()) {
		gs_addmess("Failed to begin registry update\n");
		return FALSE;
	}
	if (!cinst.UpdateRegistryKey(regkey1, regkey2)) {
		gs_addmess("Failed to open/create registry application key\n");
		return FALSE;
	}
	strcpy(szDLL, g_szTargetDir);
	strcat(szDLL, "\\");
	strcat(szDLL, cinst.GetMainDir());
	strcat(szDLL, "\\bin\\gsdll32.dll");
	if (!cinst.UpdateRegistryValue(regkey1, regkey2, "GS_DLL", szDLL)) {
		gs_addmess("Failed to add registry value\n");
		return FALSE;
	}
	strcpy(szLIB, g_szTargetDir);
	strcat(szLIB, "\\");
	strcat(szLIB, cinst.GetMainDir());
	strcat(szLIB, "\\lib;");
	strcat(szLIB, g_szTargetDir);
	strcat(szLIB, "\\fonts");
	if (g_bCJKFonts) {
	    strcat(szLIB, ";");
	    get_font_path(szLIB+strlen(szLIB), sizeof(szLIB)-strlen(szLIB)-1);
	}
	if (!cinst.UpdateRegistryValue(regkey1, regkey2, "GS_LIB", szLIB)) {
		gs_addmess("Failed to add registry value\n");
		return FALSE;
	}
	if (!cinst.UpdateRegistryEnd()) {
		gs_addmess("Failed to end registry update\n");
		return FALSE;
	}
	if (g_bQuit)
		return FALSE;
	
	// Add Start Menu items
	gs_addmess("Adding Start Menu items\n");

        memset(szPlatformSuffix, 0, sizeof(szPlatformSuffix));
	if (GetProgramFiles(szPlatformSuffix)) {
	    /* If ProgramFiles has a suffix like " (x86)" then use
	     * it for Start menu entries to distinguish between
	     * 32-bit and 64-bit programs.
	     */
	    for (pSuffix = szPlatformSuffix; *pSuffix; pSuffix++)
		if ((pSuffix[0] == ' ') && (pSuffix[1] == '('))
		    break;
	}
	else {
	    pSuffix = "";
	}


	if (!cinst.StartMenuBegin()) {
		gs_addmess("Failed to begin Start Menu update\n");
		return FALSE;
	}
	strcpy(szProgram, g_szTargetDir);
	strcat(szProgram, "\\");
	strcat(szProgram, cinst.GetMainDir());
	strcat(szProgram, "\\bin\\gswin32.exe");
	strcpy(szArguments, "\042-I");
	strcat(szArguments, szLIB);
	strcat(szArguments, "\042");
	sprintf(szDescription, "Ghostscript %s%s", szDotVersion, pSuffix);
	if (!cinst.StartMenuAdd(szDescription, szProgram, szArguments)) {
		gs_addmess("Failed to add Start Menu item\n");
		return FALSE;
	}
	strcpy(szProgram, g_szTargetDir);
	strcat(szProgram, "\\");
	strcat(szProgram, cinst.GetMainDir());
	strcat(szProgram, "\\doc\\Readme.htm");
	sprintf(szDescription, "Ghostscript Readme %s%s", 
		szDotVersion, pSuffix);
	if (!cinst.StartMenuAdd(szDescription, szProgram, NULL)) {
		gs_addmess("Failed to add Start Menu item\n");
		return FALSE;
	}
	if (!cinst.StartMenuEnd()) {
		gs_addmess("Failed to end Start Menu update\n");
		return FALSE;
	}

        /* Create lib/cidfmap */
	if (g_bCJKFonts) {
		char szCIDFmap[MAXSTR];
		char szCIDFmap_bak[MAXSTR];
		char szGSPATH[MAXSTR];

		/* backup old cidfmap */
		strcpy(szCIDFmap, g_szTargetDir);
		strcat(szCIDFmap, "\\");
		strcat(szCIDFmap, cinst.GetMainDir());
		strcat(szCIDFmap, "\\lib\\cidfmap");
		strcpy(szCIDFmap_bak, szCIDFmap);
		strcat(szCIDFmap_bak, ".bak");
		gs_addmess("Backing up\n  ");
		gs_addmess(szCIDFmap);
		gs_addmess("\nto\n  ");
		gs_addmess(szCIDFmap_bak);
		gs_addmess("\n");
		rename(szCIDFmap, szCIDFmap_bak);

		/* mark backup for uninstall */
		cinst.AppendFileNew(szCIDFmap_bak);

		/* write new cidfmap */
		gs_addmess("Writing cidfmap\n   ");
		gs_addmess(szCIDFmap);
		gs_addmess("\n");
		strcpy(szGSPATH, g_szTargetDir);
		strcat(szGSPATH, "\\");
		strcat(szGSPATH, cinst.GetMainDir());
		if (!write_cidfmap(szGSPATH, szCIDFmap)) {
			gs_addmess("Failed to write cidfmap\n");
			return FALSE;
		}
	}
	
	// consolidate logs into one uninstall file
	if (cinst.MakeLog()) {
		// add uninstall entry for "Add/Remove Programs"
		gs_addmess("Adding uninstall program\n");
		if (!cinst.WriteUninstall(UNINSTALLPROG, g_bNoCopy)) {
			gs_addmess("Failed to write uninstall entry\n");
			return FALSE;
		}
	}
	else {
		gs_addmess("Failed to write uninstall log\n");
		// If batch install, files might be on a server
		// in a write protected directory.
		// Don't return an error for batch install.
		if (g_bBatch)
			return TRUE;
		return FALSE;
	}
	
	gs_addmess("Program install successful\n");
	return TRUE;
}