gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 8/9] libfunctions: reimplement gn_lib_is_connectiontype_supported


From: Ladislav Michl
Subject: [PATCH 8/9] libfunctions: reimplement gn_lib_is_connectiontype_supported
Date: Sat, 25 Jan 2020 10:48:01 +0100

We already do have a list of supported connectionis in connectiontypes
array, so use it here as well. This removes another #ifdeffery
and fixed bug where condition for TCP was inverted.
---
 common/libfunctions.c | 54 ++++---------------------------------------
 1 file changed, 5 insertions(+), 49 deletions(-)

diff --git a/common/libfunctions.c b/common/libfunctions.c
index d72cf4aa..3db61b1e 100644
--- a/common/libfunctions.c
+++ b/common/libfunctions.c
@@ -542,55 +542,11 @@ GNOKII_API const char 
*gn_lib_get_connection_name(gn_connection_type ct)
 
 GNOKII_API int gn_lib_is_connectiontype_supported(gn_connection_type ct)
 {
-       switch (ct) {
-       case GN_CT_Serial:
-       case GN_CT_DAU9P:
-       case GN_CT_DLR3P:
-       case GN_CT_M2BUS:
-       case GN_CT_Tekram:
-               return 1;
-       case GN_CT_Infrared:
-       case GN_CT_Irda:
-#ifdef HAVE_IRDA
-               return 1;
-#else
-               return 0;
-#endif
-       case GN_CT_Bluetooth:
-#ifdef HAVE_BLUETOOTH
-               return 1;
-#else
-               return 0;
-#endif
-       case GN_CT_DKU2: /* FIXME: How to detect this? */
-               return 1;
-       case GN_CT_DKU2LIBUSB:
-#ifdef HAVE_LIBUSB
-               return 1;
-#else
-               return 0;
-#endif
-       case GN_CT_PCSC:
-#ifdef HAVE_PCSC
-               return 1;
-#else
-               return 0;
-#endif
-       case GN_CT_TCP:
-#ifndef WIN32
-               return 0;
-#else
-               return 1;
-#endif
-       case GN_CT_SOCKETPHONET:
-#ifndef HAVE_SOCKETPHONET
-               return 0;
-#else
-               return 1;
-#endif
-       default:
-               return 0;
-       }
+       int i;
+       for (i = 0; i < sizeof(connectiontypes)/sizeof(connectiontypes[0]); i++)
+               if (ct == connectiontypes[i].ct)
+                       return 1;
+       return 0;
 }
 
 GNOKII_API gn_error gn_lib_search_one_connected_phone(struct gn_statemachine 
**state)
-- 
2.25.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]