From d995cdfc7dc397a080e5ed5aef63f61d2b8e01bc Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 25 Sep 2013 11:41:05 -0400 Subject: [PATCH] [lib] Add macro OWL_IS_REQUEST_TYPE() This macro allows to check if a given number is a valid request type. --- libowlps/owlps.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libowlps/owlps.h b/libowlps/owlps.h index 09d50b1..b8b6d5b 100644 --- a/libowlps/owlps.h +++ b/libowlps/owlps.h @@ -218,6 +218,8 @@ typedef struct _owl_autocalibration_order owl_autocalibration_order ; /// Undefined or unknown request type #define OWL_REQUEST_UNDEFINED 255 //@} +/* Don't forget to update the OWL_IS_REQUEST_TYPE macro below when you + * change something here! */ /** @name Wi-Fi channels' frequencies in MHz */ @@ -304,11 +306,27 @@ extern bool owl_run ; /* Macros */ + /// Converts a bool to the corresponding string #define OWL_BOOL_TO_STRING(B) ((B) ? "true" : "false") +/// Make sure the given integer is a valid request type +/** + * True if `I` is a valid request type, false otherwise. + * Do *not* pass an incremented number to this macro (e.g. type++ or + * ++type). This shouldn't be a problem with a request type, though. + */ +#define OWL_IS_REQUEST_TYPE(I) \ + ( (I) == OWL_REQUEST_NORMAL \ + || (I) == OWL_REQUEST_CALIBRATION \ + || (I) == OWL_REQUEST_AUTOCALIBRATION \ + || (I) == OWL_REQUEST_GENERATED \ + || (I) == OWL_REQUEST_IMPLICIT \ + || (I) == OWL_REQUEST_UNDEFINED) + /* Function headers */ + /** @name Miscellaneous */ //@{ /// Converts a MAC address from bytes to string