Exemple #1
0
/*
 * Try to make the needed options complete by looking through the data file,
 * environment variables and registry entries.
 */
void complete_options(void)
{
    /* Try to find a descent RelDir */
    if( !RelDir ) {
        DWORD sz = 32;
        while (1) {
            DWORD nsz;
            if (RelDir)
                free(RelDir);
            RelDir = malloc(sz);
            if (!RelDir) {
                fprintf(stderr, "** Error : failed to allocate memory\n");
                exit(1);
            }
            SetLastError(0);
            nsz = GetEnvironmentVariable((LPCTSTR) "RELDIR",
                                         (LPTSTR) RelDir,
                                         sz);
            if (nsz == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
                free(RelDir);
                RelDir = NULL;
                break;
            }
            else if (nsz <= sz)
                break;
            else
                sz = nsz;
        }
        if (RelDir == NULL) {
            if(DataFileName) {
                /* Needs to be absolute for this to work, but we
                   can try... */
                read_datafile();
                read_registry_keys();
            } else {
                /* Impossible to find all data... */
                exit_help("Need either Release directory or an absolute "
                          "datafile name.");
            }
            /* Ok, construct our own RelDir from RootDir */
            RelDir = (char *) malloc(strlen(RootDir)+strlen(RELEASE_SUBDIR)+1);
            assert(RelDir);
            sprintf(RelDir, "%s" RELEASE_SUBDIR, RootDir);
        } else {
            read_datafile();
            read_registry_keys();
        }
    } else {
        read_datafile();
        read_registry_keys();
    }
    read_bootflags();

#ifdef _DEBUG
    fprintf(stderr, "RelDir: '%s'\n", RelDir);
#endif
}
Exemple #2
0
/*
 * Try to make the needed options complete by looking through the data file,
 * environment variables and registry entries.
 */
void complete_options(void)
{
    /* Try to find a descent RelDir */
    if( !RelDir ) {
	DWORD sz = 32;
	while (1) {
	    DWORD nsz;
	    if (RelDir)
		free(RelDir);
	    RelDir = malloc(sz);
	    if (!RelDir) {
		fprintf(stderr, "** Error : failed to allocate memory\n");
		exit(1);
	    }
	    SetLastError(0);
	    nsz = GetEnvironmentVariable((LPCTSTR) "RELDIR",
					 (LPTSTR) RelDir,
					 sz);
	    if (nsz == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
		free(RelDir);
		RelDir = NULL;
		break;
	    }
	    else if (nsz <= sz)
		break;
	    else
		sz = nsz;
	}
	if (RelDir == NULL) {
	  if (!RootDir) {
	    /* Impossible to find all data... */
	    exit_help("Need either Root directory nor Release directory.");
	  }
	  /* Ok, construct our own RelDir from RootDir */
	  RelDir = (char *) malloc(strlen(RootDir)+strlen(RELEASE_SUBDIR)+1);
	  assert(RelDir);
	  sprintf(RelDir, "%s" RELEASE_SUBDIR, RootDir);
	  read_datafile();
	} else {
	    read_datafile();
	}
    } else {
	read_datafile();
    }
    if( !RootDir ) {
	/* Try to construct RootDir from RelDir */
	char *p;
	RootDir = malloc(strlen(RelDir)+1);
	strcpy(RootDir,RelDir);
	p = RootDir+strlen(RootDir)-1;
	if (p >= RootDir && (*p == '/' || *p == '\\'))
	    --p;
	while (p >= RootDir && *p != '/' &&  *p != '\\')
	    --p;
	if (p <= RootDir) { /* Empty RootDir is also an error */
	    exit_help("Cannot determine Root directory from "
		      "Release directory.");
	}
	*p = '\0';
    }
	    
    
    BinDir = (char *) malloc(strlen(RootDir)+strlen(ERTS_SUBDIR_PREFIX)+
			     strlen(Version)+strlen(BIN_SUBDIR)+1);
    assert(BinDir);
    sprintf(BinDir, "%s" ERTS_SUBDIR_PREFIX "%s" BIN_SUBDIR, RootDir, Version);

    read_bootflags();
    
#ifdef _DEBUG
    fprintf(stderr, "RelDir: '%s'\n", RelDir);
    fprintf(stderr, "BinDir: '%s'\n", BinDir);
#endif
}