@ -26,18 +26,19 @@ char *to_string(int number)
}
}
char * generateCheckString ( int ID , char * p assword)
char * generateCheckString ( int customer ID, char * customerP assword)
{
char * IDString = to_string ( ID ) ;
/*The purpose of this function is to generate a string that is needed when a user wants to login.
* This string is searched for in the customer - data file and if it is found , the login is successful .
* This function is needed when a new user is created because then it is written in the file for the first time .
* The format of the string is : [ ID ] = [ PASSWORD ] */
char * IDString = to_string ( customerID ) ;
int IDLength = strlen ( IDString ) ;
int passwordLength = strlen ( password ) ;
/*the checkString has this form: ID=password, so in order to calculate its length the length of the ID, one byte for the =, the length of the password and
* one byte for ' \0 ' are needed . */
int passwordLength = strlen ( customerPassword ) ;
int checkStringLength = IDLength + 1 + passwordLength + 1 ;
char * checkString = calloc ( checkStringLength , sizeof ( char ) ) ;
checkString = strcat ( IDString , " = " ) ;
checkString = strcat ( checkString , p assword) ;
checkString = strcat ( checkString , customerP assword) ;
* ( checkString + checkStringLength ) = ' \0 ' ;
return checkString ;
}