예제 #1
0
파일: setupc.c 프로젝트: 131/gsview
int
unzip_to_dir(char *filename, char *destination)
{
    /* start unzip session */  
    char fullname[256];
    FILE *f;
    int file_exists = 0;
    char cwd[256];
    int len;
    int rc;

    /* prompt for disk to be installed */
    strcpy(fullname, sourcedir);
    strcat(fullname, filename);
    while (!file_exists) {
	gs_addmess("Unzipping ");
	gs_addmess(fullname);
	gs_addmess("\n");
        if ( (f = fopen(fullname, "r")) == (FILE *)NULL ) {
	    char buf[256], mess[256];
	    gs_addmess_update();
	    load_string(IDS_INSERTDISK, mess, sizeof(mess));
	    sprintf(buf, mess, fullname);
	    strcpy(get_string_answer, fullname);
	    if (dialog(IDD_FILE, InputDlgProc) != DID_OK) {
		load_string(IDS_ZIPNOTFOUND, error_message, sizeof(error_message));
		return 1;
	    }
	    strcpy(fullname, get_string_answer);
	}
	else {
	    file_exists = TRUE;
	    fclose(f);
	}
    }

    getcwd(cwd, sizeof(cwd));
    gs_chdir(destination);
    strcpy(unzipprefix, destination);
    len = strlen(unzipprefix);
    if (len && (unzipprefix[len-1] == '\\'))
	unzipprefix[len-1] = '\0';
    rc = unzip(fullname);
    gs_chdir(cwd);

    if (!rc) {
        if (cancelling) {
	    load_string(IDS_UNZIPCANCELLED, error_message, sizeof(error_message));
	    return -1;
	}
    }
    return rc;
}
예제 #2
0
파일: gvwdde2.c 프로젝트: 131/gsview
/* Assume dde_initialise has already been called */
BOOL
dde_execute(char *str)
{
HSZ hszServName;
HSZ hszTopicName;
HCONV hConv;
DWORD dwResult = DDE_FNOTPROCESSED;

    /* Make connection to server */
    hszServName = DdeCreateStringHandleA(idInst, (LPSTR)szServiceName, 
	CP_WINANSI);
    hszTopicName = DdeCreateStringHandleA(idInst, (LPSTR)szTopicName, 
	CP_WINANSI);
    hConv = DdeConnect(idInst, hszServName, hszTopicName, (PCONVCONTEXT)NULL);
    if (hConv == NULL) {
	DdeFreeStringHandle(idInst, hszServName);
	DdeFreeStringHandle(idInst, hszTopicName);
	if (debug)
	    gs_addmess("DdeConnect failed\r\n");
	return FALSE;
    }

    /* send command */
    DdeClientTransaction((LPBYTE)str, strlen(str)+1, hConv,
	NULL, CF_TEXT, XTYP_EXECUTE, 10000, &dwResult);

    /* Disconnect from server */
    DdeDisconnect(hConv);
    DdeFreeStringHandle(idInst, hszServName);
    DdeFreeStringHandle(idInst, hszTopicName);
    if (debug) {
	gs_addmess("Sent XTYP_EXECUTE: ");
	gs_addmess(str);
	gs_addmess("\r\n");
    }
    return (dwResult == DDE_FACK);
}
예제 #3
0
파일: gvpmisc.c 프로젝트: 131/gsview
int
send_prolog(int resource)
{  
char *prolog, *p;
APIRET rc;
int code = -1;
	rc = DosGetResource(0, RT_RCDATA, resource, (PPVOID)&prolog);
	if (!rc && (prolog != (char *)NULL) ) {
	    code = 0;
	    p = prolog;
	    while (*p) {
		if (debug & DEBUG_GENERAL)
		    gs_addmess(p);
		if (!code)
	            code = gs_execute(p, strlen(p));
		p += strlen(p)+1;
	    }
	    DosFreeResource(prolog);
	}
	return code;
}
예제 #4
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;
}
예제 #5
0
// install program and files
BOOL
install_all()
{
	gs_addmess("Source Directory=");
	gs_addmess(g_szSourceDir);
	gs_addmess("\n");
	gs_addmess("Target Directory=");
	gs_addmess(g_szTargetDir);
	gs_addmess("\n");
	gs_addmess("Target Shell Folder=");
	gs_addmess(g_szTargetGroup);
	gs_addmess("\n");
	gs_addmess(g_bAllUsers ? "  All users\n" : "  Current user\n");
	
	if (stricmp(g_szSourceDir, g_szTargetDir) == 0) {
		// Don't copy files
		if (!g_bBatch)
			if (::MessageBox(g_hWndText, "Install location is the same as the current file location.  No files will be copied.", g_szAppName, MB_OKCANCEL) 
				!= IDOK) {
				return FALSE;
			}
		g_bNoCopy = TRUE;
	}
	
	
	if (g_bQuit)
		return FALSE;
	
	if (!install_prog()) {
		cinst.CleanUp();
		g_bError = TRUE;
		return FALSE;
	}
	
	gs_addmess("Install successful\n");
	
	// show start menu folder
	if (!g_bBatch) {
		char szFolder[MAXSTR];
		szFolder[0] = '\0';
		cinst.GetPrograms(g_bAllUsers, szFolder, sizeof(szFolder));
		strcat(szFolder, "\\");
		strcat(szFolder, g_szTargetGroup);
		ShellExecute(HWND_DESKTOP, "open", szFolder, 
			NULL, NULL, SW_SHOWNORMAL);
	}
	
#ifdef DEBUG
	return FALSE;
#endif

	return TRUE;
}
예제 #6
0
파일: gvwpgdi.cpp 프로젝트: 131/gsview
// Background part as separate thread
// Don't do any GUI things on this thread.
void print_gdi_thread(void *pdummy)
{
    PGDI_THREAD *pth= (PGDI_THREAD *)pdummy;
    CPrintDIB printdib;
    char buf[MAXSTR];
    int length;
    LPBYTE pLine;
    LPBYTE p;
    DWORD dwRead;
    int i;

    GFile *pFile = gfile_open_handle((int)pth->hPipeRd);

    int page = 0;
    BOOL print_it;
    printdib.debug = (debug & DEBUG_GDI);

    while (printdib.ReadHeader(pFile)) {
	page++;
	print_it = TRUE;
	if ((pth->oddeven == EVEN_PAGES) && ((page & 1) == 1))
		print_it = FALSE;
	else if ((pth->oddeven == ODD_PAGES) && ((page & 1) == 0))
		print_it = FALSE;
	if ((pth->from > 0) && (page < pth->from))
		print_it = FALSE;
	if ((pth->to > 0) && (page > pth->to))
		print_it = FALSE;
	
	sprintf(buf, "Page %d, %s\n", page, print_it ? "PRINT" : "ignore");
	gs_addmess(buf);
	if (print_it)
	    StartPage(pth->hdc);
	length = printdib.m_bytewidth;
	pLine = new BYTE[length];
	
	for (i=0; i < printdib.m_PageBmp.bmp2.biHeight; i++) {
	    // read a scan line
	    length = printdib.m_bytewidth;
	    p = pLine;
	    while (length && (dwRead = gfile_read(pFile, p, length)) != 0) {
		    length -= dwRead;
		    p += dwRead;
	    }
	    if (print_it)
		    printdib.AddPrintLine(pth->hdc, i, pLine);
	}
	if (print_it) {
		printdib.FlushPrintBitmap(pth->hdc);
		EndPage(pth->hdc);
	}
	delete pLine;
    }

    EndDoc(pth->hdc);
    DeleteDC(pth->hdc);
    pth->hdc = NULL;
    gfile_close(pFile);

    free(pth);

    print_count--;

    /* if printing from command line, close GSview */
    if (print_exit && (print_count==0) && !(debug & DEBUG_GDI))
	gsview_command(IDM_EXIT);

    gs_addmess("\nPrint GDI finished\n");
}
예제 #7
0
파일: gvwpgdi.cpp 프로젝트: 131/gsview
BOOL
init_print_gdi(HDC hdc)
{
    // create the pipe for capturing printer output
    /* Set the bInheritHandle flag so pipe handles are inherited. */
    SECURITY_ATTRIBUTES saAttr;
    saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
    saAttr.bInheritHandle = TRUE;
    saAttr.lpSecurityDescriptor = NULL;
    HANDLE hPipeTemp;

    if (!CreatePipe(&hPipeTemp, &print_gdi_write_handle, &saAttr, 0)) {
	gs_addmess("failed to open printer pipe\n");
	return FALSE;
    }
    /* make the read handle non-inherited */
    if (!DuplicateHandle(GetCurrentProcess(), hPipeTemp,
	    GetCurrentProcess(), &print_gdi_read_handle, 0,
	    FALSE,       /* not inherited */
	    DUPLICATE_SAME_ACCESS)) {
	gs_addmess("failed to duplicate pipe handle\n");
	return FALSE;
    }
    CloseHandle(hPipeTemp);

    // open printer, get size and resolution
    DOCINFO di;
    TCHAR wpsname[MAXSTR];
    convert_multibyte(wpsname, psfile_name(&psfile), 
	sizeof(wpsname)/sizeof(TCHAR)-1);
    memset(&di, 0, sizeof(DOCINFO));
    di.cbSize = sizeof(DOCINFO);
    di.lpszDocName = wpsname;
    di.lpszOutput = NULL;
    if (StartDoc(hdc, &di) == SP_ERROR) {
	DWORD err = GetLastError();
	LPSTR lpMessageBuffer;
	char buf[MAXSTR];
	sprintf(buf, "StartDoc failed, error %d\n", err);
	gs_addmess(buf);
	FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
	    FORMAT_MESSAGE_FROM_SYSTEM,
	    NULL, err,
	    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* user default language */
	    (LPSTR)&lpMessageBuffer, 0, NULL);
	if (lpMessageBuffer) {
	    gs_addmess(lpMessageBuffer);
	    gs_addmess("\r\n");
	    LocalFree(LocalHandle(lpMessageBuffer));
	}
	return FALSE;
    }

    // Need to pass these back to gvcprn.cpp.
    // Use global variables for now.
    print_gdi_width = GetDeviceCaps(hdc, PHYSICALWIDTH);
    print_gdi_height = GetDeviceCaps(hdc, PHYSICALHEIGHT);
    print_gdi_xdpi = GetDeviceCaps(hdc, LOGPIXELSX);
    print_gdi_ydpi = GetDeviceCaps(hdc, LOGPIXELSY);
    if (debug & DEBUG_GDI) {
	char buf[MAXSTR];
	sprintf(buf, "GDI width=%d height=%d xdpi=%d ydpy=%d\n",
	    print_gdi_width, print_gdi_height, print_gdi_xdpi, print_gdi_ydpi);
	gs_addmess(buf);
    }

    if ( (print_gdi_width == 0) || (print_gdi_height == 0) ) {
	gs_addmess("Printer width or height is zero\n");
	return FALSE;
    }
 
    return TRUE;
}
예제 #8
0
파일: gvwpgdi.cpp 프로젝트: 131/gsview
/* Start child program with inherited pipe */
BOOL start_gvwgs_with_pipe(HDC hdc)
{
    STARTUPINFO siStartInfo;
    LPVOID env;
    TCHAR wcommand[MAXSTR+MAXSTR];
    TCHAR wgsdll[MAXSTR];
    TCHAR woptname[MAXSTR];
    TCHAR wpsname[MAXSTR];

    convert_multibyte(wgsdll, option.gsdll, 
	sizeof(wgsdll)/sizeof(TCHAR)-1);
    convert_multibyte(woptname, printer.optname, 
	sizeof(woptname)/sizeof(TCHAR)-1);
    convert_multibyte(wpsname, printer.psname, 
	sizeof(wpsname)/sizeof(TCHAR)-1);

    PGDI_THREAD *pth= (PGDI_THREAD *)malloc(sizeof(PGDI_THREAD));
    if (pth == NULL) {
	gs_addmess("Failed to allocate PGDI_THREAD\n");
	return FALSE;
    }

    if (psfile.dsc != (CDSC *)NULL && !psfile.print_ignoredsc) {
	// PostScript file contains only needed pages
	// Print all
	pth->from = 1;
	pth->to = 9999;
	pth->oddeven = ALL_PAGES;
    }
    else {
	// we render all pages, and print only some
	pth->from = psfile.print_from;
	pth->to = psfile.print_to;
	pth->oddeven = psfile.print_oddeven;
    }
    pth->hdc = hdc;
    pth->hPipeRd = print_gdi_read_handle;

    wsprintf(wcommand, TEXT("\042%s%s\042 %s \042%s\042 \042%s\042 \042%s\042"),
	szExePath,
#ifdef DECALPHA
	TEXT("gvwgsda.exe"),
#else
# ifdef _WIN64
	TEXT("gvwgs64.exe"),
# else
	TEXT("gvwgs32.exe"),
# endif
#endif
	debug ? TEXT("/d") : TEXT(""),
	wgsdll, woptname, wpsname);
	

    info_wait(IDS_WAIT);


    /* Now create the child process. */

    /* Set up members of STARTUPINFO structure. */

    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_SHOWNORMAL;	
    siStartInfo.wShowWindow = SW_SHOWMINNOACTIVE;	
    siStartInfo.cbReserved2 = 0;
    siStartInfo.lpReserved2 = NULL;
    siStartInfo.hStdInput = NULL;
    siStartInfo.hStdOutput = NULL;
    siStartInfo.hStdError = NULL;

    env = NULL;

    /* Create the child process. */
    PROCESS_INFORMATION piProcInfo;

    if (!CreateProcess(NULL,
        wcommand,      /* command line                       */
        NULL,          /* process security attributes        */
        NULL,          /* primary thread security attributes */
        TRUE,          /* handles are inherited              */
        0,             /* creation flags                     */
        env,           /* environment                        */
        NULL,          /* use parent's current directory     */
        &siStartInfo,  /* STARTUPINFO pointer                */
	&piProcInfo)	/* receives PROCESS_INFORMATION  */
	) {
        char command[MAXSTR+MAXSTR];
	// cleanup items created by gsviev_cprint()
	if (!debug)
	    unlink(printer.psname);
	printer.psname[0] = '\0';
	if (!debug)
	    unlink(printer.optname);
	printer.optname[0] = '\0';
	// also items PRINT_GDI items
	CloseHandle(print_gdi_read_handle);
	print_gdi_read_handle = NULL;
	CloseHandle(print_gdi_write_handle);
	print_gdi_write_handle = NULL;
	EndDoc(pth->hdc);
	free(pth);
	info_wait(IDS_NOWAIT);
	convert_widechar(command, wcommand, sizeof(command)-1);
	gserror(IDS_CANNOTRUN, command, MB_ICONHAND, SOUND_ERROR);
	return FALSE;
    }

    WaitForInputIdle(piProcInfo.hProcess, 30000);
    info_wait(IDS_NOWAIT);

    /* we shouldn't exit GSview until print_gdi_thread finishes
     * and print_count becomes 0.
     */
    print_count++;	

    _beginthread(print_gdi_thread, 65536, (void *)pth);
    // we don't need to know anything more */
    CloseHandle(piProcInfo.hProcess);
    CloseHandle(piProcInfo.hThread);

    // Now that Ghostscript has started, close our copy of the write
    // handle so that pipe will break when Ghostscript closes its 
    // write handle.
    CloseHandle(print_gdi_write_handle);

    return TRUE;
}
예제 #9
0
파일: gvwdde2.c 프로젝트: 131/gsview
/* This is called whenever someone sends us XTYP_EXECUTE */
void 
dde_server_execute(HDDEDATA hData)
{
char buffer[256];
char *p;
char *q;
    DdeGetData(hData, (LPBYTE)buffer, sizeof(buffer), 0);
    DdeFreeDataHandle(hData);

    if (debug) {
	gs_addmess("XTYP_EXECUTE: ");
	gs_addmess(buffer);
	gs_addmess("\r\n");
    }


    p = buffer;
    while (*p) {
	while (*p && *p!= '[')
	    p++;
        if (*p)
	    p++;
	q = p;

	if (strncmp(p, "Command(", 8) == 0) {
	    p+= 8;
	    q = skiparg(p);
	    if (*p == '\042')
		p++;
	    drop_filename(hwndimg, p);
	}
	else if (strncmp(p, "FileOpen(", 9) == 0) {
	    p+= 9;
	    q = skiparg(p);
	    if (*p == '\042')
		p++;
	    drop_filename(hwndimg, p);
	}
	else if (strncmp(p, "FileExit(", 9) == 0) {
	    p+= 9;
	    q = skiparg(p);
	    if (print_count)
		/* if busy printing, exit after finished */
		print_exit = TRUE;
	    else
		/* otherwise exit now */
	        gsview_command(IDM_EXIT);
	}
	else if (strncmp(p, "NextPage(", 9) == 0) {
	    p+= 9;
	    q = skiparg(p);
	    gsview_command(IDM_NEXT);
	}
	else if (strncmp(p, "PrevPage(", 9) == 0) {
	    p+= 9;
	    q = skiparg(p);
	    gsview_command(IDM_PREV);
	}
	else if (strncmp(p, "GoBack(", 7) == 0) {
	    p+= 7;
	    q = skiparg(p);
	    gsview_command(IDM_GOBACK);
	}
	else if (strncmp(p, "GotoPage(", 9) == 0) {
	    int page;
	    p+= 9;
	    q = skiparg(p);
	    page = atoi(p);
	    gsview_goto_page(page);
	}
	else if (strncmp(p, "ShowWindow(", 11) == 0) {
 	    int nCmdShow;
	    p+= 11;
	    q = skiparg(p);
	    nCmdShow = atoi(p);
	    ShowWindow(hwndimg, nCmdShow);
	    if ((nCmdShow == SW_SHOW) || (nCmdShow == SW_SHOWMAXIMIZED) 
		|| (nCmdShow == SW_SHOWNORMAL))
	        SetForegroundWindow(hwndimg);
	}
	else if (strncmp(p, "FullScreen(", 11) == 0) {
	    p+= 11;
	    q = skiparg(p);
	    gsview_fullscreen();
	}
	
	p = q;
	while (*p && *p!= ']')
	    p++;
    }
}
예제 #10
0
파일: gvccmd.c 프로젝트: 131/gsview
/* gsview menu commands */
int
gsview_command(int command)
{
    switch (command) {
    case IDM_NEXTHOME:
    case IDM_NEXT:
    case IDM_NEXTSKIP:
    case IDM_REDISPLAY:
    case IDM_PREVHOME:
    case IDM_PREVSKIP:
    case IDM_PREV:
    case IDM_GOBACK:
    case IDM_GOFWD:
    case IDM_MAGPLUS:
    case IDM_MAGMINUS:
    case IDM_FITWIN:
    case IDM_ZOOM:
    case IDM_FULLSCREEN:
        /* These don't close the full screen window */
        break;
    default:
        gsview_fullscreen_end();
    }
    switch (command) {
    case IDM_FULLSCREEN:
        gsview_fullscreen();
        return 0;
    case IDM_OPEN:
        if (pending.psfile) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        gsview_display();
        return 0;
    case IDM_LASTFILE1:
    case IDM_LASTFILE2:
    case IDM_LASTFILE3:
    case IDM_LASTFILE4:
        if (pending.psfile) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        make_cwd(last_files[command-IDM_LASTFILE1]);
        gsview_displayfile(last_files[command-IDM_LASTFILE1]);
        return 0;
    case IDM_CLOSE:
        /* doesn't unload DLL */
        /* close file */
        if (gsdll.open && (gsdll.state != GS_UNINIT)) {
            PSFILE *tpsfile;
            if (pending.psfile) {
                play_sound(SOUND_BUSY);
                return 0;
            }
            tpsfile = (PSFILE *)malloc(sizeof(PSFILE));
            if (tpsfile == NULL)
                return 0;
            memset((char *)tpsfile, 0, sizeof(PSFILE));
            pending.psfile = tpsfile;
            pending.now = TRUE;
            if (psfile.name[0] && psfile.dsc==(CDSC *)NULL)
                pending.abort = TRUE;
        }
        else {
            /* DLL isn't loaded */
            if (psfile.file)
                dfclose();	/* just to make sure */
            psfile_free(&psfile);
            post_img_message(WM_GSTITLE, 0);
            info_wait(IDS_NOWAIT);
        }
        return 0;
    case IDM_CLOSE_DONE:
        if (selectname[0] != '\0') {
            /* pending IDM_SELECT */
            PSFILE *tpsfile;
            tpsfile = gsview_openfile(selectname);
            if (tpsfile) {
                psfile = *tpsfile;
                free(tpsfile);
            }
            selectname[0] = '\0';
            post_img_message(WM_GSTITLE, 0);
            info_wait(IDS_NOWAIT);
        }
        return 0;
    case IDM_NEXTHOME:
#ifdef UNIX
        set_scroll(-1, 0);
#else
#ifdef _Windows
        PostMessage(hwnd_image ,WM_VSCROLL,SB_TOP,0L);
#else
        WinPostMsg(hwnd_frame, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_TOP));
#endif
#endif
    /* fall thru */
    case IDM_NEXT:
        if (not_open())
            return 0;
        gs_page_skip(1);
        return 0;
    case IDM_NEXTSKIP:
        if (not_dsc())
            return 0;
        if (order_is_special())
            return 0;
        gs_page_skip(page_skip);
        return 0;
    case IDM_REDISPLAY:
        if (dfchanged()) {
            PSFILE *tpsfile;
            if (dfchanged() < 0) {
                gs_addmess("File has been deleted\n");
                gsview_command(IDM_CLOSE);
                pending.unload = TRUE;
                pending.now = FALSE;
                return 0;
            }
            if (pending.psfile)
                tpsfile = pending.psfile;	/* new file, old file deleted */
            else
                tpsfile = gsview_openfile(psfile.name);
            if (tpsfile) {
                tpsfile->pagenum = psfile.pagenum;
                request_mutex();
                pending.psfile = tpsfile;
                if ( gsdll.hmodule &&  (psfile.dsc==(CDSC *)NULL) &&
                        (gsdll.state != GS_IDLE) )
                    /* don't know where we are so close and reopen */
                    pending.abort = TRUE;
                pending.now = TRUE;
                release_mutex();
            }
        }

        if (not_open())
            return 0;
        if (psfile.dsc==(CDSC *)NULL) {
            /* don't know where we are so close and reopen */
            if (gsdll.state != GS_IDLE) {
                if (!pending.psfile) {
                    pending.psfile = (PSFILE *)malloc(sizeof(PSFILE));
                    if (pending.psfile)
                        *pending.psfile = psfile;
                }
                pending.psfile->pagenum = pending.pagenum = 1;
                pending.abort = TRUE;
                pending.now = TRUE;
            }
        }
        else {
            pending.pagenum = -1;  /* default page number is current page */
            if (psfile.dsc->page_order == CDSC_SPECIAL)
                pending.pagenum = 1;	/* restart */
        }
        gsview_unzoom();
        pending.now = TRUE;
        return 0;
    case IDM_PREVHOME:
#ifdef UNIX
        set_scroll(-1, 0);
#else
#ifdef _Windows
        PostMessage(hwnd_image ,WM_VSCROLL,SB_TOP,0L);
#else
        WinPostMsg(hwnd_frame, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_TOP));
