Пример #1
0
plist windows_list_create(plist ests_factorizations) {

    my_assert(ests_factorizations!=NULL);

    DEBUG("Creazione della lista delle finestre di genomica da considerare come fattori unici");

    pEST p;
    plistit plist_it_id, plist_it_f;
    pfactorization pfact;
    pfactor pf;
    plistit plist_it_factor;

    plist list_of_factors=list_create();

    plist_it_id=list_first(ests_factorizations);

    while(listit_has_next(plist_it_id)) {
        p= listit_next(plist_it_id);
        plist_it_f=list_first(p->factorizations);

        while(listit_has_next(plist_it_f)) {
            pfact=listit_next(plist_it_f);
            plist_it_factor=list_first(pfact);

            //fprintf(stdout, "EST %s\n", p->info->EST_id);

            while(listit_has_next(plist_it_factor)) {
                pf=listit_next(plist_it_factor);

                list_of_factors=update_windows(list_of_factors,pf);

                /*fprintf(stdout, "add %d-%d\n", pf->GEN_start, pf->GEN_end);
                 fprintf(stdout, "Windows: ");
                 plistit t_it=list_first(list_of_factors);
                 while(listit_has_next(t_it)){
                  pfactor win=(pfactor)listit_next(t_it);
                  fprintf(stdout, "%d-%d ", win->GEN_start, win->GEN_end);
                 }
                 fprintf(stdout, "\n");
                 listit_destroy(t_it);*/

            }
            listit_destroy(plist_it_factor);
        }
        listit_destroy(plist_it_f);
    }

    listit_destroy(plist_it_id);

    return list_of_factors;
}
Пример #2
0
/*
 * Return the maximum age a cache entry can have before it is purged
 * from the cache.
 *
 * A maxage of 0 indicates that the cache entries should never be
 * purged, in effect disabling the aging of cache entries.
 */
static int
cache_maxage(void)
{
	int age = 0;
	LIST *var = var_get( "DEPCACHEMAXAGE" );

	if( list_first(var) ) {
		age = atoi( list_value(list_first(var)) );
		if( age < 0 )
			age = 0;
	}

	return age;
}
Пример #3
0
/** Get next ready segment from incoming queue.
 *
 * Return the segment with the earliest sequence number if it is ready.
 * A segment is ready if its SEG.SEQ is earlier or equal to RCV.NXT.
 *
 * @param iqueue	Incoming queue
 * @param seg		Place to store pointer to segment
 * @return		EOK on success, ENOENT if no segment is ready
 */
