Ticket #9: 800_win32_apps.patch

File 800_win32_apps.patch, 7.2 KB (added by hsattler, 18 months ago)

fix building of example apps

  • openobex-anoncvs

    old new  
    3636#include <config.h> 
    3737#endif 
    3838 
     39#ifdef _WIN32 
     40#include <windows.h> 
     41#define sleep(sec) Sleep(1000*sec) 
     42#endif 
     43 
    3944#include <stdio.h> 
    4045#include <unistd.h> 
    4146#include <stdlib.h> 
  • apps/obex_test_client.c

    old new  
    3333#include <stdlib.h> 
    3434#include <unistd.h> 
    3535#include <fcntl.h> 
    36 #include <libgen.h> 
    3736#include <string.h> 
    3837 
     38#ifdef _WIN32 
     39#warning "No implementation for basename() in win32!" 
     40#define basename(x) (x) 
     41#else 
     42#include <libgen.h> 
     43#endif 
     44 
    3945#include <openobex/obex.h> 
    4046 
    4147#include "obex_io.h" 
  • apps/obex_test_cable.h

    old new  
    3333 
    3434#define CABLE_DEBUG 1 
    3535 
    36  
     36#ifdef _WIN32 
     37#include <windows.h> 
     38#define tty_desc_t DCB 
     39#else 
    3740#include <termios.h> 
     41#define tty_desc_t struct termios 
     42#endif 
    3843 
    3944#ifdef CABLE_DEBUG 
    4045#define CDEBUG(format, args...) printf("%s(): " format, __FUNCTION__ , ##args) 
     
    4752        const char *portname; 
    4853        int ttyfd; 
    4954        char inputbuf[500]; 
    50         struct termios oldtio, newtio; 
     55        tty_desc_t oldtio, newtio; 
    5156        int r320; 
    5257}; 
    5358 
  • apps/obex_test_cable.c

    old new  
    3535#include <stdio.h> 
    3636#include <stdlib.h> 
    3737#include <sys/time.h> 
    38 #include <sys/ioctl.h> 
    3938#include <fcntl.h> 
    4039#include <errno.h> 
    4140#include <string.h> 
    4241#include <unistd.h> 
    43 #include <termios.h> 
     42 
     43#ifndef _WIN32 
     44#include <sys/ioctl.h> 
     45#endif 
    4446 
    4547#include <openobex/obex.h> 
    4648 
     
    6062// 
    6163int cobex_do_at_cmd(struct cobex_context *gt, char *cmd, char *rspbuf, int rspbuflen, int timeout) 
    6264{ 
     65#ifdef _WIN32 
     66#warning "Implementation for win32 is missing!" 
     67        return -1; 
     68#else 
    6369        fd_set ttyset; 
    6470        struct timeval tv; 
    6571        int fd; 
     
    151157        strncpy(rspbuf, answer, answer_size); 
    152158        rspbuf[answer_size] = 0; 
    153159        return 0; 
     160#endif 
    154161} 
    155162 
    156163// 
     
    158165// 
    159166static int cobex_init(struct cobex_context *gt) 
    160167{ 
     168#ifdef _WIN32 
     169#warning "Implementation for win32 is missing!" 
     170#else 
    161171        char rspbuf[200]; 
    162172 
    163173        CDEBUG("\n"); 
     
    214224                return 1; 
    215225err: 
    216226        cobex_cleanup(gt, TRUE); 
     227#endif 
    217228        return -1; 
    218229} 
    219230 
     
    222233// 
    223234static void cobex_cleanup(struct cobex_context *gt, int force) 
    224235{ 
     236#ifndef _WIN32 
    225237        if(force)       { 
    226238                // Send a break to get out of OBEX-mode 
    227239#ifdef TCSBRKP 
     
    236248        } 
    237249        close(gt->ttyfd); 
    238250        gt->ttyfd = -1; 
     251#endif 
    239252} 
    240253 
    241254// 
  • openobex-anoncvs

    old new  
    205205 *    First remove path and add "/tmp/". Then save. 
    206206 * 
    207207 */ 
     208#ifndef DEFFILEMODE 
     209#define DEFFILEMODE 0 
     210#endif 
    208211int safe_save_file(char *name, const uint8_t *buf, int len) 
    209212{ 
    210213        char *s = NULL; 
     
    222225                s++; 
    223226 
    224227        strncat(filename, s, 250); 
    225 #ifdef _WIN32 
    226         fd = open(filename, O_RDWR | O_CREAT, 0); 
    227 #else 
    228228        fd = open(filename, O_RDWR | O_CREAT, DEFFILEMODE); 
    229 #endif 
    230229 
    231230        if ( fd < 0) { 
    232231                perror( filename); 
  • ircp/dirtraverse.c

    old new  
    4040                } 
    4141                else { 
    4242                        snprintf(t, MAXPATHLEN, "%s/%s", path, dirent->d_name); 
     43#ifdef _WIN32 
     44#warning "Do not use symbolic links in Windows Vista or fix this." 
     45                        if (stat(t, &statbuf) < 0) { 
     46#else 
    4347                        if(lstat(t, &statbuf) < 0) { 
     48#endif 
    4449                                return -1; 
    4550                        } 
    4651                        else if(S_ISREG(statbuf.st_mode)) { 
  • openobex-anoncvs

    old new  
    115115// 
    116116// Open a file, but do some sanity-checking first. 
    117117// 
     118#ifndef DEFFILEMODE 
     119#define DEFFILEMODE 0 
     120#endif 
    118121int ircp_open_safe(const char *path, const char *name) 
    119122{ 
    120123        char diskname[MAXPATHLEN]; 
     
    169172        } 
    170173        if(flags & CD_CREATE) { 
    171174                DEBUG(4, "Will try to create %s\n", newpath); 
     175#ifdef _WIN32 
     176                ret = _mkdir(newpath); 
     177#else 
    172178                ret = mkdir(newpath, DEFFILEMODE | S_IXGRP | S_IXUSR | S_IXOTH); 
     179#endif 
    173180        } 
    174181        else { 
    175182                ret = -1; 
  • apps/Makefile.am

    old new  
    1414        obex_test_server.c obex_test_server.h \ 
    1515        obex_test_cable.c obex_test_cable.h 
    1616 
    17 obex_test_LDADD = $(top_builddir)/lib/libopenobex.la @BLUETOOTH_LIBS@ libmisc.a 
     17obex_test_LDADD = libmisc.a $(top_builddir)/lib/libopenobex.la @BLUETOOTH_LIBS@ 
    1818 
    19 LDADD = $(top_builddir)/lib/libopenobex.la libmisc.a 
     19AM_CFLAGS = @OPENOBEX_CFLAGS@ 
     20 
     21LDADD = libmisc.a $(top_builddir)/lib/libopenobex.la 
    2022 
    2123INCLUDES = @BLUETOOTH_CFLAGS@ -I$(top_builddir)/include 
    2224endif 
  • apps/obex_test.c

    old new  
    4444#endif /* _WIN32 */ 
    4545 
    4646#ifdef HAVE_BLUETOOTH 
    47 #ifdef HAVE_BLUETOOTH_LINUX 
    48 #include <bluetooth/bluetooth.h> 
    49 #include <bluetooth/rfcomm.h> 
    50 #endif 
    51 #ifdef HAVE_BLUETOOTH_FREEBSD 
    52 #include <bluetooth.h> 
    53 #define sockaddr_rc  sockaddr_rfcomm 
    54 #define rc_family    rfcomm_family 
    55 #define rc_bdaddr    rfcomm_bdaddr 
    56 #define rc_channel   rfcomm_channel 
    57 #define str2ba       bt_aton 
    58 #endif 
    59 #ifdef HAVE_BLUETOOTH_NETBSD 
    60 #define rc_family    bt_family 
    61 #define rc_bdaddr    bt_bdaddr 
    62 #define rc_channel   bt_channel 
    63 #define sockaddr_rc  sockaddr_bt 
    64 #define str2ba       bt_aton 
    65 #include <bluetooth.h> 
    66 #include <netbt/rfcomm.h> 
    67 #endif 
     47#include "../lib/bluez_compat.h" 
    6848#endif 
    6949 
    7050#include <openobex/obex.h> 
  • ircp/Makefile.am

    old new  
    1111 
    1212bin_PROGRAMS = ircp  
    1313 
     14AM_CFLAGS = @OPENOBEX_CFLAGS@ 
     15 
    1416LDADD = libircp.a $(top_builddir)/lib/libopenobex.la 
    1517 
    1618INCLUDES = -I$(top_builddir)/include