Commit a7355c5c authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Xau: mark NX changes

libXau is integrated into libNX_X11, but the differences to libXau original code where not explicitly marked. This path adds some ifdefs and also restores the original code. Attributes to ArcticaProject/nx-libs#850
parent e721ba29
...@@ -30,13 +30,16 @@ in this Software without prior written authorization from The Open Group. ...@@ -30,13 +30,16 @@ in this Software without prior written authorization from The Open Group.
#endif #endif
#include <nx-X11/Xauth.h> #include <nx-X11/Xauth.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef NX_TRANS_SOCKET
#include <errno.h> #include <errno.h>
#endif
static int static int
read_short (unsigned short *shortp, FILE *file) read_short (unsigned short *shortp, FILE *file)
{ {
unsigned char file_short[2]; unsigned char file_short[2];
#ifdef NX_TRANS_SOCKET
/* /*
* Added a check on EINTR to prevent the fread() call to be * Added a check on EINTR to prevent the fread() call to be
* interrupted by any signal not blocked by OsBlockSignals(). * interrupted by any signal not blocked by OsBlockSignals().
...@@ -53,6 +56,10 @@ read_short (unsigned short *shortp, FILE *file) ...@@ -53,6 +56,10 @@ read_short (unsigned short *shortp, FILE *file)
} }
break; break;
} }
#else
if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
return 0;
#endif
*shortp = file_short[0] * 256 + file_short[1]; *shortp = file_short[0] * 256 + file_short[1];
return 1; return 1;
} }
...@@ -71,6 +78,7 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file) ...@@ -71,6 +78,7 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file)
data = malloc ((unsigned) len); data = malloc ((unsigned) len);
if (!data) if (!data)
return 0; return 0;
#ifdef NX_TRANS_SOCKET
for (;;) for (;;)
{ {
if (fread (data, (int) sizeof (char), (int) len, file) != len) if (fread (data, (int) sizeof (char), (int) len, file) != len)
...@@ -87,6 +95,13 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file) ...@@ -87,6 +95,13 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file)
} }
break; break;
} }
#else
if (fread (data, (int) sizeof (char), (int) len, file) != len) {
bzero (data, len);
free (data);
return 0;
}
#endif
} }
*stringp = data; *stringp = data;
*countp = len; *countp = len;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment