diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-03-31 09:36:14 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-04-27 19:13:10 -0700 |
commit | 1f6143b4386b750ae9e732a6c591cdca73d2b2df (patch) | |
tree | 68ed3697fefedda6cdade6191ef838e66c400e12 /src | |
parent | 4ae6b302d6a15fe25a60f4fc85a441e8a3c6e7f4 (diff) |
Allow test programs to provide responses to selected QueryExtension calls
Allows them to provide their own psuedo-implementations of Extensions.
If the sequence in a response is set to XHIV_SEQ_MATCHDATA, then the new
match_data field has a pointer to additional matching constraints. So far
only X_QueryExtension will check those, and it expects a null terminated
extension name string to match against the queried extension.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/server.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/server.c b/src/server.c index 24a9872..c1acfe0 100644 --- a/src/server.c +++ b/src/server.c @@ -521,7 +521,7 @@ HandleClientRequest(client_state *client, xhiv_response *responses) switch (req.reqType) { case X_QueryExtension: /* XOpenDisplay checks for BIG-REQUESTS & XKB extensions. - We only simulate BIG-REQUESTS for now */ + We only simulate BIG-REQUESTS here for now */ { int nbytes = client->req_len_remaining; char extension[32] = ""; @@ -533,11 +533,12 @@ HandleClientRequest(client_state *client, xhiv_response *responses) .first_event = 0, .first_error = 0 }; - xhiv_response qext_response = { + xhiv_response default_qext_response = { .length = bytes_to_int32(sz_xQueryExtensionReply), .response_data = &qext_reply, .response_datalen = sizeof(qext_reply) }; + xhiv_response *qext_response = &default_qext_response; if (nbytes > sizeof(extension)) nbytes = sizeof(extension); @@ -546,17 +547,30 @@ HandleClientRequest(client_state *client, xhiv_response *responses) if (rbytes > 0) { assert(client->req_len_remaining >= rbytes); client->req_len_remaining -= rbytes; - if (strncmp(extension + 4, XBigReqExtensionName, - sizeof(XBigReqExtensionName)) == 0) { - qext_reply.present = xTrue; - qext_reply.major_opcode = BIGREQ_REQTYPE; + /* Check to see if caller provided a match */ + for (r = responses; r != NULL ; r = r->next) { + if ((r->reqType == X_QueryExtension) && + (r->sequence == XHIV_SEQ_MATCHDATA) && + (strncmp(extension + 4, r->match_data, + sizeof(extension) - 4) == 0)) { + qext_response = r; + break; + } + } + /* If caller didn't, then handle ourselves */ + if (qext_response == &default_qext_response) { + if (strncmp(extension + 4, XBigReqExtensionName, + sizeof(XBigReqExtensionName)) == 0) { + qext_reply.present = xTrue; + qext_reply.major_opcode = BIGREQ_REQTYPE; + } } } else { assert(rbytes == 0); } client->crb = - AddResponseToBuffer(client->crb, &qext_response, + AddResponseToBuffer(client->crb, qext_response, client->sequence); } break; |