int tcp_iqueue_get_ready_seg(tcp_iqueue_t *iqueue, tcp_segment_t **seg)
{
	tcp_iqueue_entry_t *iqe;
	link_t *link;

	log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_get_ready_seg()");

	link = list_first(&iqueue->list);
	if (link == NULL) {
		log_msg(LOG_DEFAULT, LVL_DEBUG, "iqueue is empty");
		return ENOENT;
	}

	iqe = list_get_instance(link, tcp_iqueue_entry_t, link);

	while (!seq_no_segment_acceptable(iqueue->conn, iqe->seg)) {
		log_msg(LOG_DEFAULT, LVL_DEBUG, "Skipping unacceptable segment (RCV.NXT=%"
		    PRIu32 ", RCV.NXT+RCV.WND=%" PRIu32 ", SEG.SEQ=%" PRIu32
		    ", SEG.LEN=%" PRIu32 ")", iqueue->conn->rcv_nxt,
		    iqueue->conn->rcv_nxt + iqueue->conn->rcv_wnd,
		    iqe->seg->seq, iqe->seg->len);

		list_remove(&iqe->link);
		tcp_segment_delete(iqe->seg);

         	link = list_first(&iqueue->list);
		if (link == NULL) {
			log_msg(LOG_DEFAULT, LVL_DEBUG, "iqueue is empty");
			return ENOENT;
		}

		iqe = list_get_instance(link, tcp_iqueue_entry_t, link);
	}

	/* Do not return segments that are not ready for processing */
	if (!seq_no_segment_ready(iqueue->conn, iqe->seg)) {
		log_msg(LOG_DEFAULT, LVL_DEBUG, "Next segment not ready: SEG.SEQ=%u, "
		    "RCV.NXT=%u, SEG.LEN=%u", iqe->seg->seq,
		    iqueue->conn->rcv_nxt, iqe->seg->len);
		return ENOENT;
	}

	log_msg(LOG_DEFAULT, LVL_DEBUG, "Returning ready segment %p", iqe->seg);
	list_remove(&iqe->link);
	*seg = iqe->seg;
	free(iqe);

	return EOK;
}
Пример #4
0
void
config_dump( config_t *c){
  LOGDEBUG( "Config Dump: *LDAP:*");
  LOGDEBUG_IFSET(c->ldap->uri,"  URI");
  LOGDEBUG_IFSET(c->ldap->binddn,"  BindDN");
  LOGDEBUG( "  SSL: %s", c->ldap->ssl );
  LOGDEBUG( "  LDAP VERSION: %d", c->ldap->version );
  LOGDEBUG( "  LDAP TIMEOUT: %d", c->ldap->timeout );
  /* Dump each profiles */
  list_item_t *item;
  profile_config_t *p;
  for( item = list_first( c->profiles ); item; item = item->next){
    p = item->data;
    LOGDEBUG( "*Custom Profile:*" );
    LOGDEBUG_IFSET(p->basedn, "  BaseDN");
    LOGDEBUG( "  Search Scope: %s", config_search_scope_to_string( p->search_scope ) );
    LOGDEBUG( "  Search filter: %s", p->search_filter );
    LOGDEBUG_IFSET(p->groupdn,"  GroupDN");
    LOGDEBUG_IFSET(p->group_search_filter, "  Group Search Filter");
    LOGDEBUG_IFSET(p->member_attribute,"  Member Attribute");
    LOGDEBUG( "  Enable PF: %s", ternary_to_string(p->enable_pf));
    LOGDEBUG( "  Default PF rules: %s", p->default_pf_rules ? p->default_pf_rules : "Undefined" );
#ifdef ENABLE_LDAPUSERCONF
    LOGDEBUG( "  Default Profile DN: %s", p->default_profiledn ? p->default_profiledn : "Undefined" );
#endif

  }
}
Пример #5
0
void
ship_fire(SHIP *ship, ALLEGRO_TIMER *timer)
{
  LIST *head = NULL;
  MISSILE *missile = NULL;
  VECTOR position;

  /* full button press required for each missile */
  if(ship->fire_debounce)
    return;

  /* find an inactive missile to launch */
  head = list_first(ship->missiles);
  while(head && !missile) {
    MISSILE *m = (MISSILE *) head->data;
    if(!m->active)
      missile = m;

    head = head->next;
  }

  /* all missiles in use? */
  if(missile == NULL)
    return;

  position.x = ship->position->x;
  position.y = ship->position->y;

  missile_fire(missile, &position, ship->angle, timer);
  ship->fire_debounce = true;
}
Пример #6
0
/*
 * Funzione che restituisce la posizione del fattore all'interno della lista di fattori unici.
 * Se is_not_window e' true la ricerca e' precisa, altrimenti la ricerca e' di contenimento (da usare
 * nel caso in cui i fattori unici siano finestre di genomica (vedi procedura windows_list_create())
 */
