From af72adf2ee13ced8ae567095e898e65b8c60b5d0 Mon Sep 17 00:00:00 2001 From: Lev Stipakov Date: Thu, 13 May 2021 11:27:47 +0300 Subject: [PATCH] fix log() confusion By some reasons Release build ignores _INC_MATH and includes math.h, which conflicts with our own log definition. Rename it to log_. While on it, also rename other enum names for consistency. Signed-off-by: Lev Stipakov --- main.c | 22 +++++++++++----------- manage.c | 48 ++++++++++++++++++++++++------------------------ manage.h | 24 ++++++++++++------------ 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/main.c b/main.c index 431f968..d25429a 100644 --- a/main.c +++ b/main.c @@ -175,17 +175,17 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance, /* Initialize handlers for manangement interface notifications */ mgmt_rtmsg_handler handler[] = { - { ready, OnReady }, - { hold, OnHold }, - { log, OnLogLine }, - { state, OnStateChange }, - { password, OnPassword }, - { proxy, OnProxy }, - { stop, OnStop }, - { needok, OnNeedOk }, - { needstr, OnNeedStr }, - { echo, OnEcho }, - { bytecount,OnByteCount }, + { ready_, OnReady }, + { hold_, OnHold }, + { log_, OnLogLine }, + { state_, OnStateChange }, + { password_, OnPassword }, + { proxy_, OnProxy }, + { stop_, OnStop }, + { needok_, OnNeedOk }, + { needstr_, OnNeedStr }, + { echo_, OnEcho }, + { bytecount_,OnByteCount }, { 0, NULL } }; InitManagement(handler); diff --git a/manage.c b/manage.c index 5489258..45106b1 100644 --- a/manage.c +++ b/manage.c @@ -212,7 +212,7 @@ OnManagement(SOCKET sk, LPARAM lParam) if (c->state != disconnected) c->state = timedout; CloseManagement (c); - rtmsg_handler[stop](c, ""); + rtmsg_handler[stop_](c, ""); } } else @@ -282,55 +282,55 @@ OnManagement(SOCKET sk, LPARAM lParam) pos = line + 1; if (strncmp(pos, "LOG:", 4) == 0) { - if (rtmsg_handler[log]) - rtmsg_handler[log](c, pos + 4); + if (rtmsg_handler[log_]) + rtmsg_handler[log_](c, pos + 4); } else if (strncmp(pos, "STATE:", 6) == 0) { - if (rtmsg_handler[state]) - rtmsg_handler[state](c, pos + 6); + if (rtmsg_handler[state_]) + rtmsg_handler[state_](c, pos + 6); } else if (strncmp(pos, "HOLD:", 5) == 0) { - if (rtmsg_handler[hold]) - rtmsg_handler[hold](c, pos + 5); + if (rtmsg_handler[hold_]) + rtmsg_handler[hold_](c, pos + 5); } else if (strncmp(pos, "PASSWORD:", 9) == 0) { - if (rtmsg_handler[password]) - rtmsg_handler[password](c, pos + 9); + if (rtmsg_handler[password_]) + rtmsg_handler[password_](c, pos + 9); } else if (strncmp(pos, "PROXY:", 6) == 0) { - if (rtmsg_handler[proxy]) - rtmsg_handler[proxy](c, pos + 6); + if (rtmsg_handler[proxy_]) + rtmsg_handler[proxy_](c, pos + 6); } else if (strncmp(pos, "INFO:", 5) == 0) { /* delay until management interface accepts input */ Sleep(100); - if (rtmsg_handler[ready]) - rtmsg_handler[ready](c, pos + 5); + if (rtmsg_handler[ready_]) + rtmsg_handler[ready_](c, pos + 5); } else if (strncmp(pos, "NEED-OK:", 8) == 0) { - if (rtmsg_handler[needok]) - rtmsg_handler[needok](c, pos + 8); + if (rtmsg_handler[needok_]) + rtmsg_handler[needok_](c, pos + 8); } else if (strncmp(pos, "NEED-STR:", 9) == 0) { - if (rtmsg_handler[needstr]) - rtmsg_handler[needstr](c, pos + 9); + if (rtmsg_handler[needstr_]) + rtmsg_handler[needstr_](c, pos + 9); } else if (strncmp(pos, "ECHO:", 5) == 0) { - if (rtmsg_handler[echo]) - rtmsg_handler[echo](c, pos + 5); + if (rtmsg_handler[echo_]) + rtmsg_handler[echo_](c, pos + 5); } else if (strncmp(pos, "BYTECOUNT:", 10) == 0) { - if (rtmsg_handler[bytecount]) - rtmsg_handler[bytecount](c, pos + 10); + if (rtmsg_handler[bytecount_]) + rtmsg_handler[bytecount_](c, pos + 10); } } else if (c->manage.cmd_queue) @@ -349,7 +349,7 @@ OnManagement(SOCKET sk, LPARAM lParam) char buf[256]; _snprintf_0(buf, "%lld,N,Previous command sent to management failed: %s", (long long)time(NULL), line) - rtmsg_handler[log](c, buf); + rtmsg_handler[log_](c, buf); if (cmd->handler) cmd->handler(c, NULL); @@ -374,8 +374,8 @@ OnManagement(SOCKET sk, LPARAM lParam) case FD_CLOSE: CloseManagement (c); - if (rtmsg_handler[stop]) - rtmsg_handler[stop](c, ""); + if (rtmsg_handler[stop_]) + rtmsg_handler[stop_](c, ""); break; } } diff --git a/manage.h b/manage.h index 94632bd..6d563dd 100644 --- a/manage.h +++ b/manage.h @@ -25,18 +25,18 @@ #include typedef enum { - ready, - stop, - bytecount, - echo, - hold, - log, - password, - proxy, - state, - needok, - needstr, - pkcs11_id_count, + ready_, + stop_, + bytecount_, + echo_, + hold_, + log_, + password_, + proxy_, + state_, + needok_, + needstr_, + pkcs11_id_count_, mgmt_rtmsg_type_max } mgmt_rtmsg_type;