コード例 #1
0
ファイル: runtime_sliders.c プロジェクト: bigamil/MegaTunix
/*!
  \brief Accel enrichment slider limit checker, This takes care fo the special 
  0/100 cases where controls should be enabled/disabled as appropriate
  \param widget is the slider/range
  \param data is unused
  \returns FALSE to let other signals run
  */
G_MODULE_EXPORT gboolean ae_slider_check_limits(GtkWidget *widget, gpointer data)
{
	gboolean mapae_ctrl_state = FALSE;
	gboolean tpsae_ctrl_state = FALSE;
	GHashTable *widget_group_states = NULL;
 	gfloat value = gtk_range_get_value(GTK_RANGE(widget));

	if (value == 0)
		tpsae_ctrl_state = FALSE;
	else
		tpsae_ctrl_state = TRUE;

	if (value == 100)
		mapae_ctrl_state = FALSE;
	else
		mapae_ctrl_state = TRUE;

	widget_group_states = (GHashTable *)DATA_GET(global_data,"widget_group_states");
	g_hash_table_insert(widget_group_states,g_strdup("tps_ae_ctrls"),GINT_TO_POINTER(tpsae_ctrl_state));
	g_hash_table_insert(widget_group_states,g_strdup("map_ae_ctrls"),GINT_TO_POINTER(mapae_ctrl_state));
	g_list_foreach(get_list("tps_ae_ctrls"),alter_widget_state,NULL);
	g_list_foreach(get_list("map_ae_ctrls"),alter_widget_state,NULL);
	return FALSE;

}
コード例 #2
0
ファイル: logviewer_gui.c プロジェクト: toxicgumbo/MegaTunix
/*!
  \brief Saves the default loggable choices
  \param widget is unused
  \returns FALSE
 */
G_MODULE_EXPORT gboolean save_default_choices(GtkWidget *widget)
{
	GtkWidget *tmpwidget = NULL;
	GList * list = NULL;
	GList * defaults = NULL;
	gconstpointer *object = NULL;
	gchar *name = NULL;
	gint i = 0;

	defaults = get_list("logviewer_defaults");
	if (defaults)
	{
		g_list_foreach(defaults,(GFunc)g_free,NULL);
		g_list_free(defaults);
		defaults = NULL;
		remove_list("logviewer_defaults");
	}
	list = get_list("viewables");
	for (i=0;i<g_list_length(list);i++)
	{
		tmpwidget = g_list_nth_data(list,i);
		object = OBJ_GET(tmpwidget,"object");
		if ((GBOOLEAN)DATA_GET(object,"being_viewed"))
		{
			if (DATA_GET(global_data,"playback_mode"))
				name = DATA_GET(object,"lview_name");
			else
				name = DATA_GET(object,"dlog_gui_name");

			defaults = g_list_append(defaults,g_strdup(name));
		}
	}
	store_list("logviewer_defaults",defaults);
	return FALSE;
}
コード例 #3
0
ファイル: guifilelist.c プロジェクト: hiro2233/libspmp8k-1
void get_file_list() {
	filesread = 0;

	get_list(FT_DIRS);
	get_list(FT_FILES);
	gui_Qsort(file_list, 0, filesread-1);
}
コード例 #4
0
ファイル: ops.c プロジェクト: xupingmao-old/venus
tm_obj tm_add(  tm_obj a, tm_obj b){
	if( a.type == b.type ){
		switch( a.type ){
			case TM_NUM:
				get_num(a) += get_num(b);
				return a;
			case TM_STR:
			{
				char* sa = get_str(a);
				char* sb = get_str(b);
				int la = get_str_len(a);
				int lb = get_str_len(b);
				if( la == 0){
					return b;
				}
				if( lb == 0){
					return a;
				}
				int len = la + lb;
				tm_obj des = str_new(NULL, len);
				char*s = get_str(des);
				memcpy(s,      sa, la);
				memcpy(s + la, sb, lb);
				return des;
			}
			case TM_LST:
			{
				return list_join(get_list(a), get_list(b) );
			}
		}
	}
    tm_raise("tm_add: can not add %t and %t", (a),(b));
	return obj_none;
}
コード例 #5
0
ファイル: ops.c プロジェクト: xupingmao-old/venus
int tm_eq(tm_obj a, tm_obj b){
	if( a.type != b.type ) return 0;
	switch( a.type ){
		case TM_NUM:
			return get_num(a) == get_num(b);
		case TM_STR:
		{
			char* sa = get_str(a);
			char* sb = get_str(b);
			return sa == sb || ( get_str_len(a) == get_str_len(b) && 
				strncmp(sa, sb, get_str_len(a)) == 0 );
		}
		case TM_LST:
		{
			if( get_list(a) == get_list(b)) return 1;
			int i;
			int len = get_list(a)->len;
			tm_obj* nodes1 = get_list(a)->nodes;
			tm_obj* nodes2 = get_list(b)->nodes;
			for(i = 0; i < len; i++){
				if( !tm_eq(nodes1[i], nodes2[i]) ){
					return 0;
				}
			}
			return 1;
		}
		case TM_NON:return 1;
		default: tm_raise("tm_eq(): not supported type %d", a.type);
	}
	return 0;
}
コード例 #6
0
ファイル: logviewer_gui.c プロジェクト: toxicgumbo/MegaTunix
/*!
  \brief set_default_lview_choices_state() sets the default logviewer values
  */
