コード例 #1
0
ファイル: test_properties.c プロジェクト: korween/oio-sds
static void
test_set_content_property_again(gs_grid_storage_t * gs)
{
	gs_error_t **err = NULL;
	gchar **result = NULL;

	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	hc_ul_content_from_file(gs, nameCont, "Content", "file_test.txt", err);
	gs_content_t *content = gs_get_content_from_path(container, "Content", err);

	char *props = "key1=value1";
	char *props2 = "key1=value2";

	hc_set_content_property(content, &props, err);
	hc_set_content_property(content, &props2, err);
	g_assert_true(err == NULL);

	hc_get_content_properties(content, &result, err);
	if (strcmp(result[0], "key1=value2"))
		g_test_fail();

	gs_content_free(content);
	test_end(gs, nameRef, container);
}
コード例 #2
0
int astobj2_init(void)
{
#ifdef REF_DEBUG
	char ref_filename[1024];
#endif

	if (container_init() != 0) {
		return -1;
	}

#ifdef REF_DEBUG
	snprintf(ref_filename, sizeof(ref_filename), "%s/refs", ast_config_AST_LOG_DIR);
	ref_log = fopen(ref_filename, "w");
	if (!ref_log) {
		ast_log(LOG_ERROR, "Could not open ref debug log file: %s\n", ref_filename);
	}
#endif

#if defined(AO2_DEBUG)
	ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2));
