Ticket #9: 800_win32_glib.patch
| File 800_win32_glib.patch, 4.7 KB (added by hsattler, 18 months ago) |
|---|
-
glib/obex-lowlevel.c
old new 30 30 #include <malloc.h> 31 31 #include <string.h> 32 32 #include <time.h> 33 34 #ifdef _WIN32 35 #include <winsock2.h> 36 #warning "Incomplete implementation: no gmtime_r() on win32!" 37 #define gmtime_r(time_p,result) NULL 38 #define EISCONN WSAEISCONN 39 #define ENOTCONN WSAENOTCONN 40 #else 33 41 #include <arpa/inet.h> 42 #endif 34 43 35 44 #include <glib.h> 36 45 -
glib/Makefile.am
old new 8 8 9 9 libopenobex_glib_la_SOURCES = obex-lowlevel.h obex-lowlevel.c obex-client.c obex-debug.h obex-error.c obex-error.h 10 10 11 libopenobex_glib_la_LDFLAGS = - version-info 1:0:011 libopenobex_glib_la_LDFLAGS = -no-undefined -version-info 1:0:0 12 12 13 libopenobex_glib_la_LIBADD = @GLIB_LIBS@ $(top_builddir)/lib/libopenobex.la 13 libopenobex_glib_la_LIBADD = @GLIB_LIBS@ $(top_builddir)/lib/libopenobex.la @EXTRA_LIBS@ 14 14 15 15 BUILT_SOURCES = obex-marshal.h obex-marshal.c 16 16 -
glib/obex-error.c
old new 25 25 #include <config.h> 26 26 #endif 27 27 28 #ifdef _WIN32 29 #include <winsock2.h> 30 #define EISCONN WSAEISCONN 31 #define ENOTCONN WSAENOTCONN 32 #endif 33 28 34 #include <errno.h> 29 35 30 36 #include "obex-debug.h" -
glib/test-lowlevel.c
old new 30 30 #include <fcntl.h> 31 31 #include <unistd.h> 32 32 #include <stdlib.h> 33 34 #ifdef _WIN32 35 #include <io.h> 36 #define SOME_TTY "COM4" 37 #else 33 38 #include <termios.h> 39 #define SOME_TTY "/dev/rfcomm42" 40 #endif 34 41 35 42 #include "obex-lowlevel.h" 36 43 37 44 static int open_device(const char *device) 38 45 { 39 struct termios ti;40 46 int fd; 47 #ifdef _WIN32 48 HANDLE h; 49 DCB ti; 50 51 h = CreateFile(device, 52 GENERIC_READ|GENERIC_WRITE, 53 0,NULL,OPEN_EXISTING,0,NULL); 54 if (h == INVALID_HANDLE_VALUE) 55 return -1; 56 57 //TODO: tcflush-equivalent function? 58 ti.StopBits = ONESTOPBIT; 59 ti.Parity = NOPARITY; 60 ti.ByteSize = 8; 61 ti.fNull = FALSE; 62 SetCommState(h,&ti); 63 fd = _open_osfhandle((intptr_t)h,0); 64 #else 65 struct termios ti; 41 66 42 67 fd = open(device, O_RDWR | O_NOCTTY); 43 68 if (fd < 0) … … 47 72 48 73 cfmakeraw(&ti); 49 74 tcsetattr(fd, TCSANOW, &ti); 50 75 #endif 51 76 return fd; 52 77 } 53 78 … … 56 81 obex_t *handle; 57 82 int fd; 58 83 59 fd = open_device( "/dev/rfcomm42");84 fd = open_device(SOME_TTY); 60 85 if (fd < 0) { 61 86 perror("Can't open device"); 62 87 exit(EXIT_FAILURE); -
glib/test-client.c
old new 32 32 #include <stdlib.h> 33 33 #include <string.h> 34 34 #include <signal.h> 35 #include <termios.h>36 35 #include <sys/types.h> 37 36 #include <sys/stat.h> 38 37 38 #ifdef _WIN32 39 #include <windows.h> 40 #include <io.h> 41 #else 42 #include <termios.h> 43 #endif 44 39 45 #include "obex-client.h" 40 46 41 47 #define FTP_UUID (guchar *) \ … … 50 56 51 57 static int open_device(const char *device) 52 58 { 53 struct termios ti;54 59 int fd; 60 #ifdef _WIN32 61 HANDLE h; 62 DCB ti; 63 64 h = CreateFile(device, 65 GENERIC_READ|GENERIC_WRITE, 66 0,NULL,OPEN_EXISTING,0,NULL); 67 if (h == INVALID_HANDLE_VALUE) 68 return -1; 69 70 //TODO: tcflush-equivalent function? 71 ti.StopBits = ONESTOPBIT; 72 ti.Parity = NOPARITY; 73 ti.ByteSize = 8; 74 ti.fNull = FALSE; 75 SetCommState(h,&ti); 76 fd = _open_osfhandle((intptr_t)h,0); 77 #else 78 struct termios ti; 55 79 56 80 fd = open(device, O_RDWR | O_NOCTTY); 57 81 if (fd < 0) … … 61 85 62 86 cfmakeraw(&ti); 63 87 tcsetattr(fd, TCSANOW, &ti); 64 88 #endif 65 89 return fd; 66 90 } 67 91 … … 154 178 int main(int argc, char *argv[]) 155 179 { 156 180 ObexClient *client; 157 struct sigaction sa;158 181 int fd, io = -1; 182 #ifndef _WIN32 183 struct sigaction sa; 184 #endif 159 185 160 186 g_type_init(); 161 187 … … 193 219 obex_client_get_object(client, NULL, "telecom/devinfo.txt", NULL); 194 220 195 221 222 #ifndef _WIN32 196 223 memset(&sa, 0, sizeof(sa)); 197 224 sa.sa_handler = sig_term; 198 225 sigaction(SIGTERM, &sa, NULL); 199 226 sigaction(SIGINT, &sa, NULL); 227 #endif 200 228 201 229 g_main_loop_run(mainloop); 202 230
