Esempio n. 1
0
void print_B()
{
	printf("********@s********\n", current_user->name);
	printf("1. Create Message\n");
	printf("2. Send Message\n");
	printf("3. List All [@d]\n", get_total_count());
	printf("4. List Drafts [@d]\n", get_draft_count(current_user->name));
	printf("5. List Inbox [@d]\n", get_inbox_count(current_user->name));
	printf("6. Delete Draft\n");
	printf("7. Logout\n");
	printf("8. Exit\n");
	printf(": \n");
}
Esempio n. 2
0
static guint
count_total (GtkRBTree *tree,
             GtkRBNode *node)
{
  guint res;
  
  if (_gtk_rbtree_is_nil (node))
    return 0;
  
  res =
    count_total (tree, node->left) +
    count_total (tree, node->right) +
    (guint)1 +
    (node->children ? count_total (node->children, node->children->root) : 0);

  if (res != node->total_count)
    g_print ("total count incorrect for node\n");

  if (get_total_count (node) != node->total_count)
    g_error ("Node has incorrect total count %u, should be %u", node->total_count, get_total_count (node));
  
  return res;
}
Esempio n. 3
0
TEST(STORE_STAT_TEST, HandleNoneZeroInput) 
{

   MEM_POOL* mem_pool = mem_pool_init(M_1M);  
   store_stats_init(1000*10,mem_pool);

   uint64 i;
   for(i=0;i<10000;i++)
   	record_time("index_equal",1000*100);


   ASSERT_EQ(100.000000,get_avg_time_inms("index_equal"));
   ASSERT_EQ(10000,get_count("index_equal"));
   ASSERT_EQ(10000,get_total_count("index_equal"));
   sleep(2);
   ASSERT_EQ(5000,get_throughput("index_equal"));
}
Esempio n. 4
0
int handle_B_input()
{
	char buf[3] = {0};
	size_t l = 0;
	while (l < 1)
		l = receive_until( buf, '\n', 2);

	if (buf[0] == '7')
	{
		// LOGOUT
		printf("Logging out of user @s\n", current_user->name);
		logout();
		return 2;
	}
	else if (buf[0] == '8')
	{
		// EXIT
		printf("The end.\n");
		_terminate(0);
	}
	else if (buf[0] == '2')
	{
		// SEND MESSAGE from drafts list
		if (get_draft_count(current_user->name) == 0)
		{
			printf("Must create draft first.\n");
			return 0;
		}

		// list all drafts with number in front
		// user enters valid number
		// that message is changed from drafts 1->0
		print_draft_for_send(current_user->name);
	}
	else if (buf[0] == '1')
	{
		// ADD A MESSAGE TO DRAFTS
		if (msg_count_login >= MAX_MESSAGES_LOGIN)
		{
			printf("Reached maximum messages for this session.\n");
			return 0;
		}

		printf("To:\n");

		char dest[MAX_NAME_LEN];
		size_t len = receive_until( dest, '\n', MAX_NAME_LEN - 1);
		dest[len++] = 0;

		printf("Message:\n");
		char msg_buf[MAX_MSG_LEN];
		len = receive_until( msg_buf, '\n', MAX_MSG_LEN - 1);
		msg_buf[len++] = 0;

		if (add_message(dest, current_user->name, msg_buf, 1) != 1)
			printf("add_message failed\n");
	}
	else if (buf[0] == '3')
	{
		// LIST MESSAGES
		// list all messages in summary
		if (get_total_count() == 0)
		{
			printf("No messages.\n");
			return 0;
		}

		list_all_messages();
	}
	else if (buf[0] == '4')
	{
		// LIST DRAFTS
		list_drafts(current_user->name);
	}
	else if (buf[0] == '5')
	{
		// LIST INCOMING MSGS
		list_inbox(current_user->name);
	}
	else if (buf[0] == '6')
	{
		// DELETE MESSAGE from drafts list
		if (get_draft_count(current_user->name) == 0)
		{
			printf("Must create draft first.\n");
			return 0;
		}
		print_draft_for_del(current_user->name);
	}
	else
		printf("unknown input: @c @c", buf[0], buf[1]);
	return 0;
}