fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
+ documentation, and that the name of Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
+ Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
#include "xkbcomp.h"
+#include "xkbmisc.h"
#include "tokens.h"
#include "expr.h"
static Bool
ReportMismatch(unsigned action, unsigned field, const char *type)
{
- ERROR2("Value of %s field must be of type %s\n", fieldText(field), type);
- ACTION1("Action %s definition ignored\n", XkbActionTypeText(action));
+ ERROR("Value of %s field must be of type %s\n", fieldText(field), type);
+ ACTION("Action %s definition ignored\n", XkbcActionTypeText(action));
return False;
}
static Bool
ReportIllegal(unsigned action, unsigned field)
{
- ERROR2("Field %s is not defined for an action of type %s\n",
- fieldText(field), XkbActionTypeText(action));
+ ERROR("Field %s is not defined for an action of type %s\n",
+ fieldText(field), XkbcActionTypeText(action));
ACTION("Action definition ignored\n");
return False;
}
static Bool
ReportActionNotArray(unsigned action, unsigned field)
{
- ERROR2("The %s field in the %s action is not an array\n",
- fieldText(field), XkbActionTypeText(action));
+ ERROR("The %s field in the %s action is not an array\n",
+ fieldText(field), XkbcActionTypeText(action));
ACTION("Action definition ignored\n");
return False;
}
static Bool
ReportNotFound(unsigned action, unsigned field, const char *what, char *bad)
{
- ERROR2("%s named %s not found\n", what, bad);
- ACTION2("Ignoring the %s field of an %s action\n", fieldText(field),
- XkbActionTypeText(action));
+ ERROR("%s named %s not found\n", what, bad);
+ ACTION("Ignoring the %s field of an %s action\n", fieldText(field),
+ XkbcActionTypeText(action));
return False;
}
static Bool
HandleNoAction(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
return ReportIllegal(action->type, field);
if (value->op == ExprIdent)
{
register char *valStr;
- valStr = XkbcAtomGetString(NULL, value->value.str);
+ valStr = XkbcAtomText(value->value.str);
if (valStr && ((uStrCaseCmp(valStr, "usemodmapmods") == 0) ||
(uStrCaseCmp(valStr, "modmapmods") == 0)))
{
static Bool
HandleSetLatchMods(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
- XkbModAction *act;
+ struct xkb_mod_action *act;
unsigned rtrn;
unsigned t1, t2;
- act = (XkbModAction *) action;
+ act = (struct xkb_mod_action *) action;
if (array_ndx != NULL)
{
switch (field)
{
act->flags = t1;
act->real_mods = act->mask = (t2 & 0xff);
- t2 = (t2 >> 8) & 0xffff;
- XkbSetModActionVMods(act, t2);
+ act->vmods = (t2 >> 8) & 0xffff;
return True;
}
return False;
static Bool
HandleLockMods(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
- XkbModAction *act;
+ struct xkb_mod_action *act;
unsigned t1, t2;
- act = (XkbModAction *) action;
+ act = (struct xkb_mod_action *) action;
if ((array_ndx != NULL) && (field == F_Modifiers))
return ReportActionNotArray(action->type, field);
switch (field)
{
act->flags = t1;
act->real_mods = act->mask = (t2 & 0xff);
- t2 = (t2 >> 8) & 0xffff;
- XkbSetModActionVMods(act, t2);
+ act->vmods = (t2 >> 8) & 0xffff;
return True;
}
return False;
return ReportMismatch(action, F_Group, "integer (range 1..8)");
if ((rtrn.ival < 1) || (rtrn.ival > XkbNumKbdGroups))
{
- ERROR2("Illegal group %d (must be in the range 1..%d)\n", rtrn.ival,
+ ERROR("Illegal group %d (must be in the range 1..%d)\n", rtrn.ival,
XkbNumKbdGroups);
- ACTION1("Action %s definition ignored\n", XkbActionTypeText(action));
+ ACTION("Action %s definition ignored\n", XkbcActionTypeText(action));
return False;
}
if (value->op == OpNegate)
static Bool
HandleSetLatchGroup(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
XkbGroupAction *act;
static Bool
HandleLockGroup(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
XkbGroupAction *act;
static Bool
HandleMovePtr(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
- XkbPtrAction *act;
+ struct xkb_pointer_action *act;
Bool absolute;
- act = (XkbPtrAction *) action;
+ act = (struct xkb_pointer_action *) action;
if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
return ReportActionNotArray(action->type, field);
static Bool
HandlePtrBtn(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
- XkbPtrBtnAction *act;
+ struct xkb_pointer_button_action *act;
- act = (XkbPtrBtnAction *) action;
+ act = (struct xkb_pointer_button_action *) action;
if (field == F_Button)
{
if (array_ndx != NULL)
if ((rtrn.ival < 0) || (rtrn.ival > 5))
{
ERROR("Button must specify default or be in the range 1..5\n");
- ACTION1("Illegal button value %d ignored\n", rtrn.ival);
+ ACTION("Illegal button value %d ignored\n", rtrn.ival);
return False;
}
act->button = rtrn.ival;
if ((rtrn.ival < 0) || (rtrn.ival > 255))
{
ERROR("The count field must have a value in the range 0..255\n");
- ACTION1("Illegal count %d ignored\n", rtrn.ival);
+ ACTION("Illegal count %d ignored\n", rtrn.ival);
return False;
}
act->count = rtrn.ival;
static Bool
HandleSetPtrDflt(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
if ((rtrn.ival < 0) || (rtrn.ival > 5))
{
ERROR("New default button value must be in the range 1..5\n");
- ACTION1("Illegal default button value %d ignored\n", rtrn.ival);
+ ACTION("Illegal default button value %d ignored\n", rtrn.ival);
return False;
}
if (rtrn.ival == 0)
static Bool
HandleISOLock(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
- XkbISOAction *act;
+ struct xkb_iso_action *act;
unsigned flags, mods;
int group;
- act = (XkbISOAction *) action;
+ act = (struct xkb_iso_action *) action;
switch (field)
{
case F_Modifiers:
{
act->flags = flags & (~XkbSA_ISODfltIsGroup);
act->real_mods = mods & 0xff;
- mods = (mods >> 8) & 0xff;
- XkbSetModActionVMods(act, mods);
+ act->vmods = (mods >> 8) & 0xff;
return True;
}
return False;
if (CheckGroupField(action->type, value, &flags, &group))
{
act->flags = flags | XkbSA_ISODfltIsGroup;
- XkbSASetGroup(act, group);
+ act->group = group;
return True;
}
return False;
static Bool
HandleSwitchScreen(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
if ((rtrn.ival < 0) || (rtrn.ival > 255))
{
ERROR("Screen index must be in the range 1..255\n");
- ACTION1("Illegal screen value %d ignored\n", rtrn.ival);
+ ACTION("Illegal screen value %d ignored\n", rtrn.ival);
return False;
}
if (value->op == OpNegate)
static Bool
HandleSetLockControls(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
- XkbCtrlsAction *act;
+ struct xkb_controls_action *act;
- act = (XkbCtrlsAction *) action;
+ act = (struct xkb_controls_action *) action;
if (field == F_Controls)
{
if (array_ndx != NULL)
if (!ExprResolveMask
(value, &rtrn, SimpleLookup, (char *) ctrlNames))
return ReportMismatch(action->type, field, "controls mask");
- XkbActionSetCtrls(act, rtrn.uval);
+ act->ctrls = rtrn.uval;
return True;
}
return ReportIllegal(action->type, field);
static Bool
HandleActionMessage(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
- XkbMessageAction *act;
+ struct xkb_message_action *act;
- act = (XkbMessageAction *) action;
+ act = (struct xkb_message_action *) action;
switch (field)
{
case F_Report:
if ((len < 1) || (len > 6))
{
WARN("An action message can hold only 6 bytes\n");
- ACTION1("Extra %d bytes ignored\n", len - 6);
+ ACTION("Extra %d bytes ignored\n", len - 6);
}
strncpy((char *) act->message, rtrn.str, 6);
}
if (ndx > 5)
{
ERROR("An action message is at most 6 bytes long\n");
- ACTION1("Attempt to use data[%d] ignored\n", ndx);
+ ACTION("Attempt to use data[%d] ignored\n", ndx);
return False;
}
if (!ExprResolveInteger(value, &rtrn, NULL, NULL))
if ((rtrn.ival < 0) || (rtrn.ival > 255))
{
ERROR("Message data must be in the range 0..255\n");
- ACTION1("Illegal datum %d ignored\n", rtrn.ival);
+ ACTION("Illegal datum %d ignored\n", rtrn.ival);
return False;
}
act->message[ndx] = rtrn.uval;
static Bool
HandleRedirectKey(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
- XkbRedirectKeyAction *act;
- unsigned t1, t2, vmods, vmask;
+ struct xkb_redirect_key_action *act;
+ unsigned t1, t2;
unsigned long tmp;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
- act = (XkbRedirectKeyAction *) action;
+ act = (struct xkb_redirect_key_action *) action;
switch (field)
{
case F_Keycode:
if (!FindNamedKey(xkb, tmp, &t1, True, CreateKeyNames(xkb), 0))
{
return ReportNotFound(action->type, field, "Key",
- XkbKeyNameText(rtrn.keyName.name,
- XkbMessage));
+ XkbcKeyNameText(rtrn.keyName.name));
}
act->new_key = t1;
return True;
act->mods &= ~(t2 & 0xff);
t2 = (t2 >> 8) & 0xffff;
- vmods = XkbSARedirectVMods(act);
- vmask = XkbSARedirectVModsMask(act);
- vmask |= t2;
+ XkbSARedirectSetVModsMask(act, XkbSARedirectVModsMask(act) | t2);
if (field == F_Modifiers)
- vmods |= t2;
+ XkbSARedirectSetVMods(act, XkbSARedirectVMods(act) | t2);
else
- vmods &= ~t2;
- XkbSARedirectSetVMods(act, vmods);
- XkbSARedirectSetVModsMask(act, vmask);
+ XkbSARedirectSetVMods(act, XkbSARedirectVMods(act) & ~t2);
return True;
}
return True;
static Bool
HandleDeviceBtn(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
if ((rtrn.ival < 0) || (rtrn.ival > 255))
{
ERROR("Button must specify default or be in the range 1..255\n");
- ACTION1("Illegal button value %d ignored\n", rtrn.ival);
+ ACTION("Illegal button value %d ignored\n", rtrn.ival);
return False;
}
act->button = rtrn.ival;
if ((rtrn.ival < 0) || (rtrn.ival > 255))
{
ERROR("The count field must have a value in the range 0..255\n");
- ACTION1("Illegal count %d ignored\n", rtrn.ival);
+ ACTION("Illegal count %d ignored\n", rtrn.ival);
return False;
}
act->count = rtrn.ival;
if ((rtrn.ival < 0) || (rtrn.ival > 255))
{
ERROR("Device must specify default or be in the range 1..255\n");
- ACTION1("Illegal device value %d ignored\n", rtrn.ival);
+ ACTION("Illegal device value %d ignored\n", rtrn.ival);
return False;
}
act->device = rtrn.ival;
static Bool
HandleDeviceValuator(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
#if 0
static Bool
HandlePrivate(XkbcDescPtr xkb,
- XkbAnyAction * action,
+ struct xkb_any_action * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
if ((rtrn.ival < 0) || (rtrn.ival > 255))
{
ERROR("Private action type must be in the range 0..255\n");
- ACTION1("Illegal type %d ignored\n", rtrn.ival);
+ ACTION("Illegal type %d ignored\n", rtrn.ival);
return False;
}
action->type = rtrn.uval;
if ((len < 1) || (len > 7))
{
WARN("A private action has 7 data bytes\n");
- ACTION1("Extra %d bytes ignored\n", len - 6);
+ ACTION("Extra %d bytes ignored\n", len - 6);
return False;
}
- strncpy((char *) action->data, rtrn.str, 7);
+ strncpy((char *) action->pad, rtrn.str, XkbcAnyActionDataSize);
}
+ free(rtrn.str);
return True;
}
else
return False;
}
ndx = rtrn.uval;
- if (ndx > 6)
+ if (ndx >= XkbcAnyActionDataSize)
{
- ERROR("The data for a private action is 7 bytes long\n");
- ACTION1("Attempt to use data[%d] ignored\n", ndx);
+ ERROR("The data for a private action is 18 bytes long\n");
+ ACTION("Attempt to use data[%d] ignored\n", ndx);
return False;
}
if (!ExprResolveInteger(value, &rtrn, NULL, NULL))
if ((rtrn.ival < 0) || (rtrn.ival > 255))
{
ERROR("All data for a private action must be 0..255\n");
- ACTION1("Illegal datum %d ignored\n", rtrn.ival);
+ ACTION("Illegal datum %d ignored\n", rtrn.ival);
return False;
}
- action->data[ndx] = rtrn.uval;
+ action->pad[ndx] = rtrn.uval;
return True;
}
}
}
typedef Bool(*actionHandler) (XkbcDescPtr /* xkb */ ,
- XkbAnyAction * /* action */ ,
+ struct xkb_any_action * /* action */ ,
unsigned /* field */ ,
ExprDef * /* array_ndx */ ,
ExprDef * /* value */
/***====================================================================***/
static void
-ApplyActionFactoryDefaults(XkbAction * action)
+ApplyActionFactoryDefaults(union xkb_action * action)
{
if (action->type == XkbSA_SetPtrDflt)
{ /* increment default button */
action->dflt.affect = XkbSA_AffectDfltBtn;
action->dflt.flags = 0;
- XkbSASetPtrDfltValue(&action->dflt, 1);
+ action->dflt.value = 1;
}
else if (action->type == XkbSA_ISOLock)
{
int
HandleActionDef(ExprDef * def,
XkbcDescPtr xkb,
- XkbAnyAction * action, unsigned mergeMode, ActionInfo * info)
+ struct xkb_any_action * action, unsigned mergeMode, ActionInfo * info)
{
ExprDef *arg;
register char *str;
if (def->op != ExprActionDecl)
{
- ERROR1("Expected an action definition, found %s\n",
+ ERROR("Expected an action definition, found %s\n",
exprOpText(def->op));
return False;
}
- str = XkbcAtomGetString(NULL, def->value.action.name);
+ str = XkbcAtomText(def->value.action.name);
if (!str)
{
WSGO("Missing name in action definition!!\n");
}
if (!stringToAction(str, &tmp))
{
- ERROR1("Unknown action %s\n", str);
+ ERROR("Unknown action %s\n", str);
return False;
}
action->type = hndlrType = tmp;
if (action->type != XkbSA_NoAction)
{
- ApplyActionFactoryDefaults((XkbAction *) action);
+ ApplyActionFactoryDefaults((union xkb_action *) action);
while (info)
{
if ((info->action == XkbSA_NoAction)
if (elemRtrn.str != NULL)
{
ERROR("Cannot change defaults in an action definition\n");
- ACTION2("Ignoring attempt to change %s.%s\n", elemRtrn.str,
+ ACTION("Ignoring attempt to change %s.%s\n", elemRtrn.str,
fieldRtrn.str);
+ free(elemRtrn.str);
+ free(fieldRtrn.str);
return False;
}
if (!stringToField(fieldRtrn.str, &fieldNdx))
{
- ERROR1("Unknown field name %s\n", uStringText(fieldRtrn.str));
+ ERROR("Unknown field name %s\n", uStringText(fieldRtrn.str));
+ free(elemRtrn.str);
+ free(fieldRtrn.str);
return False;
}
+ free(elemRtrn.str);
+ free(fieldRtrn.str);
if (!(*handleAction[hndlrType])
(xkb, action, fieldNdx, arrayRtrn, value))
{
else
{
if (!stringToAction(elem, &new->action))
+ {
+ free(new);
return False;
+ }
if (new->action == XkbSA_NoAction)
{
- ERROR1("\"%s\" is not a valid field in a NoAction action\n",
+ ERROR("\"%s\" is not a valid field in a NoAction action\n",
field);
+ free(new);
return False;
}
}
if (!stringToField(field, &new->field))
{
- ERROR1("\"%s\" is not a legal field name\n", field);
+ ERROR("\"%s\" is not a legal field name\n", field);
+ free(new);
return False;
}
new->array_ndx = array_ndx;
constTrue.common.next = NULL;
constTrue.op = ExprIdent;
constTrue.type = TypeBoolean;
- constTrue.value.str = XkbcInternAtom(NULL, "true", False);
+ constTrue.value.str = XkbcInternAtom("true", False);
constFalse.common.stmtType = StmtExpr;
constFalse.common.next = NULL;
constFalse.op = ExprIdent;
constFalse.type = TypeBoolean;
- constFalse.value.str = XkbcInternAtom(NULL, "false", False);
+ constFalse.value.str = XkbcInternAtom("false", False);
actionsInitialized = 1;
}
return;