#endif
#endif
    /* fall thru */
    case IDM_PREV:
        if (not_dsc())
            return 0;
        if (order_is_special())
            return 0;
        gs_page_skip(-1);
        return 0;
    case IDM_PREVSKIP:
        if (not_dsc())
            return 0;
        if (order_is_special())
            return 0;
        gs_page_skip(-page_skip);
        return 0;
    case IDM_GOTO:
        if (not_dsc())
            return 0;
        if (order_is_special())
            return 0;
        if (psfile.dsc->page_count == 0) {
            gserror(IDS_NOPAGE, NULL, MB_ICONEXCLAMATION, SOUND_NONUMBER);
            return 0;
        }
        nHelpTopic = IDS_TOPICGOTO;
        {   int pagenum;
            pagenum = psfile.pagenum;
            if (get_page(&pagenum, FALSE, FALSE)) {
                gsview_goto_page(pagenum);
            }
        }
        return 0;
    case IDM_GOBACK:
        if (not_dsc())
            return 0;
        if (order_is_special())
            return 0;
        history_back();
        return 0;
    case IDM_GOFWD:
        if (not_open())
            return 0;
        if (psfile.dsc == (CDSC *)NULL)
            gsview_command(IDM_NEXT);
        else
            history_forward();
        return 0;
    case IDM_INFO:
        show_info();
        return 0;
    case IDM_SELECT:
        if (pending.psfile) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        gsview_select();
        return 0;
