int find(st_info *buf_head,const int flag_num)
{
	char check[21];
	st_info *p1 = buf_head,*p2 = NULL,*p3 = NULL;
	find_link *q1,*q2,*find_head=NULL;
	unsigned int flag_find = 0;
	system("cls");
	switch (flag_num)
	{
	case 0:print_tips("  查询学生体检信息  ");break;
	case 2:print_tips("  修改学生体检信息  ");break;
	case 1:print_tips("  删除学生体检信息  ");break;
	}
	if(buf_head->next == NULL)
	{
		printf("\n Error!-----没有数据可供查询!请录入!");
		return 0;
	}
	printf("\n\n\n\n Tips:-----请输入姓名或者学号:");
	fflush(stdin);
	scanf("%20s",check);
	print_star();
	printf(menu_print);
	while (p1->next)
	{
		p2 = p1;
		p1 = p1->next;
		if(strcmp(p1->name,check) == 0 || strcmp(p1->num,check) == 0)
		{
			++flag_find;
			if(flag_find == 1)
			{
				find_head = (find_link *)malloc(M);
				q1 = (find_link *)malloc(M);
				find_head->next = q1;
			}
			q1->buf_find = p2;
			q2 = q1;
			q1 = (find_link *)malloc(M); 
			q2->next = q1;
		}
	}
	if(flag_find != 0)
	{
		free(q1);
		q2->next = NULL;
	}
	printf("\n\n");
	if(flag_find > 10)
	{
		free_find(find_head);
		printf("\n\n Warning!-----系统检测到您的查询结果已超过10个,数据文件可能存在问题!请检查!");
		return 0;
	}
	find_print(find_head,flag_find);
	if(find_head == NULL)
	{
		return 0;
	}
	switch (flag_num)
	{
	case 0:free_find(find_head);break;
	case 1:del_info(find_head,flag_find);free_find(find_head);break;
	case 2:change_info(find_head,flag_find);free_find(find_head);break;
	}
	return 1;
}
Exemplo n.º 2
0
static int
sasl_cmd_cb (char *word[], char *word_eol[], void *userdata)
{
	const char* login;
	const char* password;
	const char* network;
	const char* mode = word[2];

	if (!g_ascii_strcasecmp ("ADD", mode))
	{
		login = word[3];
		password = word[4];
		network = word_eol[5];

		if (!network || !*network)	/* only check for the last word, if it's there, the previous ones will be there, too */
		{
			hexchat_printf (ph, "%s", sasl_help);
			return HEXCHAT_EAT_ALL;
		}

		if (add_info (login, password, network))
		{
			hexchat_printf (ph, "%s\tEnabled SASL authentication for the \"%s\" network\n", name, network);
		}
		else
		{
			hexchat_printf (ph, "%s\tFailed to enable SASL authentication for the \"%s\" network\n", name, network);
		}

		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("DEL", mode))
	{
		network = word_eol[3];

		if (!network || !*network)
		{
			hexchat_printf (ph, "%s", sasl_help);
			return HEXCHAT_EAT_ALL;
		}

		if (del_info (network))
		{
			hexchat_printf (ph, "%s\tDisabled SASL authentication for the \"%s\" network\n", name, network);
		}
		else
		{
			hexchat_printf (ph, "%s\tFailed to disable SASL authentication for the \"%s\" network\n", name, network);
		}

		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("LIST", mode))
	{
		print_info ();
		return HEXCHAT_EAT_ALL;
	}
	else
	{
		hexchat_printf (ph, "%s", sasl_help);
		return HEXCHAT_EAT_ALL;
	}
}