int get_factor_position(pfactor factor,plist factors, bool is_not_window)
{

    my_assert((factor!=NULL)&&(factors!=NULL));


    pfactor pf;
    plistit plist_it_factor;
    int pos=-1;

    //fprintf(stdout, "\t\tSearch for %d-%d\n", factor->GEN_start, factor->GEN_end);

    plist_it_factor=list_first(factors);

    while(listit_has_next(plist_it_factor)) {

        pos=pos+1;
        pf=listit_next(plist_it_factor);

        //fprintf(stdout, "\t\t\t...%d-%d\n", pf->GEN_start, pf->GEN_end);

        if(equal_factor(pf,factor,is_not_window)) {
            break;
        }
    }
    listit_destroy(plist_it_factor);

    //fprintf(stdout, "\t\t\tPos=%d\n", pos);

    return pos;
}
int main()
{
	list_t l = list_create(5);
	if (!l)
	{
		printf("list create error.\n");
		return -1;
	}
	assert(1 == list_is_empty(l));
	assert(0 == list_insert(l, (position_t)l, 333));
	position_t p = list_first(l);
	assert(p->elm == 333);
	p = list_find(l, 333);
	assert(0 == list_insert(l, p, 444));
	assert(p->elm == 333);
	p = list_find_previous(l, 444);
	assert(p->elm == 333);
	assert(p->next->elm == 444);
	p = list_find(l, 444);
	assert(p->elm == 444);
	list_make_empty(l);
	assert(NULL == list_find(l, 444));
	list_destroy(l);
	return 0;
}
Пример #8
0
void io_libraryRelease(io_library_t *library)
{
	spinlock_lock(&library->lock);

	if((-- library->refCount) == 0)
	{
		struct io_dependency_s *dependency = list_first(library->dependencies);
		while(dependency)
		{
			io_libraryRelease(dependency->library);
			dependency = dependency->next;
		}

		io_storeRemoveLibrary(library);

		if(library->vmemory)
			vm_free(vm_getKernelDirectory(), library->vmemory, library->pages);

		if(library->pmemory)
			pm_free(library->pmemory, library->pages);

		hfree(NULL, library->path);
		list_destroy(library->dependencies);
		return;
	}

	spinlock_unlock(&library->lock);
}
Пример #9
0
LIST *
compile_rule(
	PARSE	*parse,
	LOL	*args,
	int	*jmp )
{
	LOL	nargs[1];
	LIST	*result = 0;
	LIST	*ll;
	LISTITEM *l;
	PARSE	*p;

	/* list of rules to run -- normally 1! */

	ll = (*parse->left->func)( parse->left, args, jmp );

	/* Build up the list of arg lists */

	lol_init( nargs );

	for( p = parse->right; p; p = p->left )
	    lol_add( nargs, (*p->right->func)( p->right, args, jmp ) );

	/* Run rules, appending results from each */

	for( l = list_first(ll); l; l = list_next( l ) ) {
	    list_free(result); /* Keep only last result */
	    result = evaluate_rule( list_value(l), nargs, result );
	}

	list_free( ll );
	lol_free( nargs );

	return result;
}
Пример #10
0
int smallest(list_t list)
// REQUIRES: list is not empty
// EFFECTS: returns smallest element in list
{
	return compare_help(list_first(list),
		list_rest(list), min);
}
Пример #11
0
int largest(list_t list)
// REQUIRES: list is not empty
// EFFECTS: returns largest element in list
{
	return compare_help(list_first(list),
		list_rest(list), max);
}
Пример #12
0
/**
 * Export tld struct to xml file
 *
 * @param file is the name that will be used
 * @return void - no returend value
 *
 */
void xml_export_tld(char *file)
{
    FILE *ptr;
    TLD *t;
    lnode_t *tn;

    ptr = new_xml(file);

    SET_SEGV_LOCATION();

    if (ptr) {
        xml_write_header(ptr);
        xml_write_block_top(ptr, "tld");
        list_sort(Thead, sortusers);
        tn = list_first(Thead);
        while (tn) {
            t = lnode_get(tn);
            denora_cmd_pong(ServerName, ServerName);
            xml_write_block_top(ptr, "domain");
            xml_write_tag(ptr, "countrycode", t->countrycode);
            xml_write_tag(ptr, "country", t->country);
            xml_write_tag_int(ptr, "current", t->count);
            xml_write_tag_int(ptr, "overall", t->overall);
            xml_write_block_bottom(ptr, "domain");
            tn = list_next(Thead, tn);
        }
        xml_write_block_bottom(ptr, "tld");
        xml_write_footer(ptr);
    }
}
Пример #13
0
/**
 * Export ctcp struct to xml file
 *
 * @param file is the name that will be used
 * @return void - no returend value
 *
 */
void xml_export_ctcp(char *file)
{
    FILE *ptr;
    CTCPVerStats *c;
    lnode_t *tn;

    ptr = new_xml(file);

    SET_SEGV_LOCATION();

    if (ptr) {
        xml_write_header(ptr);

        xml_write_block_top(ptr, "ctcp");

        tn = list_first(CTCPhead);
        while (tn) {
            c = lnode_get(tn);
            xml_write_block_top(ptr, "client");
            xml_write_tag(ptr, "version", c->version);
            xml_write_tag_int(ptr, "current", c->count);
            xml_write_tag_int(ptr, "overall", c->overall);
            xml_write_block_bottom(ptr, "client");
            tn = list_next(CTCPhead, tn);
        }
        xml_write_block_bottom(ptr, "ctcp");
        xml_write_footer(ptr);
    }
}
Пример #14
0
/** Get a received message.
 *
 * Pull one message from the association's receive queue.
 */
