/* File Name : process.c Course Number : ISYS 290 04 Student Name : Jason Gradziel Student Number : 826-135-535 Professors Name : Brian Perry Class Name : Wednesday 9:55 - 12:35 Lab Title : Assignment #2 E-Mail. */ #include #include int word_count(char* str); int process (char* result, char* source) { char input[35] = {"\0"}; char register_email[14] = {"\0"}; char code[11] = {"\0"}; char mail_id_char[4] = {"\0"}; char mail_id_num[4] = {"\0"}; int return_num = 0; int num = 0; int count = 0; int flag = 0; char r_email[] = {"REGISTER_EMAIL"}; char* c[] = { "CENG303-50", "ISYS290-04", "ISYS290-06", "ISYS291-01", "ISYS291-50", }; int n=0; /* set result to null*/ strcpy(result,NULL); num = word_count(source); if (num>4) { strcpy(result,"INVALID"); return num; } /* to copy contents of source to input */ strcpy(input, source); /* to copy the needed contents of input to register_email */ for (count=0; count<14; count++) { register_email[count] = input[count]; } /* to copy the needed contents of input to code */ for (count=15; count<25; count++) { code[count-15] = input[count]; } /* to copy the needed contents of input to mail_id_char */ for (count=26; count<31; count++) { mail_id_char[count-26] = input[count]; } /* to copy the needed contents of input to mail_id_num */ for (count=30; count<34; count++) { mail_id_num[count-30] = input[count]; } /* Check */ /* check first word REGISTER_EMAIL */ num=0; for (count=0; count<14; count++) { if (register_email[count] == r_email[count]) { num++; } } if (num==14) { flag++; } /* check second word course code */ num=0; for (n=0; n<5; n++) { for (count=0; count<10; count++) { if (code[count] == c[n][count]) { num++; if (num==10) { flag++; n=5; count=10; } } } } /*if (num==10) { flag++; }*/ /* check third word e-mail */ /* check first four alpha characters */ num=0; for (count=0; count<4; count++) { if (isalpha(mail_id_char[count])) { num++; } } if (num == 4) flag++; /* check last four numaric characters */ num=0; for (count=0; count<4; count++) { if (isdigit(mail_id_num[count])) { num++; } } if (num == 4) flag++; /* Copy to result if correct or incorrect */ if (flag == 4) { strcpy(result,input); /*result=input; for (count=0; count<35; count++) { result[count] = input[count]; }*/ return_num=0; } else { strcpy(result,"INVALID"); return_num = 19; } /*printf("\n%s", result); getch();*/ return return_num; }