⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 midpstartup.c

📁 用于移动设备上的java虚拟机源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
            IMPL_VERSION, RELEASE);        fprintf(stdout, "Configuration: %s\n",            getInternalProp("microedition.configuration"));            exit(0);        } else if (strcmp(argv[currentArg], "-transient") == 0) {            MidpCommandState.initialCommand = INSTALL_RUN;            ppTarget = &MidpCommandState.suiteURL;            MidpCommandState.runOnce = KNI_TRUE;        } else if (strcmp(argv[currentArg], "-autotest") == 0) {            MidpCommandState.initialCommand = INSTALL_RUN;            ppTarget = &MidpCommandState.suiteURL;            MidpCommandState.removeRMS = KNI_TRUE;            MidpCommandState.forceOverwrite = KNI_TRUE;            MidpCommandState.autotest = KNI_TRUE;            /* domain could have already been set */            if (NULL == MidpCommandState.securityDomain) {                MidpCommandState.securityDomain = midpStrdup("maximum");                if (MidpCommandState.securityDomain == NULL) {                    puts("Out of Memory: could not allocate security domain");                    exit(-1);                }            }            MidpCommandState.midletNumber = midpStrdup("1");            if (MidpCommandState.midletNumber == NULL) {                puts("Out of Memory: could not allocate midlet number");                exit(-1);            }        } else if (strcmp(argv[currentArg], "-classpath") == 0) {            currentArg++;            if (currentArg == argc) {                puts("Missing classpath for classpath option");                exit(-1);            }            MidpCommandLineClassPath = argv[currentArg];        } else if (strcmp(argv[currentArg], "-Xdescriptor") == 0 ||                   strcmp(argv[currentArg], "-descriptor") == 0) {            currentArg++;            if (currentArg == argc) {                printf("Missing filename for %s option\n",                       argv[currentArg - 1]);                exit(-1);            }            MidpCommandState.descriptorName = midpStrdup(argv[currentArg]);            if (MidpCommandState.descriptorName == NULL) {                puts("Out of Memory: could not allocate descriptor name");                exit(-1);            }        } else if (strcmp(argv[currentArg], "-domain") == 0) {            currentArg++;            if (currentArg == argc) {                puts("Missing name for security domain option");                exit(-1);            }            MidpCommandState.securityDomain = midpStrdup(argv[currentArg]);            if (MidpCommandState.securityDomain == NULL) {                puts("Out of Memory: could not allocate security domain");                exit(-1);            }        } else if (strcmp(argv[currentArg], "-install") == 0) {            MidpCommandState.initialCommand = INSTALL;            ppTarget = &MidpCommandState.suiteURL;        } else if (strcmp(argv[currentArg], "-force") == 0) {            MidpCommandState.forceOverwrite = KNI_TRUE;        } else if (strcmp(argv[currentArg], "-removeRMS") == 0) {            MidpCommandState.removeRMS = KNI_TRUE;        } else if (strcmp(argv[currentArg], "-run") == 0) {            MidpCommandState.initialCommand = RUN;            ppTarget = &MidpCommandState.suiteStorageName;        } else if (strcmp(argv[currentArg], "-remove") == 0) {            MidpCommandState.initialCommand = REMOVE;            ppTarget = &MidpCommandState.suiteStorageName;        } else if (strcmp(argv[currentArg], "-list") == 0) {            MidpCommandState.initialCommand = LIST;        } else if (strcmp(argv[currentArg], "-storageNames") == 0) {            MidpCommandState.initialCommand = STORAGE_NAMES;        } else if ((*argv[currentArg] == '-')           || (*argv[currentArg] == '+')           || (*argv[currentArg] == '=')) {            int cldcArgs;            /* may be a CLDC arg */            cldcArgs = midp_parseVmArg(currentArg, argc, argv);            if (cldcArgs == 0) {                /*                 * Not a CLDC arg, presume it to be an invalid argument                 */                fprintf(stdout, "Invalid argument \"%s\"\n\n",                        argv[currentArg]);                midpPrintUsage(progName);                exit(-1);            } else {                /*                 * Increase currentArg by the number of arguments processed         * by CLDC. currentArg will be incremented as part of the         * loop, so, we increment by cldcArgs - 1.                 */                currentArg += (cldcArgs - 1);            }        } else if (NULL == *ppTarget) {            *ppTarget = midpStrdup(argv[currentArg]);            if (*ppTarget == NULL) {                puts("Out of Memory: could not allocate command target");                exit(-1);            }        } else if (NULL == MidpCommandState.midletName) {            /*             * assume if there is a non-option parameter after the target             *  it is a name of a MIDlet             */            MidpCommandState.midletName = midpStrdup(argv[currentArg]);            if (MidpCommandState.midletName == NULL) {                puts("Out of Memory: could not allocate midlet name");                exit(-1);            }        }    }    if ((MidpCommandState.initialCommand == INSTALL_RUN ||      MidpCommandState.initialCommand == INSTALL) &&     *ppTarget == NULL) {    fprintf(stdout, "Must specify URL of .jad file\n");    exit(-1);    }    if (MidpCommandState.initialCommand == RUN_CLASS &&            MidpCommandState.midletClassName == NULL &&            MidpCommandState.descriptorName == NULL) {        /*         * Running with no target and no descriptor,         * means to run the Graphical Manager         */        MidpCommandState.initialCommand = MANAGE;    }    MidpCommandState.nextCommand = MidpCommandState.initialCommand;#if ENABLE_JAVA_DEBUGGER    if (debuggerActive && MidpCommandState.autotest) {        fprintf(stderr,                "Can't combine -debugger with -autotest option");        exit(-1);    }#endif    /* convert the midlet suite number if any, to storage name */    if (MidpCommandState.suiteStorageName != NULL) {        int onlyDigits;        int len;        int i;        /* if the storage name only digits, convert it */        onlyDigits = 1;        len = strlen(MidpCommandState.suiteStorageName);        for (i = 0; i < len; i++) {            if (!isdigit(MidpCommandState.suiteStorageName[i])) {                onlyDigits = 0;                break;            }        }        if (onlyDigits) {            char* temp = MidpCommandState.suiteStorageName;            MidpCommandState.suiteStorageName = getStorageNameFromNumber(temp);            midpFree(temp);        }    }}/*========================================================================= * FUNCTION:      midpSetClassPath * OVERVIEW:      Generate a complete classpath in preparation to *                 run the MIDlet Suite stored in 'storageName' * INTERFACE: *   parameters:  storageName:    'C' string of the MIDlet Suite storage *                                 name. *                userClassPath:  (out) The classpath to be used to *                                 to execute the MIDlet Suite. *   returns:     int:            '0' if the classpath was generated *                                 without errors. '-1' if the system *                                 has run out of memory. *=======================================================================*/intmidpSetClassPath(char* storageName, char** userClassPath) {    int newPathLen = 0;    char* newPath = NULL;    char* suitePath = NULL;    if (*userClassPath != NULL) {        midpFree(*userClassPath);        *userClassPath = NULL;    }    if (storageName != NULL) {        suitePath = buildJarPath(storageName);        if (NULL == suitePath) {            return -1;        }    }    /* the base classpath may have been specified */    if (MidpCommandLineClassPath != NULL) {        newPathLen += strlen(MidpCommandLineClassPath) + 1;    }    if (suitePath != NULL) {        newPathLen += strlen(suitePath) + 1;    }    if (0 == newPathLen) {        *userClassPath = (char*)midpStrdup(getStorageRoot());        return 0;    }    newPath = (char*)midpMalloc(newPathLen);    if (NULL == newPath) {        midpFree(suitePath);        return -1;    }    newPath[0] = 0;    if (MidpCommandLineClassPath != NULL) {        strcat(newPath,  MidpCommandLineClassPath);    }    if (suitePath != NULL) {        if (newPath[0] != 0) {            strcat(newPath, getPathSeparator());        }        strcat(newPath, suitePath);        midpFree(suitePath);    }    *userClassPath = newPath;    return 0;}/*========================================================================= * FUNCTION:      midpPrintUsage * OVERVIEW:      Print usage information for MIDP. Usage information *                includes command-line arguments for both the MIDP and *                the underlying VM. * INTERFACE: *   parameters:  progname:  A 'C' string containing the name of the *                            MIDP executable. *   returns:     none *=======================================================================*/voidmidpPrintUsage(char *progname) {    fprintf(stdout, MidpUsageText, progname);    midp_printVmUsage();}/*========================================================================= * FUNCTION:      buildJarPath * OVERVIEW:      Build an absolute pathname to the JAR file for a given *                 MIDlet suite. * INTERFACE: *   parameters:  suiteStorageName:  'C' string of the MIDlet Suite. *   returns:     'C' string:        A 'C' string of the absolute path *                                    to the JAR file. NULL if there *                                    was an out of memory condition. *=======================================================================*/static char*buildJarPath(char* suiteStorageName) {    char* path;    int pathLen = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -