Exemplo n.º 1
0
void
CreateExecutionEnvironment(int *_argc,
			   char ***_argv,
			   char jrepath[],
			   jint so_jrepath,
			   char jvmpath[],
			   jint so_jvmpath,
			   char **_jvmtype,
			   char **original_argv) {
    char *execname = NULL;
    int original_argc = *_argc;

    /* Compute the name of the executable */
    execname = SetExecname(*_argc, *_argv);

    /* Find out where the JRE is that we will be using. */
    if (!GetJREPath(jrepath, so_jrepath)) {
	fprintf(stderr, "Error: could not find Java 2 Runtime Environment.\n");
	exit(2);
    }

    /* Find the specified JVM type */
    if (ReadKnownVMs(jrepath) < 1) {
	fprintf(stderr, "Error: no known VMs. (check for corrupt jvm.cfg file)\n");
	exit(1);
    }
    *_jvmtype = CheckJvmType(_argc, _argv);

    jvmpath[0] = '\0';
    if (!GetJVMPath(jrepath, *_jvmtype, jvmpath, so_jvmpath)) {
	fprintf(stderr, "Error: no `%s' JVM at `%s'.\n", *_jvmtype, jvmpath);
	exit(4);
    }
    /* If we got here, jvmpath has been correctly initialized. */

    /* Set the LD_LIBRARY_PATH environment variable, check data model
       flags, and exec process, if needed */
    SetLibraryPath(_argc, _argv, original_argc, original_argv, execname, jrepath, jvmpath);
}
Exemplo n.º 2
0
int main(int nArgc, char **ppArgv)
{
    CommandArgs args;
    CLSModule *pModule;

    if (ParseArgs(nArgc, ppArgv, &args) < 0) exit(1);

    if (args.pszFactoryUrl) SetFactoryUrl(args.pszFactoryUrl);
    if (args.pszSourcePath) SetSourcePath(args.pszSourcePath);
    if (args.pszLibraryPath) SetLibraryPath(args.pszLibraryPath);

    pModule = CompileCAR(args.pszSource, args.mAttribs);
    if (!pModule) exit(1);

    // generate file(s) specified by command line
    //
    if (args.pszCAR) {
        if (CLS2CAR(args.pszCAR, pModule) < 0) goto ErrorExit;
    }
    if (args.pszCLS) {
        if (SaveCLS(args.pszCLS, pModule) < 0) goto ErrorExit;
    }
    if (args.mAttribs & Command_E_GenExCLS) {
        if (ExtendCLS(pModule, TRUE) < 0) goto ErrorExit;
        if (SaveCLS(args.pszExCLS, pModule) < 0) goto ErrorExit;
    }

    DestroyAllLibraries();
    DestroyCLS(pModule);
    return 0;

ErrorExit:
    fprintf(stderr, "[ERROR] carc (0x1004) : Writing file failed, aborting.\n");
    DestroyCLS(pModule);
    exit(1);
}