From f9fba638cf2d45e00e4ee1321cb70ef077928d07 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 21 Aug 2025 17:48:26 +0200 Subject: [PATCH] dix: add macro X_SEND_REPLY_SIMPLE() for sending simple replies This macro fixes up a given reply header, computes it's full size and sends it out. Signed-off-by: Enrico Weigelt, metux IT consult --- dix/dix_priv.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dix/dix_priv.h b/dix/dix_priv.h index 0c30c41e28..bdb90a4df3 100644 --- a/dix/dix_priv.h +++ b/dix/dix_priv.h @@ -766,6 +766,22 @@ static inline void __write_reply_hdr_and_rpcbuf( WriteRpcbufToClient(pClient, rpcbuf); } +static inline void __write_reply_hdr_simple( + ClientPtr pClient, void *hdrData, size_t hdrLen) +{ + xGenericReply *reply = hdrData; + reply->type = X_Reply; + reply->length = (bytes_to_int32(hdrLen - sizeof(xGenericReply))); + reply->sequenceNumber = pClient->sequence; + + if (pClient->swapped) { + swaps(&reply->sequenceNumber); + swapl(&reply->length); + } + + WriteToClient(pClient, hdrLen, hdrData); +} + /* * send reply with header struct (not pointer!) along with rpcbuf payload * @@ -776,4 +792,13 @@ static inline void __write_reply_hdr_and_rpcbuf( #define X_SEND_REPLY_WITH_RPCBUF(client, hdrstruct, rpcbuf) \ __write_reply_hdr_and_rpcbuf(client, &hdrstruct, sizeof(hdrstruct), &rpcbuf); +/* + * send reply with header struct (not pointer!) without any payload + * + * @param client pointer to the client (ClientPtr) + * @param hdrstruct the header struct (not pointer, the struct itself!) + */ +#define X_SEND_REPLY_SIMPLE(client, hdrstruct) \ + __write_reply_hdr_simple(client, &hdrstruct, sizeof(hdrstruct)); + #endif /* _XSERVER_DIX_PRIV_H */