-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.c
129 lines (104 loc) · 2.62 KB
/
signup.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# include <ctype.h>
char str[100];
struct signup
{
char fname[20],lname[20],nickname[20],username[20],password[20],re_password[20];
}s;
char *Cmd_Signup()
{
int i=-1,flag=0,count,length;
char c=0;
struct signup s;
strcpy(s.password,"");
strcpy(s.re_password,"");
clear();
printf("\n\n\n\t\t\tCh@t ONE\n\n");
printf("\n\n\t\t\tAlready a User?? LOGIN..!!!\n");
/* firstname */
while(flag!=1)
{
printf("\n\tFirst Name : ");
scanf("%s",s.fname);
length=strlen(s.fname);
flag=validate_text(s.fname,length);
if(flag==0)
printf("Warning: First Name must be alphabetic");
}
flag=0;
/* lastname */
while(flag!=1)
{
printf("\n\tLast Name : ");
scanf("%s",s.lname);
length=strlen(s.lname);
flag=validate_text(s.lname,length);
if(flag==0)
printf("Warning: Last Name must be alphabetic");
}
flag=0;
/* username */
while(flag!=1)
{
printf("\n\tUsername : ");
scanf("%s",s.username);
length=strlen(s.username);
flag=validate_username(s.username,length);
}
flag=0;
/* password */
while(flag!=1)
{
printf("\n\tPassword : ");
/* masks the password and catches it into variable password */
count=0;
c=getch();
while((c=getch())!='\n')/* calls the getch() in file password.c to mask the input */
{
printf("*");
s.password[count++]=c;/* catches the password to the variable 'password' one character a time */
}
s.password[count]='\0';
length=strlen(s.password);
flag=validate_password(s.password,length);
}
count=0;
/* confirm password */
printf("\n\n\tConfirm Password : ");
/* masks the confirm-password and catches it into variable re_password */
while((c=getch())!='\n')/* calls the getch() in file password.c to mask the input */
{
printf("*");
s.re_password[count++]=c;/* catches the password to the variable 're_password' one character a time */
}
s.re_password[count]='\0';
/* validates the password and confirm-password */
if(strcmp(s.password,s.re_password)!=0)
{
printf("\n\n\t\tWarning: Password Mismatch");
printf("\n");
sleep(2);
Cmd_Signup();/* Function recall caused by password mismatch */
return 0;
}
/* nickname */
printf("\n\n\tNickname : ");
scanf("%s",s.nickname);
/* serialize user inputs to wire it to server */
strcpy(str,"register ");
strcat(str,s.username);
strcat(str,",");
strcat(str,s.password);
strcat(str,",");
strcat(str,s.nickname);
strcat(str,",");
strcat(str,s.fname);
strcat(str,",");
strcat(str,s.lname);
strcat(str,",");
strcat(str,"end");
strcat(str,",");
sleep(2);
printf("\n\n\t\tLoading...\n\n");
//flag = setupConnection(str); /* call to networking module in loginclient.c */
return str;
}