Example #1
0
File: nfa.c Project: march1896/snev
nfa* nfa_star  (nfa* old) {
	atm_context* context = old->context;
	atm* fa = atm_create(context);
	atm_state *source, *dest;

	dbg_assert(ilist_size(old->accept_states) == 1);

	foreach_v(ilist_itr_begin(old->states), ilist_itr_end(old->states), add_state, fa);
	source = atm_state_create(fa);
	dest   = atm_state_create(fa);
	dbg_assert(source != NULL && dest != NULL);
	ilist_add_back(fa->states, source);
	ilist_add_back(fa->states, dest);

	fa->start_state = source;
	ilist_add_back(fa->accept_states, dest);

	atm_transform_create(fa, source, old->start_state, Epsilon);
	atm_transform_create(fa, source, dest, Epsilon);
	atm_transform_create(fa, (atm_state*)ilist_front(old->accept_states), dest, Epsilon);
	atm_transform_create(fa, (atm_state*)ilist_front(old->accept_states), old->start_state, Epsilon);

	ilist_clear(old->accept_states);
	ilist_clear(old->states);
	old->start_state = NULL;
	old->lifestate = atm_joined;

	fa->lifestate = atm_active;
	return fa;
}
Example #2
0
/* This function inits the counters */
void destroy_counters(void)
{
	sd.changes = 0UL;
	sd.crypto = 0UL;
	sd.acct_changes = 0UL;
	sd.good_logins = 0UL;
	sd.bad_logins = 0UL;
	sd.good_auth = 0UL;
	sd.bad_auth = 0UL;
	sd.events = 0UL;
	sd.avcs = 0UL;
	sd.mac = 0UL;
	sd.failed_syscalls = 0UL;
	sd.anomalies = 0UL;
	sd.responses = 0UL;
	slist_clear(&sd.users);
	slist_clear(&sd.terms);
	slist_clear(&sd.files);
	slist_clear(&sd.hosts);
	slist_clear(&sd.exes);
	slist_clear(&sd.avc_objs);
	slist_clear(&sd.keys);
	ilist_clear(&sd.pids);
	ilist_clear(&sd.sys_list);
	ilist_clear(&sd.anom_list);
	ilist_create(&sd.mac_list);
	ilist_clear(&sd.resp_list);
	ilist_create(&sd.crypto_list);
}
Example #3
0
int main(void)
{
	int i = 0;
	ilist e;
	int_node *node;

	ilist_create(&e);

	ilist_add_if_uniq(&e, 6, 0);
	ilist_add_if_uniq(&e, 5, 0);
	ilist_add_if_uniq(&e, 7, 0);
	ilist_add_if_uniq(&e, 1, 0);
	ilist_add_if_uniq(&e, 8, 0);
	ilist_add_if_uniq(&e, 2, 0);
	ilist_add_if_uniq(&e, 9, 0);
	ilist_add_if_uniq(&e, 0, 0);
	ilist_add_if_uniq(&e, 4, 0);
	ilist_add_if_uniq(&e, 3, 0);

	ilist_first(&e);
	do {
		node = ilist_get_cur(&e);
		if (i != node->num) {
			printf("Test failed - i:%d != num:%d\n", i, node->num);
			return 1;
		}
		i++;
	} while ((node = ilist_next(&e)));
	
	ilist_clear(&e);
	printf("ilist test passed\n");
	return 0;
}
Example #4
0
void
kill_stack_ocean(int who)
{
  static ilist l = NULL;
  int i;
  int where;

  ilist_clear(&l);

  loop_stack(who, i) {
    ilist_append(&l, i);
  }
Example #5
0
File: nfa.c Project: march1896/snev
nfa* nfa_union (nfa* first, nfa* second) {
	atm_context* context = first->context;
	atm* fa = atm_create(context);
	atm_state *source, *dest;

	dbg_assert(first->context == second->context);
	dbg_assert(ilist_size(first->accept_states) == 1);
	dbg_assert(ilist_size(second->accept_states) == 1);

	foreach_v(ilist_itr_begin(first->states), ilist_itr_end(first->states), add_state, fa);
	foreach_v(ilist_itr_begin(second->states), ilist_itr_end(second->states), add_state, fa);
	source = atm_state_create(fa);
	dest   = atm_state_create(fa);
	dbg_assert(source != NULL && dest != NULL);
	ilist_add_back(fa->states, source);
	ilist_add_back(fa->states, dest);

	fa->start_state = source;
	ilist_add_back(fa->accept_states, dest);

	atm_transform_create(fa, source, first->start_state, Epsilon);
	atm_transform_create(fa, source, second->start_state, Epsilon);
	atm_transform_create(fa, (atm_state*)ilist_front(first->accept_states), dest, Epsilon);
	atm_transform_create(fa, (atm_state*)ilist_front(second->accept_states), dest, Epsilon);

	ilist_clear(first->accept_states);
	ilist_clear(first->states);
	first->start_state = NULL;
	first->lifestate = atm_joined;

	ilist_clear(second->accept_states);
	ilist_clear(second->states);
	second->start_state = NULL;
	second->lifestate = atm_joined;

	fa->lifestate = atm_active;
	return fa;
}
Example #6
0
int
v_ct(struct command *c)
{
  int i;

  loop_loc(i) {
    if (subkind(i) == sub_city) {
      ilist_clear((ilist *) & bx[i]->trades);
    }
  }
  next_loc;

  location_trades();

  return TRUE;
}
void
all_here(int who, ilist *l)
{
	int i;
	struct loc_info *p;

	assert(valid_box(who));

	ilist_clear(l);

	p = rp_loc_info(who);

	if (p == NULL)
		return;

	for (i = 0; i < ilist_len(p->here_list); i++)
		add_here(p->here_list[i], l);
}
void
all_stack(int who, ilist *l)
{
	int i;
	struct loc_info *p;

	assert(valid_box(who));

	ilist_clear(l);
	ilist_append(l, who);

	p = rp_loc_info(who);

	if (p == NULL)
		return;

	for (i = 0; i < ilist_len(p->here_list); i++)
		if (kind(p->here_list[i]) == T_char)
			add_char_here(p->here_list[i], l);
}
Example #9
0
int main(void)
{
	int i = 0;
	ilist e;
	int_node *node;

	ilist_create(&e);

	// This first test checks to see if list is 
	// created in a numeric order
	ilist_add_if_uniq(&e, 6, 0);
	ilist_add_if_uniq(&e, 5, 0);
	ilist_add_if_uniq(&e, 7, 0);
	ilist_add_if_uniq(&e, 1, 0);
	ilist_add_if_uniq(&e, 8, 0);
	ilist_add_if_uniq(&e, 2, 0);
	ilist_add_if_uniq(&e, 9, 0);
	ilist_add_if_uniq(&e, 0, 0);
	ilist_add_if_uniq(&e, 4, 0);
	ilist_add_if_uniq(&e, 3, 0);

	ilist_first(&e);
	do {
		node = ilist_get_cur(&e);
		if (i != node->num) {
			printf("Test failed - i:%d != num:%d\n", i, node->num);
			return 1;
		}
		i++;
	} while ((node = ilist_next(&e)));

	ilist_clear(&e);
	puts("starting sort test");

	// Now test to see if the sort function works
	// Fill the list exactly backwards
	ilist_add_if_uniq(&e, 3, 0);
	ilist_add_if_uniq(&e, 3, 0);
	ilist_add_if_uniq(&e, 4, 0);
	ilist_add_if_uniq(&e, 3, 0);
	ilist_add_if_uniq(&e, 4, 0);
	ilist_add_if_uniq(&e, 2, 0);
	ilist_add_if_uniq(&e, 4, 0);
	ilist_add_if_uniq(&e, 2, 0);
	ilist_add_if_uniq(&e, 4, 0); 
	ilist_add_if_uniq(&e, 1, 0);

	ilist_sort_by_hits(&e);

	i = 0;
	ilist_first(&e);
	do {
		node = ilist_get_cur(&e);
		if (node->hits != (4-i)) {
			printf("Sort test failed - i:%d != ihits:%d\n", i, node->hits);
			return 1;
		}
		i++;
	} while ((node = ilist_next(&e)));
	
	ilist_clear(&e);

	printf("ilist tests passed\n");
	return 0;
}
Example #10
0
void free_config(prelude_conf_t *config)
{
	free((void *)config->profile);
	ilist_clear(&config->watched_accounts);
}
Example #11
0
/*! \brief Do the Quest Info menu
 *
 * Show the current list of quest information items
 * \sa ILIST
 * \author PH
 * \date 20050429
 */
static void quest_info(void)
{
    int ii = 0;
    int i, base;

    /* Call into the script */
    ilist_clear(&quest_list);
    do_questinfo();
    if (quest_list.count == 0)
    {
        /* There was nothing.. */
        play_effect(SND_BAD, 128);
        return;
    }

    while (1)
    {
        timer_count = 0;
        drawmap();
        base = ii - ii % 10;
        menubox(double_buffer, 88 + xofs, 92 + yofs, 18, 10, BLUE);
        menubox(double_buffer, 88 + xofs, 188 + yofs, 18, 3, BLUE);
        for (i = 0; i < 10; ++i)
        {
            if (i + base < quest_list.count)
            {
                print_font(double_buffer, 104 + xofs, 100 + 8 * i + yofs, quest_list.root[i + base].key, FNORMAL);
            }
        }
        draw_sprite(double_buffer, menuptr, 88 + xofs, 100 + 8 * (ii - base) + yofs);
        if (ii < quest_list.count)
        {
            print_font(double_buffer, 96 + xofs, 196 + yofs, quest_list.root[ii].text, FNORMAL);
        }
        blit2screen(xofs, yofs);
        readcontrols();
        if (PlayerInput.up)
        {
            --ii;
            play_effect(SND_CLICK, 128);
            unpress();
        }
        if (PlayerInput.down)
        {
            ++ii;
            play_effect(SND_CLICK, 128);
            unpress();
        }
        if (PlayerInput.left)
        {
            ii -= 10;
            play_effect(SND_CLICK, 128);
            unpress();
        }
        if (PlayerInput.right)
        {
            ii += 10;
            play_effect(SND_CLICK, 128);
            unpress();
        }
        if (ii < 0)
        {
            ii = quest_list.count - 1;
        }
        if (ii >= quest_list.count)
        {
            ii = 0;
        }
        if (PlayerInput.balt || PlayerInput.bctrl)
        {
            unpress();
            return;
        }
    }
}