Esempio n. 1
0
File: setupc.c Progetto: 131/gsview
void
zip_message(char *str, int count)
{
int n = 0;
int i;
    gs_addmess_count(str, count);
    gs_addmess_update();
    if (unziplogfile != (FILE *)NULL) {
	/* keep log of installed files, for later uninstalling */
	if (strncmp(str, "  inflating: ", 13)==0)
	    n = 13;
	if (strncmp(str, "  extracting: ", 14)==0)
	    n = 14;
	if (strncmp(str, " extracting: ", 13)==0)
	    n = 13;
	if (n!=0) {
	    fprintf(unziplogfile, "%s\\", unzipprefix);
	    for (i=n; i<count; i++) {
		if (str[i]!='/')
		    fputc(str[i], unziplogfile);
	 	else
		    fputc('\\', unziplogfile);
	    }
	    fwrite("\n", 1, 1, unziplogfile);
	}
    }
    return;
}
Esempio n. 2
0
File: setupc.c Progetto: 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;
}
Esempio n. 3
0
// Add string to log window
void
gs_addmess_count(const char *str, int count)
{
	const char *s;
	char *p;
	int i, lfcount;
	MSG msg;
	
	// we need to add \r after each \n, so count the \n's
	lfcount = 0;
	s = str;
	for (i=0; i<count; i++) {
		if (*s == '\n')
			lfcount++;
		s++;
	}
	
	if (count + lfcount >= TWSCROLL)
		return;		// too large
	if (count + lfcount + twend >= TWLENGTH-1) {
		// scroll buffer
		twend -= TWSCROLL;
		memmove(twbuf, twbuf+TWSCROLL, twend);
	}
	p = twbuf+twend;
	for (i=0; i<count; i++) {
		if (*str == '\n') {
			*p++ = '\r';
		}
		*p++ = *str++;
	}
	twend += (count + lfcount);
	*(twbuf+twend) = '\0';
	
	
	// Update the dialog box
	if (g_bBatch)
		return;
	
	gs_addmess_update();
	while (PeekMessage(&msg, (HWND)NULL, 0, 0, PM_REMOVE)) {
		if (!IsDialogMessage(g_hWndText, &msg) && 
			!IsDialogMessage(g_hMain, &msg)) {
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
}
Esempio n. 4
0
BOOL
init()
{
	DWORD dwVersion = GetVersion();
	// get source directory
	GetCurrentDirectory(sizeof(g_szSourceDir), g_szSourceDir);
	
	// load strings
	LoadString(g_hInstance, IDS_APPNAME, g_szAppName, sizeof(g_szAppName));
	LoadString(g_hInstance, IDS_TARGET_GROUP, 
		g_szTargetGroup, sizeof(g_szTargetGroup));
	
	if (LOBYTE(LOWORD(dwVersion)) < 4) {
        MessageBox(HWND_DESKTOP, 
			"This install program needs Windows 4.0 or later",
			g_szAppName, MB_OK);
		return FALSE;
	}
	if ( (HIWORD(dwVersion) & 0x8000) == 0)
		is_winnt = TRUE;
	
	
	cinst.SetMessageFunction(message_box);

#define MAXCMDTOKENS 128

	int argc;
	LPSTR argv[MAXCMDTOKENS];
	LPSTR p;
	char command[256];
	char *args;
	char *d, *e;
     
	p = GetCommandLine();

	argc = 0;
	args = (char *)malloc(lstrlen(p)+1);
	if (args == (char *)NULL)
		return 1;
       
	// Parse command line handling quotes.
	d = args;
	while (*p) {
		// for each argument

		if (argc >= MAXCMDTOKENS - 1)
			break;

		e = d;
		while ((*p) && (*p != ' ')) {
			if (*p == '\042') {
				// Remove quotes, skipping over embedded spaces.
				// Doesn't handle embedded quotes.
				p++;
				while ((*p) && (*p != '\042'))
					*d++ =*p++;
			}
			else 
				*d++ = *p;
			if (*p)
				p++;
		}
		*d++ = '\0';
		argv[argc++] = e;

		while ((*p) && (*p == ' '))
			p++;	// Skip over trailing spaces
	}
	argv[argc] = NULL;

	if (strlen(argv[0]) == 0) {
		GetModuleFileName(g_hInstance, command, sizeof(command)-1);
		argv[0] = command;
	}

	if (argc > 2) {
		// Probably creating filelist.txt
		return make_filelist(argc, argv);
	}


	// check if batch mode requested
	// get location of target directory from command line as argv[1]
	if (argc == 2) {
		strncpy(g_szTargetDir, argv[1], sizeof(g_szTargetDir));
		g_bBatch = TRUE;
		if (is_winnt)
			g_bAllUsers = TRUE;
	}
	if (g_bBatch) {
		if (!install_all()) {
			// display log showing error
			g_bBatch = FALSE;
			g_hWndText = CreateDialogParam(g_hInstance, 
				MAKEINTRESOURCE(IDD_TEXTWIN), 
				(HWND)HWND_DESKTOP, TextWinDlgProc, 
				(LPARAM)NULL);
			gs_addmess_update();
		}
		return TRUE;
	}
	
	// Interactive setup
	if (!GetProgramFiles(g_szTargetDir))
	    strcpy(g_szTargetDir, "C:\\Program Files");
	strcat(g_szTargetDir, "\\");
	LoadString(g_hInstance, IDS_TARGET_DIR, 
	    g_szTargetDir+strlen(g_szTargetDir), 
	    sizeof(g_szTargetDir)-strlen(g_szTargetDir));
	
	// main dialog box
	g_hMain = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MAIN), (HWND)NULL, MainDlgProc, (LPARAM)NULL);
	// centre dialog on screen
	int width = GetSystemMetrics(SM_CXFULLSCREEN);
	int height = GetSystemMetrics(SM_CYFULLSCREEN);
	RECT rect;
	GetWindowRect(g_hMain, &rect);
	MoveWindow(g_hMain, (width - (rect.right - rect.left))/2,
		(height - (rect.bottom - rect.top))/2,
		(rect.right - rect.left),
		(rect.bottom - rect.top), FALSE);
	
	// initialize targets
	cinst.SetMessageFunction(message_box);
	if (!cinst.Init(g_szSourceDir, "filelist.txt"))
		return FALSE;

	SetDlgItemText(g_hMain, IDC_TARGET_DIR, g_szTargetDir);
	SetDlgItemText(g_hMain, IDC_TARGET_GROUP, g_szTargetGroup);
	SetDlgItemText(g_hMain, IDC_PRODUCT_NAME, cinst.GetUninstallName());
	ShowWindow(g_hMain, SW_SHOWNORMAL);
	
	return (g_hMain != (HWND)NULL); /* success */
}