示例#1
0
static void printProperties(int fd, uint32_t* props, uint64_t* values, int count) {
	drmModePropertyRes* prop;
	int i;

	for (i = 0; i < count; i++) {
		prop = drmModeGetProperty(fd, props[i]);
		printProperty(fd, prop, values[i]);
		drmModeFreeProperty(prop);
    }
}
示例#2
0
void printKextProperty(
    OSKextRef theKext,
    CFStringRef propKey,
    char lineEnd)
{
    CFTypeRef       value = NULL;

    value = OSKextGetValueForInfoDictionaryKey(theKext, propKey);
    if (value) {
        printProperty(NULL, propKey, value, lineEnd);
    }

    return;
}
示例#3
0
void printKextMatchProperty(
    OSKextRef theKext,
    CFStringRef propKey,
    char lineEnd)
{
    CFDictionaryRef personalitiesDict = NULL;
    CFStringRef * names = NULL;
    CFDictionaryRef * personalities = NULL;
    CFIndex numPersonalities;
    CFIndex i;

    personalitiesDict = OSKextGetValueForInfoDictionaryKey(theKext,
        CFSTR(kIOKitPersonalitiesKey));
    if (!personalitiesDict) {
        goto finish;
    }

    numPersonalities = CFDictionaryGetCount(personalitiesDict);
    if (!numPersonalities) {
        goto finish;
    }

    names = malloc(numPersonalities * sizeof(CFStringRef));
    personalities = malloc(numPersonalities * sizeof(CFDictionaryRef));
    if (!names || !personalities) {
        goto finish;
    }

    CFDictionaryGetKeysAndValues(personalitiesDict, (const void **)names,
        (const void **)personalities);

    for (i = 0; i < numPersonalities; i++) {
        CFTypeRef value = CFDictionaryGetValue(personalities[i], propKey);
        if (value) {
            printProperty(names[i], propKey, value, lineEnd);
        }
    }

finish:
    if (names)             free(names);
    if (personalities)     free(personalities);

    return;
}
示例#4
0
/**
 * Lists all installed MIDlet suites. This is an example of how to use
 * the public MIDP API.
 *
 * @param argc The total number of arguments
 * @param argv An array of 'C' strings containing the arguments
 *
 * @return <tt>0</tt> for success, otherwise <tt>-1</tt>
 *
 * IMPL_NOTE: determine if it is desirable for user targeted output
 *       messages to be sent via the log/trace service, or if
 *       they should remain as printf calls
 */
int
listMidlets(int argc, char* argv[]) {
    int   status = -1;
    int   i;
    long  size;
    char* midpHome = NULL;

    (void)argv;                                   /* Avoid compiler warnings */
    if (argc > 1) {
        REPORT_ERROR(LC_AMS, "Too many arguments given");
        fprintf(stderr, "Too many arguments given\n");
        return -1;
    }

    /* get midp home directory, set it */
    midpHome = midpFixMidpHome(argv[0]);
    if (midpHome == NULL) {
        return -1;
    }
    /* set up midpHome before calling initialize */
    midpSetHomeDir(midpHome);

    if (midpInitialize() != 0) {
        REPORT_ERROR(LC_AMS, "Not enough memory");
        fprintf(stderr, "Not enough memory\n");
        return -1;
    }

    do {
        SuiteIdType* pSuites = NULL;
        int numberOfSuites = 0;
        MIDPError err;

        err = midp_get_suite_ids(&pSuites, &numberOfSuites);
        if (err != ALL_OK) {
            REPORT_ERROR1(LC_AMS, "Error in midp_get_suite_ids(), code %d",
                          err);
            fprintf(stderr, "Error in midp_get_suite_ids(), code %d.\n", err);
            break;
        }

        if (numberOfSuites == 0) {
            REPORT_ERROR(LC_AMS, "No MIDlet Suites installed on phone");
            printf("** No MIDlet Suites installed on phone\n");
            status = 0;
            break;
        }

        for (i = 0; i < numberOfSuites; i++) {
            MidpInstallInfo info;
            MidpProperties properties;

            info = midp_get_suite_install_info(pSuites[i]);
            if (BAD_ID_INFO_STATUS(info)) {
                REPORT_ERROR(LC_AMS, "Suite list is corrupt");
                fprintf(stderr, "Suite list is corrupt\n");
                break;
            }

            if (OUT_OF_MEM_INFO_STATUS(info)) {
                REPORT_ERROR(LC_AMS, "Out Of Memory for Info");
                fprintf(stderr, "Out Of Memory for Info\n");
                break;
            }

            if (SUITE_CORRUPTED_ERR_STATUS(info)) {
                /*
                 * Installinfo is not initialsed in case of an error
                 * so no need to free it
                 */
                REPORT_ERROR1(LC_AMS, "Error : Suite %d is corrupted", (i+1));
                fprintf(stderr, "Error : Suite %d is corrupted\n", (i+1));
                continue;
            }

            if (READ_ERROR_INFO_STATUS(info)) {
                REPORT_ERROR(LC_AMS, "Corrupt install info");
                fprintf(stderr, "Corrupt install info\n");
                break;
            }

            properties = midp_get_suite_properties(pSuites[i]);
            if (OUT_OF_MEM_PROPERTY_STATUS(properties)) {
                midp_free_install_info(&info);
                midp_free_properties(&properties);
                REPORT_ERROR(LC_AMS, "Out Of Memory for properties");
                fprintf(stderr, "Out Of Memory for properties\n");
                break;
            }

            if (CORRUPTED_PROPERTY_STATUS(properties)) {
                midp_free_install_info(&info);
                midp_free_properties(&properties);
                REPORT_ERROR1(LC_AMS, "Error : Suite %d is corrupted", (i+1));
                fprintf(stderr, "Error : Suite %d is corrupted\n", (i+1));
                continue;
            }

            if (READ_ERROR_PROPERTY_STATUS(properties)) {
                midp_free_install_info(&info);
                midp_free_properties(&properties);
                REPORT_ERROR(LC_AMS, "Corrupt properties");
                fprintf(stderr, "Corrupt properties\n");
                break;
            }

            printf("[%d]\n", (i + 1));
            printProperty("  Name: ", &SUITE_NAME_PROP, properties);
            printProperty("  Vendor: ", &SUITE_VENDOR_PROP, properties);
            printProperty("  Version: ", &SUITE_VERSION_PROP, properties);
            printProperty("  Description: ", &SUITE_DESC_PROP, properties);

            if (info.authPathLen > 0) {
                int j;

                puts("  Authorized by: ");
                for (j = 0; j < info.authPathLen; j++) {
                    print_field("    ", &info.authPath_as[j]);
                }
            }

            print_field("  SecurityDomain: ", &info.domain_s);
            printf("  Verified: %s\n",
                (info.pVerifyHash != NULL ? "true" : "false"));
            printf("  Suite ID: %ld\n", (long)pSuites[i]);
            print_field("  JAD URL: ", &info.jadUrl_s);
            print_field("  JAR URL: ", &info.jarUrl_s);
            size = midp_get_suite_storage_size(pSuites[i]);
            if (size < 0) {
                fprintf(stderr, "Ran out of memory getting the size\n");
            } else {
                printf("  Size: %ldK\n", (size + 1023) / 1024);
            }

            midp_free_install_info(&info);
            midp_free_properties(&properties);
        }

        midp_free_suite_ids(pSuites, numberOfSuites);

        status = 0;
    } while (0);

    midpFinalize();

    return status;
}