#ifndef VIEWONLY
    case IDM_PRINT:
    case IDM_PRINTTOFILE:
    case IDM_CONVERTFILE:
        if (psfile.name[0] == '\0')
            gsview_select();
        if (gsdll.state == GS_BUSY) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        if (dfreopen() != 0)
            return 0;
        if (command == IDM_PRINTTOFILE)
            option.print_to_file = TRUE;
        if (psfile.name[0] != '\0')
            gsview_print(command == IDM_CONVERTFILE);
        dfclose();
        return 0;
    case IDM_SPOOL:
        gsview_spool((char *)NULL, (char *)NULL);
        return 0;
    case IDM_SAVEAS:
        if (gsdll.state == GS_BUSY) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        if (psfile.name[0] == '\0')
            gsview_select();
        if (psfile.name[0] != '\0')
            gsview_saveas();
        return 0;
    case IDM_EXTRACT:
        if (gsdll.state == GS_BUSY) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        if (psfile.name[0] == '\0')
            gsview_select();
        if (order_is_special())
            return 0;
        if (psfile.name[0] != '\0')
            gsview_extract();
        return 0;
    case IDM_PSTOEDIT:
        if (gsdll.state == GS_BUSY) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        if (psfile.name[0] == '\0')
            gsview_select();
        (void)order_is_special();    /* warn, but allow it anyway */
        if (dfreopen() != 0)
            return 0;
        if (psfile.name[0] != '\0')
            gsview_pstoedit();
        dfclose();
        return 0;
    case IDM_TEXTEXTRACT:
        if (psfile.name[0] == '\0')
            gsview_select();
        if (psfile.name[0] != '\0')
            gsview_text_extract();
        return 0;
    case IDM_TEXTEXTRACT_SLOW:
        gsview_text_extract_slow();
        return 0;
    case IDM_TEXTFIND:
        gsview_text_find();
        return 0;
    case IDM_TEXTFINDNEXT:
        gsview_text_findnext();
        return 0;
    case IDM_COPYCLIP:
        copy_clipboard();
        return 0;
    case IDM_PASTETO:
        paste_to_file();
        return 0;
    case IDM_CONVERT:
        clip_convert();
        return 0;
    case IDM_MEASURE:
        if (gsdll.state == GS_BUSY) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        measure_show();
        return 0;
