Zitat von Iain Hibbert <plu...@netbsd.org>:

> From: Iain Hibbert <plu...@galant.ukfsn.org>
>
> this should work on NetBSD and FreeBSD
> and possibly OpenBSD and DragonflyBSD also with a little work
> ---
>  acinclude.m4     |   84 ++++++--------
>  obexftp/bt_kit.c |  347  
> +++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  obexftp/bt_kit.h |   34 +++---
>  obexftp/client.c |    7 +-
>  4 files changed, 405 insertions(+), 67 deletions(-)
>
> diff --git a/acinclude.m4 b/acinclude.m4
> index 9326885..c8ba777 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -50,31 +50,44 @@ AC_DEFUN([AC_PATH_WINBT], [
>       AC_MSG_RESULT([$winbt_found])
>  ])
>
> -AC_DEFUN([AC_PATH_NETBSDBT], [
> -     AC_CACHE_CHECK([for NetBSD Bluetooth support], netbsdbt_found, [
> +AC_DEFUN([AC_PATH_BSDBT], [
> +     AC_CACHE_CHECK([for BSD Bluetooth support], bsdbt_found, [
>               AC_TRY_COMPILE([
>                               #include <bluetooth.h>
>                       ], [
> -                             struct sockaddr_bt *bt;
> -                     ], netbsdbt_found=yes, netbsdbt_found=no)
> +                             #ifndef BTPROTO_RFCOMM
> +                             #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM
> +                             #endif
> +
> +                             bdaddr_t bdaddr;
> +                             int family = AF_BLUETOOTH;
> +                             int proto = BTPROTO_RFCOMM;
> +                     ], bsdbt_found=yes, bsdbt_found=no)
>       ])
> -])
> -
> -AC_DEFUN([AC_PATH_FREEBSDBT], [
> -     AC_CACHE_CHECK([for FreeBSD Bluetooth support], freebsdbt_found, [
> -             AC_TRY_COMPILE([
> -                             #include <bluetooth.h>
> -                     ], [
> -                             struct sockaddr_rfcomm *rfcomm;
> -                     ], freebsdbt_found=yes, freebsdbt_found=no)
> -     ])
> -     if test "${freebsdbt_found}" = "yes"; then
> +     if test "${bsdbt_found}" = "yes"; then
>               BLUETOOTH_LIBS=-lbluetooth
> +             AC_CACHE_CHECK([for BSD Service Discovery support], 
> bsdsdp_found, [
> +                     AC_TRY_COMPILE([
> +                                     #include <bluetooth.h>
> +                                     #include <sdp.h>
> +                             ], [
> +                                     struct bt_devinquiry di;
> +                                     sdp_data_t data;
> +                             ], bsdsdp_found=yes, bsdsdp_found=no)
> +             ])
>       fi
>  ])
>
>  AC_DEFUN([AC_PATH_BLUEZ], [
> -     PKG_CHECK_MODULES(BLUETOOTH, bluez, bluez_found=yes, AC_MSG_RESULT(no))
> +     PKG_CHECK_MODULES(BLUETOOTH, bluez, [
> +             bluez_found=yes
> +             AC_MSG_CHECKING(for BlueZ Service Discovery support)
> +             AC_TRY_COMPILE([
> +                             #include <bluetooth/sdp.h>
> +                     ],[
> +                             sdp_list_t sdplist;
> +                     ], bluezsdp_found=yes, bluezsdp_found=no)
> +     ], AC_MSG_RESULT(no))
>  ])
>
>  AC_DEFUN([AC_PATH_BLUETOOTH], [
> @@ -83,10 +96,10 @@ AC_DEFUN([AC_PATH_BLUETOOTH], [
>                  AC_PATH_BLUEZ
>                  ;;
>          *-*-freebsd*)
> -                AC_PATH_FREEBSDBT
> +                AC_PATH_BSDBT
>                  ;;
>          *-*-netbsd*)
> -                AC_PATH_NETBSDBT
> +                AC_PATH_BSDBT
>                  ;;
>       *-*-mingw32*)
>               AC_PATH_WINBT
> @@ -96,44 +109,21 @@ AC_DEFUN([AC_PATH_BLUETOOTH], [
>       AC_SUBST(BLUETOOTH_LIBS)
>  ])
>
> -AC_DEFUN([BLUETOOTH_CHECK],[
> +AC_DEFUN([BLUETOOTH_CHECK],[
>  AC_ARG_ENABLE([bluetooth],
>                [AC_HELP_STRING([--disable-bluetooth],
>                                [Disables bluetooth support  
> @<:@default=auto@:>@])],
>                     [ac_bluetooth_enabled=$enableval], 
> [ac_bluetooth_enabled=yes])
>
>  if test "$ac_bluetooth_enabled" = yes; then
> -             AC_PATH_BLUETOOTH
> -     if test "${netbsdbt_found}" = "yes" -o "${freebsdbt_found}" =  
> "yes" -o "${bluez_found}" = "yes" -o "${winbt_found}" = "yes"; then
> +     AC_PATH_BLUETOOTH
> +     if test "${bsdbt_found}" = "yes" -o "${bluez_found}" = "yes" -o  
> "${winbt_found}" = "yes"; then
>               AC_DEFINE([HAVE_BLUETOOTH], [1], [Define if system supports  
> Bluetooth and it's enabled])
>       fi
> -fi
> -])
> -
> -
> -dnl
> -dnl Check for Bluetooth SDP library
> -dnl Waring: the AC_TRY_COMPILE won't work with -Werror
> -dnl
> -
> -AC_DEFUN([SDPLIB_CHECK],[
> -     AC_MSG_CHECKING(for Bluetooth SDP support)
> -
> -     AC_TRY_COMPILE( [
> -                             #include <bluetooth/sdp.h>
> -                     ],[
> -                             sdp_list_t sdplist;
> -                     ],
> -                             am_cv_sdplib_found=yes,
> -                             am_cv_sdplib_found=no
> -                     )
> -
> -     if test $am_cv_sdplib_found = yes; then
> -             AC_DEFINE(HAVE_SDPLIB,1,[Define if system supports Bluetooth 
> SDP])
> -
> +     if test "${bsdsdp_found}" = "yes" -o "${bluezsdp_found}" = "yes"; then
> +             AC_DEFINE([HAVE_SDP], [1], [Define if system supports Bluetooth 
>  
> Service Discovery])
>       fi
> -
> -     AC_MSG_RESULT($am_cv_sdplib_found)
> +fi
>  ])
>
>
> diff --git a/obexftp/bt_kit.c b/obexftp/bt_kit.c
> index 41aa224..67ee4ec 100644
> --- a/obexftp/bt_kit.c
> +++ b/obexftp/bt_kit.c
> @@ -349,8 +349,350 @@ int btkit_unregister_service(int UNUSED(svclass))
>
>  #else /* _WIN32 */
>
> -#ifdef HAVE_SDPLIB /* should switch on OS here */
> +#ifdef HAVE_SDP
> +#if defined(__NetBSD__) || defined(__FreeBSD__)
[...]
> +#else /* defined(__NetBSD__) || defined(__FreeBSD__) */

Is it possible with the build system (autotools) to no used ifdef here  
but separate files like bt_kit_bsd.c, bt_kit_win32.c, bt_kit_linux.c  
and bt_kit_dummy.c? If not, enlarging this one file is ok, too.

>  /**
>       Discover all bluetooth devices in range.
> @@ -695,6 +1037,7 @@ int btkit_register_obex(int service, int channel)
>       return 0;
>  }
>
> +#endif       /* BlueZ/Linux */
>
>  #else
>  #warning "no bluetooth sdp support for this platform"
> @@ -723,7 +1066,7 @@ int btkit_unregister_service(int UNUSED(svclass))
>       return -1;
>  }
>
> -#endif /* HAVE_SDPLIB */
> +#endif /* HAVE_SDP */
>  #endif /* _WIN32 */
>
>  #else
> diff --git a/obexftp/bt_kit.h b/obexftp/bt_kit.h
> index 154c73b..6eeba6b 100644
> --- a/obexftp/bt_kit.h
> +++ b/obexftp/bt_kit.h
> @@ -79,26 +79,26 @@ extern "C" {
>  BTKITSYM int ba2str(const bdaddr_t *btaddr, char *straddr);
>  BTKITSYM int str2ba(const char *straddr, BTH_ADDR *btaddr);
>
> -/* FreeBSD 5 and up */
> -#elif defined(__FreeBSD__)
> -//#include <sys/types.h>
> +/* Various BSD systems */
> +#elif defined(__NetBSD__) || defined(__FreeBSD__)
> +#define COMPAT_BLUEZ

Can this be used without problems? Should be use it in OpenOBEX, too?

HS



------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Openobex-users mailing list
Openobex-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to