[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
- [PATCH 0/9] Refactor devices build, Ladislav Michl, 2020/01/25
- [PATCH 1/9] Move device_script into separate file, Ladislav Michl, 2020/01/25
- [PATCH 2/9] Cleanup device includes, Ladislav Michl, 2020/01/25
- [PATCH 3/9] configure.ac: do not mix library and device support checks, Ladislav Michl, 2020/01/25
- [PATCH 4/9] Remove nowhere used device_reset(), Ladislav Michl, 2020/01/25
- [PATCH 5/9] Remove misleading comments from tcp device, Ladislav Michl, 2020/01/25
- [PATCH 6/9] dku2libusb: move definitions into C file, Ladislav Michl, 2020/01/25
- [PATCH 7/9] dku2libusb: whitespace cleanup, Ladislav Michl, 2020/01/25
- [PATCH 8/9] libfunctions: reimplement gn_lib_is_connectiontype_supported,
Ladislav Michl <=
- [PATCH 9/9] Refactor devices build, Ladislav Michl, 2020/01/25
- Re: [PATCH 0/9] Refactor devices build, Pawel Kot, 2020/01/26