Signed-off-by: Ran Benita <ran234@gmail.com>
#define UNCONSTIFY(const_ptr) ((void *) (uintptr_t) (const_ptr))
#define uDupString(s) ((s) ? strdup(s) : NULL)
#define UNCONSTIFY(const_ptr) ((void *) (uintptr_t) (const_ptr))
#define uDupString(s) ((s) ? strdup(s) : NULL)
-#define uStringText(s) ((s) == NULL ? "<NullString>" : (s))
#define uStrCasePrefix(s1, s2) (strncasecmp((s1), (s2), strlen(s1)) == 0)
/* Compiler Attributes */
#define uStrCasePrefix(s1, s2) (strncasecmp((s1), (s2), strlen(s1)) == 0)
/* Compiler Attributes */
/***====================================================================***/
static inline bool
/***====================================================================***/
static inline bool
-ReportMismatch(unsigned action, unsigned field, const char *type)
+ReportMismatch(struct xkb_keymap *keymap, unsigned action, unsigned field,
+ const char *type)
- ERROR("Value of %s field must be of type %s\n", fieldText(field), type);
- ACTION("Action %s definition ignored\n", XkbcActionTypeText(action));
+ log_err(keymap->ctx,
+ "Value of %s field must be of type %s; "
+ "Action %s definition ignored\n",
+ fieldText(field), type, XkbcActionTypeText(action));
return false;
}
static inline bool
return false;
}
static inline bool
-ReportIllegal(unsigned action, unsigned field)
+ReportIllegal(struct xkb_keymap *keymap, unsigned action, unsigned field)
- ERROR("Field %s is not defined for an action of type %s\n",
- fieldText(field), XkbcActionTypeText(action));
- ACTION("Action definition ignored\n");
+ log_err(keymap->ctx,
+ "Field %s is not defined for an action of type %s; "
+ "Action definition ignored\n",
+ fieldText(field), XkbcActionTypeText(action));
return false;
}
static inline bool
return false;
}
static inline bool
-ReportActionNotArray(unsigned action, unsigned field)
+ReportActionNotArray(struct xkb_keymap *keymap, unsigned action,
+ unsigned field)
- ERROR("The %s field in the %s action is not an array\n",
- fieldText(field), XkbcActionTypeText(action));
- ACTION("Action definition ignored\n");
+ log_err(keymap->ctx,
+ "The %s field in the %s action is not an array; "
+ "Action definition ignored\n",
+ fieldText(field), XkbcActionTypeText(action));
return false;
}
static inline bool
return false;
}
static inline bool
-ReportNotFound(unsigned action, unsigned field, const char *what,
- const char *bad)
+ReportNotFound(struct xkb_keymap *keymap, unsigned action, unsigned field,
+ const char *what, const char *bad)
- ERROR("%s named %s not found\n", what, bad);
- ACTION("Ignoring the %s field of an %s action\n", fieldText(field),
- XkbcActionTypeText(action));
+ log_err(keymap->ctx,
+ "%s named %s not found; "
+ "Ignoring the %s field of an %s action\n",
+ what, bad, fieldText(field), XkbcActionTypeText(action));
return false;
}
static bool
HandleNoAction(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
return false;
}
static bool
HandleNoAction(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
else
return false; /* WSGO! */
if (!ExprResolveBoolean(keymap->ctx, value, &result))
else
return false; /* WSGO! */
if (!ExprResolveBoolean(keymap->ctx, value, &result))
- return ReportMismatch(action, field, "boolean");
+ return ReportMismatch(keymap, action, field, "boolean");
if (result.uval)
*flags_inout |= tmp;
else
if (result.uval)
*flags_inout |= tmp;
else
}
}
if (!ExprResolveVModMask(value, &rtrn, keymap))
}
}
if (!ExprResolveVModMask(value, &rtrn, keymap))
- return ReportMismatch(action, F_Modifiers, "modifier mask");
+ return ReportMismatch(keymap, action, F_Modifiers, "modifier mask");
*mods_rtrn = rtrn.uval;
*flags_inout &= ~XkbSA_UseModMapMods;
return true;
*mods_rtrn = rtrn.uval;
*flags_inout &= ~XkbSA_UseModMapMods;
return true;
case F_ClearLocks:
case F_LatchToLock:
case F_Modifiers:
case F_ClearLocks:
case F_LatchToLock:
case F_Modifiers:
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
act = (struct xkb_mod_action *) action;
if ((array_ndx != NULL) && (field == F_Modifiers))
act = (struct xkb_mod_action *) action;
if ((array_ndx != NULL) && (field == F_Modifiers))
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
switch (field) {
case F_Modifiers:
t1 = act->flags;
switch (field) {
case F_Modifiers:
t1 = act->flags;
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
}
if (!ExprResolveGroup(keymap->ctx, spec, &rtrn))
}
if (!ExprResolveGroup(keymap->ctx, spec, &rtrn))
- return ReportMismatch(action, F_Group, "integer (range 1..8)");
+ return ReportMismatch(keymap, action, F_Group,
+ "integer (range 1..8)");
if (value->op == OpNegate)
*grp_rtrn = -rtrn.ival;
else if (value->op == OpUnaryPlus)
if (value->op == OpNegate)
*grp_rtrn = -rtrn.ival;
else if (value->op == OpUnaryPlus)
case F_ClearLocks:
case F_LatchToLock:
case F_Group:
case F_ClearLocks:
case F_LatchToLock:
case F_Group:
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
act = (struct xkb_group_action *) action;
if ((array_ndx != NULL) && (field == F_Group))
act = (struct xkb_group_action *) action;
if ((array_ndx != NULL) && (field == F_Group))
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (field == F_Group) {
t1 = act->flags;
if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
if (field == F_Group) {
t1 = act->flags;
if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
act = (struct xkb_pointer_action *) action;
if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
act = (struct xkb_pointer_action *) action;
if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if ((field == F_X) || (field == F_Y)) {
if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
if ((field == F_X) || (field == F_Y)) {
if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
else
absolute = true;
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
else
absolute = true;
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field, "integer");
+ return ReportMismatch(keymap, action->type, field, "integer");
if (field == F_X) {
if (absolute)
act->flags |= XkbSA_MoveAbsoluteX;
if (field == F_X) {
if (absolute)
act->flags |= XkbSA_MoveAbsoluteX;
}
else if (field == F_Accel) {
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
}
else if (field == F_Accel) {
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field, "boolean");
+ return ReportMismatch(keymap, action->type, field, "boolean");
if (rtrn.uval)
act->flags &= ~XkbSA_NoAcceleration;
else
act->flags |= XkbSA_NoAcceleration;
}
if (rtrn.uval)
act->flags &= ~XkbSA_NoAcceleration;
else
act->flags |= XkbSA_NoAcceleration;
}
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
}
static const LookupEntry lockWhich[] = {
}
static const LookupEntry lockWhich[] = {
act = (struct xkb_pointer_button_action *) action;
if (field == F_Button) {
if (array_ndx != NULL)
act = (struct xkb_pointer_button_action *) action;
if (field == F_Button) {
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveButton(keymap->ctx, value, &rtrn))
if (!ExprResolveButton(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field,
+ return ReportMismatch(keymap, action->type, field,
"integer (range 1..5)");
if ((rtrn.ival < 0) || (rtrn.ival > 5)) {
"integer (range 1..5)");
if ((rtrn.ival < 0) || (rtrn.ival > 5)) {
- ERROR("Button must specify default or be in the range 1..5\n");
- ACTION("Illegal button value %d ignored\n", rtrn.ival);
+ log_err(keymap->ctx,
+ "Button must specify default or be in the range 1..5; "
+ "Illegal button value %d ignored\n", rtrn.ival);
return false;
}
act->button = rtrn.ival;
return false;
}
act->button = rtrn.ival;
}
else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect)) {
if (array_ndx != NULL)
}
else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect)) {
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
- return ReportMismatch(action->type, field, "lock or unlock");
+ return ReportMismatch(keymap, action->type, field,
+ "lock or unlock");
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
act->flags |= rtrn.ival;
return true;
}
else if (field == F_Count) {
if (array_ndx != NULL)
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
act->flags |= rtrn.ival;
return true;
}
else if (field == F_Count) {
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveButton(keymap->ctx, value, &rtrn))
if (!ExprResolveButton(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field, "integer");
+ return ReportMismatch(keymap, action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
- ERROR("The count field must have a value in the range 0..255\n");
- ACTION("Illegal count %d ignored\n", rtrn.ival);
+ log_err(keymap->ctx,
+ "The count field must have a value in the range 0..255; "
+ "Illegal count %d ignored\n", rtrn.ival);
return false;
}
act->count = rtrn.ival;
return true;
}
return false;
}
act->count = rtrn.ival;
return true;
}
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
}
static const LookupEntry ptrDflts[] = {
}
static const LookupEntry ptrDflts[] = {
act = (struct xkb_pointer_default_action *) action;
if (field == F_Affect) {
if (array_ndx != NULL)
act = (struct xkb_pointer_default_action *) action;
if (field == F_Affect) {
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveEnum(keymap->ctx, value, &rtrn, ptrDflts))
if (!ExprResolveEnum(keymap->ctx, value, &rtrn, ptrDflts))
- return ReportMismatch(action->type, field, "pointer component");
+ return ReportMismatch(keymap, action->type, field,
+ "pointer component");
act->affect = rtrn.uval;
return true;
}
else if ((field == F_Button) || (field == F_Value)) {
ExprDef *btn;
if (array_ndx != NULL)
act->affect = rtrn.uval;
return true;
}
else if ((field == F_Button) || (field == F_Value)) {
ExprDef *btn;
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
act->flags &= ~XkbSA_DfltBtnAbsolute;
btn = value->value.child;
if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
act->flags &= ~XkbSA_DfltBtnAbsolute;
btn = value->value.child;
}
if (!ExprResolveButton(keymap->ctx, btn, &rtrn))
}
if (!ExprResolveButton(keymap->ctx, btn, &rtrn))
- return ReportMismatch(action->type, field,
+ return ReportMismatch(keymap, action->type, field,
"integer (range 1..5)");
if ((rtrn.ival < 0) || (rtrn.ival > 5)) {
"integer (range 1..5)");
if ((rtrn.ival < 0) || (rtrn.ival > 5)) {
- ERROR("New default button value must be in the range 1..5\n");
- ACTION("Illegal default button value %d ignored\n", rtrn.ival);
+ log_err(keymap->ctx,
+ "New default button value must be in the range 1..5; "
+ "Illegal default button value %d ignored\n", rtrn.ival);
return false;
}
if (rtrn.ival == 0) {
return false;
}
if (rtrn.ival == 0) {
- ERROR("Cannot set default pointer button to \"default\"\n");
- ACTION("Illegal default button setting ignored\n");
+ log_err(keymap->ctx,
+ "Cannot set default pointer button to \"default\"; "
+ "Illegal default button setting ignored\n");
return false;
}
if (value->op == OpNegate)
return false;
}
if (value->op == OpNegate)
act->value = rtrn.ival;
return true;
}
act->value = rtrn.ival;
return true;
}
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
}
static const LookupEntry isoNames[] = {
}
static const LookupEntry isoNames[] = {
switch (field) {
case F_Modifiers:
if (array_ndx != NULL)
switch (field) {
case F_Modifiers:
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
flags = act->flags;
if (CheckModifierField(keymap, action->type, value, &flags, &mods)) {
act->flags = flags & (~XkbSA_ISODfltIsGroup);
flags = act->flags;
if (CheckModifierField(keymap, action->type, value, &flags, &mods)) {
act->flags = flags & (~XkbSA_ISODfltIsGroup);
case F_Group:
if (array_ndx != NULL)
case F_Group:
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
flags = act->flags;
if (CheckGroupField(keymap, action->type, value, &flags, &group)) {
act->flags = flags | XkbSA_ISODfltIsGroup;
flags = act->flags;
if (CheckGroupField(keymap, action->type, value, &flags, &group)) {
act->flags = flags | XkbSA_ISODfltIsGroup;
case F_Affect:
if (array_ndx != NULL)
case F_Affect:
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveMask(keymap->ctx, value, &rtrn, isoNames))
if (!ExprResolveMask(keymap->ctx, value, &rtrn, isoNames))
- return ReportMismatch(action->type, field, "keyboard component");
+ return ReportMismatch(keymap, action->type, field,
+ "keyboard component");
act->affect = (~rtrn.uval) & XkbSA_ISOAffectMask;
return true;
}
act->affect = (~rtrn.uval) & XkbSA_ISOAffectMask;
return true;
}
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
if (field == F_Screen) {
ExprDef *scrn;
if (array_ndx != NULL)
if (field == F_Screen) {
ExprDef *scrn;
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
act->flags &= ~XkbSA_SwitchAbsolute;
scrn = value->value.child;
if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
act->flags &= ~XkbSA_SwitchAbsolute;
scrn = value->value.child;
}
if (!ExprResolveInteger(keymap->ctx, scrn, &rtrn))
}
if (!ExprResolveInteger(keymap->ctx, scrn, &rtrn))
- return ReportMismatch(action->type, field, "integer (0..255)");
+ return ReportMismatch(keymap, action->type, field,
+ "integer (0..255)");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
- ERROR("Screen index must be in the range 1..255\n");
- ACTION("Illegal screen value %d ignored\n", rtrn.ival);
+ log_err(keymap->ctx,
+ "Screen index must be in the range 1..255; "
+ "Illegal screen value %d ignored\n", rtrn.ival);
return false;
}
if (value->op == OpNegate)
return false;
}
if (value->op == OpNegate)
}
else if (field == F_Same) {
if (array_ndx != NULL)
}
else if (field == F_Same) {
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field, "boolean");
+ return ReportMismatch(keymap, action->type, field, "boolean");
if (rtrn.uval)
act->flags &= ~XkbSA_SwitchApplication;
else
act->flags |= XkbSA_SwitchApplication;
return true;
}
if (rtrn.uval)
act->flags &= ~XkbSA_SwitchApplication;
else
act->flags |= XkbSA_SwitchApplication;
return true;
}
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
}
const LookupEntry ctrlNames[] = {
}
const LookupEntry ctrlNames[] = {
act = (struct xkb_controls_action *) action;
if (field == F_Controls) {
if (array_ndx != NULL)
act = (struct xkb_controls_action *) action;
if (field == F_Controls) {
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
- return ReportMismatch(action->type, field, "controls mask");
+ return ReportMismatch(keymap, action->type, field,
+ "controls mask");
act->ctrls = rtrn.uval;
return true;
}
act->ctrls = rtrn.uval;
return true;
}
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
}
static const LookupEntry evNames[] = {
}
static const LookupEntry evNames[] = {
switch (field) {
case F_Report:
if (array_ndx != NULL)
switch (field) {
case F_Report:
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveMask(keymap->ctx, value, &rtrn, evNames))
if (!ExprResolveMask(keymap->ctx, value, &rtrn, evNames))
- return ReportMismatch(action->type, field, "key event mask");
+ return ReportMismatch(keymap, action->type, field,
+ "key event mask");
act->flags &= ~(XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
act->flags =
rtrn.uval & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
act->flags &= ~(XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
act->flags =
rtrn.uval & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
case F_GenKeyEvent:
if (array_ndx != NULL)
case F_GenKeyEvent:
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field, "boolean");
+ return ReportMismatch(keymap, action->type, field, "boolean");
if (rtrn.uval)
act->flags |= XkbSA_MessageGenKeyEvent;
else
if (rtrn.uval)
act->flags |= XkbSA_MessageGenKeyEvent;
else
case F_Data:
if (array_ndx == NULL) {
if (!ExprResolveString(keymap->ctx, value, &rtrn))
case F_Data:
if (array_ndx == NULL) {
if (!ExprResolveString(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field, "string");
+ return ReportMismatch(keymap, action->type, field, "string");
else {
int len = strlen(rtrn.str);
if ((len < 1) || (len > 6)) {
else {
int len = strlen(rtrn.str);
if ((len < 1) || (len > 6)) {
- WARN("An action message can hold only 6 bytes\n");
- ACTION("Extra %d bytes ignored\n", len - 6);
+ log_warn(keymap->ctx,
+ "An action message can hold only 6 bytes; "
+ "Extra %d bytes ignored\n", len - 6);
}
strncpy((char *) act->message, rtrn.str, 6);
}
}
strncpy((char *) act->message, rtrn.str, 6);
}
else {
unsigned ndx;
if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) {
else {
unsigned ndx;
if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) {
- ERROR("Array subscript must be integer\n");
- ACTION("Illegal subscript ignored\n");
+ log_err(keymap->ctx,
+ "Array subscript must be integer; "
+ "Illegal subscript ignored\n");
return false;
}
ndx = rtrn.uval;
if (ndx > 5) {
return false;
}
ndx = rtrn.uval;
if (ndx > 5) {
- ERROR("An action message is at most 6 bytes long\n");
- ACTION("Attempt to use data[%d] ignored\n", ndx);
+ log_err(keymap->ctx,
+ "An action message is at most 6 bytes long; "
+ "Attempt to use data[%d] ignored\n", ndx);
return false;
}
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return false;
}
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field, "integer");
+ return ReportMismatch(keymap, action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
- ERROR("Message data must be in the range 0..255\n");
- ACTION("Illegal datum %d ignored\n", rtrn.ival);
+ log_err(keymap->ctx,
+ "Message data must be in the range 0..255; "
+ "Illegal datum %d ignored\n", rtrn.ival);
return false;
}
act->message[ndx] = rtrn.uval;
}
return true;
}
return false;
}
act->message[ndx] = rtrn.uval;
}
return true;
}
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
unsigned long tmp;
if (array_ndx != NULL)
unsigned long tmp;
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
act = (struct xkb_redirect_key_action *) action;
switch (field) {
case F_Keycode:
if (!ExprResolveKeyName(keymap->ctx, value, &rtrn))
act = (struct xkb_redirect_key_action *) action;
switch (field) {
case F_Keycode:
if (!ExprResolveKeyName(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field, "key name");
+ return ReportMismatch(keymap, action->type, field, "key name");
tmp = KeyNameToLong(rtrn.name);
key = FindNamedKey(keymap, tmp, true, CreateKeyNames(keymap), 0);
if (!key)
tmp = KeyNameToLong(rtrn.name);
key = FindNamedKey(keymap, tmp, true, CreateKeyNames(keymap), 0);
if (!key)
- return ReportNotFound(action->type, field, "Key",
+ return ReportNotFound(keymap, action->type, field, "Key",
XkbcKeyNameText(rtrn.name));
act->new_kc = XkbKeyGetKeycode(keymap, key);
return true;
XkbcKeyNameText(rtrn.name));
act->new_kc = XkbKeyGetKeycode(keymap, key);
return true;
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
act = (struct xkb_device_button_action *) action;
if (field == F_Button) {
if (array_ndx != NULL)
act = (struct xkb_device_button_action *) action;
if (field == F_Button) {
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field,
+ return ReportMismatch(keymap, action->type, field,
"integer (range 1..255)");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
"integer (range 1..255)");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
- ERROR("Button must specify default or be in the range 1..255\n");
- ACTION("Illegal button value %d ignored\n", rtrn.ival);
+ log_err(keymap->ctx,
+ "Button must specify default or be in the range 1..255; "
+ "Illegal button value %d ignored\n", rtrn.ival);
return false;
}
act->button = rtrn.ival;
return false;
}
act->button = rtrn.ival;
}
else if ((action->type == XkbSA_LockDeviceBtn) && (field == F_Affect)) {
if (array_ndx != NULL)
}
else if ((action->type == XkbSA_LockDeviceBtn) && (field == F_Affect)) {
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
- return ReportMismatch(action->type, field, "lock or unlock");
+ return ReportMismatch(keymap, action->type, field,
+ "lock or unlock");
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
act->flags |= rtrn.ival;
return true;
}
else if (field == F_Count) {
if (array_ndx != NULL)
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
act->flags |= rtrn.ival;
return true;
}
else if (field == F_Count) {
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveButton(keymap->ctx, value, &rtrn))
if (!ExprResolveButton(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field, "integer");
+ return ReportMismatch(keymap, action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
- ERROR("The count field must have a value in the range 0..255\n");
- ACTION("Illegal count %d ignored\n", rtrn.ival);
+ log_err(keymap->ctx,
+ "The count field must have a value in the range 0..255; "
+ "Illegal count %d ignored\n", rtrn.ival);
return false;
}
act->count = rtrn.ival;
return false;
}
act->count = rtrn.ival;
}
else if (field == F_Device) {
if (array_ndx != NULL)
}
else if (field == F_Device) {
if (array_ndx != NULL)
- return ReportActionNotArray(action->type, field);
+ return ReportActionNotArray(keymap, action->type, field);
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field,
+ return ReportMismatch(keymap, action->type, field,
"integer (range 1..255)");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
"integer (range 1..255)");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
- ERROR("Device must specify default or be in the range 1..255\n");
- ACTION("Illegal device value %d ignored\n", rtrn.ival);
+ log_err(keymap->ctx,
+ "Device must specify default or be in the range 1..255; "
+ "Illegal device value %d ignored\n", rtrn.ival);
return false;
}
act->device = rtrn.ival;
return true;
}
return false;
}
act->device = rtrn.ival;
return true;
}
- return ReportIllegal(action->type, field);
+ return ReportIllegal(keymap, action->type, field);
switch (field) {
case F_Type:
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
switch (field) {
case F_Type:
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
- return ReportMismatch(PrivateAction, field, "integer");
+ return ReportMismatch(keymap, PrivateAction, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
- ERROR("Private action type must be in the range 0..255\n");
- ACTION("Illegal type %d ignored\n", rtrn.ival);
+ log_err(keymap->ctx,
+ "Private action type must be in the range 0..255; "
+ "Illegal type %d ignored\n", rtrn.ival);
return false;
}
action->type = rtrn.uval;
return false;
}
action->type = rtrn.uval;
case F_Data:
if (array_ndx == NULL) {
if (!ExprResolveString(keymap->ctx, value, &rtrn))
case F_Data:
if (array_ndx == NULL) {
if (!ExprResolveString(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field, "string");
+ return ReportMismatch(keymap, action->type, field, "string");
else {
int len = strlen(rtrn.str);
if ((len < 1) || (len > 7)) {
else {
int len = strlen(rtrn.str);
if ((len < 1) || (len > 7)) {
- WARN("A private action has 7 data bytes\n");
- ACTION("Extra %d bytes ignored\n", len - 6);
+ log_warn(keymap->ctx,
+ "A private action has 7 data bytes; "
+ "Extra %d bytes ignored\n", len - 6);
return false;
}
strncpy((char *) action->data, rtrn.str, sizeof action->data);
return false;
}
strncpy((char *) action->data, rtrn.str, sizeof action->data);
else {
unsigned ndx;
if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) {
else {
unsigned ndx;
if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) {
- ERROR("Array subscript must be integer\n");
- ACTION("Illegal subscript ignored\n");
+ log_err(keymap->ctx,
+ "Array subscript must be integer; "
+ "Illegal subscript ignored\n");
return false;
}
ndx = rtrn.uval;
if (ndx >= sizeof action->data) {
return false;
}
ndx = rtrn.uval;
if (ndx >= sizeof action->data) {
- ERROR("The data for a private action is 18 bytes long\n");
- ACTION("Attempt to use data[%d] ignored\n", ndx);
+ log_err(keymap->ctx,
+ "The data for a private action is 18 bytes long; "
+ "Attempt to use data[%d] ignored\n", ndx);
return false;
}
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return false;
}
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
- return ReportMismatch(action->type, field, "integer");
+ return ReportMismatch(keymap, action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
- ERROR("All data for a private action must be 0..255\n");
- ACTION("Illegal datum %d ignored\n", rtrn.ival);
+ log_err(keymap->ctx,
+ "All data for a private action must be 0..255; "
+ "Illegal datum %d ignored\n", rtrn.ival);
return false;
}
action->data[ndx] = rtrn.uval;
return true;
}
}
return false;
}
action->data[ndx] = rtrn.uval;
return true;
}
}
- return ReportIllegal(PrivateAction, field);
+ return ReportIllegal(keymap, PrivateAction, field);
}
typedef bool (*actionHandler)(struct xkb_keymap *keymap,
}
typedef bool (*actionHandler)(struct xkb_keymap *keymap,
ActionsInit(keymap->ctx);
if (def->op != ExprActionDecl) {
ActionsInit(keymap->ctx);
if (def->op != ExprActionDecl) {
- ERROR("Expected an action definition, found %s\n",
- exprOpText(def->op));
+ log_err(keymap->ctx, "Expected an action definition, found %s\n",
+ exprOpText(def->op));
return false;
}
str = xkb_atom_text(keymap->ctx, def->value.action.name);
if (!str) {
return false;
}
str = xkb_atom_text(keymap->ctx, def->value.action.name);
if (!str) {
- WSGO("Missing name in action definition!!\n");
+ log_wsgo(keymap->ctx, "Missing name in action definition!!\n");
return false;
}
if (!stringToAction(str, &tmp)) {
return false;
}
if (!stringToAction(str, &tmp)) {
- ERROR("Unknown action %s\n", str);
+ log_err(keymap->ctx, "Unknown action %s\n", str);
return false;
}
action->type = hndlrType = tmp;
return false;
}
action->type = hndlrType = tmp;
return false; /* internal error -- already reported */
if (elemRtrn.str != NULL) {
return false; /* internal error -- already reported */
if (elemRtrn.str != NULL) {
- ERROR("Cannot change defaults in an action definition\n");
- ACTION("Ignoring attempt to change %s.%s\n", elemRtrn.str,
- fieldRtrn.str);
+ log_err(keymap->ctx,
+ "Cannot change defaults in an action definition; "
+ "Ignoring attempt to change %s.%s\n",
+ elemRtrn.str, fieldRtrn.str);
free(elemRtrn.str);
free(fieldRtrn.str);
return false;
}
if (!stringToField(fieldRtrn.str, &fieldNdx)) {
free(elemRtrn.str);
free(fieldRtrn.str);
return false;
}
if (!stringToField(fieldRtrn.str, &fieldNdx)) {
- ERROR("Unknown field name %s\n", uStringText(fieldRtrn.str));
+ log_err(keymap->ctx, "Unknown field name %s\n", fieldRtrn.str);
free(elemRtrn.str);
free(fieldRtrn.str);
return false;
free(elemRtrn.str);
free(fieldRtrn.str);
return false;
/***====================================================================***/
int
/***====================================================================***/
int
-SetActionField(struct xkb_keymap *keymap,
- char *elem,
- char *field,
- ExprDef * array_ndx, ExprDef * value, ActionInfo ** info_rtrn)
+SetActionField(struct xkb_keymap *keymap, char *elem, char *field,
+ ExprDef *array_ndx, ExprDef *value, ActionInfo **info_rtrn)
new = malloc(sizeof(*new));
if (!new) {
new = malloc(sizeof(*new));
if (!new) {
- WSGO("Couldn't allocate space for action default\n");
+ log_wsgo(keymap->ctx, "Couldn't allocate space for action default\n");
return false;
}
if (new->action == XkbSA_NoAction) {
return false;
}
if (new->action == XkbSA_NoAction) {
- ERROR("\"%s\" is not a valid field in a NoAction action\n",
- field);
+ log_err(keymap->ctx,
+ "\"%s\" is not a valid field in a NoAction action\n",
+ field);
free(new);
return false;
}
}
if (!stringToField(field, &new->field)) {
free(new);
return false;
}
}
if (!stringToField(field, &new->field)) {
- ERROR("\"%s\" is not a legal field name\n", field);
+ log_err(keymap->ctx, "\"%s\" is not a legal field name\n", field);
free(new);
return false;
}
free(new);
return false;
}