void reg(int sockfd)
{
LOGIN *login = (LOGIN *)malloc(sizeof(LOGIN));
printf("\t\tPlease input name: ");
scanf("%s",login -> name);
printf("\t\tPlease input password: ");
scanf("%s",login -> password);
login -> action = REG;
write(sockfd,login,sizeof(LOGIN));
read(sockfd,login,sizeof(LOGIN));
if(login -> action == 1)
{
printf("\t\treg success!\n");
}
else if(login -> action == 5);
{
printf("\t\tThe User is already existed!");
getchar();
getchar();
}
return 0;
}
int login(int sockfd)
{
LOGIN *login = (LOGIN *)malloc(sizeof(LOGIN));
int i;
printf("\t\tPlease input usr name: ");
scanf("%s",login -> name);
printf("\t\tPlease input password: ");
scanf("%s",login -> password);
login -> action = LOG;
write(sockfd,login,sizeof(LOGIN));
read(sockfd,login,sizeof(LOGIN));
switch(login -> action)
{
case 1:
{
return 1;
}
case -2:
{
printf("\t\tNo this User,Please reg!\n");
getchar();
getchar();
return -1;
}
case -1:
{
printf("\t\tThe password is wrong!\n");
getchar();
getchar();
return -2;
}
default :
{
return 0;
}
}