static XkbComponentNamePtr _ReadListing(XkbReadBufferPtr buf,int count,Status *status_rtrn) { XkbComponentNamePtr first,this; register int i; CARD16 * flags; int slen,wlen; char * str; if (count<1) return NULL; first= _XkbTypedCalloc(count,XkbComponentNameRec); if (!first) return NULL; for (this=first,i=0;i<count;i++,this++) { flags= (CARD16 *)_XkbGetReadBufferPtr(buf,2*sizeof(CARD16)); if (!flags) goto BAILOUT; this->flags= flags[0]; slen= flags[1]; wlen= ((slen+1)/2)*2; /* pad to 2 byte boundary */ this->name= _XkbTypedCalloc(slen+1,char); if (!this->name) goto BAILOUT; str= (char *)_XkbGetReadBufferPtr(buf,wlen); memcpy(this->name,str,slen); } return first; BAILOUT: *status_rtrn= BadAlloc; _FreeComponentNames(i,first); return NULL; }
static Status _XkbReadGeomShapes( XkbReadBufferPtr buf, XkbGeometryPtr geom, xkbGetGeometryReply * rep) { register int i; Status rtrn; if (rep->nShapes<1) return Success; if ((rtrn=XkbAllocGeomShapes(geom,rep->nShapes))!=Success) return rtrn; for (i=0;i<rep->nShapes;i++) { xkbShapeWireDesc *shapeWire; XkbShapePtr shape; register int o; shapeWire= (xkbShapeWireDesc *) _XkbGetReadBufferPtr(buf,SIZEOF(xkbShapeWireDesc)); if (!shapeWire) return BadLength; shape= XkbAddGeomShape(geom,shapeWire->name,shapeWire->nOutlines); if (!shape) return BadAlloc; for (o=0;o<shapeWire->nOutlines;o++) { xkbOutlineWireDesc *olWire; XkbOutlinePtr ol; register int p; XkbPointPtr pt; olWire= (xkbOutlineWireDesc *) _XkbGetReadBufferPtr(buf,SIZEOF(xkbOutlineWireDesc)); if (!olWire) return BadLength; ol= XkbAddGeomOutline(shape,olWire->nPoints); if (!ol) return BadAlloc; ol->corner_radius= olWire->cornerRadius; for (p=0,pt=ol->points;p<olWire->nPoints;p++,pt++) { xkbPointWireDesc * ptWire; ptWire= (xkbPointWireDesc *) _XkbGetReadBufferPtr(buf,SIZEOF(xkbPointWireDesc)); if (!ptWire) return BadLength; pt->x= ptWire->x; pt->y= ptWire->y; } ol->num_points= olWire->nPoints; } if (shapeWire->primaryNdx!=XkbNoShape) shape->primary= &shape->outlines[shapeWire->primaryNdx]; else shape->primary= NULL; if (shapeWire->approxNdx!=XkbNoShape) shape->approx= &shape->outlines[shapeWire->approxNdx]; else shape->approx= NULL; XkbComputeShapeBounds(shape); } return Success; }
static Status _XkbReadGeomOverlay(XkbReadBufferPtr buf, XkbGeometryPtr geom, XkbSectionPtr section) { XkbOverlayPtr ol; xkbOverlayWireDesc *olWire; register int r; olWire = (xkbOverlayWireDesc *) _XkbGetReadBufferPtr(buf, SIZEOF(xkbOverlayWireDesc)); if (olWire == NULL) return BadLength; ol = XkbAddGeomOverlay(section, olWire->name, olWire->nRows); if (ol == NULL) return BadLength; for (r = 0; r < olWire->nRows; r++) { register int k; XkbOverlayRowPtr row; xkbOverlayRowWireDesc *rowWire; xkbOverlayKeyWireDesc *keyWire; rowWire = (xkbOverlayRowWireDesc *) _XkbGetReadBufferPtr(buf, SIZEOF(xkbOverlayRowWireDesc)); if (rowWire == NULL) return BadLength; row = XkbAddGeomOverlayRow(ol, rowWire->rowUnder, rowWire->nKeys); row->row_under = rowWire->rowUnder; if (!row) return BadAlloc; if (rowWire->nKeys < 1) continue; keyWire = (xkbOverlayKeyWireDesc *) _XkbGetReadBufferPtr(buf, SIZEOF(xkbOverlayKeyWireDesc) * rowWire->nKeys); if (keyWire == NULL) return BadLength; for (k = 0; k < rowWire->nKeys; k++, keyWire++, row->num_keys++) { memcpy(row->keys[row->num_keys].over.name, keyWire->over, XkbKeyNameLength); memcpy(row->keys[row->num_keys].under.name, keyWire->under, XkbKeyNameLength); } } return Success; }
static Status _XkbReadGeomDoodad( XkbReadBufferPtr buf, XkbGeometryPtr geom, XkbSectionPtr section) { XkbDoodadPtr doodad; xkbDoodadWireDesc * doodadWire; doodadWire= (xkbDoodadWireDesc *) _XkbGetReadBufferPtr(buf,SIZEOF(xkbDoodadWireDesc)); if (!doodadWire) return BadLength; doodad= XkbAddGeomDoodad(geom,section,doodadWire->any.name); if (!doodad) return BadAlloc; doodad->any.type= doodadWire->any.type; doodad->any.priority= doodadWire->any.priority; doodad->any.top= doodadWire->any.top; doodad->any.left= doodadWire->any.left; doodad->any.angle= doodadWire->any.angle; switch (doodad->any.type) { case XkbOutlineDoodad: case XkbSolidDoodad: doodad->shape.color_ndx= doodadWire->shape.colorNdx; doodad->shape.shape_ndx= doodadWire->shape.shapeNdx; break; case XkbTextDoodad: doodad->text.width= doodadWire->text.width; doodad->text.height= doodadWire->text.height; doodad->text.color_ndx= doodadWire->text.colorNdx; if (!_XkbGetReadBufferCountedString(buf,&doodad->text.text)) return BadLength; if (!_XkbGetReadBufferCountedString(buf,&doodad->text.font)) return BadLength; break; case XkbIndicatorDoodad: doodad->indicator.shape_ndx= doodadWire->indicator.shapeNdx; doodad->indicator.on_color_ndx= doodadWire->indicator.onColorNdx; doodad->indicator.off_color_ndx= doodadWire->indicator.offColorNdx; break; case XkbLogoDoodad: doodad->logo.color_ndx= doodadWire->logo.colorNdx; doodad->logo.shape_ndx= doodadWire->logo.shapeNdx; if (!_XkbGetReadBufferCountedString(buf,&doodad->logo.logo_name)) return BadLength; break; default: return BadValue; } return Success; }
Status _XkbReadGetIndicatorMapReply( Display * dpy, xkbGetIndicatorMapReply * rep, XkbDescPtr xkb, int * nread_rtrn) { XkbIndicatorPtr leds; XkbReadBufferRec buf; if ((!xkb->indicators)&&(XkbAllocIndicatorMaps(xkb)!=Success)) return BadAlloc; leds= xkb->indicators; leds->phys_indicators = rep->realIndicators; if (rep->length>0) { register int left; if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4)) return BadAlloc; if (nread_rtrn) *nread_rtrn= (int)rep->length*4; if (rep->which) { register int i,bit; left= (int)rep->which; for (i=0,bit=1;(i<XkbNumIndicators)&&(left);i++,bit<<=1) { if (left&bit) { xkbIndicatorMapWireDesc *wire; wire= (xkbIndicatorMapWireDesc *) _XkbGetReadBufferPtr(&buf, SIZEOF(xkbIndicatorMapWireDesc)); if (wire==NULL) { _XkbFreeReadBuffer(&buf); return BadAlloc; } leds->maps[i].flags= wire->flags; leds->maps[i].which_groups= wire->whichGroups; leds->maps[i].groups= wire->groups; leds->maps[i].which_mods= wire->whichMods; leds->maps[i].mods.mask= wire->mods; leds->maps[i].mods.real_mods= wire->realMods; leds->maps[i].mods.vmods= wire->virtualMods; leds->maps[i].ctrls= wire->ctrls; left&= ~bit; } } } left= _XkbFreeReadBuffer(&buf); } return Success; }
static Status _XkbReadGeomSections( XkbReadBufferPtr buf, XkbGeometryPtr geom, xkbGetGeometryReply * rep) { register int s; XkbSectionPtr section; xkbSectionWireDesc * sectionWire; Status rtrn; if (rep->nSections<1) return Success; if ((rtrn=XkbAllocGeomSections(geom,rep->nSections))!=Success) return rtrn; for (s=0;s<rep->nSections;s++) { sectionWire= (xkbSectionWireDesc *) _XkbGetReadBufferPtr(buf,SIZEOF(xkbSectionWireDesc)); if (!sectionWire) return BadLength; section= XkbAddGeomSection(geom,sectionWire->name,sectionWire->nRows, sectionWire->nDoodads, sectionWire->nOverlays); if (!section) return BadAlloc; section->top= sectionWire->top; section->left= sectionWire->left; section->width= sectionWire->width; section->height= sectionWire->height; section->angle= sectionWire->angle; section->priority= sectionWire->priority; if (sectionWire->nRows>0) { register int r; XkbRowPtr row; xkbRowWireDesc * rowWire; for (r=0;r<sectionWire->nRows;r++) { rowWire= (xkbRowWireDesc *) _XkbGetReadBufferPtr(buf,SIZEOF(xkbRowWireDesc)); if (!rowWire) return BadLength; row= XkbAddGeomRow(section,rowWire->nKeys); if (!row) return BadAlloc; row->top= rowWire->top; row->left= rowWire->left; row->vertical= rowWire->vertical; if (rowWire->nKeys>0) { register int k; XkbKeyPtr key; xkbKeyWireDesc * keyWire; for (k=0;k<rowWire->nKeys;k++) { keyWire= (xkbKeyWireDesc *) _XkbGetReadBufferPtr(buf,SIZEOF(xkbKeyWireDesc)); if (!keyWire) return BadLength; key= XkbAddGeomKey(row); if (!key) return BadAlloc; memcpy(key->name.name,keyWire->name,XkbKeyNameLength); key->gap= keyWire->gap; key->shape_ndx= keyWire->shapeNdx; key->color_ndx= keyWire->colorNdx; } } } } if (sectionWire->nDoodads>0) { register int d; for (d=0;d<sectionWire->nDoodads;d++) { if ((rtrn=_XkbReadGeomDoodad(buf,geom,section))!=Success) return rtrn; } } if (sectionWire->nOverlays>0) { register int o; for (o=0;o<sectionWire->nOverlays;o++) { if ((rtrn=_XkbReadGeomOverlay(buf,geom,section))!=Success) return rtrn; } } } return Success; }
Status _XkbReadGetCompatMapReply( Display * dpy, xkbGetCompatMapReply * rep, XkbDescPtr xkb, int * nread_rtrn) { register int i; XkbReadBufferRec buf; if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4)) return BadAlloc; if (nread_rtrn) *nread_rtrn= (int)rep->length*4; i= rep->firstSI+rep->nSI; if ((!xkb->compat)&& (XkbAllocCompatMap(xkb,XkbAllCompatMask,i)!=Success)) return BadAlloc; if (rep->nSI!=0) { XkbSymInterpretRec *syms; xkbSymInterpretWireDesc *wire; wire= (xkbSymInterpretWireDesc *)_XkbGetReadBufferPtr(&buf, rep->nSI*SIZEOF(xkbSymInterpretWireDesc)); if (wire==NULL) goto BAILOUT; syms= &xkb->compat->sym_interpret[rep->firstSI]; for (i=0;i<rep->nSI;i++,syms++,wire++) { syms->sym= wire->sym; syms->mods= wire->mods; syms->match= wire->match; syms->virtual_mod= wire->virtualMod; syms->flags= wire->flags; syms->act= *((XkbAnyAction *)&wire->act); } xkb->compat->num_si+= rep->nSI; } if (rep->groups&XkbAllGroupsMask) { register unsigned bit,nGroups; xkbModsWireDesc * wire; for (i=0,nGroups=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) { if (rep->groups&bit) nGroups++; } wire= (xkbModsWireDesc *)_XkbGetReadBufferPtr(&buf, nGroups*SIZEOF(xkbModsWireDesc)); if (wire==NULL) goto BAILOUT; for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) { if ((rep->groups&bit)==0) continue; xkb->compat->groups[i].mask= wire->mask; xkb->compat->groups[i].real_mods= wire->realMods; xkb->compat->groups[i].vmods= wire->virtualMods; wire++; } } i= _XkbFreeReadBuffer(&buf); if (i) fprintf(stderr,"CompatMapReply! Bad length (%d extra bytes)\n",i); if (i || buf.error) return BadLength; return Success; BAILOUT: _XkbFreeReadBuffer(&buf); return BadLength; }