示例#1
0
void
bookmarks_add (Bookmarks   *bookmarks,
	       const char  *path,
	       gboolean     avoid_duplicates,
	       gboolean     append)
{
	g_return_if_fail (bookmarks != NULL);
	g_return_if_fail (path != NULL);

	if (avoid_duplicates) {
		GList *scan;
		for (scan = bookmarks->list; scan; scan = scan->next)
			if (same_uri ((char*) scan->data, path))
				return;
	}

	if (append)
		bookmarks->list = g_list_append (bookmarks->list,
						 g_strdup (path));
	else
		bookmarks->list = g_list_prepend (bookmarks->list,
						  g_strdup (path));

	my_insert (bookmarks->names,
		   path,
		   get_uri_display_name (path));

	my_insert (bookmarks->tips,
		   path,
		   get_menu_item_tip (path));
}
示例#2
0
void
bookmarks_load_from_disk (Bookmarks *bookmarks)
{
	GnomeVFSResult  result;
	GnomeVFSHandle *handle;
	char           *uri;
	char            line [MAX_LINE_LENGTH];

	g_return_if_fail (bookmarks != NULL);

	bookmarks_free_data (bookmarks);
	if (bookmarks->rc_filename == NULL)
		return;

	uri = g_strconcat (get_home_uri (),
			   "/",
			   bookmarks->rc_filename,
			   NULL);
	result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
	g_free (uri);

	if (result != GNOME_VFS_OK)
		return;

	while (_gnome_vfs_read_line (handle,
				     line,
				     MAX_LINE_LENGTH,
				     NULL) == GNOME_VFS_OK) {
		char *path;

		if (line[0] != '"')
			continue;

		line[strlen (line) - 1] = 0;
		path = line + 1;

		bookmarks->list = g_list_prepend (bookmarks->list, g_strdup (path));
		my_insert (bookmarks->names,
			   path,
			   get_uri_display_name (path));
		my_insert (bookmarks->tips,
			   path,
			   get_menu_item_tip (path));
	}

	gnome_vfs_close (handle);

	bookmarks->list = g_list_reverse (bookmarks->list);
}
示例#3
0
static void test_hash_basic(void *p)
{
	struct HashTab *htab;
	int i;

	htab = hashtab_create(cf_size, mycmp, USUAL_ALLOC);

	for (i = 0; i < cf_cnt; i++) {
		int n = i + cf_ofs;
		str_check(my_lookup(htab, n), "NEXIST");
		str_check(my_insert(htab, n), "OK");
		str_check(my_lookup(htab, n), "OK");
	}

	for (i = 0; i < cf_cnt; i++) {
		int n = i + cf_ofs;
		str_check(my_lookup(htab, n), "OK");
		str_check(my_remove(htab, n), "OK");
		str_check(my_lookup(htab, n), "NEXIST");
	}

end:
	hashtab_destroy(htab);
}
int insertPort(struct packetInfo *lpi)
{
	int ret=1;

#ifdef MY_DEBUG
	if(lpi == NULL){
		return 	-1;
	}

	//debugFunc(lpi);
#endif

	if(lpi->port == 0 || lpi->protocol == 0)
	{
#ifdef MY_DEBUG_INFO
		//my_print_debug("some info is zero port %d address %d.%d.%d.%d and protocol %hu",lpi->port,NIPQUAD(lpi->address), lpi->protocol);
#endif
		return -1;
	}

	ret = my_insert(&db,lpi);

	return ret;
}
示例#5
0
void mem_block_insert_allocated(fms_mem_pool *mem_pool, fms_mem_block *new_block) {
	//printf("###########alloc:%x free=%x\n", mem_pool->allocated_blocks.rb_node, mem_pool->free_blocks.rb_node);
	my_insert(&mem_pool->allocated_blocks, new_block);
}
示例#6
0
static void mem_block_insert_free(fms_mem_pool *mem_pool, fms_mem_block *new_block) {
	//printf("@@@@@@@@@@@free:%x alloc:%x\n", mem_pool->free_blocks.rb_node, mem_pool->allocated_blocks.rb_node);
	my_insert(&mem_pool->free_blocks, new_block);
}
示例#7
0
//just for a test 
int main()
{

    GameNode g1;
	g1.Gamename=2;
	g1.GameIntroduction=13;
	g1.CompanyIntroduction=12;
	g1.PlayingHours=20;

	GameNode g2;
	g2.Gamename=3;
    g1.GameIntroduction=4;
	g1.CompanyIntroduction=2;
	g1.PlayingHours=20;



	GameNode g3;
    g3.Gamename=1;
    g3.GameIntroduction=23;
	g3.CompanyIntroduction=2;
	g3.PlayingHours=20;




	GameNode g4;
	GameNode g5;

    GameListNode *head =  malloc(sizeof(GameListNode));
	head->prev=NULL;
	head->gamenode=g1;
    GameListNode *node2 =  malloc(sizeof(GameListNode));
	head->next=node2;
	node2->prev=head;
	node2->gamenode=g2;
	node2->next=NULL;
    
   printf("%d\n",my_insert(&head,g3));

   GameListNode *current=head;
   while(current!=NULL)
   {
	   printf("%d\n",(current->gamenode).Gamename);
	   current=current->next;
   }
    
   printf("%d\n",my_remove(&head,3));

   current=head;
   while(current!=NULL)
   {
	  printf("%d\n",(current->gamenode).Gamename);
	   current=current->next;
   }
   GameListNode * gn = my_query(head,1);
    if (gn!=NULL)
   printf("query%d\n",(gn->gamenode).GameIntroduction);
   
int *test;
int i;
 test= sortByKeyWord(head,1);	
	for (i=0;i<2;i++)
		printf("%d\n",test[i]);
	return 0;
}