mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
dix: ProcListExtensions(): use x_rpcbuf_t
Use x_rpcbuf_t for payload assembly and X_SEND_REPLY_WITH_RPCBUF() for sending it all out. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
8cfcb072d2
commit
0d152c44f0
@@ -312,51 +312,26 @@ ProcQueryExtension(ClientPtr client)
|
||||
int
|
||||
ProcListExtensions(ClientPtr client)
|
||||
{
|
||||
char *bufptr, *buffer;
|
||||
int total_length = 0;
|
||||
|
||||
REQUEST_SIZE_MATCH(xReq);
|
||||
|
||||
xListExtensionsReply rep = {
|
||||
.type = X_Reply,
|
||||
.nExtensions = 0,
|
||||
.sequenceNumber = client->sequence,
|
||||
.length = 0
|
||||
};
|
||||
buffer = NULL;
|
||||
xListExtensionsReply rep = { 0 };
|
||||
|
||||
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
||||
|
||||
if (NumExtensions && extensions) {
|
||||
for (int i = 0; i < NumExtensions; i++) {
|
||||
/* call callbacks to find out whether to show extension */
|
||||
if (!ExtensionAvailable(client, extensions[i]))
|
||||
continue;
|
||||
|
||||
total_length += strlen(extensions[i]->name) + 1;
|
||||
rep.nExtensions += 1;
|
||||
}
|
||||
rep.length = bytes_to_int32(total_length);
|
||||
buffer = bufptr = calloc(1, total_length);
|
||||
if (!buffer)
|
||||
return BadAlloc;
|
||||
for (int i = 0; i < NumExtensions; i++) {
|
||||
int len;
|
||||
int len = strlen(extensions[i]->name);
|
||||
|
||||
if (!ExtensionAvailable(client, extensions[i]))
|
||||
continue;
|
||||
rep.nExtensions++;
|
||||
|
||||
*bufptr++ = len = strlen(extensions[i]->name);
|
||||
memcpy(bufptr, extensions[i]->name, len);
|
||||
bufptr += len;
|
||||
/* write a pascal string */
|
||||
x_rpcbuf_write_CARD8(&rpcbuf, len);
|
||||
x_rpcbuf_write_CARD8s(&rpcbuf, (CARD8*)extensions[i]->name, len);
|
||||
}
|
||||
}
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
swapl(&rep.length);
|
||||
}
|
||||
WriteToClient(client, sizeof(rep), &rep);
|
||||
WriteToClient(client, total_length, buffer);
|
||||
|
||||
free(buffer);
|
||||
return Success;
|
||||
return X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user