[Olsr-cvs] olsrd-current/src/win32 compat.c, 1.14, 1.15 unistd.h, 1.5, 1.6

Bernd Petrovitsch (spam-protected)
Wed May 9 02:30:06 CEST 2007


Update of /cvsroot/olsrd/olsrd-current/src/win32
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv18093/src/win32

Modified Files:
	compat.c unistd.h 
Log Message:
* added a simulate write() syscall which uses send() to work on sockets

Index: unistd.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/win32/unistd.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** unistd.h	21 Nov 2004 01:21:10 -0000	1.5
--- unistd.h	9 May 2007 00:30:04 -0000	1.6
***************
*** 42,45 ****
--- 42,47 ----
  #if !defined TL_UNISTD_H_INCLUDED
  
+ #include <stddef.h>
+ 
  #define TL_UNISTD_H_INCLUDED
  
***************
*** 53,60 ****
  int getpid(void);
  
! #define IPTOS_TOS(x) (x & 0x1e)
! #define IPTOS_PREC(x) (x & 0xe0)
  
  int isatty(int fd);
  
  #endif
--- 55,65 ----
  int getpid(void);
  
! #define IPTOS_TOS(x) ((x) & 0x1e)
! #define IPTOS_PREC(x) ((x) & 0xe0)
  
  int isatty(int fd);
  
+ typedef long ssize_t;
+ ssize_t write(int fd, const void *buf, size_t count);
+ 
  #endif

Index: compat.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/win32/compat.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** compat.c	8 May 2007 23:18:55 -0000	1.14
--- compat.c	9 May 2007 00:30:04 -0000	1.15
***************
*** 523,524 ****
--- 523,540 ----
  #endif
  }
+ 
+ #define CHUNK_SIZE 512
+ 
+ /* and we emulate a real write(2) syscall using send() */
+ ssize_t write(int fd, const void *buf, size_t count)
+ {
+   size_t written = 0;
+   while (written < count) {
+     ssize_t rc = send(fd, buf+written, min(count-written, CHUNK_SIZE), 0);
+     if (rc <= 0) {
+       break;
+     }
+     written += rc;
+   }
+   return written;
+ }





More information about the Olsr-cvs mailing list