#endif	/* defined(AO2_DEBUG) */

	ast_register_cleanup(astobj2_cleanup);

	return 0;
}
コード例 #3
0
int GUIAPI 
DefaultContainerProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    PCONTDATA pcontdata = NULL;

    switch (message) {

    case MSG_CREATE:
        if ( !container_init (hWnd) )
            return -1;
        break;

    case MSG_DESTROY:
        pcontdata = (PCONTDATA) GetWindowAdditionalData2 (hWnd);
        container_destroy (hWnd, pcontdata);
        break;

    case MSG_COMMAND:
        pcontdata = (PCONTDATA) GetWindowAdditionalData2 (hWnd);
        SendNotifyMessage (GetParent(pcontdata->hSV), 
                MSG_SVCONTCMD, wParam, lParam);
        break;

    } /* end switch */

    return DefaultPageProc (hWnd, message, wParam, lParam);
}
コード例 #4
0
ファイル: container_t.c プロジェクト: allisonmobley/frozen
container_t *   container_alloc               (void){ // {{{
	container_t           *container;

	if( (container = malloc(sizeof(container_t))) == NULL)
		return NULL;
	
	container_init(container);
	return container;
} // }}}
コード例 #5
0
ファイル: pro.c プロジェクト: SomeCrazyGuy/roguelike
npc* create_npc(int level) {
	npc* ret = calloc(1, sizeof(npc));
	ret->name = npc_names[get_rand(NAME_MAX)];
	ret->hp = 10 + (get_rand(level * 10));
	ret->xp = 0;
	ret->trait = (unsigned char) get_rand(TR_NUM);
	ret->level = (unsigned char) level;
	ret->inventory = *container_init(level);
	container_fill(&(ret->inventory));
	return ret;
}
コード例 #6
0
ファイル: test_properties.c プロジェクト: korween/oio-sds
static void
test_del_container_versioning_void(gs_grid_storage_t * gs)
{
	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	gs_error_t *err = hc_del_container_versioning(container);

	g_assert_true(err == NULL);

	test_end(gs, nameRef, container);
}
コード例 #7
0
ファイル: test_properties.c プロジェクト: korween/oio-sds
static void
test_set_container_quota(gs_grid_storage_t * gs)
{
	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	gs_error_t *err2 = hc_set_container_quota(container, "test");

	g_assert_true(err2 == NULL);

	test_end(gs, nameRef, container);
}
コード例 #8
0
ファイル: test_properties.c プロジェクト: korween/oio-sds
static void
test_set_container_storage_policy_wrong(gs_grid_storage_t * gs)	// to be improved
{
	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	gs_error_t *err =
		hc_set_container_storage_policy(container, "Wrong_stgpol");
	if (err == NULL)
		g_test_fail();

	test_end(gs, nameRef, container);
}
コード例 #9
0
ファイル: test_properties.c プロジェクト: korween/oio-sds
static void
test_set_content_storage_policy_bad_path(gs_grid_storage_t * gs)	// to be improved
{
	gs_error_t **err = NULL;

	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	hc_set_content_storage_policy(container, "Content", "TWOCOPIES", err);
	if (err == NULL)
		g_test_fail();

	test_end(gs, nameRef, container);
}
コード例 #10
0
ファイル: test_properties.c プロジェクト: korween/oio-sds
static void
test_set_content_storage_policy(gs_grid_storage_t * gs)
{
	gs_error_t **err = NULL;

	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	hc_ul_content_from_file(gs, nameCont, "Content", "file_test.txt", err);
	gs_content_t *content = gs_get_content_from_path(container, "Content", err);

	hc_set_content_storage_policy(container, "Content", "TWOCOPIES", err);
	g_assert_true(err == NULL);

	gs_content_free(content);
	test_end(gs, nameRef, container);
}
コード例 #11
0
ファイル: test_properties.c プロジェクト: korween/oio-sds
static void
test_set_content_storage_policy_wrong(gs_grid_storage_t * gs)	// to be improved
{
	gs_error_t **err = NULL;

	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	hc_ul_content_from_file(gs, nameCont, "Content", "file_test.txt", err);
	gs_content_t *content = gs_get_content_from_path(container, "Content", err);

	hc_set_content_storage_policy(container, "Content", "Wrong_stgpol", err);
	if (err == NULL)
		g_test_fail();

	gs_content_free(content);
	test_end(gs, nameRef, container);
}
コード例 #12
0
ファイル: test_properties.c プロジェクト: korween/oio-sds
static void
test_get_content_properties(gs_grid_storage_t * gs)
{
	gs_error_t **err = NULL;
	gchar **result = NULL;

	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	hc_ul_content_from_file(gs, nameCont, "Content", "file_test.txt", err);
	gs_content_t *nameContent =
		gs_get_content_from_path(container, "Content", err);

	hc_get_content_properties(nameContent, &result, err);
	g_assert_true(err == NULL);

	gs_content_free(nameContent);
	test_end(gs, nameRef, container);
}
コード例 #13
0
ファイル: test_list.c プロジェクト: ifzz/libcdf
int test_container_list(void)
{
	int ret = 0;
	allocator_t *allocator;
	iterator_t it,next,end;
	container_t *ct;

	allocator = allocator_creator(ALLOCATOR_TYPE_SYS_MALLOC,0);
	/*
	 *allocator = allocator_creator(ALLOCATOR_TYPE_CTR_MALLOC,0);
	 *allocator_ctr_init(allocator, 0, 0, 1024);
	 */

	dbg_str(DBG_CONTAINER_DETAIL,"list allocator addr:%p",allocator);

	ct = container_creator(CONTAINER_TYPE_LIST,allocator,0);

	container_init(ct,sizeof(struct test));
	/*
	 *container_push_front(ct,&test);
	 *container_push_front(ct,&test2);
	 *container_push_front(ct,&test3);
	 */
	container_push_back(ct,&test);
	container_push_back(ct,&test2);
	container_push_back(ct,&test3);

	dbg_str(DBG_CONTAINER_DETAIL,"iter ordinal");
	for(	container_begin(ct,&it),iterator_next(&it,&next);
			!iterator_equal(&it,container_end(ct,&end));
			it= next,iterator_next(&it,&next))
	{
		print_test((struct test *)iterator_get_pointer(&it));
	}

	container_insert(ct,&it,&test4);

	dbg_str(DBG_CONTAINER_DETAIL,"iter delte test");
	container_for_each_safe(it,next,ct){
		print_test((struct test *)iterator_get_pointer(&it));
	}
コード例 #14
0
ファイル: pro.c プロジェクト: SomeCrazyGuy/roguelike
void set_stage(dungeon* d) {
	d->player.level = (unsigned char) get_level(d);
	d->cur_room = &(d->rooms[d->location]);
	d->player_buff = 0;
	d->npc_buff = 0;
	d->room_chest = NULL;
	d->room_npc	= NULL;

	if(d->cur_room->chest) {
		d->room_chest = container_init((d->height + d->width)/2);
		container_fill(d->room_chest);
	}

	if(d->cur_room->boss_room) {
		d->room_npc = create_npc(get_rand(d->height + d->width));
	}

	if(d->cur_room->cold) {
		d->player_buff -= 1;
	}

	if(d->cur_room->dark) {
		d->npc_buff += 1;
	}

	if(d->cur_room->sky_view) {
		d->player_buff += 2;
	}

	if(d->cur_room->visited) {
		d->player_buff += 1;
	} else {
		d->player.xp += 1;
	}

	d->player_buff += (alignment(d->player.trait, d->player.weapon.trait)-1);
	d->npc_buff += (alignment(d->player.trait, d->player.armor.trait)-1);
	d->player_buff += (alignment(d->player.trait, (unsigned char)d->cur_room->trait)-1);
}
コード例 #15
0
// initializes the identity page table
// the permission for the kernel memory should be PTE_P, PTE_W, and PTE_G,
// while the permission for the rest should be PTE_P and PTE_W.
void idptbl_init(unsigned int mbi_adr)
{
    unsigned int i, j;
    unsigned int perm;
    container_init(mbi_adr);

    i = 0;
    while(i < 1024)
    {
      if (i < 256 || i >= 960)
        perm = PTE_P | PTE_W | PTE_G;
      else
        perm = PTE_P | PTE_W;
      j = 0;
      while(j < 1024)
      {
        set_ptbl_entry_identity(i, j, perm);
        j ++;
      }
      i ++;
    }
}
コード例 #16
0
// initializes the identity page table
// the permission for the kernel memory should be PTE_P, PTE_W, and PTE_G,
// while the permission for the rest should be PTE_P and PTE_W.
void idptbl_init(unsigned int mbi_adr)
{
    // TODO: define your local variables here.
    //
    container_init(mbi_adr);
    // TODO
    int pde_index, ptb_index;
    for (pde_index = 0; pde_index < 1024; pde_index ++)
    {
        for (ptb_index = 0; ptb_index < 1024; ptb_index++)
        {
            unsigned int ph_address = pde_index << 22 + ptb_index << 12;
            if (ph_address < 0x40000000 || ph_address >= 0xF0000000)
            {
                // reserved by kernel
                * (unsigned int *)ph_address = ph_address | 0b111;
            }
            else
            {
                * (unsigned int *)ph_address = ph_address | 0b11;
            }
        }
    }
}
コード例 #17
0
ファイル: test_properties.c プロジェクト: korween/oio-sds
static void
test_set_content_property_wrong(gs_grid_storage_t * gs)	// to be improved
{
	gs_error_t **err = NULL;
	gchar **result = NULL;

	char *nameRef = test_init(gs, "Ref_linked", NULL);
	char *nameCont = gen_random(7);
	gs_container_t *container = container_init(gs, nameCont);

	hc_ul_content_from_file(gs, nameCont, "Content", "file_test.txt", err);
	gs_content_t *content = gs_get_content_from_path(container, "Content", err);

	char *props[] = { "wrong_property" };

	hc_set_content_property(content, props, err);
	if (err == NULL)
		g_test_fail();

	hc_get_content_properties(content, &result, err);

	gs_content_free(content);
	test_end(gs, nameRef, container);
}