online-caro.cpp
/*
* Process the password request from the client.
* @param     data     [IN] The data received from the client.
* @param     response     [OUT] The response from this server.
*/
Process the password request from the client.
Process the password request from the client .
void processPassword(char* data, char* response, char* state) {
	printf("Received password '%s' from ID '%s'\n", data, state);
	Account* node = accountDB;
	while (node != NULL) {
		if (strcmp(node->username, state) == 0) {
			if (strcmp(node->password, data) == 0) {
				node->status = STATUS_LOGGED_IN;
				strcpy(response, (char*)PASSWORD_SUCCESS);
				printf("[RESPONSE]: Password success - ID '%s'\n\n", state);
			}
			else {
				printf("[RESPONSE]: Password incorrect - ID '%s'\n", state);
				if (processBlockAccount(state)) strcpy(response, (char*)ACCOUNT_IS_BLOCKED);
				else strcpy(response, (char*)PASSWORD_INCORRECT);
			}
			return;
		}
		node = node->next;
	}
}
void processPassword ( char * data , char * response , char * state ) { printf ( " \n " , data , state ) ; Account * node = accountDB ; while ( node != NULL ) { if ( strcmp ( node -> username , state ) == 0 ) { if ( strcmp ( node -> password , data ) == 0 ) { node -> status = STATUS_LOGGED_IN ; strcpy ( response , ( char * ) PASSWORD_SUCCESS ) ; printf ( " \n \n " , state ) ; } else { printf ( " \n " , state ) ; if ( processBlockAccount ( state ) ) strcpy ( response , ( char * ) ACCOUNT_IS_BLOCKED ) ; else strcpy ( response , ( char * ) PASSWORD_INCORRECT ) ; } return ; } node = node -> next ; } }
Process the password request from the client.
Process the password request from the client .