#endif /* !VIEWONLY */
    case IDM_GSMESS:
        gs_showmess();	/* show messages from Ghostscript */
        return 0;
    case IDM_EXIT:
        if (print_count) {
            /* Still busy printing.  Warn user. */
            TCHAR buf[MAXSTR];
            load_string(IDS_BUSYPRINTING, buf,
                        sizeof(buf)/sizeof(TCHAR)-1);
            if (message_box(buf, MB_OKCANCEL) != IDOK)
                return 0;
        }
        post_img_message(WM_CLOSE, 0);
        return 0;
    case IDM_CFG:	/* Easy configure */
        config_wizard(TRUE);
        return 0;
    case IDM_GSCOMMAND:	/* Advanced configure */
        if (install_gsdll() && gsdll.open)
            pending.unload = TRUE;
        return 0;
    case IDM_UNITPT:
    case IDM_UNITMM:
    case IDM_UNITINCH:
        gsview_unit(command);
        return 0;
    case IDM_UNITFINE:
        option.unitfine = !option.unitfine;
        check_menu_item(IDM_UNITMENU, IDM_UNITFINE, option.unitfine);
        return 0;
    case IDM_LANGMENU+1:
    case IDM_LANGMENU+2:
    case IDM_LANGMENU+3:
    case IDM_LANGMENU+4:
    case IDM_LANGMENU+5:
    case IDM_LANGMENU+6:
    case IDM_LANGMENU+7:
    case IDM_LANGMENU+8:
    case IDM_LANGMENU+9:
    case IDM_LANGMENU+10:
    case IDM_LANGMENU+11:
    case IDM_LANGMENU+12:
    case IDM_LANGMENU+13:
    case IDM_LANGMENU+14:
    case IDM_LANGMENU+15:
    case IDM_LANGMENU+16:
    case IDM_LANGMENU+17:
    case IDM_LANGMENU+18:
    case IDM_LANGMENU+19:
        gsview_language(command);
        return 0;
    case IDM_SAFER:
        option.safer = !option.safer;
        check_menu_item(IDM_OPTIONMENU, IDM_SAFER, option.safer);
        return 0;
    case IDM_SAVEDIR:
        option.save_dir = !option.save_dir;
        check_menu_item(IDM_OPTIONMENU, IDM_SAVEDIR, option.save_dir);
        return 0;
    case IDM_BUTTONSHOW:
        option.button_show = !option.button_show;
        check_menu_item(IDM_OPTIONMENU, IDM_BUTTONSHOW, option.button_show);
        show_buttons();
        return 0;
    case IDM_FITPAGE:
        option.fit_page = !option.fit_page;
        check_menu_item(IDM_OPTIONMENU, IDM_FITPAGE, option.fit_page);
        /* should cause WM_SIZE message to be sent */
        return 0;
    case IDM_PSTOTEXTDIS:
    case IDM_PSTOTEXTNORM:
    case IDM_PSTOTEXTCORK:
        check_menu_item(IDM_PSTOTEXTMENU, option.pstotext + IDM_PSTOTEXTMENU + 1, FALSE);
        option.pstotext = command - IDM_PSTOTEXTMENU - 1;
        check_menu_item(IDM_PSTOTEXTMENU, option.pstotext + IDM_PSTOTEXTMENU + 1, TRUE);
        return 0;
    case IDM_AUTOREDISPLAY:
        option.redisplay = !option.redisplay;
        check_menu_item(IDM_OPTIONMENU, IDM_AUTOREDISPLAY, option.redisplay);
        return 0;
    case IDM_EPSFCLIP:
        option.epsf_clip = !option.epsf_clip;
        check_menu_item(IDM_OPTIONMENU, IDM_EPSFCLIP, option.epsf_clip);
        gs_resize();
        return 0;
    case IDM_EPSFWARN:
        option.epsf_warn = !option.epsf_warn;
        check_menu_item(IDM_OPTIONMENU, IDM_EPSFWARN, option.epsf_warn);
        return 0;
    case IDM_IGNOREDSC:
        option.ignore_dsc = !option.ignore_dsc;
        check_menu_item(IDM_OPTIONMENU, IDM_IGNOREDSC, option.ignore_dsc);
        if (psfile.name[0]) {
            if (option.redisplay)
                gsview_displayfile(psfile.name);
            else
                gsview_selectfile(psfile.name);
        }
        return 0;
    case IDM_SHOWBBOX:
        option.show_bbox = !option.show_bbox;
        check_menu_item(IDM_OPTIONMENU, IDM_SHOWBBOX, option.show_bbox);
