diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c index 1a6cfa00b..8254b4e8a 100644 --- a/Xi/chgdctl.c +++ b/Xi/chgdctl.c @@ -100,7 +100,6 @@ ProcXChangeDeviceControl(ClientPtr client) xChangeDeviceControlReply rep = { .RepType = X_ChangeDeviceControl, - .sequenceNumber = client->sequence, .status = Success, }; @@ -202,10 +201,7 @@ ProcXChangeDeviceControl(ClientPtr client) SendEventToAllWindows(dev, DevicePresenceNotifyMask, (xEvent *) &dpn, 1); - if (client->swapped) { - swaps(&rep.sequenceNumber); - } - WriteToClient(client, sizeof(xChangeDeviceControlReply), &rep); + REPLY_SEND(); } return ret; diff --git a/Xi/getbmap.c b/Xi/getbmap.c index 5b54c1cd0..cb779f496 100644 --- a/Xi/getbmap.c +++ b/Xi/getbmap.c @@ -86,18 +86,11 @@ ProcXGetDeviceButtonMapping(ClientPtr client) return BadMatch; xGetDeviceButtonMappingReply rep = { - .repType = X_Reply, .RepType = X_GetDeviceButtonMapping, - .sequenceNumber = client->sequence, .nElts = b->numButtons, .length = bytes_to_int32(b->numButtons), }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - WriteToClient(client, sizeof(xGetDeviceButtonMappingReply), &rep); - WriteToClient(client, rep.nElts, &b->map[1]); + REPLY_SEND_EXTRA(&b->map[1], rep.nElts); return Success; } diff --git a/Xi/getdctl.c b/Xi/getdctl.c index 5cda7331c..7d8d024e2 100644 --- a/Xi/getdctl.c +++ b/Xi/getdctl.c @@ -88,15 +88,10 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf, *iptr++ = a->min_resolution; for (i = 0, a = v->axes; i < v->numAxes; i++, a++) *iptr++ = a->max_resolution; - if (client->swapped) { - swaps(&r->control); - swaps(&r->length); - swapl(&r->num_valuators); - iptr = (int *) buf; - for (i = 0; i < (3 * v->numAxes); i++, iptr++) { - swapl(iptr); - } - } + + CLIENT_STRUCT_CARD16_2(r, control, length); + CLIENT_STRUCT_CARD32_1(r, num_valuators); + REPLY_BUF_CARD32(buf, (3 * v->numAxes)); } static void @@ -109,10 +104,7 @@ CopySwapDeviceCore(ClientPtr client, DeviceIntPtr dev, char *buf) c->status = dev->coreEvents; c->iscore = (dev == inputInfo.keyboard || dev == inputInfo.pointer); - if (client->swapped) { - swaps(&c->control); - swaps(&c->length); - } + CLIENT_STRUCT_CARD16_2(c, control, length); } static void @@ -124,10 +116,7 @@ CopySwapDeviceEnable(ClientPtr client, DeviceIntPtr dev, char *buf) e->length = sizeof(xDeviceEnableState); e->enable = dev->enabled; - if (client->swapped) { - swaps(&e->control); - swaps(&e->length); - } + CLIENT_STRUCT_CARD16_2(e, control, length); } /*********************************************************************** @@ -189,18 +178,10 @@ ProcXGetDeviceControl(ClientPtr client) } xGetDeviceControlReply rep = { - .repType = X_Reply, .RepType = X_GetDeviceControl, - .sequenceNumber = client->sequence, - .length = bytes_to_int32(total_length), }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - WriteToClient(client, sizeof(xGetDeviceControlReply), &rep); - WriteToClient(client, total_length, savbuf); + REPLY_SEND_EXTRA(buf, total_length); free(savbuf); return Success; } diff --git a/Xi/getfctl.c b/Xi/getfctl.c index c3ab72183..75316ccc0 100644 --- a/Xi/getfctl.c +++ b/Xi/getfctl.c @@ -86,13 +86,10 @@ CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf) k2->global_auto_repeat = k->ctrl.autoRepeat; for (i = 0; i < 32; i++) k2->auto_repeats[i] = k->ctrl.autoRepeats[i]; - if (client->swapped) { - swaps(&k2->length); - swaps(&k2->pitch); - swaps(&k2->duration); - swapl(&k2->led_mask); - swapl(&k2->led_values); - } + + CLIENT_STRUCT_CARD16_3(k2, length, pitch, duration); + CLIENT_STRUCT_CARD32_2(k2, led_mask, led_values); + *buf += sizeof(xKbdFeedbackState); } @@ -114,12 +111,9 @@ CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf) p2->accelNum = p->ctrl.num; p2->accelDenom = p->ctrl.den; p2->threshold = p->ctrl.threshold; - if (client->swapped) { - swaps(&p2->length); - swaps(&p2->accelNum); - swaps(&p2->accelDenom); - swaps(&p2->threshold); - } + + CLIENT_STRUCT_CARD16_4(p2, length, accelNum, accelDenom, threshold); + *buf += sizeof(xPtrFeedbackState); } @@ -141,12 +135,10 @@ CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf) i2->resolution = i->ctrl.resolution; i2->min_value = i->ctrl.min_value; i2->max_value = i->ctrl.max_value; - if (client->swapped) { - swaps(&i2->length); - swapl(&i2->resolution); - swapl(&i2->min_value); - swapl(&i2->max_value); - } + + CLIENT_STRUCT_CARD16_1(i2, length); + CLIENT_STRUCT_CARD32_3(i2, resolution, min_value, max_value); + *buf += sizeof(xIntegerFeedbackState); } @@ -174,15 +166,10 @@ CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf) kptr = (KeySym *) (*buf); for (i = 0; i < s->ctrl.num_symbols_supported; i++) *kptr++ = *(s->ctrl.symbols_supported + i); - if (client->swapped) { - swaps(&s2->length); - swaps(&s2->max_symbols); - swaps(&s2->num_syms_supported); - kptr = (KeySym *) (*buf); - for (i = 0; i < s->ctrl.num_symbols_supported; i++, kptr++) { - swapl(kptr); - } - } + + CLIENT_STRUCT_CARD16_3(s2, length, max_symbols, num_syms_supported); + REPLY_BUF_CARD32((CARD32*)buf, s->ctrl.num_symbols_supported); + *buf += (s->ctrl.num_symbols_supported * sizeof(KeySym)); } @@ -203,11 +190,10 @@ CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf) l2->id = l->ctrl.id; l2->led_values = l->ctrl.led_values; l2->led_mask = l->ctrl.led_mask; - if (client->swapped) { - swaps(&l2->length); - swapl(&l2->led_values); - swapl(&l2->led_mask); - } + + CLIENT_STRUCT_CARD16_1(l2, length); + CLIENT_STRUCT_CARD32_2(l2, led_values, led_mask); + *buf += sizeof(xLedFeedbackState); } @@ -229,11 +215,9 @@ CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf) b2->percent = b->ctrl.percent; b2->pitch = b->ctrl.pitch; b2->duration = b->ctrl.duration; - if (client->swapped) { - swaps(&b2->length); - swaps(&b2->pitch); - swaps(&b2->duration); - } + + CLIENT_STRUCT_CARD16_3(b2, length, pitch, duration); + *buf += sizeof(xBellFeedbackState); } @@ -262,9 +246,7 @@ ProcXGetFeedbackControl(ClientPtr client) return rc; xGetFeedbackControlReply rep = { - .repType = X_Reply, .RepType = X_GetFeedbackControl, - .sequenceNumber = client->sequence, }; for (k = dev->kbdfeed; k; k = k->next) { @@ -314,14 +296,7 @@ ProcXGetFeedbackControl(ClientPtr client) for (b = dev->bell; b; b = b->next) CopySwapBellFeedback(client, b, &buf); - rep.length = bytes_to_int32(total_length); - - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.num_feedbacks); - } - WriteToClient(client, sizeof(xGetFeedbackControlReply), &rep); - WriteToClient(client, total_length, savbuf); + REPLY_FIELD_CARD16(num_feedbacks); + REPLY_SEND_EXTRA(savbuf, total_length); return Success; } diff --git a/Xi/getfocus.c b/Xi/getfocus.c index ca8f5df4d..ec46ab72b 100644 --- a/Xi/getfocus.c +++ b/Xi/getfocus.c @@ -87,9 +87,7 @@ ProcXGetDeviceFocus(ClientPtr client) focus = dev->focus; xGetDeviceFocusReply rep = { - .repType = X_Reply, .RepType = X_GetDeviceFocus, - .sequenceNumber = client->sequence, .time = focus->time.milliseconds, .revertTo = focus->revert, }; @@ -103,15 +101,8 @@ ProcXGetDeviceFocus(ClientPtr client) else rep.focus = focus->win->drawable.id; - rep.time = focus->time.milliseconds; - rep.revertTo = focus->revert; - - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.focus); - swapl(&rep.time); - } - WriteToClient(client, sizeof(xGetDeviceFocusReply), &rep); + REPLY_FIELD_CARD32(focus); + REPLY_FIELD_CARD32(time); + REPLY_SEND(); return Success; } diff --git a/Xi/getkmap.c b/Xi/getkmap.c index cae4b0db5..cab693ec0 100644 --- a/Xi/getkmap.c +++ b/Xi/getkmap.c @@ -104,18 +104,12 @@ ProcXGetDeviceKeyMapping(ClientPtr client) return BadAlloc; xGetDeviceKeyMappingReply rep = { - .repType = X_Reply, .RepType = X_GetDeviceKeyMapping, - .sequenceNumber = client->sequence, .keySymsPerKeyCode = syms->mapWidth, .length = (syms->mapWidth * stuff->count) /* KeySyms are 4 bytes */ }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - WriteToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep); + REPLY_SEND(); client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; WriteSwappedDataToClient(client, diff --git a/Xi/getmmap.c b/Xi/getmmap.c index 74a366c38..e4d6aa5e1 100644 --- a/Xi/getmmap.c +++ b/Xi/getmmap.c @@ -86,21 +86,12 @@ ProcXGetDeviceModifierMapping(ClientPtr client) return ret; xGetDeviceModifierMappingReply rep = { - .repType = X_Reply, .RepType = X_GetDeviceModifierMapping, - .sequenceNumber = client->sequence, .numKeyPerModifier = max_keys_per_mod, - /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */ - .length = max_keys_per_mod << 1 }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - WriteToClient(client, sizeof(xGetDeviceModifierMappingReply), &rep); - WriteToClient(client, max_keys_per_mod * 8, modkeymap); - + /* 8 modifiers per key, each CARD8 */ + REPLY_SEND_EXTRA(modkeymap, max_keys_per_mod * 8); free(modkeymap); return Success; diff --git a/Xi/getprop.c b/Xi/getprop.c index 26de108db..316c174c3 100644 --- a/Xi/getprop.c +++ b/Xi/getprop.c @@ -86,9 +86,7 @@ ProcXGetDeviceDontPropagateList(ClientPtr client) REQUEST_FIELD_CARD32(window); xGetDeviceDontPropagateListReply rep = { - .repType = X_Reply, .RepType = X_GetDeviceDontPropagateList, - .sequenceNumber = client->sequence, }; rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); @@ -110,12 +108,8 @@ ProcXGetDeviceDontPropagateList(ClientPtr client) } } - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.count); - } - WriteToClient(client, sizeof(xGetDeviceDontPropagateListReply), &rep); + REPLY_FIELD_CARD16(count); + REPLY_SEND(); if (count) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; diff --git a/Xi/getselev.c b/Xi/getselev.c index 41a48fd49..418ba4e8f 100644 --- a/Xi/getselev.c +++ b/Xi/getselev.c @@ -87,9 +87,7 @@ ProcXGetSelectedExtensionEvents(ClientPtr client) REQUEST_FIELD_CARD32(window); xGetSelectedExtensionEventsReply rep = { - .repType = X_Reply, .RepType = X_GetSelectedExtensionEvents, - .sequenceNumber = client->sequence, }; rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); @@ -128,13 +126,9 @@ ProcXGetSelectedExtensionEvents(ClientPtr client) ClassFromMask(aclient, others->mask[i], i, NULL, CREATE); } - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.this_client_count); - swaps(&rep.all_clients_count); - } - WriteToClient(client, sizeof(xGetSelectedExtensionEventsReply), &rep); + REPLY_FIELD_CARD16(this_client_count); + REPLY_FIELD_CARD16(all_clients_count); + REPLY_SEND(); if (total_length) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; diff --git a/Xi/getvers.c b/Xi/getvers.c index f4b001272..909973e92 100644 --- a/Xi/getvers.c +++ b/Xi/getvers.c @@ -82,22 +82,14 @@ ProcXGetExtensionVersion(ClientPtr client) return BadLength; xGetExtensionVersionReply rep = { - .repType = X_Reply, .RepType = X_GetExtensionVersion, - .sequenceNumber = client->sequence, .major_version = XIVersion.major_version, .minor_version = XIVersion.minor_version, .present = TRUE }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.major_version); - swaps(&rep.minor_version); - } - - WriteToClient(client, sizeof(xGetExtensionVersionReply), &rep); - + REPLY_FIELD_CARD16(major_version); + REPLY_FIELD_CARD16(minor_version); + REPLY_SEND(); return Success; } diff --git a/Xi/grabdev.c b/Xi/grabdev.c index 18773df07..66caa483f 100644 --- a/Xi/grabdev.c +++ b/Xi/grabdev.c @@ -92,9 +92,7 @@ ProcXGrabDevice(ClientPtr client) REQUEST_BUF_CARD32(&stuff[1], stuff->event_count); xGrabDeviceReply rep = { - .repType = X_Reply, .RepType = X_GrabDevice, - .sequenceNumber = client->sequence, }; rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); @@ -116,11 +114,7 @@ ProcXGrabDevice(ClientPtr client) if (rc != Success) return rc; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - WriteToClient(client, sizeof(xGrabDeviceReply), &rep); + REPLY_SEND(); return Success; } diff --git a/Xi/gtmotion.c b/Xi/gtmotion.c index 88243e1bb..a69318fa0 100644 --- a/Xi/gtmotion.c +++ b/Xi/gtmotion.c @@ -88,11 +88,7 @@ ProcXGetDeviceMotionEvents(ClientPtr client) MaybeStopDeviceHint(dev, client); xGetDeviceMotionEventsReply rep = { - .repType = X_Reply, .RepType = X_GetDeviceMotionEvents, - .sequenceNumber = client->sequence, - .length = 0, - .nEvents = 0, .axes = v->numAxes, .mode = Absolute /* XXX we don't do relative at the moment */ }; @@ -111,8 +107,10 @@ ProcXGetDeviceMotionEvents(ClientPtr client) rep.nEvents = GetMotionHistory(dev, (xTimecoord **) &coords, /* XXX */ start.milliseconds, stop.milliseconds, (ScreenPtr) NULL, FALSE); + if (rep.nEvents < 0) + rep.nEvents = 0; + length = rep.nEvents * size; - rep.length = bytes_to_int32(length); } } @@ -123,8 +121,9 @@ ProcXGetDeviceMotionEvents(ClientPtr client) swapl(&rep.nEvents); } - WriteToClient(client, sizeof(xGetDeviceMotionEventsReply), &rep); - WriteToClient(client, length, coords); + REPLY_BUF_CARD32(coords, bytes_to_int32(length)); + REPLY_FIELD_CARD32(nEvents); + REPLY_SEND_EXTRA(coords, length); free(coords); return Success; } diff --git a/Xi/listdev.c b/Xi/listdev.c index 470e09cfc..ae37d7a5b 100644 --- a/Xi/listdev.c +++ b/Xi/listdev.c @@ -136,9 +136,9 @@ CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf) b2->class = ButtonClass; b2->length = sizeof(xButtonInfo); b2->num_buttons = b->numButtons; - if (client && client->swapped) { - swaps(&b2->num_buttons); - } + + CLIENT_STRUCT_CARD16_1(b2, num_buttons); + *buf += sizeof(xButtonInfo); } @@ -169,9 +169,8 @@ CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes, char **buf) else dev->use = IsXExtensionDevice; - if (client->swapped) { - swapl(&dev->type); - } + CLIENT_STRUCT_CARD32_1(dev, type); + *buf += sizeof(xDeviceInfo); } @@ -192,9 +191,9 @@ CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf) k2->min_keycode = k->xkbInfo->desc->min_key_code; k2->max_keycode = k->xkbInfo->desc->max_key_code; k2->num_keys = k2->max_keycode - k2->min_keycode + 1; - if (client && client->swapped) { - swaps(&k2->num_keys); - } + + CLIENT_STRUCT_CARD16_1(k2, num_keys); + *buf += sizeof(xKeyInfo); } @@ -230,9 +229,7 @@ CopySwapValuatorClass(ClientPtr client, DeviceIntPtr dev, char **buf) v2->num_axes = t_axes; v2->mode = valuator_get_mode(dev, 0); v2->motion_buffer_size = v->numMotionEvents; - if (client && client->swapped) { - swapl(&v2->motion_buffer_size); - } + CLIENT_STRUCT_CARD32_1(v2, motion_buffer_size); *buf += sizeof(xValuatorInfo); a = v->axes + (VPC * i); a2 = (xAxisInfoPtr) * buf; @@ -240,11 +237,7 @@ CopySwapValuatorClass(ClientPtr client, DeviceIntPtr dev, char **buf) a2->min_value = a->min_value; a2->max_value = a->max_value; a2->resolution = a->resolution; - if (client && client->swapped) { - swapl(&a2->min_value); - swapl(&a2->max_value); - swapl(&a2->resolution); - } + CLIENT_STRUCT_CARD32_3(a2, min_value, max_value, resolution); a2++; a++; *buf += sizeof(xAxisInfo); @@ -378,15 +371,12 @@ ProcXListInputDevices(ClientPtr client) } xListInputDevicesReply rep = { - .repType = X_Reply, .RepType = X_ListInputDevices, - .sequenceNumber = client->sequence, .ndevices = numdevs, - .length = bytes_to_int32(total_length), }; - WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep); - WriteToClient(client, total_length, savbuf); + REPLY_SEND_EXTRA(savbuf, total_length); + free(savbuf); free(skip); return Success; diff --git a/Xi/opendev.c b/Xi/opendev.c index a394caadf..8df1703a3 100644 --- a/Xi/opendev.c +++ b/Xi/opendev.c @@ -131,19 +131,10 @@ ProcXOpenDevice(ClientPtr client) evbase[j++].event_type_base = event_base[OtherClass]; xOpenDeviceReply rep = { - .repType = X_Reply, .RepType = X_OpenDevice, - .sequenceNumber = client->sequence, - .length = bytes_to_int32(j * sizeof(xInputClassInfo)), .num_classes = j }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - - WriteToClient(client, sizeof(xOpenDeviceReply), &rep); - WriteToClient(client, j * sizeof(xInputClassInfo), evbase); + REPLY_SEND_EXTRA(evbase, j * sizeof(xInputClassInfo)); return Success; } diff --git a/Xi/queryst.c b/Xi/queryst.c index 7224bd8d9..d4b1f41e5 100644 --- a/Xi/queryst.c +++ b/Xi/queryst.c @@ -68,7 +68,6 @@ ProcXQueryDeviceState(ClientPtr client) ValuatorClassPtr v; xValuatorState *tv; DeviceIntPtr dev; - double *values; REQUEST_HEAD_STRUCT(xQueryDeviceStateReq); @@ -107,9 +106,8 @@ ProcXQueryDeviceState(ClientPtr client) tk->length = sizeof(xKeyState); tk->num_keys = k->xkbInfo->desc->max_key_code - k->xkbInfo->desc->min_key_code + 1; - if (rc != BadAccess) - for (i = 0; i < 32; i++) - tk->keys[i] = k->down[i]; + for (i = 0; i < 32; i++) + tk->keys[i] = k->down[i]; buf += sizeof(xKeyState); } @@ -132,31 +130,20 @@ ProcXQueryDeviceState(ClientPtr client) tv->mode |= (dev->proximity && !dev->proximity->in_proximity) ? OutOfProximity : 0; buf += sizeof(xValuatorState); - for (i = 0, values = v->axisVal; i < v->numAxes; i++) { + int *buf2 = (int *)buf; + for (i = 0; i < v->numAxes; i++) { if (rc != BadAccess) - *((int *) buf) = *values; - values++; - if (client->swapped) { - swapl((int *) buf); - } - buf += sizeof(int); + buf2[i] = v->axisVal[i]; } + REPLY_BUF_CARD32(buf2, v->numAxes); } xQueryDeviceStateReply rep = { - .repType = X_Reply, .RepType = X_QueryDeviceState, - .sequenceNumber = client->sequence, - .length = bytes_to_int32(total_length), .num_classes = num_classes }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - WriteToClient(client, sizeof(xQueryDeviceStateReply), &rep); - WriteToClient(client, total_length, savbuf); + REPLY_SEND_EXTRA(savbuf, total_length); free(savbuf); return Success; } diff --git a/Xi/setbmap.c b/Xi/setbmap.c index 78e3ee715..e106a2ddb 100644 --- a/Xi/setbmap.c +++ b/Xi/setbmap.c @@ -101,10 +101,6 @@ ProcXSetDeviceButtonMapping(ClientPtr client) .status = (ret == Success ? MappingSuccess : MappingBusy), }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - } - WriteToClient(client, sizeof(xSetDeviceButtonMappingReply), &rep); - + REPLY_SEND(); return Success; } diff --git a/Xi/setdval.c b/Xi/setdval.c index 8c4248b0e..405541320 100644 --- a/Xi/setdval.c +++ b/Xi/setdval.c @@ -79,9 +79,7 @@ ProcXSetDeviceValuators(ClientPtr client) REQUEST_HEAD_AT_LEAST(xSetDeviceValuatorsReq); xSetDeviceValuatorsReply rep = { - .repType = X_Reply, .RepType = X_SetDeviceValuators, - .sequenceNumber = client->sequence, .status = Success }; @@ -111,9 +109,6 @@ ProcXSetDeviceValuators(ClientPtr client) if (rep.status != Success && rep.status != AlreadyGrabbed) return rep.status; - if (client->swapped) { - swaps(&rep.sequenceNumber); - } - WriteToClient(client, sizeof(xSetDeviceValuatorsReply), &rep); + REPLY_SEND(); return Success; } diff --git a/Xi/setmmap.c b/Xi/setmmap.c index 5c8cd6dbc..15c376ee8 100644 --- a/Xi/setmmap.c +++ b/Xi/setmmap.c @@ -101,9 +101,6 @@ ProcXSetDeviceModifierMapping(ClientPtr client) .success = ret, }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - } - WriteToClient(client, sizeof(xSetDeviceModifierMappingReply), &rep); + REPLY_SEND(); return Success; } diff --git a/Xi/setmode.c b/Xi/setmode.c index 338cba259..f4d374333 100644 --- a/Xi/setmode.c +++ b/Xi/setmode.c @@ -79,9 +79,7 @@ ProcXSetDeviceMode(ClientPtr client) REQUEST_HEAD_STRUCT(xSetDeviceModeReq); xSetDeviceModeReply rep = { - .repType = X_Reply, .RepType = X_SetDeviceMode, - .sequenceNumber = client->sequence, }; rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess); @@ -112,11 +110,6 @@ ProcXSetDeviceMode(ClientPtr client) return rep.status; } - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - - WriteToClient(client, sizeof(xSetDeviceModeReply), &rep); + REPLY_SEND(); return Success; } diff --git a/Xi/xigetclientpointer.c b/Xi/xigetclientpointer.c index 8903d8be5..b7888248c 100644 --- a/Xi/xigetclientpointer.c +++ b/Xi/xigetclientpointer.c @@ -45,34 +45,24 @@ int ProcXIGetClientPointer(ClientPtr client) { - int rc; - ClientPtr winclient; - REQUEST_HEAD_STRUCT(xXIGetClientPointerReq); REQUEST_FIELD_CARD32(win); + ClientPtr winclient; if (stuff->win != None) { - rc = dixLookupResourceOwner(&winclient, stuff->win, client, DixGetAttrAccess); - - if (rc != Success) + if (dixLookupResourceOwner(&winclient, stuff->win, client, DixGetAttrAccess) != Success) return BadWindow; } else winclient = client; xXIGetClientPointerReply rep = { - .repType = X_Reply, .RepType = X_XIGetClientPointer, - .sequenceNumber = client->sequence, .set = (winclient->clientPtr != NULL), .deviceid = (winclient->clientPtr) ? winclient->clientPtr->id : 0 }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.deviceid); - } - WriteToClient(client, sizeof(xXIGetClientPointerReply), &rep); + REPLY_FIELD_CARD16(deviceid); + REPLY_SEND(); return Success; } diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c index b08a2f222..2a92c8cfd 100644 --- a/Xi/xigrabdev.c +++ b/Xi/xigrabdev.c @@ -110,17 +110,12 @@ ProcXIGrabDevice(ClientPtr client) return ret; xXIGrabDeviceReply rep = { - .repType = X_Reply, .RepType = X_XIGrabDevice, - .sequenceNumber = client->sequence, .status = status }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - } - WriteToClient(client, sizeof(rep), &rep); - return ret; + REPLY_SEND(); + return Success; } int diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c index 287a05c9c..796159dd5 100644 --- a/Xi/xipassivegrab.c +++ b/Xi/xipassivegrab.c @@ -51,13 +51,6 @@ int ProcXIPassiveGrabDevice(ClientPtr client) { DeviceIntPtr dev, mod_dev; - xXIPassiveGrabDeviceReply rep = { - .repType = X_Reply, - .RepType = X_XIPassiveGrabDevice, - .sequenceNumber = client->sequence, - .length = 0, - .num_modifiers = 0 - }; int i, ret = Success; uint32_t *modifiers; xXIGrabModifierInfo *modifiers_failed = NULL; @@ -185,6 +178,8 @@ ProcXIPassiveGrabDevice(ClientPtr client) mod_dev = (InputDevIsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD); + int num_mod = 0; + for (i = 0; i < stuff->num_modifiers; i++, modifiers++) { uint8_t status = Success; @@ -221,27 +216,24 @@ ProcXIPassiveGrabDevice(ClientPtr client) } if (status != GrabSuccess) { - xXIGrabModifierInfo *info = modifiers_failed + rep.num_modifiers; + xXIGrabModifierInfo *info = modifiers_failed + num_mod; info->status = status; info->modifiers = *modifiers; - if (client->swapped) - swapl(&info->modifiers); - - rep.num_modifiers++; - rep.length += bytes_to_int32(sizeof(xXIGrabModifierInfo)); + CLIENT_STRUCT_CARD32_1(info, modifiers); + num_mod++; } } - uint32_t length = rep.length; /* save it before swapping */ + xXIPassiveGrabDeviceReply rep = { + .RepType = X_XIPassiveGrabDevice, + .num_modifiers = num_mod, + }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.num_modifiers); - } - WriteToClient(client, sizeof(rep), &rep); - WriteToClient(client, length * 4, modifiers_failed); + uint32_t length = bytes_to_int32(sizeof(xXIGrabModifierInfo) * num_mod); + + REPLY_FIELD_CARD16(num_modifiers); + REPLY_SEND_EXTRA(modifiers_failed, length * 4); out: free(modifiers_failed); diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c index e305d8e83..dd15c879e 100644 --- a/Xi/xiproperty.c +++ b/Xi/xiproperty.c @@ -853,11 +853,10 @@ ProcXListDeviceProperties(ClientPtr client) Atom *atoms; int natoms; DeviceIntPtr dev; - int rc = Success; REQUEST_HEAD_STRUCT(xListDevicePropertiesReq); - rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess); + int rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess); if (rc != Success) return rc; @@ -866,25 +865,17 @@ ProcXListDeviceProperties(ClientPtr client) return rc; xListDevicePropertiesReply rep = { - .repType = X_Reply, .RepType = X_ListDeviceProperties, .sequenceNumber = client->sequence, .length = natoms, .nAtoms = natoms }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.nAtoms); - } - WriteToClient(client, sizeof(xListDevicePropertiesReply), &rep); - if (natoms) { - client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; - WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms); - free(atoms); - } - return rc; + REPLY_FIELD_CARD16(nAtoms); + REPLY_SEND(); + free(atoms); + + return Success; } int @@ -976,9 +967,7 @@ ProcXGetDeviceProperty(ClientPtr client) return rc; xGetDevicePropertyReply rep = { - .repType = X_Reply, .RepType = X_GetDeviceProperty, - .sequenceNumber = client->sequence, .length = bytes_to_int32(length), .propertyType = type, .bytesAfter = bytes_after, @@ -990,14 +979,10 @@ ProcXGetDeviceProperty(ClientPtr client) if (stuff->delete && (rep.bytesAfter == 0)) send_property_event(dev, stuff->property, XIPropertyDeleted); - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.propertyType); - swapl(&rep.bytesAfter); - swapl(&rep.nItems); - } - WriteToClient(client, sizeof(xGenericReply), &rep); + REPLY_FIELD_CARD32(propertyType); + REPLY_FIELD_CARD32(bytesAfter); + REPLY_FIELD_CARD32(nItems); + REPLY_SEND(); if (length) { switch (rep.format) { @@ -1051,19 +1036,14 @@ ProcXIListProperties(ClientPtr client) return rc; xXIListPropertiesReply rep = { - .repType = X_Reply, .RepType = X_XIListProperties, - .sequenceNumber = client->sequence, .length = natoms, .num_properties = natoms }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.num_properties); - } - WriteToClient(client, sizeof(xXIListPropertiesReply), &rep); + REPLY_FIELD_CARD16(num_properties); + REPLY_SEND(); + if (natoms) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms); @@ -1165,9 +1145,7 @@ ProcXIGetProperty(ClientPtr client) return rc; xXIGetPropertyReply rep = { - .repType = X_Reply, .RepType = X_XIGetProperty, - .sequenceNumber = client->sequence, .length = bytes_to_int32(length), .type = type, .bytes_after = bytes_after, @@ -1178,14 +1156,10 @@ ProcXIGetProperty(ClientPtr client) if (length && stuff->delete && (rep.bytes_after == 0)) send_property_event(dev, stuff->property, XIPropertyDeleted); - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.type); - swapl(&rep.bytes_after); - swapl(&rep.num_items); - } - WriteToClient(client, sizeof(xXIGetPropertyReply), &rep); + REPLY_FIELD_CARD32(type); + REPLY_FIELD_CARD32(bytes_after); + REPLY_FIELD_CARD32(num_items); + REPLY_SEND(); if (length) { switch (rep.format) { diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c index 61d00e44b..cf4429d74 100644 --- a/Xi/xiquerydevice.c +++ b/Xi/xiquerydevice.c @@ -101,12 +101,11 @@ ProcXIQueryDevice(ClientPtr client) } xXIQueryDeviceReply rep = { - .repType = X_Reply, .RepType = X_XIQueryDevice, - .sequenceNumber = client->sequence, - .length = len / 4, }; + int buf_len = len; + ptr = info; if (dev) { len = ListDeviceInfo(client, dev, (xXIDeviceInfo *) info); @@ -138,15 +137,9 @@ ProcXIQueryDevice(ClientPtr client) } } - len = rep.length * 4; + REPLY_FIELD_CARD16(num_devices); + REPLY_SEND_EXTRA(ptr, buf_len); - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.num_devices); - } - WriteToClient(client, sizeof(xXIQueryDeviceReply), &rep); - WriteToClient(client, len, ptr); free(ptr); free(skip); return rc; diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c index b63851b11..c5ff79805 100644 --- a/Xi/xiquerypointer.c +++ b/Xi/xiquerypointer.c @@ -115,9 +115,7 @@ ProcXIQueryPointer(ClientPtr client) pSprite = pDev->spriteInfo->sprite; xXIQueryPointerReply rep = { - .repType = X_Reply, .RepType = X_XIQueryPointer, - .sequenceNumber = client->sequence, .length = 6, .root = (InputDevCurrentRootWindow(pDev))->drawable.id, .root_x = double_to_fp1616(pSprite->hot.x), @@ -183,19 +181,14 @@ ProcXIQueryPointer(ClientPtr client) } #endif /* XINERAMA */ - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.root); - swapl(&rep.child); - swapl(&rep.root_x); - swapl(&rep.root_y); - swapl(&rep.win_x); - swapl(&rep.win_y); - swaps(&rep.buttons_len); - } - WriteToClient(client, sizeof(xXIQueryPointerReply), &rep); - WriteToClient(client, buttons_size, buttons); + REPLY_FIELD_CARD32(root); + REPLY_FIELD_CARD32(child); + REPLY_FIELD_CARD32(root_x); + REPLY_FIELD_CARD32(root_y); + REPLY_FIELD_CARD32(win_x); + REPLY_FIELD_CARD32(win_y); + REPLY_FIELD_CARD16(buttons_len); + REPLY_SEND_EXTRA(buttons, buttons_size); free(buttons); diff --git a/Xi/xiqueryversion.c b/Xi/xiqueryversion.c index 2b8ca45d7..0b8ed0983 100644 --- a/Xi/xiqueryversion.c +++ b/Xi/xiqueryversion.c @@ -115,19 +115,12 @@ ProcXIQueryVersion(ClientPtr client) } xXIQueryVersionReply rep = { - .repType = X_Reply, .RepType = X_XIQueryVersion, - .sequenceNumber = client->sequence, .major_version = major, .minor_version = minor }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swaps(&rep.major_version); - swaps(&rep.minor_version); - } - WriteToClient(client, sizeof(xXIQueryVersionReply), &rep); - + REPLY_FIELD_CARD16(major_version); + REPLY_FIELD_CARD16(minor_version); return Success; } diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c index 3baa9b545..37fe5ac65 100644 --- a/Xi/xiselectev.c +++ b/Xi/xiselectev.c @@ -135,8 +135,7 @@ ProcXISelectEvents(ClientPtr client) if (len < bytes_to_int32(sizeof(xXIEventMask))) return BadLength; len -= bytes_to_int32(sizeof(xXIEventMask)); - swaps(&evmask->deviceid); - swaps(&evmask->mask_len); + CLIENT_STRUCT_CARD16_2(evmask, deviceid, mask_len); if (len < evmask->mask_len) return BadLength; len -= evmask->mask_len; @@ -338,9 +337,7 @@ ProcXIGetSelectedEvents(ClientPtr client) return rc; xXIGetSelectedEventsReply rep = { - .repType = X_Reply, .RepType = X_XIGetSelectedEvents, - .sequenceNumber = client->sequence, }; masks = wOtherInputMasks(win); @@ -377,12 +374,9 @@ ProcXIGetSelectedEvents(ClientPtr client) evmask->deviceid = i; evmask->mask_len = mask_len; rep.num_masks++; - rep.length += sizeof(xXIEventMask) / 4 + evmask->mask_len; + length += sizeof(xXIEventMask) + mask_len * 4; - if (client->swapped) { - swaps(&evmask->deviceid); - swaps(&evmask->mask_len); - } + CLIENT_STRUCT_CARD16_2(evmask, deviceid, mask_len); memcpy(&evmask[1], devmask, j + 1); evmask = (xXIEventMask *) ((char *) evmask + @@ -395,13 +389,7 @@ ProcXIGetSelectedEvents(ClientPtr client) finish: ; uint32_t length = rep.length; /* save before swapping it */ - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.num_masks); - } - WriteToClient(client, sizeof(xXIGetSelectedEventsReply), &rep); - WriteToClient(client, length * 4, buffer); - + REPLY_FIELD_CARD16(num_masks); + REPLY_SEND_EXTRA(buffer, length); return Success; } diff --git a/Xi/xisetdevfocus.c b/Xi/xisetdevfocus.c index 8293555ad..749b1c3be 100644 --- a/Xi/xisetdevfocus.c +++ b/Xi/xisetdevfocus.c @@ -78,9 +78,7 @@ ProcXIGetFocus(ClientPtr client) return BadDevice; xXIGetFocusReply rep = { - .repType = X_Reply, .RepType = X_XIGetFocus, - .sequenceNumber = client->sequence, }; if (dev->focus->win == NoneWin) @@ -92,11 +90,7 @@ ProcXIGetFocus(ClientPtr client) else rep.focus = dev->focus->win->drawable.id; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.focus); - } - WriteToClient(client, sizeof(xXIGetFocusReply), &rep); + REPLY_FIELD_CARD32(focus); + REPLY_SEND(); return Success; }