14 #include <linux/slab.h>
15 #include <linux/kernel.h>
17 #include <linux/string.h>
19 #include <linux/ctype.h>
33 char *buf_pointer =
buf;
39 for (i = 0; i < 256; i++) {
42 if (
strcmp(
"characters", attr->
attr.name) == 0) {
43 len =
scnprintf(buf_pointer, bufsize,
"%d\t%s\n",
67 scnprintf(buf_pointer, bufsize,
"%d\t%s\n", i, cp);
73 return buf_pointer -
buf;
80 static void report_char_chartab_status(
int reset,
int received,
int used,
81 int rejected,
int do_characters)
84 "character class entries",
85 "character descriptions",
91 pr_info(
"%s reset to defaults\n", object_type[do_characters]);
92 }
else if (received) {
94 " updated %d of %d %s\n",
95 used, received, object_type[do_characters]);
97 snprintf(buf + (len - 1),
sizeof(buf) - (len - 1),
98 " with %d reject%s\n",
99 rejected, rejected > 1 ?
"s" :
"");
110 char *cp = (
char *) buf;
112 char *linefeed =
NULL;
119 unsigned long index = 0;
125 int do_characters = !
strcmp(attr->
attr.name,
"characters");
126 size_t desc_length = 0;
132 while ((cp < end) && (*cp ==
' ' || *cp ==
'\t'))
137 if ((*cp ==
'\n') ||
strchr(
"dDrR", *cp)) {
143 linefeed =
strchr(cp,
'\n');
162 while ((temp < linefeed) && (*temp ==
' ' || *temp ==
'\t'))
165 desc_length = linefeed -
temp;
183 for (i = 0; i < desc_length; i++)
185 outptr[desc_length] =
'\0';
194 if (charclass == 0) {
215 report_char_chartab_status(reset, received, used, rejected,
236 num_keys = (
int)(*cp1);
237 nstates = (
int)cp1[1];
242 for (n = 0; n <= num_keys; n++) {
243 for (i = 0; i <= nstates; i++) {
245 cp +=
sprintf(cp,
"%d,", (
int)ch);
246 *cp++ = (i < nstates) ?
SPACE :
'\n';
251 return (
int)(cp-
buf);
258 const char *buf,
size_t count)
262 char *in_buff =
NULL;
273 if (
strchr(
"dDrR", *in_buff)) {
275 pr_info(
"keymap set to default values\n");
280 if (in_buff[count - 1] ==
'\n')
281 in_buff[count - 1] =
'\0';
284 for (i = 0; i < 3; i++) {
292 i+SHIFT_TBL_SIZE+4 >=
sizeof(
key_buf)) {
294 (
int)cp1[-3], (
int)cp1[-2], (
int)cp1[-1]);
305 if (i != 0 || cp1[-1] !=
KEY_MAP_VER || cp1[-2] != 0) {
307 pr_warn(
"end %d %d %d %d\n", i,
308 (
int)cp1[-3], (
int)cp1[-2], (
int)cp1[-1]);
325 const char *buf,
size_t count)
334 if (len > 0 && len < 3) {
339 if (ch < '0' || ch >
'7') {
340 pr_warn(
"silent value '%c' not in range (0,7)\n", ch);
369 rv =
sprintf(buf,
"%s\n",
"none");
379 const char *buf,
size_t count)
382 char new_synth_name[10];
385 if (len < 2 || len > 9)
387 strncpy(new_synth_name, buf, len);
388 if (new_synth_name[len - 1] ==
'\n')
390 new_synth_name[len] =
'\0';
393 pr_warn(
"%s already in use\n", new_synth_name);
395 pr_warn(
"failed to init synth %s\n", new_synth_name);
417 bytes =
min_t(
size_t, len, 250);
439 cp +=
sprintf(cp,
"%s synthesizer driver version %s\n",
459 if (p_header ==
NULL) {
460 pr_warn(
"p_header is null, attr->attr.name is %s\n",
467 pr_warn(
"var is null, p_header->var_id is %i\n",
475 for (i = 33; i < 128; i++) {
488 const char *buf,
size_t count)
501 if (p_header ==
NULL) {
502 pr_warn(
"p_header is null, attr->attr.name is %s\n",
509 pr_warn(
"var is null, p_header->var_id is %i\n",
516 while (x && punc_buf[x - 1] ==
'\n')
522 if (*punc_buf ==
'd' || *punc_buf ==
'r')
555 rv =
sprintf(buf,
"%i\n", var->
u.
n.value);
563 for (cp = (
char *)param->
p_val; (ch = *cp); cp++) {
564 if (ch >=
' ' && ch <
'~')
567 cp1 +=
sprintf(cp1,
"\\""x%02x", ch);
578 rv =
sprintf(buf,
"Bad parameter %s, type %i\n",
592 const char *buf,
size_t count)
598 struct var_t *var_data;
608 cp =
xlate((
char *) buf);
614 if (*cp ==
'd' || *cp ==
'r' || *cp ==
'\0')
616 else if (*cp ==
'+' || *cp ==
'-')
623 var_data = param->
data;
624 pr_warn(
"value for %s out of range, expect %d to %d\n",
626 var_data->
u.
n.low, var_data->
u.
n.high);
631 if ((len >= 1) && (buf[len - 1] ==
'\n'))
633 if ((len >= 2) && (buf[0] ==
'"') && (buf[len - 1] ==
'"')) {
641 pr_warn(
"value too long for %s\n",
645 pr_warn(
"%s unknown type %d\n",
674 pr_info(
"%s reset to default value\n", attr->
attr.name);
687 char *buf_pointer =
buf;
693 for (cursor = first; cursor <= last; cursor++, index++) {
696 printed =
scnprintf(buf_pointer, bufsize,
"%d\t%s\n",
698 buf_pointer += printed;
702 return buf_pointer -
buf;
705 static void report_msg_status(
int reset,
int received,
int used,
706 int rejected,
char *groupname)
712 pr_info(
"i18n messages from group %s reset to defaults\n",
714 }
else if (received) {
716 " updated %d of %d i18n messages from group %s\n",
717 used, received, groupname);
719 snprintf(buf + (len - 1),
sizeof(buf) - (len - 1),
720 " with %d reject%s\n",
721 rejected, rejected > 1 ?
"s" :
"");
726 static ssize_t message_store_helper(
const char *buf,
size_t count,
729 char *cp = (
char *) buf;
730 char *end = cp +
count;
731 char *linefeed =
NULL;
735 size_t desc_length = 0;
736 unsigned long index = 0;
747 while ((cp < end) && (*cp ==
' ' || *cp ==
'\t'))
752 if (
strchr(
"dDrR", *cp)) {
758 linefeed =
strchr(cp,
'\n');
772 while ((temp < linefeed) && (*temp ==
' ' || *temp ==
'\t'))
775 desc_length = linefeed -
temp;
776 curmessage = firstmessage +
index;
785 if ((curmessage < firstmessage) || (curmessage > lastmessage)) {
791 msg_stored =
msg_set(curmessage, temp, desc_length);
792 if (msg_stored < 0) {
794 if (msg_stored == -
ENOMEM)
807 report_msg_status(reset, received, used, rejected, group->
name);
820 retval = message_show_helper(buf, group->
start, group->
end);
826 const char *buf,
size_t count)
832 retval = message_store_helper(buf, count, group);
896 __ATTR(chartab,
USER_RW, chars_chartab_show, chars_chartab_store);
904 __ATTR(function_names,
USER_RW, message_show, message_store);
914 static struct attribute *main_attrs[] = {
915 &keymap_attribute.
attr,
916 &silent_attribute.
attr,
917 &synth_attribute.
attr,
918 &synth_direct_attribute.
attr,
919 &version_attribute.
attr,
920 &delimiters_attribute.
attr,
921 &ex_num_attribute.
attr,
922 &punc_all_attribute.
attr,
923 &punc_most_attribute.
attr,
924 &punc_some_attribute.
attr,
925 &repeats_attribute.
attr,
926 &attrib_bleep_attribute.
attr,
927 &bell_pos_attribute.
attr,
928 &bleep_time_attribute.
attr,
929 &bleeps_attribute.
attr,
930 &cursor_time_attribute.
attr,
931 &key_echo_attribute.
attr,
932 &no_interrupt_attribute.
attr,
933 &punc_level_attribute.
attr,
934 &reading_punc_attribute.
attr,
935 &say_control_attribute.
attr,
936 &say_word_ctl_attribute.
attr,
937 &spell_delay_attribute.
attr,
941 static struct attribute *i18n_attrs[] = {
942 &announcements_attribute.
attr,
943 &characters_attribute.
attr,
944 &chartab_attribute.
attr,
945 &ctl_keys_attribute.
attr,
946 &colors_attribute.
attr,
947 &formatted_attribute.
attr,
948 &function_names_attribute.
attr,
949 &key_names_attribute.
attr,
950 &states_attribute.
attr,
969 static struct kobject *accessibility_kobj;
986 if (!accessibility_kobj) {