From 96af8adb518ff7728522ec5d868f90288f3494ca Mon Sep 17 00:00:00 2001 From: skarg Date: Mon, 7 Aug 2006 14:55:20 +0000 Subject: [PATCH] Refactored. --- bacnet-stack/apdu.c | 70 ++++++++++++++++----------------------------- bacnet-stack/apdu.h | 7 ----- 2 files changed, 24 insertions(+), 53 deletions(-) diff --git a/bacnet-stack/apdu.c b/bacnet-stack/apdu.c index a20954fd..42e76431 100644 --- a/bacnet-stack/apdu.c +++ b/bacnet-stack/apdu.c @@ -104,48 +104,6 @@ void apdu_set_confirmed_handler(BACNET_CONFIRMED_SERVICE service_choice, Confirmed_Function[service_choice] = pFunction; } -/* returns true if the handler is set */ -bool apdu_confirmed_handler(BACNET_CONFIRMED_SERVICE service_choice) -{ - bool status = false; - if ((service_choice < MAX_BACNET_CONFIRMED_SERVICE) && - (Confirmed_Function[service_choice] != NULL)) - status = true; - - return status; -} - -bool apdu_service_supported(BACNET_SERVICES_SUPPORTED service_supported) -{ - int i = 0; - bool status = false; - bool found = false; - - if (service_supported < MAX_BACNET_SERVICES_SUPPORTED) { - /* is it a confirmed service? */ - for (i = 0; i < MAX_BACNET_CONFIRMED_SERVICE; i++) { - if (confirmed_service_supported[i] == service_supported) { - if (apdu_confirmed_handler(i)) - status = true; - found = true; - break; - } - } - - if (!found) { - /* is it an unconfirmed service? */ - for (i = 0; i < MAX_BACNET_UNCONFIRMED_SERVICE; i++) { - if (unconfirmed_service_supported[i] == service_supported) { - if (apdu_unconfirmed_handler(i)) - status = true; - break; - } - } - } - } - return status; -} - /* Allow the APDU handler to automatically reject */ static confirmed_function Unrecognized_Service_Handler; @@ -169,14 +127,34 @@ void apdu_set_unconfirmed_handler(BACNET_UNCONFIRMED_SERVICE Unconfirmed_Function[service_choice] = pFunction; } -bool apdu_unconfirmed_handler(BACNET_UNCONFIRMED_SERVICE service_choice) +bool apdu_service_supported(BACNET_SERVICES_SUPPORTED service_supported) { + int i = 0; bool status = false; + bool found = false; - if ((service_choice < MAX_BACNET_UNCONFIRMED_SERVICE) && - (Unconfirmed_Function[service_choice] != NULL)) - status = true; + if (service_supported < MAX_BACNET_SERVICES_SUPPORTED) { + /* is it a confirmed service? */ + for (i = 0; i < MAX_BACNET_CONFIRMED_SERVICE; i++) { + if (confirmed_service_supported[i] == service_supported) { + if (Confirmed_Function[i] != NULL) + status = true; + found = true; + break; + } + } + if (!found) { + /* is it an unconfirmed service? */ + for (i = 0; i < MAX_BACNET_UNCONFIRMED_SERVICE; i++) { + if (unconfirmed_service_supported[i] == service_supported) { + if (Unconfirmed_Function[i] != NULL) + status = true; + break; + } + } + } + } return status; } diff --git a/bacnet-stack/apdu.h b/bacnet-stack/apdu.h index 1349b65c..b0372978 100644 --- a/bacnet-stack/apdu.h +++ b/bacnet-stack/apdu.h @@ -128,16 +128,9 @@ extern "C" { void apdu_set_confirmed_handler(BACNET_CONFIRMED_SERVICE service_choice, confirmed_function pFunction); -/* returns true if the handler is set */ - bool apdu_confirmed_handler(BACNET_CONFIRMED_SERVICE service_choice); - void apdu_set_unconfirmed_handler(BACNET_UNCONFIRMED_SERVICE service_choice, unconfirmed_function pFunction); -/* returns true if the handler is set */ - bool apdu_unconfirmed_handler(BACNET_UNCONFIRMED_SERVICE - service_choice); - /* returns true if the service is supported by a handler */ bool apdu_service_supported(BACNET_SERVICES_SUPPORTED service_supported);