예제 #1
0
파일: dump_bom.c 프로젝트: guanwei/xcbuild
int
main(int argc, char **argv)
{
    if (argc != 2) {
        fprintf(stderr, "error: missing argument\n");
        return 1;
    }

    struct bom_context *context;
    context = bom_alloc_load(bom_context_memory_file(argv[1], true));
    if (context == NULL) {
        fprintf(stderr, "error: failed to load BOM\n");
        return 1;
    }

    printf("variables:\n");
    bom_variable_iterate(context, &_bom_variable_dump, NULL);

    printf("\n");

    printf("index:\n");
    bom_index_iterate(context, &_bom_index_dump, NULL);

    return 0;
}
예제 #2
0
파일: dump_bom.c 프로젝트: Ktwu/xcbuild
int
main(int argc, char **argv)
{
    if (argc != 2) {
        fprintf(stderr, "error: missing argument\n");
        return 1;
    }

    struct bom_context *context;
    context = bom_alloc_load(bom_context_memory_file(argv[1], true, 0));
    if (context == NULL) {
        fprintf(stderr, "error: failed to load BOM\n");
        return 1;
    }

    struct bom_header *header = (struct bom_header *)bom_memory(context)->data;
    struct bom_index_header *index_header = (struct bom_index_header *)((uintptr_t)header + ntohl(header->index_offset));
    struct bom_variables *vars = (struct bom_variables *)((uintptr_t)header + ntohl(header->variables_offset));

    printf("Start of memory: %p\n", header);
    printf("Start of index header: %p - %u bytes\n", index_header, (uint32_t)ntohl(header->index_length));
    printf("Start of variable header: %p - %u bytes\n", vars, (uint32_t)ntohl(header->trailer_len));
    printf("\n");

    printf("variables:\n");
    bom_variable_iterate(context, &_bom_variable_dump, NULL);
    printf("\n");

    printf("Number of useful index blocks: %u\n", (uint32_t)ntohl(header->block_count));
    printf("\n");

    printf("index:\n");
    bom_index_iterate(context, &_bom_index_dump, NULL);

    return 0;
}