Changeset 158 for trunk

Show
Ignore:
Timestamp:
06/05/07 01:19:46 (18 months ago)
Author:
zany
Message:

enabling bt on win32

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/acinclude.m4

    r153 r158  
    4141dnl 
    4242 
     43AC_DEFUN([AC_PATH_WINBT], [  
     44        AC_CACHE_VAL(winbt_found,[  
     45                AC_CHECK_HEADERS(ws2bth.h, winbt_found=yes, winbt_found=no, [  
     46                                #include <winsock2.h>  
     47                ])  
     48        ])  
     49        AC_MSG_CHECKING([for Windows Bluetooth support])  
     50        AC_MSG_RESULT([$winbt_found])  
     51]) 
     52 
     53AC_DEFUN([AC_PATH_NETBSDBT], [ 
     54        AC_CACHE_CHECK([for NetBSD Bluetooth support], netbsdbt_found, [ 
     55                AC_TRY_COMPILE([ 
     56                                #include <bluetooth.h> 
     57                        ], [ 
     58                                struct sockaddr_bt *bt; 
     59                        ], netbsdbt_found=yes, netbsdbt_found=no) 
     60        ]) 
     61]) 
     62 
     63AC_DEFUN([AC_PATH_FREEBSDBT], [ 
     64        AC_CACHE_CHECK([for FreeBSD Bluetooth support], freebsdbt_found, [ 
     65                AC_TRY_COMPILE([ 
     66                                #include <bluetooth.h> 
     67                        ], [ 
     68                                struct sockaddr_rfcomm *rfcomm; 
     69                        ], freebsdbt_found=yes, freebsdbt_found=no) 
     70        ]) 
     71]) 
     72 
     73AC_DEFUN([AC_PATH_BLUEZ], [ 
     74        PKG_CHECK_MODULES(BLUETOOTH, bluez, bluez_found=yes, AC_MSG_RESULT(no))  
     75]) 
     76 
     77AC_DEFUN([AC_PATH_BLUETOOTH], [ 
     78        case $host in 
     79        *-*-linux*) 
     80                AC_PATH_BLUEZ 
     81                ;; 
     82        *-*-freebsd*) 
     83                AC_PATH_FREEBSDBT 
     84                ;; 
     85        *-*-netbsd*) 
     86                AC_PATH_NETBSDBT 
     87                ;; 
     88        *-*-mingw32*)  
     89                AC_PATH_WINBT  
     90                ;; 
     91        esac 
     92        AC_SUBST(BLUETOOTH_CFLAGS) 
     93        AC_SUBST(BLUETOOTH_LIBS) 
     94]) 
     95 
    4396AC_DEFUN([BLUETOOTH_CHECK],[   
    4497AC_ARG_ENABLE([bluetooth], 
     
    48101 
    49102if test "$ac_bluetooth_enabled" = yes; then 
    50         AC_CACHE_CHECK([for Bluetooth support], am_cv_bluetooth_found,[ 
    51  
    52                 AC_TRY_COMPILE([ 
    53                                 #ifdef __FreeBSD__ 
    54                                 #include <sys/types.h> 
    55                                 #include <bluetooth.h> 
    56                                 #else /* Linux */ 
    57                                 #include <sys/socket.h> 
    58                                 #include <bluetooth/bluetooth.h> 
    59                                 #include <bluetooth/rfcomm.h> 
    60                                 #endif 
    61                         ],[ 
    62                                 #ifdef __FreeBSD__ 
    63                                 bdaddr_t bdaddr; 
    64                                 struct sockaddr_rfcomm addr; 
    65                                 #else /* Linux */ 
    66                                 bdaddr_t bdaddr; 
    67                                 struct sockaddr_rc addr; 
    68                                 #endif 
    69                         ], 
    70                                 am_cv_bluetooth_found=yes, 
    71                                 am_cv_bluetooth_found=no)]) 
    72         if test $am_cv_bluetooth_found = yes; then 
     103        AC_PATH_BLUETOOTH 
     104        if test "${netbsdbt_found}" = "yes" -o "${freebsdbt_found}" = "yes" -o "${bluez_found}" = "yes" -o "${winbt_found}" = "yes"; then 
    73105                AC_DEFINE([HAVE_BLUETOOTH], [1], [Define if system supports Bluetooth and it's enabled]) 
    74                 BLUETOOTH_CFLAGS="" 
    75                 BLUETOOTH_LIBS="-lbluetooth" 
    76106        fi 
    77         AC_SUBST(BLUETOOTH_CFLAGS) 
    78         AC_SUBST(BLUETOOTH_LIBS) 
    79107fi 
    80108]) 
  • trunk/apps/obexftpd.c

    r154 r158  
    2626 */ 
    2727 
     28#ifdef HAVE_CONFIG_H 
     29#include <config.h> 
     30#endif 
     31 
    2832#define _GNU_SOURCE 
    2933#include <stdio.h> 
     
    4044#ifdef _WIN32 
    4145#include <winsock2.h> 
     46#ifdef HAVE_BLUETOOTH 
     47#include <ws2bth.h> 
     48#define bdaddr_t        BTH_ADDR 
     49#define BDADDR_ANY      BTH_ADDR_NULL 
     50#endif 
    4251#define S_IRGRP 0 
    4352#define S_IROTH 0 
  • trunk/configure.in

    r155 r158  
    3333dnl IRDA_CHECK 
    3434BLUETOOTH_CHECK 
    35 if test $am_cv_bluetooth_found = yes; then 
     35if test "${bluez_found}" = "yes"; then 
    3636        SDPLIB_CHECK 
    3737fi 
  • trunk/obexftp/client.c

    r156 r158  
    5151 
    5252#ifdef HAVE_BLUETOOTH 
     53#ifdef _WIN32 
     54#include <ws2bth.h> 
     55#define bdaddr_t        BTH_ADDR 
     56#define BDADDR_ANY      BTH_ADDR_NULL 
     57#define bacpy(dst,src)  memcpy((dst),(src),sizeof(BTH_ADDR)) 
     58#else /* _WIN32 */ 
     59 
    5360#ifdef __FreeBSD__ 
    5461#include <sys/types.h> 
     
    6067#include <bluetooth/hci_lib.h> 
    6168#endif /* __FreeBSD__ */ 
    62 #endif 
     69 
     70#endif /* _WIN32 */ 
     71#endif /* HAVE_BLUETOOTH */ 
    6372 
    6473#include <openobex/obex.h> 
     
    8190} __attribute__((packed)) apparam_t; 
    8291 
     92#ifdef _WIN32 
     93#ifdef HAVE_BLUETOOTH 
     94static int str2ba(const char *straddr, BTH_ADDR *btaddr) 
     95{ 
     96        int i; 
     97        unsigned int aaddr[6]; 
     98        BTH_ADDR tmpaddr = 0; 
     99 
     100        if (sscanf(straddr, "%02x:%02x:%02x:%02x:%02x:%02x", 
     101                   &aaddr[0], &aaddr[1], &aaddr[2], &aaddr[3], &aaddr[4], &aaddr[5]) != 6) 
     102                return 1; 
     103        *btaddr = 0; 
     104        for (i = 0; i < 6; i++) { 
     105                tmpaddr = (BTH_ADDR) (aaddr[i] & 0xff); 
     106                *btaddr = ((*btaddr) << 8) + tmpaddr; 
     107        } 
     108        return 0; 
     109} 
     110#endif 
     111#endif 
    83112 
    84113static void dummy_info_cb(int UNUSED(event), const char *UNUSED(msg), int UNUSED(len), void *UNUSED(data)) 
     
    555584                        peer.sin_family = AF_INET; 
    556585                        peer.sin_port = htons(port); /* overridden with OBEX_PORT 650 anyhow */ 
    557                         ret = OBEX_TransportConnect(cli->obexhandle, (struct sockaddr *) &peer, 
     586                        ret = InOBEX_TransportConnect(cli->obexhandle, (struct sockaddr *) &peer, 
    558587                                                  sizeof(struct sockaddr_in)); 
    559588                        DEBUG(3, "%s() TCP %d\n", __func__, ret); 
     
    581610                        str2ba(src, &src_addr); 
    582611                        hci_id = atoi(src); 
     612#ifndef _WIN32 
    583613                        if (hci_id > 0) { 
    584614                                hci_devba(hci_id, &src_addr);    
    585615                        } 
     616#endif 
    586617                } 
    587618                if (!device) {