int udp_assoc_recv(udp_assoc_t *assoc, udp_msg_t **msg, udp_sock_t *fsock)
{
	link_t *link;
	udp_rcv_queue_entry_t *rqe;

	log_msg(LVL_DEBUG, "udp_assoc_recv()");

	fibril_mutex_lock(&assoc->lock);
	while (list_empty(&assoc->rcv_queue)) {
		log_msg(LVL_DEBUG, "udp_assoc_recv() - waiting");
		fibril_condvar_wait(&assoc->rcv_queue_cv, &assoc->lock);
	}

	log_msg(LVL_DEBUG, "udp_assoc_recv() - got a message");
	link = list_first(&assoc->rcv_queue);
	rqe = list_get_instance(link, udp_rcv_queue_entry_t, link);
	list_remove(link);
	fibril_mutex_unlock(&assoc->lock);

	*msg = rqe->msg;
	*fsock = rqe->sp.foreign;
	free(rqe);

	return EOK;
}
Пример #15
0
int
main(int argc, char *argv[])
{

    list_t *l = list_create(LISTCOUNT_T_MAX);
    entry_t *e = (entry_t *)u_malloc(sizeof(entry_t));
    char *x = "foo";
    e->name = x;
    e->n.list_data = (void *)"bar";

    list_append(l, &e->n);


    entry_t *y = (entry_t *)list_first(l);
    while (y != NULL) {
        char *name = (char *)y->n.list_data;
        e = (entry_t *)y;
        printf("%s\n", name);
        printf("%s\n", y->name);
        y = (entry_t *)list_next(l, &(y->n) );
    }
    
    
    return  0;
}
Пример #16
0
void
test_list(void)
{
    struct histogram *hist1 = histogram_create("hist1");
    struct histogram *hist2 = histogram_create("hist2");
    struct histogram *hist3 = aim_zmalloc(sizeof(*hist3));
    histogram_register(hist3, "hist3");

    AIM_ASSERT(!strcmp(hist1->name, "hist1"));
    AIM_ASSERT(!strcmp(hist2->name, "hist2"));
    AIM_ASSERT(!strcmp(hist3->name, "hist3"));

    struct list_head *head = histogram_list();

    struct list_links *cur = list_first(head);
    AIM_ASSERT(container_of(cur, links, struct histogram) == hist1);

    cur = cur->next;
    AIM_ASSERT(container_of(cur, links, struct histogram) == hist2);

    cur = cur->next;
    AIM_ASSERT(container_of(cur, links, struct histogram) == hist3);

    AIM_ASSERT(cur->next == &head->links);

    histogram_destroy(hist1);
    histogram_destroy(hist2);
    histogram_unregister(hist3);
    aim_free(hist3);
}
Пример #17
0
/** Insert segment into incoming queue.
 *
 * @param iqueue	Incoming queue
 * @param seg		Segment
 */
void tcp_iqueue_insert_seg(tcp_iqueue_t *iqueue, tcp_segment_t *seg)
{
	tcp_iqueue_entry_t *iqe;
	tcp_iqueue_entry_t *qe;
	link_t *link;
	log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_iqueue_insert_seg()");

	iqe = calloc(1, sizeof(tcp_iqueue_entry_t));
	if (iqe == NULL) {
		log_msg(LOG_DEFAULT, LVL_ERROR, "Failed allocating IQE.");
		return;
	}

	iqe->seg = seg;

	/* Sort by sequence number */

	link = list_first(&iqueue->list);
	while (link != NULL) {
		qe = list_get_instance(link,
		    tcp_iqueue_entry_t, link);

		if (seq_no_seg_cmp(iqueue->conn, iqe->seg, qe->seg) >= 0)
			break;
	}

	if (link != NULL)
		list_insert_before(&iqe->link, &qe->link);
	else
		list_append(&iqe->link, &iqueue->list);
}
Пример #18
0
/*
 * Profiling shows us that we must pre-render the menu and store
 * the results internally. The menu struct contains a cstring member,
 * rendered, which initially is NULL. Render the data to that buffer
 * and return a pointer to it, or NULL if an error occurs.
 */
