summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-03-17 00:17:48 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-03-30 20:31:13 -0700
commit9e73cd99f48ace69c17a5dea20f4aa18b8874055 (patch)
tree88dc6ccbe970adf913009bb54713e45e4dd9d4a6 /src
parent19989884334aa9b8be1b1389320e59f7927acc2f (diff)
Switch xtrans from X11_t to XSERV_t to avoid conflicts with pre-xcb Xlib
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/os.h20
-rw-r--r--src/server.c32
-rw-r--r--src/xstrans.c2
4 files changed, 38 insertions, 17 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index a1d8306..4457540 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,7 @@
noinst_LIBRARIES = libXhiv.a
libXhiv_a_SOURCES = \
+ os.h \
proto.h \
xlib_client.c \
xstrans.c \
diff --git a/src/os.h b/src/os.h
new file mode 100644
index 0000000..94749a4
--- /dev/null
+++ b/src/os.h
@@ -0,0 +1,20 @@
+/*
+ * Xtrans expects "os.h" to provide ErrorF() & VErrorF() functions compatible
+ * with the ones provided by the X server.
+ */
+static inline void _X_ATTRIBUTE_PRINTF(1, 0)
+VErrorF(const char *f, va_list args)
+{
+ vfprintf(stderr, f, args);
+ fflush(stderr);
+}
+
+static inline void _X_ATTRIBUTE_PRINTF(1, 2)
+ErrorF(const char *f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+ VErrorF(f, args);
+ va_end(args);
+}
diff --git a/src/server.c b/src/server.c
index 50f5e41..21c378d 100644
--- a/src/server.c
+++ b/src/server.c
@@ -28,7 +28,7 @@
#include "xhiv.h"
#include "proto.h"
-#define X11_t
+#define XSERV_t
#define TRANS_SERVER
#include <X11/Xtrans/Xtrans.h>
#include <X11/Xtrans/Xtransint.h>
@@ -281,7 +281,7 @@ CloseListenTrans(XtransConnInfo *ListenTransConns, int ListenTransCount)
int i;
for (i = 0; i < ListenTransCount; i++)
- _X11TransClose(ListenTransConns[i]);
+ _XSERVTransClose(ListenTransConns[i]);
}
static XtransConnInfo
@@ -295,7 +295,7 @@ WaitForClient(XtransConnInfo *ListenTransConns, int ListenTransCount)
assert (pollfds != NULL);
for (i = 0; i < ListenTransCount; i++) {
- pollfds[i].fd = _X11TransGetConnectionNumber(ListenTransConns[i]);
+ pollfds[i].fd = _XSERVTransGetConnectionNumber(ListenTransConns[i]);
pollfds[i].events = POLLIN;
}
@@ -311,7 +311,7 @@ WaitForClient(XtransConnInfo *ListenTransConns, int ListenTransCount)
else if (pollfds[i].revents) {
int status;
ClientTransConn =
- _X11TransAccept(ListenTransConns[i], &status);
+ _XSERVTransAccept(ListenTransConns[i], &status);
if (ClientTransConn)
break;
}
@@ -355,14 +355,14 @@ HandleClientResponses(client_state *client)
memcpy(&rep, crb->response_data, nbytes);
rep.sequenceNumber = (CARD16) crb->response_sequence;
- wbytes = _X11TransWrite(client->conn, (char *) &rep, nbytes);
+ wbytes = _XSERVTransWrite(client->conn, (char *) &rep, nbytes);
if (wbytes > 0)
crb->response_written += wbytes;
}
if (crb->response_written < crb->response_datalen) {
nbytes = crb->response_datalen - crb->response_written;
- wbytes = _X11TransWrite(client->conn,
+ wbytes = _XSERVTransWrite(client->conn,
(const char *) crb->response_data + crb->response_written,
nbytes);
if (wbytes > 0)
@@ -395,7 +395,7 @@ HandleClientResponses(client_state *client)
read(urandom_fd, ranbuf, nbytes);
do {
- wbytes = _X11TransWrite(client->conn, ranbuf, nbytes);
+ wbytes = _XSERVTransWrite(client->conn, ranbuf, nbytes);
if (wbytes > 0)
crb->response_written += wbytes;
if (wbytes != nbytes) /* pipe is full, try again later */
@@ -428,7 +428,7 @@ DiscardRequestData(client_state *client)
while (client->req_len_remaining) {
int nbytes = (client->req_len_remaining > sizeof(readbuf)) ?
sizeof(readbuf) : client->req_len_remaining;
- int rbytes = _X11TransRead(client->conn, (char *)readbuf, nbytes);
+ int rbytes = _XSERVTransRead(client->conn, (char *)readbuf, nbytes);
if (rbytes <= 0)
break;
client->req_len_remaining -= rbytes;
@@ -472,10 +472,10 @@ HandleClientRequest(client_state *client, xhiv_response *responses)
return; /* back to poll again for more data */
errno = 0;
- rbytes = _X11TransRead(client->conn, (char *)&req, sizeof(req));
+ rbytes = _XSERVTransRead(client->conn, (char *)&req, sizeof(req));
if ((rbytes == 0) && (errno == 0)) {
/* client disconnected */
- _X11TransClose(client->conn);
+ _XSERVTransClose(client->conn);
return;
}
if (rbytes <= 0) {
@@ -486,7 +486,7 @@ HandleClientRequest(client_state *client, xhiv_response *responses)
}
assert(rbytes == sizeof(req));
if (req.length == 0) { /* BIG Request */
- rbytes = _X11TransRead(client->conn, (char *)&length, 4);
+ rbytes = _XSERVTransRead(client->conn, (char *)&length, 4);
assert(rbytes == 4);
}
else
@@ -524,7 +524,7 @@ HandleClientRequest(client_state *client, xhiv_response *responses)
if (nbytes > sizeof(extension))
nbytes = sizeof(extension);
- rbytes = _X11TransRead(client->conn, (char *)&extension,
+ rbytes = _XSERVTransRead(client->conn, (char *)&extension,
nbytes);
if (rbytes > 0) {
assert(client->req_len_remaining >= rbytes);
@@ -643,8 +643,8 @@ XhivRunServer(XtransConnInfo *ListenTransConns, int ListenTransCount,
/* Wait for a client to connect - when it does, the connections
passed in are closed, and only the client socket remains open */
client.conn = WaitForClient(ListenTransConns, ListenTransCount);
- clientfd.fd = _X11TransGetConnectionNumber(client.conn);
- _X11TransSetOption(client.conn, TRANS_NONBLOCKING, 1);
+ clientfd.fd = _XSERVTransGetConnectionNumber(client.conn);
+ _XSERVTransSetOption(client.conn, TRANS_NONBLOCKING, 1);
for (;;) { /* repeat until client hangs up on us */
int readyfds = poll(&clientfd, 1, -1);
@@ -673,7 +673,7 @@ XhivRunServer(XtransConnInfo *ListenTransConns, int ListenTransCount,
else
clientfd.events = POLLIN | POLLOUT;
}
- _X11TransClose(client.conn);
+ _XSERVTransClose(client.conn);
exit(0);
}
@@ -737,7 +737,7 @@ XhivOpenServer(xhiv_response *responses, pid_t *return_pid)
snprintf(port, sizeof(port), "%d", i);
- if (_X11TransMakeAllCOTSServerListeners(
+ if (_XSERVTransMakeAllCOTSServerListeners(
port, &partial, &ListenTransCount, &ListenTransConns) >= 0)
{
snprintf(port, sizeof(port), ":%d", i);
diff --git a/src/xstrans.c b/src/xstrans.c
index 2381f77..67c66ab 100644
--- a/src/xstrans.c
+++ b/src/xstrans.c
@@ -26,5 +26,5 @@
#endif
#define TRANS_SERVER
-#define X11_t
+#define XSERV_t
#include <X11/Xtrans/transport.c>