src/communication/security-server-comm.c
/* Return code in packet is positive integer *
 * We need to convert them to error code which are negative integer */
Return code in packet is positive integer
We need to convert them to error code which are negative integer
Return code in packet is positive integer We need to convert them to error code which are negative integer
int return_code_to_error_code(int ret_code)
{
	int ret;
	switch(ret_code)
	{
		case SECURITY_SERVER_RETURN_CODE_SUCCESS:
		case SECURITY_SERVER_RETURN_CODE_ACCESS_GRANTED:
			ret = SECURITY_SERVER_SUCCESS;
			break;
		case SECURITY_SERVER_RETURN_CODE_BAD_REQUEST:
			ret = SECURITY_SERVER_ERROR_BAD_REQUEST;
			break;
		case SECURITY_SERVER_RETURN_CODE_AUTHENTICATION_FAILED:
			ret = SECURITY_SERVER_ERROR_AUTHENTICATION_FAILED;
			break;
		case SECURITY_SERVER_RETURN_CODE_ACCESS_DENIED:
			ret = SECURITY_SERVER_ERROR_ACCESS_DENIED;
			break;
		case SECURITY_SERVER_RETURN_CODE_NO_SUCH_OBJECT:
			ret = SECURITY_SERVER_ERROR_NO_SUCH_OBJECT;
			break;
		case SECURITY_SERVER_RETURN_CODE_SERVER_ERROR:
			ret = SECURITY_SERVER_ERROR_SERVER_ERROR;
			break;
		case SECURITY_SERVER_RETURN_CODE_NO_SUCH_COOKIE:
			ret = SECURITY_SERVER_ERROR_NO_SUCH_COOKIE;
			break;
		case SECURITY_SERVER_RETURN_CODE_NO_PASSWORD:
			ret = SECURITY_SERVER_ERROR_NO_PASSWORD;
			break;
		case SECURITY_SERVER_RETURN_CODE_PASSWORD_EXIST:
			ret = SECURITY_SERVER_ERROR_PASSWORD_EXIST;
			break;
		case SECURITY_SERVER_RETURN_CODE_PASSWORD_MISMATCH:
			ret = SECURITY_SERVER_ERROR_PASSWORD_MISMATCH;
			break;
		case SECURITY_SERVER_RETURN_CODE_PASSWORD_RETRY_TIMER:
			ret = SECURITY_SERVER_ERROR_PASSWORD_RETRY_TIMER;
			break;
		case SECURITY_SERVER_RETURN_CODE_PASSWORD_EXPIRED:
			ret = SECURITY_SERVER_ERROR_PASSWORD_EXPIRED;
			break;
		case SECURITY_SERVER_RETURN_CODE_PASSWORD_MAX_ATTEMPTS_EXCEEDED:
			ret = SECURITY_SERVER_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED;
			break;
		case SECURITY_SERVER_RETURN_CODE_PASSWORD_REUSED:
			ret = SECURITY_SERVER_ERROR_PASSWORD_REUSED;
			break;
		default:
			ret = SECURITY_SERVER_ERROR_UNKNOWN;
			break;
	}
	return ret;
}
int return_code_to_error_code ( int ret_code ) { int ret ; switch ( ret_code ) { case SECURITY_SERVER_RETURN_CODE_SUCCESS : case SECURITY_SERVER_RETURN_CODE_ACCESS_GRANTED : ret = SECURITY_SERVER_SUCCESS ; break ; case SECURITY_SERVER_RETURN_CODE_BAD_REQUEST : ret = SECURITY_SERVER_ERROR_BAD_REQUEST ; break ; case SECURITY_SERVER_RETURN_CODE_AUTHENTICATION_FAILED : ret = SECURITY_SERVER_ERROR_AUTHENTICATION_FAILED ; break ; case SECURITY_SERVER_RETURN_CODE_ACCESS_DENIED : ret = SECURITY_SERVER_ERROR_ACCESS_DENIED ; break ; case SECURITY_SERVER_RETURN_CODE_NO_SUCH_OBJECT : ret = SECURITY_SERVER_ERROR_NO_SUCH_OBJECT ; break ; case SECURITY_SERVER_RETURN_CODE_SERVER_ERROR : ret = SECURITY_SERVER_ERROR_SERVER_ERROR ; break ; case SECURITY_SERVER_RETURN_CODE_NO_SUCH_COOKIE : ret = SECURITY_SERVER_ERROR_NO_SUCH_COOKIE ; break ; case SECURITY_SERVER_RETURN_CODE_NO_PASSWORD : ret = SECURITY_SERVER_ERROR_NO_PASSWORD ; break ; case SECURITY_SERVER_RETURN_CODE_PASSWORD_EXIST : ret = SECURITY_SERVER_ERROR_PASSWORD_EXIST ; break ; case SECURITY_SERVER_RETURN_CODE_PASSWORD_MISMATCH : ret = SECURITY_SERVER_ERROR_PASSWORD_MISMATCH ; break ; case SECURITY_SERVER_RETURN_CODE_PASSWORD_RETRY_TIMER : ret = SECURITY_SERVER_ERROR_PASSWORD_RETRY_TIMER ; break ; case SECURITY_SERVER_RETURN_CODE_PASSWORD_EXPIRED : ret = SECURITY_SERVER_ERROR_PASSWORD_EXPIRED ; break ; case SECURITY_SERVER_RETURN_CODE_PASSWORD_MAX_ATTEMPTS_EXCEEDED : ret = SECURITY_SERVER_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED ; break ; case SECURITY_SERVER_RETURN_CODE_PASSWORD_REUSED : ret = SECURITY_SERVER_ERROR_PASSWORD_REUSED ; break ; default : ret = SECURITY_SERVER_ERROR_UNKNOWN ; break ; } return ret ; }
Return code in packet is positive integer
 We need to convert them to error code which are negative integer
Return code in packet is positive integer We need to convert them to error code which are negative integer