#ifdef UNIX
        gtk_widget_draw(img, NULL);
#else
#ifdef _Windows
        PostMessage(hwndimg, WM_GSSYNC, 0, 0L);
#else
        if (!WinInvalidateRect(hwnd_bmp, (PRECTL)NULL, TRUE))
            error_message("error invalidating rect");
        if (!WinUpdateWindow(hwnd_bmp))
            error_message("error updating window");
#endif
#endif
        return 0;
#ifndef VIEWONLY
    case IDM_PSTOEPS:
        if (not_open())
            return 0;
        if (psfile.name[0] != '\0') {
            if (dfreopen() != 0)
                return 0;
            ps_to_eps();
            dfclose();
        }
        return 0;
    case IDM_MAKEEPSI:
        if ( (option.orientation == IDM_PORTRAIT) ||
                (option.auto_orientation == TRUE) ) {
            char epsname[MAXSTR];
            epsname[0] = '\0';
            if (dfreopen() != 0)
                return 0;
            if (!get_filename(epsname, TRUE, FILTER_EPS, 0,
                              IDS_TOPICPREVIEW)) {
                dfclose();
                return 0;
            }
            image_lock(view.img);
            make_eps_interchange(FALSE, epsname);
            image_unlock(view.img);
            dfclose();
        }
        else
            gserror(IDS_MUSTUSEPORTRAIT, 0, MB_ICONEXCLAMATION, 0);
        return 0;
    case IDM_MAKEEPST4:
    case IDM_MAKEEPST6U:
    case IDM_MAKEEPST6P:
        if ( (option.orientation == IDM_PORTRAIT) ||
                (option.auto_orientation == TRUE) ) {
            char epsname[MAXSTR];
            epsname[0] = '\0';
            if (dfreopen() != 0)
                return 0;
            if (!get_filename(epsname, TRUE, FILTER_EPS, 0,
                              IDS_TOPICPREVIEW)) {
                dfclose();
                return 0;
            }
            image_lock(view.img);
            make_eps_tiff(command, FALSE, epsname);
            image_unlock(view.img);
            dfclose();
        }
        else
            gserror(IDS_MUSTUSEPORTRAIT, 0, MB_ICONEXCLAMATION, 0);
        return 0;
    case IDM_MAKEEPSW:
        if ( (option.orientation == IDM_PORTRAIT) ||
                (option.auto_orientation == TRUE) ) {
            char epsname[MAXSTR];
            epsname[0] = '\0';
            if (dfreopen() != 0)
                return 0;
            if (!get_filename(epsname, TRUE, FILTER_EPS, 0,
                              IDS_TOPICPREVIEW)) {
                dfclose();
                return 0;
            }
            image_lock(view.img);
            make_eps_metafile(FALSE, epsname);
            image_unlock(view.img);
            dfclose();
        }
        else
            gserror(IDS_MUSTUSEPORTRAIT, 0, MB_ICONEXCLAMATION, 0);
        return 0;
    case IDM_MAKEEPSU:
        if (dfreopen() != 0)
            return 0;
        make_eps_user();
        dfclose();
        return 0;
    case IDM_EXTRACTPS:
    case IDM_EXTRACTPRE:
        if (dfreopen() != 0)
            return 0;
        extract_doseps(command);
        dfclose();
        return 0;