G_MODULE_EXPORT void set_default_lview_choices_state(void)
{
	GList *defaults = NULL;
	GList *list = NULL;
	GtkWidget * widget = NULL;
	gint i = 0;
	gint j = 0;
	gchar * name;
	gchar * potential;
	gconstpointer *object;

	defaults = get_list("logviewer_defaults");
	list = get_list("viewables");
	for (i=0;i<g_list_length(defaults);i++)
	{
		name = g_list_nth_data(defaults,i);
		for (j=0;j<g_list_length(list);j++)
		{
			widget = g_list_nth_data(list,j);
			object = OBJ_GET(widget,"object");
			if (DATA_GET(global_data,"playback_mode"))
				potential = DATA_GET(object,"lview_name");
			else
				potential = DATA_GET(object,"dlog_gui_name");
			if (g_strcasecmp(name,potential) == 0)

				set_widget_active(GTK_WIDGET(widget),GINT_TO_POINTER(TRUE));
		}
	}
	return;
}
コード例 #7
0
ファイル: trade.c プロジェクト: mikekmv/aeriebsd-src
void
trade()
{
	int	tradee, i;

	trading = TRUE;
	for (i = 0; i < 2; i++) {
		trades[i].cash = 0;
		trades[i].gojf = FALSE;
		trades[i].prop_list = NULL;
	}
over:
	if (num_play == 1) {
		printf("There ain't no-one around to trade WITH!!\n");
		return;
	}
	if (num_play > 2) {
		tradee = getinp("Which player do you wish to trade with? ",
		    name_list);
		if (tradee == num_play)
			return;
		if (tradee == player) {
			printf("You can't trade with yourself!\n");
			goto over;
		}
	}
	else
		tradee = 1 - player;
	get_list(0, player);
	get_list(1, tradee);
	if (getyn("Do you wish a summary? ") == 0)
		summate();
	if (getyn("Is the trade ok? ") == 0)
		do_trade();
}
コード例 #8
0
ファイル: cut.c プロジェクト: UNGLinux/Obase
int
main(int argc, char *argv[])
{
	FILE *fp;
	void (*fcn)(FILE *, char *);
	int ch;

	setlocale (LC_ALL, "");

	dchar = '\t';			/* default delimiter is \t */

	/* Since we don't support multi-byte characters, the -c and -b 
	   options are equivalent, and the -n option is meaningless. */
	while ((ch = getopt(argc, argv, "b:c:d:f:sn")) != -1)
		switch(ch) {
		case 'b':
		case 'c':
			fcn = c_cut;
			get_list(optarg);
			cflag = 1;
			break;
		case 'd':
			dchar = *optarg;
			dflag = 1;
			break;
		case 'f':
			get_list(optarg);
			fcn = f_cut;
			fflag = 1;
			break;
		case 's':
			sflag = 1;
			break;
		case 'n':
			break;
		case '?':
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	if (fflag) {
		if (cflag)
			usage();
	} else if (!cflag || dflag || sflag)
		usage();

	if (*argv)
		for (; *argv; ++argv) {
			if (!(fp = fopen(*argv, "r")))
				err(1, "%s", *argv);
			fcn(fp, *argv);
			(void)fclose(fp);
		}
	else
		fcn(stdin, "stdin");
	exit(0);
}
コード例 #9
0
ファイル: user_data.cpp プロジェクト: Ancient/NetGuard
user_data_list_idx User_Data_Tools::get_list_idx()
{
	user_data_list_idx user_data;
	ip_storage_hash::iterator it;
	for (it=get_list()->begin(); it != get_list()->end(); it++)
		user_data.push_back((*it).first);
	return user_data;
}
コード例 #10
0
ファイル: rca.cpp プロジェクト: fluffbeast/wesnoth-old
// This is defined in the source file so that it can easily access the logger
bool candidate_action_factory::is_duplicate(const std::string& name)
{
	if (get_list().find(name) != get_list().end()) {
		ERR_AI_STAGE_RCA << "Error: Attempt to double-register candidate action " << name << std::endl;
		return true;
	}
	return false;
}
コード例 #11
0
ファイル: stage.cpp プロジェクト: GregoryLundberg/wesnoth
// This is defined in the source file so that it can easily access the logger
bool stage_factory::is_duplicate(const std::string& name)
{
	if (get_list().find(name) != get_list().end()) {
		ERR_AI_STAGE << "Error: Attempt to double-register stage " << name << std::endl;
		return true;
	}
	return false;
}
コード例 #12
0
static int mailprivacy_smime_add_encryption_id(struct mailprivacy * privacy,
    mailmessage * msg, char * encryption_id)
{
  clist * encryption_id_list;
  int r;
  int res;
  
  LOCK();
  
  res = -1;
  
  encryption_id_list = get_list(privacy, msg);
  if (encryption_id_list == NULL) {
    if (encryption_id_hash == NULL)
      encryption_id_hash = chash_new(CHASH_DEFAULTSIZE, CHASH_COPYKEY);
    
    if (encryption_id_hash != NULL) {
      encryption_id_list = clist_new();
      if (encryption_id_list != NULL) {
        chashdatum key;
        chashdatum value;
        
        key.data = &msg;
        key.len = sizeof(msg);
        value.data = encryption_id_list;
        value.len = 0;
        r = chash_set(encryption_id_hash, &key, &value, NULL);
        if (r < 0)
          clist_free(encryption_id_list);
      }
    }
  }
  
  encryption_id_list = get_list(privacy, msg);
  if (encryption_id_list != NULL) {
    char * str;
    
    str = strdup(encryption_id);
    if (str != NULL) {
      r = clist_append(encryption_id_list, str);
      if (r < 0) {
        free(str);
      }
      else {
        res = 0;
      }
    }
  }
  
  UNLOCK();
  
  return res;
}
コード例 #13
0
ファイル: exer13.c プロジェクト: wyt0602/algorithm
int main()
{
    LinkedNode *list1 = get_list(100, 500, UNIQUE_NON_SORTED);
    LinkedNode *list2 = get_list(100, 500, UNIQUE_NON_SORTED);

    if (!(list1 && list2))
	return 0;

    printf("list1:\n");
    print_list(list1);

    LinkedNode *head1 = list1;
    LinkedNode *head2 = list2;
    while (head1->next){
	head2->value = head1->value;
	head1 = head1->next;
	head2 = head2->next;
    }
    //head2->value = 1234;
    head2->value = head1->value;
    head2 = NULL;

    LinkedNode *node = (LinkedNode*)malloc(sizeof(LinkedNode));
    if (node == NULL)
	return 0;
    node->visit = 0;
    node->value = 7777;
    node->next = NULL;

    //make ODD list
    head1->next = node;
    head1 = head1->next;

    while (list2){
	LinkedNode *temp = list2;
	list2 = list2->next;
	temp->next = head2;
	head2 = temp;
    }
    head1->next = head2;
    printf("palindrom list1:\n");
    print_list(list1);

    if (is_palindrom(list1) == true)
	printf("is palindrom!\n");
    else
	printf("is not palindrom!\n");

    return 0;

}
コード例 #14
0
ファイル: env.c プロジェクト: ErisBlastar/osfree
// edit an existing environment variable or alias
int eset_cmd( int argc, char **argv )
{
    char *arg;
    int nLength;
    int i, rval = 0;
    long fEset;
    PCH vname, feptr, pchList;
    unsigned char buffer[CMDBUFSIZ];

    // check for alias or master environment switches
    if (( GetSwitches( argv[1], "AM", &fEset, 1 ) != 0 ) || ( first_arg( argv[1] ) == NULL ))
        return ( usage( ESET_USAGE ));

    for ( i = 0; (( arg = ntharg( argv[1], i )) != NULL ); i++ ) {

        pchList = (( fEset & ESET_MASTER ) ? glpMasterEnvironment : glpEnvironment );

        // try environment variables first, then aliases
        if (( fEset & ESET_ALIAS ) || (( feptr = get_list( arg, pchList )) == 0L)) {

            // check for alias editing
            if (( feptr = get_list( arg, glpAliasList )) == 0L ) {
                rval = error((( fEset & ESET_ALIAS ) ? ERROR_4DOS_NOT_ALIAS : ERROR_4DOS_NOT_IN_ENVIRONMENT ), arg );
                continue;
            }

            pchList = glpAliasList;
        }

        // get the start of the alias or variable name
        for ( vname = feptr; (( vname > pchList ) && ( vname[-1] != '\0' )); vname-- )
            ;

        // length of alias/variable name
        nLength = (int)( feptr - vname );

        sprintf( buffer, "%.*Fs%.*Fs", nLength, vname, (( CMDBUFSIZ - 1 ) - nLength), feptr );

        // echo & edit the argument
        printf( FMT_FAR_PREC_STR, nLength, vname );
        (void)egets( buffer + nLength, (( CMDBUFSIZ - 1 ) - nLength ), EDIT_ECHO );

        if ( add_list( buffer, pchList ) != 0 )
            rval = ERROR_EXIT;
    }

    return rval;
}
コード例 #15
0
void ConnectivityRestraint::add_particle(kernel::Particle *ps) {
  if (!sc_) {
    sc_ = new IMP::internal::InternalListSingletonContainer(
        ps->get_model(), "connectivity list");
  }
  get_list(sc_)->add(IMP::internal::get_index(ps));
}
コード例 #16
0
void mailprivacy_smime_encryption_id_list_clear(struct mailprivacy * privacy,
    mailmessage * msg)
{
  clist * encryption_id_list;
  clistiter * iter;
  
  LOCK();
  encryption_id_list = get_list(privacy, msg);
  if (encryption_id_list != NULL) {
    chashdatum key;
    
    for(iter = clist_begin(encryption_id_list) ;
        iter != NULL ; iter = clist_next(iter)) {
      char * str;
      
      str = clist_content(iter);
      free(str);
    }
    clist_free(encryption_id_list);
    
    key.data = &msg;
    key.len = sizeof(msg);
    chash_delete(encryption_id_hash, &key, NULL);
    
    if (chash_count(encryption_id_hash) == 0) {
      chash_free(encryption_id_hash);
      encryption_id_hash = NULL;
    }
  }
  UNLOCK();
}
コード例 #17
0
ファイル: mm_segregated2.c プロジェクト: abapst/15213-labs
/*
 * add_block - add a block to the list in order of address
 */
static void add_block(void *bp) {
    int list = get_list(GET_SIZE(HDRP(bp)));
    void *next = free_lists[list];

    while (next != LIST_END) {
        /* Insert bp in middle of list, or beginning if prev(next) is NULL */
        if (next > bp) {
            if (GET_PREV_FREE(next) == LIST_END)
                free_lists[list] = bp; /* Update list head */
            else
                SET_NEXT_FREE(GET_PREV_FREE(next), bp);
            SET_PREV_FREE(bp, GET_PREV_FREE(next));
            SET_PREV_FREE(next, bp);
            SET_NEXT_FREE(bp, next);    
            return;
        /* Reached end of list, add bp to the end using saved block */
        } else if (GET_NEXT_FREE(next) == LIST_END) {
            SET_PREV_FREE(bp, next);
            SET_NEXT_FREE(next, bp);
            SET_NEXT_FREE(bp, LIST_END); 
            return;
        } 
        next = GET_NEXT_FREE(next);
    }

    /* Edge case: list is empty, add bp */
    SET_PREV_FREE(bp, LIST_END);
    SET_NEXT_FREE(bp, LIST_END);
    free_lists[list] = bp;
}
コード例 #18
0
ファイル: lxc_autostart.c プロジェクト: kikitux/lxc
int main(int argc, char *argv[])
{
    int count = 0;
    int i = 0;
    int ret = 0;
    struct lxc_container **containers = NULL;
    struct lxc_list *cmd_groups_list = NULL;
    struct lxc_list *c_groups_list = NULL;
    struct lxc_list *it, *next;
    char *const default_start_args[] = {
        "/sbin/init",
        '\0',
    };

    if (lxc_arguments_parse(&my_args, argc, argv))
        return 1;

    count = list_defined_containers(NULL, NULL, &containers);

    if (count < 0)
        return 1;

    qsort(&containers[0], count, sizeof(struct lxc_container *), cmporder);

    if (my_args.groups && !my_args.all)
        cmd_groups_list = get_list((char*)my_args.groups, ",");

    for (i = 0; i < count; i++) {
        struct lxc_container *c = containers[i];

        if (!c->may_control(c)) {
            lxc_container_put(c);
            continue;
        }

        if (get_config_integer(c, "lxc.start.auto") != 1) {
            lxc_container_put(c);
            continue;
        }

        if (!my_args.all) {
            /* Filter by group */
            c_groups_list = get_config_list(c, "lxc.group");

            ret = lists_contain_common_entry(cmd_groups_list, c_groups_list);

            if (c_groups_list) {
                lxc_list_for_each_safe(it, c_groups_list, next) {
                    lxc_list_del(it);
                    free(it->elem);
                    free(it);
                }
                free(c_groups_list);
            }

            if (ret == 0) {
                lxc_container_put(c);
                continue;
            }
        }
コード例 #19
0
static struct lxc_list *get_config_list(struct lxc_container *c, char *key) {
	int len = 0;
	char* value = NULL;
	struct lxc_list *config_list = NULL;

	len = c->get_config_item(c, key, NULL, 0);
	if (len < 0)
		return NULL;

	value = (char*) malloc(sizeof(char)*len + 1);
	if (value == NULL)
		return NULL;

	if (c->get_config_item(c, key, value, len + 1) != len) {
		free(value);
		return NULL;
	}

	if (strlen(value) == 0) {
		free(value);
		return NULL;
	}

	config_list = get_list(value, "\n");
	free(value);

	return config_list;
}
コード例 #20
0
iterator* info_base::first(char* col_nm, c_code_t code)
{
   handler* x = get_set(col_nm);

   if ( x == 0 ) {
      handler* x = get_list(col_nm);
   }

   if ( x == 0 ) {
      throw(stringException("unknown collection name"));
   }

   page_storage *s = (page_storage*)(x -> its_store());

   if ( s == 0 ) {
      throw(stringException("collection has no store"));
   }

   if ( s -> my_oid().ccode() != PAGE_STORAGE_CODE ) {
      throw(stringException("non page store no supported"));
   }

   iterator* it = new iterator(x, code);

   it -> ind = s -> first_loc();

   if ( managers::template_mgr -> peek_slot(s, it->ind) != code ) {
      this -> next(*it);
   }

   return it;
}
コード例 #21
0
ファイル: tabloader.c プロジェクト: JacobD10/MegaTunix
/*!
  \brief  Removed a pointer/widget from a list of lists
  \param lists is the comma separated list of list names
  \param data is the pointer to the item to remove from each list
  */
G_MODULE_EXPORT void remove_from_lists(const gchar * lists, gpointer data)
{
	gint i = 0;
	gint bind_num_keys = 0;
	gchar **tmpvector = NULL;
	GList *list = NULL;

	ENTER();
	if (!lists)
	{
		EXIT();
		return;
	}

	tmpvector = parse_keys(lists,&bind_num_keys,",");

	for (i=0;i<bind_num_keys;i++)
	{
		list = get_list(tmpvector[i]);
		list = g_list_remove(list,(gpointer)data);
		store_list(tmpvector[i],list);
	}
	g_strfreev(tmpvector);
	EXIT();
	return;
}
コード例 #22
0
ファイル: mm_segregated2.c プロジェクト: abapst/15213-labs
/*
 * delete_block - delete a block from the free list
 */
static void delete_block(void *bp) {
    void *prev = GET_PREV_FREE(bp);
    void *next = GET_NEXT_FREE(bp);

    int list = get_list(GET_SIZE(HDRP(bp)));

    /* Case 1: bp is the only block in list */
    if ((prev == LIST_END) && (next == LIST_END)) {
        free_lists[list] = NULL;
        return;
    /* Case 2: bp is the first block in the list */
    } else if (prev == LIST_END) {
        SET_PREV_FREE(next, LIST_END);
        free_lists[list] = next;
        return;
    /* Case 3: bp is the last block in the list */
    } else if (next == LIST_END) {
        SET_NEXT_FREE(prev, LIST_END);
        return;
    /* Case 4: bp is in the middle of the list */
    } else {
        SET_NEXT_FREE(prev, next);
        SET_PREV_FREE(next, prev);
        return;
    }
}
コード例 #23
0
ファイル: cmd_privmsg.c プロジェクト: Ankirama/Epitech
static void	_send_to_channel(t_server *server, int fd,
				 char *chan, char *msg)
{
  t_channel	*tmp;
  int		i;
  t_list	*lst;

  if (!(tmp = get_channel(server->channels, chan)))
    send_code_msg(server, fd, ERR_NOSUCHNICK,
		  create_error_msg(chan, " :No such nick/channel"));
  else if (get_list(tmp->clients, server->client[fd].nick) == tmp->clients)
    send_code_msg(server, fd, ERR_CANNOTSENDTOCHAN,
		  create_error_msg(chan, " :Cannot send to channel"));
  else
    {
      lst = tmp->clients->next;
      while (lst != tmp->clients)
	{
	  i = -1;
	  while (++i < MAX_FD)
	    if (server->type_fd[i] == FD_CLIENT &&
		strcmp(server->client[i].nick, lst->data) == 0)
	      break;
	  if (i != fd)
	    send_info_msg(server, i, server->client[fd].nick, msg);
	  lst = lst->next;
	}
    }
}
コード例 #24
0
ファイル: list.c プロジェクト: axelhellman/Lager2.0
node* remove_amount(node* n, int r_amount)
{
  list* l = get_list(n);
  linked_list_node* crnt_node = l -> ll_first;
  while(r_amount != 0)
    {
      int crnt_amount = get_shelf_amount2(crnt_node);
      shelf* crnt_shelf = crnt_node -> ll_content;
      if (r_amount == crnt_amount)
	{
	  remove_shelf(n, crnt_shelf);
	  r_amount = r_amount - crnt_amount;
	}
      else if (r_amount < crnt_amount)
	{
	  crnt_shelf -> amount = crnt_amount - r_amount;
	  l -> total = l -> total - r_amount;

	  char* shelf_name = strdup(get_shelf_name1(crnt_shelf));
	  int new_amount = crnt_shelf -> amount;
	  remove_shelf(n, crnt_shelf);
	  add_shelf(n, shelf_name, new_amount);
	  free(shelf_name);
	  r_amount = 0;
	}
      else 
	{
	  crnt_node = crnt_node -> next_node;
	  remove_shelf(n, crnt_shelf);
	  r_amount = r_amount - crnt_amount;
	}
     
    }
  return n;
}
コード例 #25
0
int		sudoki_bi()
{
  char		***tab;
  t_list	*list;
  t_present	*present;
  int		i;

  if ((tab = get_all_tab()) == NULL)
    return (-1);
  i = -1;
  while (++i < my_tablen(tab))
    {
      if ((present = get_present(tab[i])) == NULL ||
	  (list = get_list(tab[i])) == NULL)
	return (-1);
      filler(tab[i], list, present);
      if (check_valid(tab[i]) == 1)
        error_aff_tab();
      else
        aff_table(tab[i]);
      if (i < (my_tablen(tab) - 1))
        write(1, "####################\n", 21);
      free_function_bis(list, present);
    }
  free_function(tab);
  return (0);
}
コード例 #26
0
ファイル: sync.c プロジェクト: xrdavies/android-wallet
/* notifies synchronization mechanism about found block */
int xdag_sync_pop_block(struct xdag_block *b)
{
	struct sync_block **p, *q, *r;
	xdag_hash_t hash;

	xdag_hash(b, sizeof(struct xdag_block), hash);
 
begin:
	pthread_mutex_lock(&g_sync_hash_mutex);

	for (p = get_list(hash); (q = *p); p = &q->next) {
		if (!memcmp(hash, q->b.field[q->nfield].hash, sizeof(xdag_hashlow_t))) {
			*p = q->next;
			g_xdag_extstats.nwaitsync--;

			for (p = get_list_r(q->hash); (r = *p) && r != q; p = &r->next_r);
				
			if (r == q) {
				*p = q->next_r;
			}

			pthread_mutex_unlock(&g_sync_hash_mutex);
			
			q->b.field[0].transport_header = q->ttl << 8 | 1;
			xdag_sync_add_block(&q->b, q->conn);			
			free(q);
			
			goto begin;
		}
	}

	pthread_mutex_unlock(&g_sync_hash_mutex);

	return 0;
}
コード例 #27
0
ファイル: tabloader.c プロジェクト: JacobD10/MegaTunix
/*!
  \brief bind_to_lists() binds a widget to any number of string named lists.
  \param widget is the widget to bind to lists
  \param lists is the command seperated string list of lists to bind this
  widget into.
  */
G_MODULE_EXPORT void bind_to_lists(GtkWidget * widget, const gchar * lists)
{
	gint bind_num_keys = 0;
	gchar **tmpvector = NULL;
	GList *dest_list = NULL;
	gint i = 0;

	ENTER();
	if (!lists)
	{
		printf(_("Error, bind_to_lists(), lists is NULL\n"));
		EXIT();
		return;
	}
	tmpvector = parse_keys(lists,&bind_num_keys,",");

	/* This looks convoluted,  but it allows for an arbritrary 
	 * number of lists, that are indexed by a keyword.
	 * The get_list function looks the list up in a hashtable, if
	 * it isn't found (i.e. new list) it returns NULL which is OK
	 * as g_list_prepend() uses that to create a new list,  that
	 * returned list is used to store back into the hashtable so
	 * that the list is always stored and up to date...
	 */
	for (i=0;i<bind_num_keys;i++)
	{
		dest_list = get_list(tmpvector[i]);
		dest_list = g_list_prepend(dest_list,(gpointer)widget);

		store_list(tmpvector[i],dest_list);
	}
	g_strfreev(tmpvector);
	EXIT();
	return;
}
コード例 #28
0
ファイル: _F_destruct.c プロジェクト: Lundex/gurbalib
atomic private void del_clone(void) {
  object * ptr;
  object prev;
  object next;

  ptr = get_list( "clones" );
  prev = ptr[LIST_PREV];
  next = ptr[LIST_NEXT];

  /*
   * If there is a next object in the list, ensure its
   * 'prev' object gets set to our 'prev' object.
   */
  if(next) {
    ptr = next->get_list( "clones" );
    ptr[LIST_PREV] = prev;
  }

  /*
   * Set the 'next' object in our 'prev', if there is no
   * 'prev' we are in big trouble. (this should only
   * occur in the master, and the code that runs here
   * should never get called in the master)
   */
  if(prev) {
    ptr = prev->get_list( "clones" );
    ptr[LIST_NEXT] = next;
  } else {
    error("There must be a previous link when removing a clone");
  }
  find_object(base_name())->_F_remove_clone();
}
コード例 #29
0
ファイル: list.c プロジェクト: axelhellman/Lager2.0
void print_check_out_aux(node* n, int amount)
{
  char* name = get_key(n);
  list* l = get_list(n);
  linked_list_node* crnt_node = l -> ll_first;
  while(amount != 0)
    {
      int crnt_amount = get_shelf_amount2(crnt_node);
      shelf* crnt_shelf = crnt_node -> ll_content;
      char* shelf_name = crnt_shelf -> shelf_name;
      
      if (amount == crnt_amount)
	{
	  printf("* %s (%d %s)\n", shelf_name, crnt_amount, name);
	  amount = amount - crnt_amount;
	}
      else if (amount < crnt_amount)
	{
	  printf("* %s (%d %s)\n", shelf_name, amount, name);
	  amount = 0;
	}
      else 
	{
	  printf("* %s (%d %s)\n", shelf_name, crnt_amount, name);
	  crnt_node = crnt_node -> next_node;
 	  amount = amount - crnt_amount;
	}
    }
  return;
}
コード例 #30
0
void ConnectivityRestraint::add_particles(const kernel::ParticlesTemp &ps) {
  if (!sc_ && !ps.empty()) {
    sc_ = new IMP::internal::InternalListSingletonContainer(
        ps[0]->get_model(), "connectivity list");
  }
  get_list(sc_)->add(IMP::internal::get_index(ps));
}