int html_menu_render(html_menu m, cstring buffer)
{
    const char *text, *link, *image, *hover_image;
    html_menu submenu;
    list_iterator i;

    text = html_menu_get_text(m);
    link = html_menu_get_link(m);
    image = html_menu_get_image(m);
    hover_image = html_menu_get_hover_image(m);
    (void)image;
    (void)hover_image;

    if (text != NULL) {
        if (link != NULL) {
            if (!cstring_printf(buffer, "<a href='%s'>%s</a><br>\n", link, text))
                return 0;
        }
        else if (!cstring_concat(buffer, text))
            return 0;
    }

    if (m->items != NULL) {
        for (i = list_first(m->items); !list_end(i); i = list_next(i)) {
            submenu = list_get(i);
            if (!html_menu_render(submenu, buffer))
                return 0;
        }
    }

    return 1;
}
Пример #19
0
/** Register clonable service.
 *
 * @param service Service to be registered.
 * @param phone   Phone to be used for connections to the service.
 * @param call    Pointer to call structure.
 *
 */
void register_clonable(sysarg_t service, sysarg_t phone, ipc_call_t *call,
    ipc_callid_t callid)
{
	link_t *req_link;

	req_link = list_first(&cs_req);
	if (req_link == NULL) {
		/* There was no pending connection request. */
		printf("%s: Unexpected clonable server.\n", NAME);
		ipc_answer_0(callid, EBUSY);
		return;
	}
	
	cs_req_t *csr = list_get_instance(req_link, cs_req_t, link);
	list_remove(req_link);
	
	/* Currently we can only handle a single type of clonable service. */
	assert(csr->service == SERVICE_LOAD);
	
	ipc_answer_0(callid, EOK);
	
	ipc_forward_fast(csr->callid, phone, IPC_GET_ARG2(csr->call),
	    IPC_GET_ARG3(csr->call), 0, IPC_FF_NONE);
	
	free(csr);
	ipc_hangup(phone);
}
Пример #20
0
static size_t reload_cache(void)
{
    size_t files = 0;
    list lst;

    if ( (lst = list_new()) == NULL)
        goto err;
    else if (!walk_all_directories(g_dirs, g_patterns, g_npatterns, lst, 1))
        goto err;
    else if (!filecache_invalidate(g_filecache))
        goto err;
    else {
        list_iterator li;
        unsigned long id;
        for (li = list_first(lst); !list_end(li); li = list_next(li)) {
            fileinfo fi = list_get(li);

            /* Now filecache owns the fileinfo objects */
            if (!filecache_add(g_filecache, fi, 1, &id))
                goto err;

            files++;
        }
    }

    sublist_free(lst);
    return files;

err:
    list_free(lst, (dtor)fileinfo_free);
    return 0;
}
Пример #21
0
void html_ctcp_table(FILE * ptr)
{
    CTCPVerStats *c;
    lnode_t *tn;
    char *tempc;
    int x = 0;

    if (ptr) {
        fprintf(ptr, "%s", getstring(NULL, HTML_CTCP_HEADER));
        list_sort(CTCPhead, sortctcp);
        tn = list_first(CTCPhead);
        while (tn) {
            c = lnode_get(tn);
            if (c->overall) {
                tempc = char_encode(c->version);
                dfprintf(ptr, getstring(NULL, HTML_CTCP_CONTENT),
                         tempc, c->overall);
                free(tempc);
                x++;
                if (x > 10) {
                    break;
                }
            }
            tn = list_next(CTCPhead, tn);
        }
        fprintf(ptr, "%s", getstring(NULL, HTML_CTCP_FOOTER));
    }
}
Пример #22
0
/*
 * Questa procedura considera la lista passata come argomento come lista di fattori unici (sulla
 * genomica).
 * E quindi e' inutile stampare anche EST_start e EST_end, o no?
 */
