online-caro.cpp
/*
* Process the username request from the client.
* @param     data     [IN] The data received from the client.
* @param     response    [OUT] The response from this server.
*/
Process the username request from the client.
Process the username request from the client .
void processUsername(char* data, char* response, char* state) {
	printf("Received username: %s\n", data);
	strcpy(state, data);
	Account* node = accountDB;
	while (node != NULL) {
		if (strcmp(node->username, data) == 0) {
			if (node->status == STATUS_BLOCKED) {
				printf("[ERROR]: Account ID '%s' is blocked\n", state);
				strcpy(response, (char*)ACCOUNT_IS_BLOCKED);
				return;
			}
			else if (node->status == STATUS_LOGGED_IN) {
				printf("[ERROR]: Account ID '%s' is already logged in\m", state);
				strcpy(response, (char*)ACCOUNT_IS_LOGGED_IN);
				return;
			}
			printf("[RESPONSE]: Username success - ID '%s'\n", state);
			strcpy(response, (char*)USERNAME_SUCCESS);
			return;
		}
		node = node->next;
	}
	printf("[RESPONSE]: Username not found - ID '%s'\n", state);
	strcpy(response, (char*)USERNAME_NOT_FOUND);
}
void processUsername ( char * data , char * response , char * state ) { printf ( " \n " , data ) ; strcpy ( state , data ) ; Account * node = accountDB ; while ( node != NULL ) { if ( strcmp ( node -> username , data ) == 0 ) { if ( node -> status == STATUS_BLOCKED ) { printf ( " \n " , state ) ; strcpy ( response , ( char * ) ACCOUNT_IS_BLOCKED ) ; return ; } else if ( node -> status == STATUS_LOGGED_IN ) { printf ( " \m " , state ) ; strcpy ( response , ( char * ) ACCOUNT_IS_LOGGED_IN ) ; return ; } printf ( " \n " , state ) ; strcpy ( response , ( char * ) USERNAME_SUCCESS ) ; return ; } node = node -> next ; } printf ( " \n " , state ) ; strcpy ( response , ( char * ) USERNAME_NOT_FOUND ) ; }
Process the username request from the client.
Process the username request from the client .