Ejemplo n.º 1
0
int
main (int argc, char *argv[])
  /*@globals errno, insthier_len, progname, stderr, insthier, ctxt_fakeroot @*/
  /*@modifies stderr @*/
{
  unsigned long index;
  unsigned int flag;
  struct install_status_t status;

  argv = 0;

  if (ctxt_fakeroot[0] != (char) 0) {
    (void) fprintf (stderr, "%s: info: using fake root - %s\n", progname, ctxt_fakeroot);
    install_fake_root (ctxt_fakeroot);
  }

  status = install_init ("conf-sosuffix");
  if (status.status != INSTALL_STATUS_OK) {
    assert (status.message != NULL);
    (void) fprintf (stderr, "%s: fatal: init: %s - %s\n", progname,
      status.message, status.error_message);
    exit (EXIT_FAILURE);
  }

  install_callback_warn_set (cb_warn);
  install_callback_info_set (cb_info);

  flag = (argc > 1) ? INSTALL_DRYRUN : 0;
  for (index = 0; index < insthier_len; ++index) {
    status = install (&insthier[index], flag);
    switch (status.status) {
      case INSTALL_STATUS_OK:
        break;
      case INSTALL_STATUS_ERROR:
        assert (status.message != NULL);
        (void) fprintf (stderr, "%s: error: %s - %s\n", progname,
          status.message, status.error_message);
        break;
      case INSTALL_STATUS_FATAL:
        assert (status.message != NULL);
        (void) fprintf (stderr, "%s: fatal: %s - %s\n", progname,
          status.message, status.error_message);
        exit (EXIT_FAILURE);
    }
  }

  return 0;
}
Ejemplo n.º 2
0
/***********************************************************************
 *      LaunchINFSectionW   (ADVPACK.@)
 *
 * Installs an INF section without BACKUP/ROLLBACK capabilities.
 *
 * PARAMS
 *   hWnd    [I] Handle to parent window, NULL for desktop.
 *   hInst   [I] Instance of the process.
 *   cmdline [I] Contains parameters in the order INF,section,flags,reboot.
 *   show    [I] How the window should be shown.
 *
 * RETURNS
 *  Success: ADV_SUCCESS.
 *  Failure: ADV_FAILURE.
 *
 * NOTES
 *  INF - Filename of the INF to launch.
 *  section - INF section to install.
 *  flags - see advpub.h.
 *  reboot - smart reboot behavior
 *    'A' Always reboot.
 *    'I' Reboot if needed (default).
 *    'N' No reboot.
 */
INT WINAPI LaunchINFSectionW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
{
    ADVInfo info;
    LPWSTR cmdline_copy, cmdline_ptr;
    LPWSTR inf_filename, install_sec;
    LPWSTR str_flags;
    DWORD flags = 0;
    HRESULT hr = S_OK;

    TRACE("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_w(cmdline), show);

    if (!cmdline)
        return ADV_FAILURE;

    cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR));
    cmdline_ptr = cmdline_copy;
    lstrcpyW(cmdline_copy, cmdline);

    inf_filename = get_parameter(&cmdline_ptr, ',', TRUE);
    install_sec = get_parameter(&cmdline_ptr, ',', TRUE);

    str_flags = get_parameter(&cmdline_ptr, ',', TRUE);
    if (str_flags)
        flags = atolW(str_flags);

    ZeroMemory(&info, sizeof(ADVInfo));

    hr = install_init(inf_filename, install_sec, NULL, flags, &info);
    if (hr != S_OK)
        goto done;

    hr = spapi_install(&info);
    if (hr != S_OK)
        goto done;

    hr = adv_install(&info);