void print_factors_list(plist list_of_factors, bool is_not_window) {

    my_assert(list_of_factors!=NULL);

    //DEBUG("**** Stampa della lista dei fattori unici ****");
    if (is_not_window) {
        DEBUG("**** Stampa della lista dei fattori unici sulla genomica ****");
    } else {
        DEBUG("**** Stampa della lista delle finestre di contenimento sulla genomica ****");
    }

    int number_of_factor= 0;

    pfactor pf;
    plistit list_it;

    list_it=list_first(list_of_factors);

    INFO("Factors (%zd)", list_size(list_of_factors));

    while(listit_has_next(list_it)) {
        pf=listit_next(list_it);
        number_of_factor=number_of_factor+1;
        INFO("%d\t%d\t%d", number_of_factor, pf->GEN_start,pf->GEN_end);
    }
    listit_destroy(list_it);
}
Пример #23
0
LIST *
compile_set(
	PARSE	*parse,
	LOL	*args,
	int	*jmp )
{
	LIST	*nt = (*parse->left->func)( parse->left, args, jmp );
	LIST	*ns = (*parse->right->func)( parse->right, args, jmp );
	LISTITEM	*l;

	if( DEBUG_COMPILE )
	{
	    debug_compile( 0, "set" );
	    list_print( nt );
	    printf( " %s ", set_names[ parse->num ] );
	    list_print( ns );
	    printf( "\n" );
	}

	/* Call var_set to set variable */
	/* var_set keeps ns, so need to copy it */

	for( l = list_first(nt); l; l = list_next( l ) )
	    var_set( list_value(l), list_copy( L0, ns ), parse->num );

	list_free( nt );

	return ns;
}
Пример #24
0
/*
 * is_not_window deve essere true, se il confronto e' di uguaglianza (cioe' factors e' stata costruita con
 * factors_list_create(), e deve essere false se factors e' stata costruita con
 * windows_list_create()
 */
void add_EST(pEST p,plist factors, bool is_not_window)
{
    my_assert((p!=NULL)&&(factors!=NULL));

    plistit list_it;
    plist factorization;

    //fprintf(stdout, "EST %s\n", p->info->EST_id);

    list_it=list_first(p->factorizations);

    while(listit_has_next(list_it)) {

        factorization=listit_next(list_it);

        /*plistit temp=list_first(factorization);
         fprintf(stdout, "\tFactorization\n");
         while(listit_has_next(temp)){
          pfactor f_t=(pfactor)listit_next(temp);
          fprintf(stdout, "\t\t%d-%d\n", f_t->GEN_start, f_t->GEN_end);
         }
         listit_destroy(temp);*/

        add_factoriz(p,factorization,factors,is_not_window);
    }
    listit_destroy(list_it);
}
Пример #25
0
int LS_jam_expand(ls_lua_State *L)
{
    LIST *list = L0;
    LISTITEM* item;
    int index;

    int numParams = ls_lua_gettop(L);
    if (numParams < 1  ||  numParams > 1)
        return 0;

    if (!ls_lua_isstring(L, 1))
        return 0;

    {
        LOL lol;
        const char* src = ls_lua_tostring(L, 1);
        lol_init(&lol);
        list = var_expand(L0, src, src + strlen(src), &lol, 0);
    }

    ls_lua_newtable(L);
    index = 1;
    for (item = list_first(list); item; item = list_next(item), ++index)
    {
        ls_lua_pushnumber(L, index);
        ls_lua_pushstring(L, list_value(item));
        ls_lua_settable(L, -3);
    }

    return 1;
}
Пример #26
0
cDict *dict_from_slices(cList *slices)
{
    cList *keys, *values;
    cDict *dict;
    cData *d;

    /* Make lists for keys and values. */
    keys = list_new(list_length(slices));
    values = list_new(list_length(slices));

    for (d = list_first(slices); d; d = list_next(slices, d)) {
        if (d->type != LIST || list_length(d->u.list) != 2) {
            /* Invalid slice.  Throw away what we had and return NULL. */
            list_discard(keys);
            list_discard(values);
            return NULL;
        }
        keys = list_add(keys, list_elem(d->u.list, 0));
        values = list_add(values, list_elem(d->u.list, 1));
    }

    /* Slices were all valid; return new dict. */
    dict = dict_new(keys, values);
    list_discard(keys);
    list_discard(values);
    return dict;
}
Пример #27
0
/*
 * is_not_window deve essere true, se il confronto e' di uguaglianza (cioe' factors e' stata costruita con
 * factors_list_create(), e deve essere false se factors e' stata costruita con
 * windows_list_create()
 */
