Exemple #1
0
static struct fmap *fmap_create_test(void)
{
	struct fmap *fmap;
	uint64_t base = 0;
	uint32_t size = 0x100000;
	char name[] = "test_fmap";

	status = fail;

	fmap = fmap_create(base, size, (uint8_t *)name);
	if (!fmap)
		return NULL;

	if (memcmp(&fmap->signature, FMAP_SIGNATURE, strlen(FMAP_SIGNATURE))) {
		printf("FAILURE: signature is incorrect\n");
		goto fmap_create_test_exit;
	}

	if ((fmap->ver_major != FMAP_VER_MAJOR) ||
	    (fmap->ver_minor != FMAP_VER_MINOR)) {
		printf("FAILURE: version is incorrect\n");
		goto fmap_create_test_exit;
	}

	if (fmap->base != base) {
		printf("FAILURE: base is incorrect\n");
		goto fmap_create_test_exit;
	}

	if (fmap->size != 0x100000) {
		printf("FAILURE: size is incorrect\n");
		goto fmap_create_test_exit;
	}

	if (strcmp((char *)fmap->name, "test_fmap")) {
		printf("FAILURE: name is incorrect\n");
		goto fmap_create_test_exit;
	}

	if (fmap->nareas != 0) {
		printf("FAILURE: number of areas is incorrect\n");
		goto fmap_create_test_exit;
	}

	status = pass;
fmap_create_test_exit:
	/* preserve fmap if all went well */
	if (status == fail) {
		fmap_destroy(fmap);
		fmap = NULL;
	}
	return fmap;
}
Exemple #2
0
void http_init() {
    if (NULL == (defined_status_map = fmap_create_int())) {
        fatal("http status map init faild");
    }
    if (NULL == (defined_header_map = fmap_create())) {
        fatal("http header map init faild");
    }

    int len = sizeof(defined_status) / sizeof(defined_status[0]);
    for (int i = 0; i < len; ++i) {
        fmap_add(defined_status_map, (void *) defined_status[i].status, &defined_status[i]);
    }

    len = sizeof(defined_headers) / sizeof(defined_headers[0]);
    for (int i = 0; i < len; ++i) {
        fmap_add(defined_header_map, defined_headers[i].key, &defined_headers[i]);
    }
}