Am Sonntag 17 Dezember 2006 19:09 schrieb Marcel Holtmann:
> please post the patch to the mailing list. I need to review it and I am
> sure that we have to break it into pieces.
I attached them. Order is:
win32.patch
old-compiler.patch
ws2bth.patch
glib-win32.patch
apps-win32.patch
The first three are for lib/ and include/ subdirs. win32.patch contains all
changes to auto* files.
The *-win32.patch files are additions and restricted to the specific subdirs,
each containing their own small changes to local Makefile.am files.
HS
Index: openobex-cvs/include/obex_const.h
===================================================================
--- openobex-cvs.orig/include/obex_const.h 2006-12-17 02:10:50.306439506 +0100
+++ openobex-cvs/include/obex_const.h 2006-12-17 02:12:01.598895006 +0100
@@ -65,7 +65,7 @@
/* Active data interface description, typically empty */
char *data_interface_active;
/* Internal information for the transport layer in the library */
- struct obex_usb_intf_transport_t *interface;
+ struct obex_usb_intf_transport_t *intf;
} obex_usb_intf_t;
/* Generic OBEX interface information */
Index: openobex-cvs/lib/obex.c
===================================================================
--- openobex-cvs.orig/lib/obex.c 2006-12-17 02:12:01.294876006 +0100
+++ openobex-cvs/lib/obex.c 2006-12-17 02:12:01.630897006 +0100
@@ -1122,7 +1122,7 @@
* An easier connect function to connect to a discovered interface (currently
* USB OBEX only).
*/
-int OBEX_InterfaceConnect(obex_t *self, obex_interface_t *interface)
+int OBEX_InterfaceConnect(obex_t *self, obex_interface_t *intf)
{
DEBUG(4, "\n");
@@ -1133,12 +1133,12 @@
return -EBUSY;
}
- obex_return_val_if_fail(interface != NULL, -1);
+ obex_return_val_if_fail(intf != NULL, -1);
switch (self->trans.type) {
case OBEX_TRANS_USB:
- obex_return_val_if_fail(interface->usb.interface != NULL, -1);
+ obex_return_val_if_fail(intf->usb.intf != NULL, -1);
#ifdef HAVE_USB
- usbobex_prepare_connect(self, interface->usb.interface);
+ usbobex_prepare_connect(self, intf->usb.intf);
return obex_transport_connect_request(self);
#else
return -ESOCKTNOSUPPORT;
Index: openobex-cvs/include/obex.h
===================================================================
--- openobex-cvs.orig/include/obex.h 2006-12-17 02:12:01.162867756 +0100
+++ openobex-cvs/include/obex.h 2006-12-17 14:43:55.334327256 +0100
@@ -141,8 +141,8 @@
/*
* OBEX interface discovery API
*/
- int OBEX_FindInterfaces(obex_t *self, obex_interface_t **interfaces);
- int OBEX_InterfaceConnect(obex_t *self, obex_interface_t *interface);
+ int OBEX_FindInterfaces(obex_t *self, obex_interface_t **intf);
+ int OBEX_InterfaceConnect(obex_t *self, obex_interface_t *intf);
void OBEX_FreeInterfaces(obex_t *self);
#ifdef __cplusplus
Index: openobex-cvs/apps/Makefile.am
===================================================================
--- openobex-cvs.orig/apps/Makefile.am 2006-12-17 02:12:19.992044506 +0100
+++ openobex-cvs/apps/Makefile.am 2006-12-17 02:12:59.518514756 +0100
@@ -16,7 +16,7 @@
obex_test_LDADD = $(top_builddir)/lib/libopenobex.la @BLUETOOTH_LIBS@ libmisc.a
-LDADD = $(top_builddir)/lib/libopenobex.la libmisc.a
+LDADD = libmisc.a $(top_builddir)/lib/libopenobex.la
INCLUDES = @BLUETOOTH_CFLAGS@ -I$(top_builddir)/include
endif
Index: openobex-cvs/apps/irxfer.c
===================================================================
--- openobex-cvs.orig/apps/irxfer.c 2006-12-17 02:12:20.040047506 +0100
+++ openobex-cvs/apps/irxfer.c 2006-12-17 02:12:59.542516256 +0100
@@ -36,6 +36,11 @@
#include <config.h>
#endif
+#ifdef _WIN32
+#include <windows.h>
+#define sleep(sec) Sleep(1000*sec)
+#endif
+
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
Index: openobex-cvs/apps/obex_test_client.c
===================================================================
--- openobex-cvs.orig/apps/obex_test_client.c 2006-12-17 02:12:20.084050256 +0100
+++ openobex-cvs/apps/obex_test_client.c 2006-12-17 02:31:49.273120006 +0100
@@ -33,9 +33,15 @@
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
-#include <libgen.h>
#include <string.h>
+#ifdef _WIN32
+#warning "No implementation for basename() in win32!"
+#define basename(x) (x)
+#else
+#include <libgen.h>
+#endif
+
#include <openobex/obex.h>
#include "obex_io.h"
Index: openobex-cvs/apps/obex_test_cable.h
===================================================================
--- openobex-cvs.orig/apps/obex_test_cable.h 2006-12-17 02:12:20.132053256 +0100
+++ openobex-cvs/apps/obex_test_cable.h 2006-12-17 02:12:59.642522506 +0100
@@ -33,8 +33,13 @@
#define CABLE_DEBUG 1
-
+#ifdef _WIN32
+#include <windows.h>
+#define tty_desc_t DCB
+#else
#include <termios.h>
+#define tty_desc_t struct termios
+#endif
#ifdef CABLE_DEBUG
#define CDEBUG(format, args...) printf("%s(): " format, __FUNCTION__ , ##args)
@@ -47,7 +52,7 @@
const char *portname;
int ttyfd;
char inputbuf[500];
- struct termios oldtio, newtio;
+ tty_desc_t oldtio, newtio;
int r320;
};
Index: openobex-cvs/apps/obex_test_cable.c
===================================================================
--- openobex-cvs.orig/apps/obex_test_cable.c 2006-12-17 02:12:20.176056006 +0100
+++ openobex-cvs/apps/obex_test_cable.c 2006-12-17 02:17:57.437133506 +0100
@@ -35,12 +35,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
-#include <sys/ioctl.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
-#include <termios.h>
+
+#ifndef _WIN32
+#include <sys/ioctl.h>
+#endif
#include <openobex/obex.h>
@@ -60,6 +62,10 @@
//
int cobex_do_at_cmd(struct cobex_context *gt, char *cmd, char *rspbuf, int rspbuflen, int timeout)
{
+#ifdef _WIN32
+#warning "Implementation for win32 is missing!"
+ return -1;
+#else
fd_set ttyset;
struct timeval tv;
int fd;
@@ -151,6 +157,7 @@
strncpy(rspbuf, answer, answer_size);
rspbuf[answer_size] = 0;
return 0;
+#endif
}
//
@@ -158,6 +165,9 @@
//
static int cobex_init(struct cobex_context *gt)
{
+#ifdef _WIN32
+#warning "Implementation for win32 is missing!"
+#else
char rspbuf[200];
CDEBUG("\n");
@@ -214,6 +224,7 @@
return 1;
err:
cobex_cleanup(gt, TRUE);
+#endif
return -1;
}
@@ -222,6 +233,7 @@
//
static void cobex_cleanup(struct cobex_context *gt, int force)
{
+#ifndef _WIN32
if(force) {
// Send a break to get out of OBEX-mode
#ifdef TCSBRKP
@@ -236,6 +248,7 @@
}
close(gt->ttyfd);
gt->ttyfd = -1;
+#endif
}
//
Index: openobex-cvs/apps/obex_io.c
===================================================================
--- openobex-cvs.orig/apps/obex_io.c 2006-12-17 02:12:20.224059006 +0100
+++ openobex-cvs/apps/obex_io.c 2006-12-17 02:12:59.702526256 +0100
@@ -205,6 +205,9 @@
* First remove path and add "/tmp/". Then save.
*
*/
+#ifndef DEFFILEMODE
+#define DEFFILEMODE 0
+#endif
int safe_save_file(char *name, const uint8_t *buf, int len)
{
char *s = NULL;
@@ -222,11 +225,7 @@
s++;
strncat(filename, s, 250);
-#ifdef _WIN32
- fd = open(filename, O_RDWR | O_CREAT, 0);
-#else
fd = open(filename, O_RDWR | O_CREAT, DEFFILEMODE);
-#endif
if ( fd < 0) {
perror( filename);
Index: openobex-cvs/ircp/dirtraverse.c
===================================================================
--- openobex-cvs.orig/ircp/dirtraverse.c 2006-12-17 02:12:20.268061756 +0100
+++ openobex-cvs/ircp/dirtraverse.c 2006-12-17 02:12:59.762530006 +0100
@@ -40,7 +40,12 @@
}
else {
snprintf(t, MAXPATHLEN, "%s/%s", path, dirent->d_name);
+#ifdef _WIN32
+#warning "Do not use symbolic links in Windows Vista or fix this."
+ if (stat(t, &statbuf) < 0) {
+#else
if(lstat(t, &statbuf) < 0) {
+#endif
return -1;
}
else if(S_ISREG(statbuf.st_mode)) {
Index: openobex-cvs/ircp/ircp_io.c
===================================================================
--- openobex-cvs.orig/ircp/ircp_io.c 2006-12-17 02:12:20.320065006 +0100
+++ openobex-cvs/ircp/ircp_io.c 2006-12-17 02:12:59.798532256 +0100
@@ -115,6 +115,9 @@
//
// Open a file, but do some sanity-checking first.
//
+#ifndef DEFFILEMODE
+#define DEFFILEMODE 0
+#endif
int ircp_open_safe(const char *path, const char *name)
{
char diskname[MAXPATHLEN];
@@ -169,7 +172,11 @@
}
if(flags & CD_CREATE) {
DEBUG(4, "Will try to create %s\n", newpath);
+#ifdef _WIN32
+ ret = _mkdir(newpath);
+#else
ret = mkdir(newpath, DEFFILEMODE | S_IXGRP | S_IXUSR | S_IXOTH);
+#endif
}
else {
ret = -1;
Index: openobex-cvs/lib/btobex.c
===================================================================
--- openobex-cvs.orig/lib/btobex.c 2006-12-17 14:43:55.030308256 +0100
+++ openobex-cvs/lib/btobex.c 2006-12-17 14:50:19.974365756 +0100
@@ -37,6 +37,49 @@
#include <winsock2.h>
#include <ws2bth.h>
+/* define everything needed for bluez compatibility */
+#define bdaddr_t BTH_ADDR
+#define sockaddr_rc _SOCKADDR_BTH
+#define rc_family addressFamily
+#define rc_bdaddr btaddr
+#define rc_channel port
+#define PF_BLUETOOTH PF_BTH
+#define AF_BLUETOOTH PF_BLUETOOTH
+#define BTPROTO_RFCOMM BTHPROTO_RFCOMM
+
+static inline
+bacpy(bdaddr_t *dst, const bdaddr_t *src)
+{
+ memcpy(dst, src, sizeof(bdaddr_t));
+}
+
+static inline
+void winbt_cleanup (void)
+{
+ WSACleanup();
+}
+
+#define VER_MAJOR 2
+#define VER_MINOR 2
+static inline
+int winbt_init ()
+{
+ WORD ver = MAKEWORD(VER_MAJOR,VER_MINOR);
+ WSADATA data;
+ int err;
+
+ err = WSAStartup(ver,&data);
+ if (err != 0 )
+ return -WSAGetLastError();
+
+ if (LOBYTE(data.wVersion) != VER_MAJOR ||
+ HIBYTE(data.wVersion) != VER_MINOR) {
+ winbt_cleanup();
+ return 0;
+ }
+ return 1;
+}
+
#else /* _WIN32 */
/* Linux/FreeBSD/NetBSD case */
@@ -80,7 +123,10 @@
*/
void btobex_prepare_connect(obex_t *self, bdaddr_t *src, bdaddr_t *dst, uint8_t channel)
{
-#ifndef _WIN32
+#ifdef _WIN32
+ if (winbt_init() <= 0)
+ return
+#endif
self->trans.self.rfcomm.rc_family = AF_BLUETOOTH;
bacpy(&self->trans.self.rfcomm.rc_bdaddr, src);
self->trans.self.rfcomm.rc_channel = 0;
@@ -88,7 +134,6 @@
self->trans.peer.rfcomm.rc_family = AF_BLUETOOTH;
bacpy(&self->trans.peer.rfcomm.rc_bdaddr, dst);
self->trans.peer.rfcomm.rc_channel = channel;
-#endif /* _WIN32 */
}
/*
@@ -99,12 +144,14 @@
*/
void btobex_prepare_listen(obex_t *self, bdaddr_t *src, uint8_t channel)
{
-#ifndef _WIN32
+#ifdef _WIN32
+ if (winbt_init() <= 0)
+ return
+#endif
/* Bind local service */
self->trans.self.rfcomm.rc_family = AF_BLUETOOTH;
bacpy(&self->trans.self.rfcomm.rc_bdaddr, src);
self->trans.self.rfcomm.rc_channel = channel;
-#endif /* _WIN32 */
}
/*
@@ -115,11 +162,10 @@
*/
int btobex_listen(obex_t *self)
{
-#ifndef _WIN32
DEBUG(3, "\n");
self->serverfd = obex_create_socket(self, AF_BLUETOOTH);
- if(self->serverfd < 0) {
+ if (invalid_socket(self->serverfd)) {
DEBUG(0, "Error creating socket\n");
return -1;
}
@@ -143,7 +189,6 @@
out_freesock:
obex_delete_socket(self, self->serverfd);
self->serverfd = -1;
-#endif /* _WIN32 */
return -1;
}
@@ -157,7 +202,6 @@
*/
int btobex_accept(obex_t *self)
{
-#ifndef _WIN32
socklen_t addrlen = sizeof(struct sockaddr_rc);
//int mtu;
//int len = sizeof(int);
@@ -171,7 +215,6 @@
}
self->trans.mtu = OBEX_DEFAULT_MTU;
-#endif /* _WIN32 */
return 0;
}
@@ -184,7 +227,6 @@
int btobex_connect_request(obex_t *self)
{
int ret;
-#ifndef _WIN32
int mtu = 0;
//int len = sizeof(int);
@@ -192,7 +234,7 @@
if(self->fd < 0) {
self->fd = obex_create_socket(self, AF_BLUETOOTH);
- if(self->fd < 0)
+ if(invalid_socket(self->fd))
return -1;
}
@@ -221,7 +263,6 @@
out_freesock:
obex_delete_socket(self, self->fd);
self->fd = -1;
-#endif /* _WIN32 */
return ret;
}
@@ -234,13 +275,14 @@
int btobex_disconnect_request(obex_t *self)
{
int ret;
-#ifndef _WIN32
DEBUG(4, "\n");
ret = obex_delete_socket(self, self->fd);
if(ret < 0)
return ret;
self->fd = -1;
-#endif /* _WIN32 */
+#ifdef _WIN32
+ winbt_cleanup();
+#endif
return ret;
}
@@ -255,11 +297,12 @@
int btobex_disconnect_server(obex_t *self)
{
int ret;
-#ifndef _WIN32
DEBUG(4, "\n");
ret = obex_delete_socket(self, self->serverfd);
self->serverfd = -1;
-#endif /* _WIN32 */
+#ifdef _WIN32
+ winbt_cleanup();
+#endif
return ret;
}
Index: openobex-cvs/lib/inobex.c
===================================================================
--- openobex-cvs.orig/lib/inobex.c 2006-12-17 14:43:55.090312006 +0100
+++ openobex-cvs/lib/inobex.c 2006-12-17 14:46:13.286948756 +0100
@@ -88,7 +88,7 @@
DEBUG(4, "\n");
self->serverfd = obex_create_socket(self, AF_INET);
- if(self->serverfd < 0) {
+ if(invalid_socket(self->serverfd)) {
DEBUG(0, "Cannot create server-socket\n");
return -1;
}
@@ -147,7 +147,7 @@
int ret;
self->fd = obex_create_socket(self, AF_INET);
- if(self->fd < 0)
+ if(invalid_socket(self->fd))
return -1;
/* Set these just in case */
Index: openobex-cvs/lib/irobex.c
===================================================================
--- openobex-cvs.orig/lib/irobex.c 2006-12-17 14:43:55.146315506 +0100
+++ openobex-cvs/lib/irobex.c 2006-12-17 14:46:13.306950006 +0100
@@ -131,7 +131,7 @@
DEBUG(3, "\n");
self->serverfd = obex_create_socket(self, AF_IRDA);
- if(self->serverfd < 0) {
+ if(invalid_socket(self->serverfd)) {
DEBUG(0, "Error creating socket\n");
return -1;
}
@@ -351,7 +351,7 @@
if(self->fd < 0) {
self->fd = obex_create_socket(self, AF_IRDA);
- if(self->fd < 0)
+ if(invalid_socket(self->fd))
return -1;
}
Index: openobex-cvs/lib/obex_main.c
===================================================================
--- openobex-cvs.orig/lib/obex_main.c 2006-12-17 14:43:55.206319256 +0100
+++ openobex-cvs/lib/obex_main.c 2006-12-17 14:46:13.330951506 +0100
@@ -80,9 +80,10 @@
* Create socket if needed.
*
*/
-int obex_create_socket(obex_t *self, int domain)
+socket_t obex_create_socket(obex_t *self, int domain)
{
- int fd, proto;
+ socket_t fd;
+ int proto;
DEBUG(4, "\n");
proto = 0;
@@ -102,7 +103,7 @@
* Close socket if opened.
*
*/
-int obex_delete_socket(obex_t *self, int fd)
+int obex_delete_socket(obex_t *self, socket_t fd)
{
int ret;
Index: openobex-cvs/lib/obex_main.h
===================================================================
--- openobex-cvs.orig/lib/obex_main.h 2006-12-17 14:43:55.266323006 +0100
+++ openobex-cvs/lib/obex_main.h 2006-12-17 14:46:13.394955506 +0100
@@ -33,11 +33,19 @@
#include <time.h>
-#ifndef _WIN32
+#ifdef _WIN32
+#include <winsock2.h>
+#define socket_t SOCKET
+#define invalid_socket(s) ((s) == INVALID_SOCKET)
+
+#else /* _WIN32 */
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/types.h>
-#endif
+#define socket_t int
+#define invalid_socket(s) ((s) == -1)
+
+#endif /* _WIN32 */
/* Forward decl */
typedef struct obex obex_t;
@@ -122,9 +130,9 @@
uint16_t mtu_rx; /* Maximum OBEX RX packet size */
uint16_t mtu_tx_max; /* Maximum TX we can accept */
- int fd; /* Socket descriptor */
- int serverfd;
- int writefd; /* write descriptor - only OBEX_TRANS_FD */
+ socket_t fd; /* Socket descriptor */
+ socket_t serverfd;
+ socket_t writefd; /* write descriptor - only OBEX_TRANS_FD */
unsigned int state;
int keepserver; /* Keep server alive */
@@ -147,8 +155,8 @@
};
-int obex_create_socket(obex_t *self, int domain);
-int obex_delete_socket(obex_t *self, int fd);
+socket_t obex_create_socket(obex_t *self, int domain);
+int obex_delete_socket(obex_t *self, socket_t fd);
void obex_deliver_event(obex_t *self, int event, int cmd, int rsp, int del);
int obex_data_indication(obex_t *self, uint8_t *buf, int buflen);
Index: openobex-cvs/include/obex.h
===================================================================
--- openobex-cvs.orig/include/obex.h 2006-12-17 14:43:55.334327256 +0100
+++ openobex-cvs/include/obex.h 2006-12-17 14:46:13.454959256 +0100
@@ -51,10 +51,6 @@
typedef void* obex_t;
typedef void* obex_object_t;
typedef void (*obex_event_t)(obex_t *handle, obex_object_t *obj, int mode, int event, int obex_cmd, int obex_rsp);
-// This is to workaround compilation without Bluetooth support. - Jean II
-#ifndef SOL_RFCOMM
-typedef char* bdaddr_t;
-#endif
#include <openobex/obex_const.h>
@@ -130,8 +126,13 @@
/*
* Bluetooth OBEX API
*/
+#ifdef SOL_RFCOMM
+#ifdef _WIN32
+#define bdaddr_t BTH_ADDR
+#endif
int BtOBEX_ServerRegister(obex_t *self, bdaddr_t *src, uint8_t channel);
int BtOBEX_TransportConnect(obex_t *self, bdaddr_t *src, bdaddr_t *dst, uint8_t channel);
+#endif
/*
* OBEX File API
Index: openobex-cvs/glib/obex-lowlevel.c
===================================================================
--- openobex-cvs.orig/glib/obex-lowlevel.c 2006-12-17 02:12:21.576143506 +0100
+++ openobex-cvs/glib/obex-lowlevel.c 2006-12-17 03:11:48.143040006 +0100
@@ -30,7 +30,16 @@
#include <malloc.h>
#include <string.h>
#include <time.h>
+
+#ifdef _WIN32
+#include <winsock2.h>
+#warning "Incomplete implementation: no gmtime_r() on win32!"
+#define gmtime_r(time_p,result) NULL
+#define EISCONN WSAEISCONN
+#define ENOTCONN WSAENOTCONN
+#else
#include <arpa/inet.h>
+#endif
#include <glib.h>
Index: openobex-cvs/glib/Makefile.am
===================================================================
--- openobex-cvs.orig/glib/Makefile.am 2006-12-17 02:12:21.624146506 +0100
+++ openobex-cvs/glib/Makefile.am 2006-12-17 02:12:59.374505756 +0100
@@ -8,9 +8,9 @@
libopenobex_glib_la_SOURCES = obex-lowlevel.h obex-lowlevel.c obex-client.c obex-debug.h obex-error.c obex-error.h
-libopenobex_glib_la_LDFLAGS = -version-info 1:0:0
+libopenobex_glib_la_LDFLAGS = -no-undefined -version-info 1:0:0
-libopenobex_glib_la_LIBADD = @GLIB_LIBS@ $(top_builddir)/lib/libopenobex.la
+libopenobex_glib_la_LIBADD = @GLIB_LIBS@ $(top_builddir)/lib/libopenobex.la @LIBLINK_LIBS@
BUILT_SOURCES = obex-marshal.h obex-marshal.c
Index: openobex-cvs/glib/obex-error.c
===================================================================
--- openobex-cvs.orig/glib/obex-error.c 2006-12-17 02:12:21.668149256 +0100
+++ openobex-cvs/glib/obex-error.c 2006-12-17 02:12:59.406507756 +0100
@@ -25,6 +25,12 @@
#include <config.h>
#endif
+#ifdef _WIN32
+#include <winsock2.h>
+#define EISCONN WSAEISCONN
+#define ENOTCONN WSAENOTCONN
+#endif
+
#include <errno.h>
#include "obex-debug.h"
Index: openobex-cvs/glib/test-lowlevel.c
===================================================================
--- openobex-cvs.orig/glib/test-lowlevel.c 2006-12-17 02:12:21.716152256 +0100
+++ openobex-cvs/glib/test-lowlevel.c 2006-12-17 02:12:59.438509756 +0100
@@ -30,14 +30,39 @@
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
+
+#ifdef _WIN32
+#include <io.h>
+#define SOME_TTY "COM4"
+#else
#include <termios.h>
+#define SOME_TTY "/dev/rfcomm42"
+#endif
#include "obex-lowlevel.h"
static int open_device(const char *device)
{
- struct termios ti;
int fd;
+#ifdef _WIN32
+ HANDLE h;
+ DCB ti;
+
+ h = CreateFile(device,
+ GENERIC_READ|GENERIC_WRITE,
+ 0,NULL,OPEN_EXISTING,0,NULL);
+ if (h == INVALID_HANDLE_VALUE)
+ return -1;
+
+ //TODO: tcflush-equivalent function?
+ ti.StopBits = ONESTOPBIT;
+ ti.Parity = NOPARITY;
+ ti.ByteSize = 8;
+ ti.fNull = FALSE;
+ SetCommState(h,&ti);
+ fd = _open_osfhandle((intptr_t)h,0);
+#else
+ struct termios ti;
fd = open(device, O_RDWR | O_NOCTTY);
if (fd < 0)
@@ -47,7 +72,7 @@
cfmakeraw(&ti);
tcsetattr(fd, TCSANOW, &ti);
-
+#endif
return fd;
}
@@ -56,7 +81,7 @@
obex_t *handle;
int fd;
- fd = open_device("/dev/rfcomm42");
+ fd = open_device(SOME_TTY);
if (fd < 0) {
perror("Can't open device");
exit(EXIT_FAILURE);
Index: openobex-cvs/glib/test-client.c
===================================================================
--- openobex-cvs.orig/glib/test-client.c 2006-12-17 02:12:21.768155506 +0100
+++ openobex-cvs/glib/test-client.c 2006-12-17 02:12:59.466511506 +0100
@@ -32,10 +32,16 @@
#include <stdlib.h>
#include <string.h>
#include <signal.h>
-#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef _WIN32
+#include <windows.h>
+#include <io.h>
+#else
+#include <termios.h>
+#endif
+
#include "obex-client.h"
#define FTP_UUID (guchar *) \
@@ -50,8 +56,26 @@
static int open_device(const char *device)
{
- struct termios ti;
int fd;
+#ifdef _WIN32
+ HANDLE h;
+ DCB ti;
+
+ h = CreateFile(device,
+ GENERIC_READ|GENERIC_WRITE,
+ 0,NULL,OPEN_EXISTING,0,NULL);
+ if (h == INVALID_HANDLE_VALUE)
+ return -1;
+
+ //TODO: tcflush-equivalent function?
+ ti.StopBits = ONESTOPBIT;
+ ti.Parity = NOPARITY;
+ ti.ByteSize = 8;
+ ti.fNull = FALSE;
+ SetCommState(h,&ti);
+ fd = _open_osfhandle((intptr_t)h,0);
+#else
+ struct termios ti;
fd = open(device, O_RDWR | O_NOCTTY);
if (fd < 0)
@@ -61,7 +85,7 @@
cfmakeraw(&ti);
tcsetattr(fd, TCSANOW, &ti);
-
+#endif
return fd;
}
@@ -154,8 +178,10 @@
int main(int argc, char *argv[])
{
ObexClient *client;
- struct sigaction sa;
int fd, io = -1;
+#ifndef _WIN32
+ struct sigaction sa;
+#endif
g_type_init();
@@ -193,10 +219,12 @@
obex_client_get_object(client, NULL, "telecom/devinfo.txt", NULL);
+#ifndef _WIN32
memset(&sa, 0, sizeof(sa));
sa.sa_handler = sig_term;
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
+#endif
g_main_loop_run(mainloop);
Index: openobex-cvs/acinclude.m4
===================================================================
--- openobex-cvs.orig/acinclude.m4 2006-12-16 12:47:16.017234756 +0100
+++ openobex-cvs/acinclude.m4 2006-12-16 12:52:03.635209756 +0100
@@ -76,9 +76,26 @@
])
AC_DEFUN([AC_PATH_BLUEZ], [
- PKG_CHECK_MODULES(BLUEZ, bluez, bluez_found=yes, AC_MSG_RESULT(no))
- AC_SUBST(BLUEZ_CFLAGS)
- AC_SUBST(BLUEZ_LIBS)
+ PKG_CHECK_MODULES(BLUETOOTH, bluez, bluez_found=yes, AC_MSG_RESULT(no))
+ AC_SUBST(BLUETOOTH_CFLAGS)
+ AC_SUBST(BLUETOOTH_LIBS)
+])
+
+AC_DEFUN([AC_PATH_WINBT], [
+ winbt_found=n
+ AC_CHECK_HEADERS(winsock2.h,
+ [AC_CHECK_HEADERS(ws2bth.h,
+ [BLUETOOTH_LIBS="-lws2_32"
+ AC_SUBST(BLUETOOTH_LIBS)
+ LIBLINK_LIBS="$BLUETOOTH_LIBS"
+ AC_SUBST(LIBLINK_LIBS)
+ winbt_found=yes
+ ],[],[
+ #include <winsock2.h>
+ ])
+ ],[AC_MSG_ERROR(You need to get the w32api mingw package.)]
+ )
+ AC_CACHE_CHECK([for Windows Bluetooth support],winbt_found,[])
])
AC_DEFUN([AC_PATH_BLUETOOTH], [
@@ -92,11 +109,22 @@
*-*-netbsd*)
AC_PATH_NETBSDBT
;;
+ *-*-mingw32*)
+ AC_PATH_WINBT
+ ;;
esac
])
AC_DEFUN([AC_PATH_USB], [
- PKG_CHECK_MODULES(USB, libusb, usb_found=yes, AC_MSG_RESULT(no))
+ case $host in
+ *-*-mingw32*)
+ USB_CFLAGS=""
+ USB_LIBS="-lusb"
+ ;;
+ *)
+ PKG_CHECK_MODULES(USB, libusb, usb_found=yes, AC_MSG_RESULT(no))
+ ;;
+ esac
AC_SUBST(USB_CFLAGS)
AC_SUBST(USB_LIBS)
AC_CHECK_LIB(usb, usb_get_busses, dummy=yes, AC_DEFINE(NEED_USB_GET_BUSSES, 1, [Define to 1 if you need the usb_get_busses() function.]))
Index: openobex-cvs/apps/obex_tcp.c
===================================================================
--- openobex-cvs.orig/apps/obex_tcp.c 2006-12-16 12:47:16.073238256 +0100
+++ openobex-cvs/apps/obex_tcp.c 2006-12-16 12:52:03.643210256 +0100
@@ -38,7 +38,7 @@
#include <string.h>
#if _WIN32
-#include <winsock.h>
+#include <winsock2.h>
#else
#include <sys/stat.h>
Index: openobex-cvs/apps/obex_test.c
===================================================================
--- openobex-cvs.orig/apps/obex_test.c 2006-12-16 12:47:16.125241506 +0100
+++ openobex-cvs/apps/obex_test.c 2006-12-16 12:52:03.687213006 +0100
@@ -35,7 +35,7 @@
#include <string.h>
#if _WIN32
-#include <winsock.h>
+#include <winsock2.h>
#else
#include <sys/socket.h>
#include <arpa/inet.h>
Index: openobex-cvs/include/obex.h
===================================================================
--- openobex-cvs.orig/include/obex.h 2006-12-16 12:47:16.241248756 +0100
+++ openobex-cvs/include/obex.h 2006-12-16 13:37:49.626823506 +0100
@@ -34,7 +34,7 @@
#include <inttypes.h>
#ifdef _WIN32
-#include <winsock.h>
+#include <winsock2.h>
#else
#include <sys/socket.h>
#endif
Index: openobex-cvs/lib/btobex.c
===================================================================
--- openobex-cvs.orig/lib/btobex.c 2006-12-16 12:47:16.289251756 +0100
+++ openobex-cvs/lib/btobex.c 2006-12-16 13:37:07.956219256 +0100
@@ -34,7 +34,8 @@
#ifdef HAVE_BLUETOOTH
#ifdef _WIN32
-#include <winsock.h>
+#include <winsock2.h>
+#include <ws2bth.h>
#else /* _WIN32 */
/* Linux/FreeBSD/NetBSD case */
Index: openobex-cvs/lib/inobex.c
===================================================================
--- openobex-cvs.orig/lib/inobex.c 2006-12-16 12:47:16.337254756 +0100
+++ openobex-cvs/lib/inobex.c 2006-12-16 13:37:08.008222506 +0100
@@ -35,7 +35,8 @@
#include <string.h>
#ifdef _WIN32
-#include <winsock.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
#else
#include <sys/types.h>
Index: openobex-cvs/lib/irobex.c
===================================================================
--- openobex-cvs.orig/lib/irobex.c 2006-12-16 12:47:16.385257756 +0100
+++ openobex-cvs/lib/irobex.c 2006-12-16 13:37:08.060225756 +0100
@@ -35,7 +35,7 @@
#ifdef HAVE_IRDA
#ifdef _WIN32
-#include <winsock.h>
+#include <winsock2.h>
#include <irda_wrap.h>
Index: openobex-cvs/lib/obex.c
===================================================================
--- openobex-cvs.orig/lib/obex.c 2006-12-16 12:47:16.433260756 +0100
+++ openobex-cvs/lib/obex.c 2006-12-16 13:37:12.908528756 +0100
@@ -38,7 +38,7 @@
#include <errno.h>
#ifdef _WIN32
-#include <winsock.h>
+#include <winsock2.h>
#define ESOCKTNOSUPPORT 1
#else /* _WIN32 */
Index: openobex-cvs/lib/obex_main.c
===================================================================
--- openobex-cvs.orig/lib/obex_main.c 2006-12-16 12:47:16.485264006 +0100
+++ openobex-cvs/lib/obex_main.c 2006-12-16 13:37:08.112229006 +0100
@@ -33,7 +33,7 @@
#endif
#ifdef _WIN32
-#include <winsock.h>
+#include <winsock2.h>
#else /* _WIN32 */
#include <unistd.h>
Index: openobex-cvs/lib/obex_transport.h
===================================================================
--- openobex-cvs.orig/lib/obex_transport.h 2006-12-16 12:47:16.533267006 +0100
+++ openobex-cvs/lib/obex_transport.h 2006-12-16 12:52:04.015233506 +0100
@@ -31,7 +31,7 @@
#define OBEX_TRANSPORT_H
#ifdef _WIN32
-#include <winsock.h>
+#include <winsock2.h>
#else
#include <netinet/in.h>
#endif
Index: openobex-cvs/apps/Makefile.am
===================================================================
--- openobex-cvs.orig/apps/Makefile.am 2006-12-16 12:47:16.181245006 +0100
+++ openobex-cvs/apps/Makefile.am 2006-12-16 12:52:04.043235256 +0100
@@ -14,11 +14,11 @@
obex_test_server.c obex_test_server.h \
obex_test_cable.c obex_test_cable.h
-obex_test_LDADD = $(top_builddir)/lib/libopenobex.la @BLUEZ_LIBS@ libmisc.a
+obex_test_LDADD = $(top_builddir)/lib/libopenobex.la @BLUETOOTH_LIBS@ libmisc.a
LDADD = $(top_builddir)/lib/libopenobex.la libmisc.a
-INCLUDES = @BLUEZ_CFLAGS@ -I$(top_builddir)/include
+INCLUDES = @BLUETOOTH_CFLAGS@ -I$(top_builddir)/include
endif
MAINTAINERCLEANFILES = Makefile.in
Index: openobex-cvs/lib/Makefile.am
===================================================================
--- openobex-cvs.orig/lib/Makefile.am 2006-12-16 12:47:16.577269756 +0100
+++ openobex-cvs/lib/Makefile.am 2006-12-16 12:52:04.063236506 +0100
@@ -18,10 +18,11 @@
usbobex.c usbobex.h
libopenobex_la_LDFLAGS = \
+ -no-undefined
-version-info 4:0:3 \
-export-symbols $(top_srcdir)/lib/obex.sym
-libopenobex_la_LIBADD = @USB_LIBS@
+libopenobex_la_LIBADD = @USB_LIBS@ @LIBLINK_LIBS@
INCLUDES = -I$(top_builddir)/include
Index: openobex-cvs/lib/obex_main.h
===================================================================
--- openobex-cvs.orig/lib/obex_main.h 2006-12-16 12:47:16.629273006 +0100
+++ openobex-cvs/lib/obex_main.h 2006-12-16 13:37:08.168232506 +0100
@@ -96,9 +96,8 @@
# endif /* OBEX_DUMP != 0 */
#else /* _WIN32 */
-
-void DEBUG(unsigned int n, ...);
-void DUMPBUFFERS(n, label, msg);
+#define DEBUG(n, format, args...)
+#define DUMPBUFFER(n, label, msg)
#endif /* _WIN32 */
Index: openobex-cvs/configure.in
===================================================================
--- openobex-cvs.orig/configure.in 2006-12-16 12:47:16.685276506 +0100
+++ openobex-cvs/configure.in 2006-12-16 12:52:04.123240256 +0100
@@ -17,6 +17,7 @@
m4_define([_LT_AC_TAGCONFIG], [])
m4_ifdef([AC_LIBTOOL_TAGS], [AC_LIBTOOL_TAGS([])])
+AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_CANONICAL_HOST
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Openobex-users mailing list
[email protected]
http://lists.sourceforge.net/lists/listinfo/openobex-users