void add_factoriz(pEST est,plist factorization,plist factors, bool is_not_window)
{

    my_assert((est!=NULL)&&(factorization!=NULL)&&(factors!=NULL));

    pfactor pf;
    plistit plist_it_factor;

    int factor_pos;
    pbit_vect bv=BV_create(list_size(factors));

    if(est->bin_factorizations==NULL) {
        est->bin_factorizations=list_create();
    }

    plist_it_factor=list_first(factorization);

    while(listit_has_next(plist_it_factor)) {

        pf=listit_next(plist_it_factor);
        factor_pos=get_factor_position(pf,factors,is_not_window);

        //fprintf(stdout, "\t\tFactor position %d\n", factor_pos);

        BV_set(bv,factor_pos,true);
    }
    list_add_to_tail(est->bin_factorizations,bv);
    listit_destroy(plist_it_factor);
}
Пример #28
0
// keyboard service routine
void keyboard_routine(void) {
  struct list_head *e;
  struct task_struct *t;
  unsigned char c = inb(0x60);
  if ((c & 0x80) == 0) { // make
    char aux = char_map[c&0x7F];
    if (aux != '\0') {
        print_key(aux);
        add_key(aux);
        if (threads_waiting()) {
          //sys_write(1,"esperant",8);
          e = list_first(&key_buffer.keyboardqueue);
          t = list_head_to_task_struct(e);
          if (can_read(t->num_chars_to_read)) {
            sys_write(1,"llegim",6);
            list_del(e);
            list_add_tail(e, &readyqueue);
          }
        }
        //char b[1];
        //itoa(current()->num_chars_to_read,b);
        //sys_write(1,b,1);
        //print_buffer(6);
    }
    else {
      print_key('C');
    }
  }
  else { // break 
    // do nothing
  }
}
Пример #29
0
/*
 * is_not_window deve essere true, se il confronto e' di uguaglianza (cioe' factors e' da costruire con
 * factors_list_create(), e deve essere false se factors e' da costruire con
 * windows_list_create()
 */
plist color_matrix_create(plist ests_factorizations, bool is_not_window)
{

    my_assert(ests_factorizations!=NULL);

    pEST p;
    plistit plist_it_id;

    plist factors;
    if (is_not_window) {
        factors=factors_list_create(ests_factorizations);
    } else {
//Da sostituire
        factors=windows_list_create(ests_factorizations);
    }

    INFO("Total factors (prior of simplification): %zu", list_size(factors));
    DEBUG("Creazione della lista dei fattori unici avvenuta correttamente!!");
    plist_it_id=list_first(ests_factorizations);

    while(listit_has_next(plist_it_id)) {
        p= listit_next(plist_it_id);
        add_EST(p,factors,is_not_window);
    }
    listit_destroy(plist_it_id);

    return factors;

}
Пример #30
0
struct nsa_token *
create_unit(struct nsa_parser *p,const char *s,struct nsa_token *t)
{
  const char *n = nsa_trim_morph(p->context, s);
  struct nsa_hash_data *d = hash_find(p->context->step_index, (unsigned char *)n);
  if (d)
    {
      struct nsa_token *tu = new_token();
      struct nsa_unit *u = new_unit();
      List *l = list_create(LIST_SINGLE);

      list_add(l,t);

      if (d->continuations)
	d = check_continuations(d,p,&n,l);

      u->name = (char *)npool_copy((unsigned char *)n,p->pool);
      u->cands = d->cands;
      tu->type = NSA_T_UNIT;
      if (t)
	{
	  struct nsa_token *lt;
	  int i;
	  tu->children = new_children(list_len(l));
	  for (i = 0, lt = list_first(l); lt; lt = list_next(l),++i)
	    tu->children[i] = lt;
	}
      tu->d.u = u;
      list_free(l,NULL);
      return tu;
    }
  else
    return t;
}