From 6bc1b521a5546d68a60b2f2ff1eaf1f836467011 Mon Sep 17 00:00:00 2001 From: Pedro Kiefer Date: Fri, 20 Jul 2012 12:07:20 -0300 Subject: [PATCH 3/6] Extract constant number to defines --- apps/app_alarmreceiver.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c index f828956..22aaf62 100644 --- a/apps/app_alarmreceiver.c +++ b/apps/app_alarmreceiver.c @@ -58,6 +58,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 362635 $") #define ALMRCV_CONFIG "alarmreceiver.conf" #define ADEMCO_CONTACT_ID "ADEMCO_CONTACT_ID" +#define ADEMCO_MSG_TYPE_1 "18" +#define ADEMCO_MSG_TYPE_2 "98" struct event_node{ char data[17]; @@ -519,9 +521,8 @@ static int receive_ademco_contact_id(struct ast_channel *chan, const void *data, } /* Check the message type for correctness */ - - if (strncmp(event + 4, "18", 2)) { - if (strncmp(event + 4, "98", 2)) { + if (strncmp(event + 4, ADEMCO_MSG_TYPE_1, 2)) { + if (strncmp(event + 4, ADEMCO_MSG_TYPE_2, 2)) { database_increment("format-errors"); ast_verb(2, "AlarmReceiver: Wrong message type\n"); ast_debug(1, "AlarmReceiver: Wrong message type\n"); -- 1.7.9.5