librfb: port rfbsrc to MinGW

Fixes #606677
This commit is contained in:
Руслан Ижбулатов 2010-01-12 00:46:27 +03:00 committed by Tim-Philipp Müller
parent 08d13fd191
commit d61abce8e4
3 changed files with 21 additions and 5 deletions

View file

@ -342,10 +342,6 @@ if test "x$HAVE_WINSOCK2_H" = "xyes"; then
AC_SUBST(XDG_LIBS) AC_SUBST(XDG_LIBS)
fi fi
if test "x$HAVE_SYS_SOCKET_H" != "xyes"; then
AG_GST_DISABLE_PLUGIN(librfb)
fi
if test "x$HAVE_PTHREAD_H" = "xyes"; then if test "x$HAVE_PTHREAD_H" = "xyes"; then
DCCP_LIBS="$DCCP_LIBS -lpthread" DCCP_LIBS="$DCCP_LIBS -lpthread"
AC_SUBST(DCCP_LIBS) AC_SUBST(DCCP_LIBS)

View file

@ -8,9 +8,13 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef G_OS_WIN32
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#else
#include <winsock2.h>
#endif
#include <errno.h> #include <errno.h>
#include "vncauth.h" #include "vncauth.h"
@ -112,7 +116,11 @@ rfb_decoder_connect_tcp (RfbDecoder * decoder, gchar * addr, guint port)
sa.sin_family = AF_INET; sa.sin_family = AF_INET;
sa.sin_port = htons (port); sa.sin_port = htons (port);
#ifndef G_OS_WIN32
inet_pton (AF_INET, addr, &sa.sin_addr); inet_pton (AF_INET, addr, &sa.sin_addr);
#else
sa.sin_addr.s_addr = inet_addr (addr);
#endif
if (connect (decoder->fd, (struct sockaddr *) &sa, if (connect (decoder->fd, (struct sockaddr *) &sa,
sizeof (struct sockaddr)) == -1) { sizeof (struct sockaddr)) == -1) {
close (decoder->fd); close (decoder->fd);
@ -164,7 +172,11 @@ rfb_decoder_read (RfbDecoder * decoder, guint32 len)
} }
while (total < len) { while (total < len) {
#ifndef G_OS_WIN32
now = recv (decoder->fd, decoder->data + total, len - total, 0); now = recv (decoder->fd, decoder->data + total, len - total, 0);
#else
now = recv (decoder->fd, (char *) decoder->data + total, len - total, 0);
#endif
if (now <= 0) { if (now <= 0) {
GST_WARNING ("rfb read error on socket"); GST_WARNING ("rfb read error on socket");
return NULL; return NULL;

View file

@ -22,6 +22,7 @@
*/ */
#include "config.h" #include "config.h"
#include <glib.h>
#include "_stdint.h" #include "_stdint.h"
#include "stdio.h" #include "stdio.h"
#include "stdlib.h" #include "stdlib.h"
@ -130,10 +131,17 @@ vncRandomBytes (unsigned char *bytes)
{ {
int32_t i; int32_t i;
uint32_t seed = (uint32_t) time (0); uint32_t seed = (uint32_t) time (0);
#ifndef G_OS_WIN32
srandom (seed); srandom (seed);
#else
srand (seed);
#endif
for (i = 0; i < CHALLENGESIZE; i++) { for (i = 0; i < CHALLENGESIZE; i++) {
#ifndef G_OS_WIN32
bytes[i] = (unsigned char) (random () & 255); bytes[i] = (unsigned char) (random () & 255);
#else
bytes[i] = (unsigned char) (rand () & 255);
#endif
} }
} }