done:
    install_release(&info);
    HeapFree(GetProcessHeap(), 0, cmdline_copy);

    return SUCCEEDED(hr) ? ADV_SUCCESS : ADV_FAILURE;
}
Ejemplo n.º 3
0
int
main (void)
{
  unsigned long i;
  struct install_status_t status;

  status = install_init ("conf-sosuffix");
  if (status.status != INSTALL_STATUS_OK) {
    printf ("%s: fatal: init: %s - %s\n", progname,
      status.message, install_error (errno));
    exit (112);
  }

  install_callback_warn_set (cb_warn);
  install_callback_info_set (cb_info);

  for (i = 0; i < insthier_len; ++i) {
    status = install_check (&insthier[i]);
    switch (status.status) {
      case INSTALL_STATUS_OK:
        break;
      case INSTALL_STATUS_ERROR:
        fprintf (stderr, "%s: error: %s - %s\n", progname,
          status.message, install_error (errno));
        break;
      case INSTALL_STATUS_FATAL:
        fprintf (stderr, "%s: fatal: %s - %s\n", progname,
          status.message, install_error (errno));
        exit (112);
        break;
    }
  }

  if (install_failed) {
    fprintf (stderr, "%s: %lu of %lu files failed\n", progname,
      install_failed, insthier_len);
    return 1;
  }
  return 0;
}
Ejemplo n.º 4
0
int
main (int argc, char *argv[])
{
  unsigned long i;
  unsigned int flag;
  struct install_status_t status;

  argv = 0;

  status = install_init ();
  if (status.status != INSTALL_STATUS_OK) {
    fprintf (stderr, "%s: fatal: init: %s - %s\n", progname,
      status.message, install_error (errno));
    exit (112);
  }

  install_callback_warn_set (cb_warn);
  install_callback_info_set (cb_info);

  flag = (argc > 1) ? INSTALL_DRYRUN : 0;
  for (i = insthier_len - 1;; --i) {
    status = deinstall (&insthier[i], flag);
    switch (status.status) {
      case INSTALL_STATUS_OK:
        break;
      case INSTALL_STATUS_ERROR:
        fprintf (stderr, "%s: error: %s - %s\n", progname,
          status.message, install_error (errno));
        break;
      case INSTALL_STATUS_FATAL:
        fprintf (stderr, "%s: fatal: %s - %s\n", progname,
          status.message, install_error (errno));
        exit (112);
        break;
    }
    if (i == 0) break;
  }

  return 0;
}
Ejemplo n.º 5
0
/***********************************************************************
 *      RunSetupCommandW  (ADVPACK.@)
 *
 * Executes an install section in an INF file or a program.
 *
 * PARAMS
 *   hWnd          [I] Handle to parent window, NULL for quiet mode
 *   szCmdName     [I] Inf or EXE filename to execute
 *   szInfSection  [I] Inf section to install, NULL for DefaultInstall
 *   szDir         [I] Path to extracted files
 *   szTitle       [I] Title of all dialogs
 *   phEXE         [O] Handle of EXE to wait for
 *   dwFlags       [I] Flags; see include/advpub.h
 *   pvReserved    [I] Reserved
 *
 * RETURNS
 *   S_OK                                 Everything OK
 *   S_ASYNCHRONOUS                       OK, required to wait on phEXE
 *   ERROR_SUCCESS_REBOOT_REQUIRED        Reboot required
 *   E_INVALIDARG                         Invalid argument given
 *   HRESULT_FROM_WIN32(ERROR_OLD_WIN_VERSION)
 *                                        Not supported on this Windows version
 *   E_UNEXPECTED                         Unexpected error
 *   HRESULT_FROM_WIN32(GetLastError())   Some other error
 */
HRESULT WINAPI RunSetupCommandW(HWND hWnd, LPCWSTR szCmdName,
                                LPCWSTR szInfSection, LPCWSTR szDir,
                                LPCWSTR lpszTitle, HANDLE *phEXE,
                                DWORD dwFlags, LPVOID pvReserved)
{
    ADVInfo info;
    HRESULT hr;

    TRACE("(%p, %s, %s, %s, %s, %p, %d, %p)\n",
          hWnd, debugstr_w(szCmdName), debugstr_w(szInfSection),
          debugstr_w(szDir), debugstr_w(lpszTitle),
          phEXE, dwFlags, pvReserved);

    if (dwFlags & RSC_FLAG_UPDHLPDLLS)
        FIXME("Unhandled flag: RSC_FLAG_UPDHLPDLLS\n");

    if (!szCmdName || !szDir)
        return E_INVALIDARG;

    if (!(dwFlags & RSC_FLAG_INF))
        return launch_exe(szCmdName, szDir, phEXE);

    ZeroMemory(&info, sizeof(ADVInfo));

    hr = install_init(szCmdName, szInfSection, szDir, dwFlags, &info);
    if (hr != S_OK)
        goto done;

    hr = spapi_install(&info);
    if (hr != S_OK)
        goto done;

    hr = adv_install(&info);

done:
    install_release(&info);

    return hr;
}
Ejemplo n.º 6
0
/* internal: see DoInfInstall */
static HRESULT DoInfInstallW(const SETUPCOMMAND_PARAMSW *setup)
{
    ADVInfo info;
    HRESULT hr;

    TRACE("(%p)\n", setup);

    ZeroMemory(&info, sizeof(ADVInfo));

    hr = install_init(setup->inf_name, setup->section_name, setup->dir, 0, &info);
    if (hr != S_OK)
        goto done;

    hr = spapi_install(&info);
    if (hr != S_OK)
        goto done;

    hr = adv_install(&info);

done:
    install_release(&info);

    return S_OK;
}
Ejemplo n.º 7
0
Archivo: setupc.c Proyecto: 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;
}