#endif
    case IDM_SETTINGS:
        write_profile();
        return 0;
    case IDM_SAVESETTINGS:
        option.settings = !option.settings;
        check_menu_item(IDM_OPTIONMENU, IDM_SAVESETTINGS, option.settings);
        {   char buf[MAXSTR];
            PROFILE *prf = profile_open(szIniFile);
            sprintf(buf, "%d", (int)option.settings);
            profile_write_string(prf, INISECTION, "SaveSettings", buf);
            profile_close(prf);
        }
        return 0;
    case IDM_SOUNDS:
        change_sounds();
        return 0;
    case IDM_AUTOORIENT:
    case IDM_PORTRAIT:
    case IDM_LANDSCAPE:
    case IDM_UPSIDEDOWN:
    case IDM_SEASCAPE:
    case IDM_SWAPLANDSCAPE:
        gsview_orientation(command);
        return 0;
    case IDM_DSC_OFF:
    case IDM_DSC_ERROR:
    case IDM_DSC_WARN:
    case IDM_DSC_INFO:
        check_menu_item(IDM_DSCMENU, option.dsc_warn, FALSE);
        option.dsc_warn = command;
        check_menu_item(IDM_DSCMENU, option.dsc_warn, TRUE);
        return 0;
    case IDM_ZOOM:		/* called indirectly from Right Mouse Button */
        if (not_dsc()) {
            zoom = FALSE;
            return 0;
        }
        if (order_is_special()) {
            zoom = FALSE;
            return 0;
        }
        if (! ((gsdll.state == GS_PAGE) || (gsdll.state == GS_IDLE)) ) {
            zoom = FALSE;
            gserror(IDS_NOZOOM, NULL, MB_ICONEXCLAMATION, SOUND_ERROR);
            return 0;
        }
        gs_resize();
        pending.pagenum = -1;  /* default page number is current page */
        pending.now = TRUE;
        return 0;
    case IDM_MAGPLUS:
        gs_magnify((float)1.2);
        return 0;
    case IDM_MAGMINUS:
        gs_magnify((float)0.8333);
        return 0;
    case IDM_FITWIN:
        /* fit media to size of current window */
        gsview_fitwin();
        return 0;
    case IDM_DISPLAYSETTINGS:
        display_settings();
        return 0;
    case IDM_MEDIAROTATE:
        option.media_rotate = !option.media_rotate;
        check_menu_item(IDM_MEDIAMENU, IDM_MEDIAROTATE,
                        option.media_rotate);
        zoom = FALSE;
        gs_resize();
        return 0;
    case IDM_11x17:
    case IDM_A3:
    case IDM_A4:
    case IDM_A5:
    case IDM_B4:
    case IDM_B5:
    case IDM_LEDGER:
    case IDM_LEGAL:
    case IDM_LETTER:
    case IDM_NOTE:
    case IDM_USERSIZE:
    case IDM_USERSIZE1:
    case IDM_USERSIZE2:
    case IDM_USERSIZE3:
    case IDM_USERSIZE4:
    case IDM_USERSIZE5:
    case IDM_USERSIZE6:
    case IDM_USERSIZE7:
    case IDM_USERSIZE8:
    case IDM_USERSIZE9:
    case IDM_USERSIZE10:
    case IDM_USERSIZE11:
    case IDM_USERSIZE12:
    case IDM_USERSIZE13:
        if (command == IDM_USERSIZE)
            if (!gsview_usersize())
                return 0;
        gsview_media(command);
        return 0;
    case IDM_HELPCONTENT:
#ifdef UNIX
        nHelpTopic = IDS_TOPICROOT;
        get_help();
#else
#ifdef _Windows
#ifdef USE_HTMLHELP
        nHelpTopic = IDS_TOPICROOT;
        get_help();
#else
        WinHelp(hwndimg,szHelpName,HELP_CONTENTS,(DWORD)NULL);
#endif
#else
        WinSendMsg(hwnd_help, HM_HELP_CONTENTS, 0L, 0L);
#endif
#endif
        return 0;
    case IDM_HELPSEARCH:
#ifdef UNIX
        gs_addmess("IDM_HELPSEARCH: not implemented\n");
#else
#ifdef _Windows
#ifdef USE_HTMLHELP
        HtmlHelp(hwndimg,szHelpName,HH_DISPLAY_INDEX, (DWORD)TEXT(""));
        gs_addmessf("HtmlHelp: %s HH_DISPLAY_INDEX\n", szHelpName);
#else
        WinHelp(hwndimg,szHelpName,HELP_PARTIALKEY,(DWORD)"");
#endif
#else
        WinSendMsg(hwnd_help, HM_HELP_INDEX, 0L, 0L);
#endif
#endif
        return 0;
    case IDM_HELPKEYS:
        nHelpTopic = IDS_TOPICKEYS;
        get_help();
        return 0;
    case IDM_ABOUT:
        show_about();
        return 0;
    case IDM_REGISTER:
        registration_nag();
        return 0;
    }
    return 0;
}
예제 #11
0
파일: setupc.c 프로젝트: 131/gsview
int
do_install(void)
{
int rc=0;
char buf[MAXSTR];
char gsviewdir[MAXSTR];
char gstoolsdir[MAXSTR];
    install_init();

    gs_addmess("Destination ");
    gs_addmess(destdir);
    gs_addmess("\n");
    gs_addmess("Installing GSview: ");
    if (install_gsview)
        gs_addmess("true\n");
    else
        gs_addmess("false\n");
    gs_addmess("Installing Ghostscript: ");
    if (install_gs)
        gs_addmess("true\n");
    else
        gs_addmess("false\n");

    if (!rc) {
	char logname[MAXSTR];
	char *p;

	strcpy(gsviewdir, destdir);
	if (strlen(gsviewdir) == 2)
	    strcat(gsviewdir, "\\");	/* is root directory */
	strcpy(gstoolsdir, gsviewdir);
	if (strlen(gsviewdir) && (gsviewdir[strlen(gsviewdir)-1] != '\\'))
	    strcat(gsviewdir, "\\");
	strcat(gsviewdir, gsviewbase);
	mkdirall(gsviewdir);

	strcpy(logname, gsviewdir);
	strcat(logname, "\\");
	strcat(logname, GSVIEW_ZIP);
	p = strrchr(logname, '.');
	strcpy(p, ".log");
	unziplogfile = fopen(logname, "w");	/* don't append */
	if (unziplogfile == (FILE *)NULL) {
	    load_string(IDS_CANTOPENWRITE, buf, sizeof(buf)); 
	    sprintf(error_message, buf, logname);
	    rc = 1;
	}
    }

    if (install_gs || install_gsview) {
	if (!rc) {
	    /* copy unzip DLL so we don't demand load it from floppy */
	    strcpy(unzipname, gsviewdir);
	    strcat(unzipname, "\\");
	    strcat(unzipname, szUnzipDll);
	    strcpy(buf, sourcedir);
	    strcat(buf, szUnzipDll);
	    rc = copyfile(unzipname, buf);
	}

	if (cancelling)
	    rc = 1;

	/* unzip GSview and Ghostscript */
	if (!rc) {
	    char zipname[MAXSTR];
	    load_unzip(unzipname, phInstance, 
		find_page_from_id(IDD_TEXTWIN)->hwnd, (HWND)NULL);

	    if (!rc && install_gsview) {
		rc = unzip_to_dir(GSVIEW_ZIP, gsviewdir);
		if (cancelling)
		    rc = 1;
	    }
#ifdef OS2
	    if (!rc) {
		/* install EMX if needed */
	        char emxbuf[MAXSTR];
		sprintf(emxbuf, "%s\\", bootdrive);
		if (!emx)
		    rc = unzip_to_dir(EMXZIP, emxbuf);
		if (cancelling)
		    rc = 1;
	    }
#endif

	    if (!rc && install_gs) {
		if (gsver < 600) {
		    sprintf(zipname, "%sini.zip", gs_zipprefix);
		    if (!rc)
			rc = unzip_to_dir(zipname, gstoolsdir);
		    if (cancelling)
			rc = 1;
		}
#ifdef OS2
		sprintf(zipname, "%sos2.zip", gs_zipprefix);
#else
		sprintf(zipname, "%sw32.zip", gs_zipprefix);
#endif
		if (!rc)
		    rc = unzip_to_dir(zipname, gstoolsdir);
		if (cancelling)
		    rc = 1;
		if (gsver < 600) {
		    sprintf(zipname, "%sfn1.zip", gs_zipprefix);
		    if (!rc) {
			strcpy(buf, gstoolsdir);
			if (strlen(buf) && (buf[strlen(buf)-1] != '\\'))
			    strcat(buf, "\\");
			strcat(buf, gs_basedir);
			rc = unzip_to_dir(zipname, buf);
			if (cancelling)
			    rc = 1;
		    }
		}
	    }

	    gs_chdir(workdir);
	    free_unzip();
	}

	/* remove unneeded unzip DLL */
	unlink(unzipname);
    }

    if (!rc && install_autoexec)
	rc = update_config();
    if (cancelling)
	rc = 1;

    if (!rc && install_group)
	rc = create_object();
    if (cancelling)
	rc = 1;

    if (!rc) {
#ifdef OS2
	char szIniName[MAXSTR];
	strcpy(szIniName, bootdrive);
	strcat(szIniName, "\\os2\\gvpm.ini");
#endif
	/* This doesn't work for Windows per user profiles */
	rc = update_ini(szIniName);
    }
    if (cancelling)
	rc = 1;

    if (unziplogfile!=(FILE *)NULL)
	fclose(unziplogfile);

    return rc;
}