162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci/* Internationalization implementation. Includes definitions of English 362306a36Sopenharmony_ci * string arrays, and the i18n pointer. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <linux/slab.h> /* For kmalloc. */ 762306a36Sopenharmony_ci#include <linux/ctype.h> 862306a36Sopenharmony_ci#include <linux/module.h> 962306a36Sopenharmony_ci#include <linux/string.h> 1062306a36Sopenharmony_ci#include "speakup.h" 1162306a36Sopenharmony_ci#include "spk_priv.h" 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_cistatic char *speakup_msgs[MSG_LAST_INDEX]; 1462306a36Sopenharmony_cistatic char *speakup_default_msgs[MSG_LAST_INDEX] = { 1562306a36Sopenharmony_ci [MSG_BLANK] = "blank", 1662306a36Sopenharmony_ci [MSG_IAM_ALIVE] = "I'm aLive!", 1762306a36Sopenharmony_ci [MSG_YOU_KILLED_SPEAKUP] = "You killed speakup!", 1862306a36Sopenharmony_ci [MSG_HEY_THATS_BETTER] = "hey. That's better!", 1962306a36Sopenharmony_ci [MSG_YOU_TURNED_ME_OFF] = "You turned me off!", 2062306a36Sopenharmony_ci [MSG_PARKED] = "parked!", 2162306a36Sopenharmony_ci [MSG_UNPARKED] = "unparked!", 2262306a36Sopenharmony_ci [MSG_MARK] = "mark", 2362306a36Sopenharmony_ci [MSG_CUT] = "cut", 2462306a36Sopenharmony_ci [MSG_MARK_CLEARED] = "mark, cleared", 2562306a36Sopenharmony_ci [MSG_PASTE] = "paste", 2662306a36Sopenharmony_ci [MSG_BRIGHT] = "bright", 2762306a36Sopenharmony_ci [MSG_ON_BLINKING] = "on blinking", 2862306a36Sopenharmony_ci [MSG_OFF] = "off", 2962306a36Sopenharmony_ci [MSG_ON] = "on", 3062306a36Sopenharmony_ci [MSG_NO_WINDOW] = "no window", 3162306a36Sopenharmony_ci [MSG_CURSORING_OFF] = "cursoring off", 3262306a36Sopenharmony_ci [MSG_CURSORING_ON] = "cursoring on", 3362306a36Sopenharmony_ci [MSG_HIGHLIGHT_TRACKING] = "highlight tracking", 3462306a36Sopenharmony_ci [MSG_READ_WINDOW] = "read windo", 3562306a36Sopenharmony_ci [MSG_READ_ALL] = "read all", 3662306a36Sopenharmony_ci [MSG_EDIT_DONE] = "edit done", 3762306a36Sopenharmony_ci [MSG_WINDOW_ALREADY_SET] = "window already set, clear then reset", 3862306a36Sopenharmony_ci [MSG_END_BEFORE_START] = "error end before start", 3962306a36Sopenharmony_ci [MSG_WINDOW_CLEARED] = "window cleared", 4062306a36Sopenharmony_ci [MSG_WINDOW_SILENCED] = "window silenced", 4162306a36Sopenharmony_ci [MSG_WINDOW_SILENCE_DISABLED] = "window silence disabled", 4262306a36Sopenharmony_ci [MSG_ERROR] = "error", 4362306a36Sopenharmony_ci [MSG_GOTO_CANCELED] = "goto canceled", 4462306a36Sopenharmony_ci [MSG_GOTO] = "go to?", 4562306a36Sopenharmony_ci [MSG_LEAVING_HELP] = "leaving help", 4662306a36Sopenharmony_ci [MSG_IS_UNASSIGNED] = "is unassigned", 4762306a36Sopenharmony_ci [MSG_HELP_INFO] = 4862306a36Sopenharmony_ci "press space to exit, up or down to scroll, or a letter to go to a command", 4962306a36Sopenharmony_ci [MSG_EDGE_TOP] = "top,", 5062306a36Sopenharmony_ci [MSG_EDGE_BOTTOM] = "bottom,", 5162306a36Sopenharmony_ci [MSG_EDGE_LEFT] = "left,", 5262306a36Sopenharmony_ci [MSG_EDGE_RIGHT] = "right,", 5362306a36Sopenharmony_ci [MSG_NUMBER] = "number", 5462306a36Sopenharmony_ci [MSG_SPACE] = "space", 5562306a36Sopenharmony_ci [MSG_START] = "start", 5662306a36Sopenharmony_ci [MSG_END] = "end", 5762306a36Sopenharmony_ci [MSG_CTRL] = "control-", 5862306a36Sopenharmony_ci [MSG_DISJUNCTION] = "or", 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci/* Messages with embedded format specifiers. */ 6162306a36Sopenharmony_ci [MSG_POS_INFO] = "line %ld, col %ld, t t y %d", 6262306a36Sopenharmony_ci [MSG_CHAR_INFO] = "hex %02x, decimal %d", 6362306a36Sopenharmony_ci [MSG_REPEAT_DESC] = "times %d .", 6462306a36Sopenharmony_ci [MSG_REPEAT_DESC2] = "repeated %d .", 6562306a36Sopenharmony_ci [MSG_WINDOW_LINE] = "window is line %d", 6662306a36Sopenharmony_ci [MSG_WINDOW_BOUNDARY] = "%s at line %d, column %d", 6762306a36Sopenharmony_ci [MSG_EDIT_PROMPT] = "edit %s, press space when done", 6862306a36Sopenharmony_ci [MSG_NO_COMMAND] = "no commands for %c", 6962306a36Sopenharmony_ci [MSG_KEYDESC] = "is %s", 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci /* Control keys. */ 7262306a36Sopenharmony_ci /* Most of these duplicate the entries in state names. */ 7362306a36Sopenharmony_ci [MSG_CTL_SHIFT] = "shift", 7462306a36Sopenharmony_ci [MSG_CTL_ALTGR] = "altgr", 7562306a36Sopenharmony_ci [MSG_CTL_CONTROL] = "control", 7662306a36Sopenharmony_ci [MSG_CTL_ALT] = "alt", 7762306a36Sopenharmony_ci [MSG_CTL_LSHIFT] = "l shift", 7862306a36Sopenharmony_ci [MSG_CTL_SPEAKUP] = "speakup", 7962306a36Sopenharmony_ci [MSG_CTL_LCONTROL] = "l control", 8062306a36Sopenharmony_ci [MSG_CTL_RCONTROL] = "r control", 8162306a36Sopenharmony_ci [MSG_CTL_CAPSSHIFT] = "caps shift", 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci /* Color names. */ 8462306a36Sopenharmony_ci [MSG_COLOR_BLACK] = "black", 8562306a36Sopenharmony_ci [MSG_COLOR_BLUE] = "blue", 8662306a36Sopenharmony_ci [MSG_COLOR_GREEN] = "green", 8762306a36Sopenharmony_ci [MSG_COLOR_CYAN] = "cyan", 8862306a36Sopenharmony_ci [MSG_COLOR_RED] = "red", 8962306a36Sopenharmony_ci [MSG_COLOR_MAGENTA] = "magenta", 9062306a36Sopenharmony_ci [MSG_COLOR_YELLOW] = "yellow", 9162306a36Sopenharmony_ci [MSG_COLOR_WHITE] = "white", 9262306a36Sopenharmony_ci [MSG_COLOR_GREY] = "grey", 9362306a36Sopenharmony_ci [MSG_COLOR_BRIGHTBLUE] = "bright blue", 9462306a36Sopenharmony_ci [MSG_COLOR_BRIGHTGREEN] = "bright green", 9562306a36Sopenharmony_ci [MSG_COLOR_BRIGHTCYAN] = "bright cyan", 9662306a36Sopenharmony_ci [MSG_COLOR_BRIGHTRED] = "bright red", 9762306a36Sopenharmony_ci [MSG_COLOR_BRIGHTMAGENTA] = "bright magenta", 9862306a36Sopenharmony_ci [MSG_COLOR_BRIGHTYELLOW] = "bright yellow", 9962306a36Sopenharmony_ci [MSG_COLOR_BRIGHTWHITE] = "bright white", 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci /* Names of key states. */ 10262306a36Sopenharmony_ci [MSG_STATE_DOUBLE] = "double", 10362306a36Sopenharmony_ci [MSG_STATE_SPEAKUP] = "speakup", 10462306a36Sopenharmony_ci [MSG_STATE_ALT] = "alt", 10562306a36Sopenharmony_ci [MSG_STATE_CONTROL] = "ctrl", 10662306a36Sopenharmony_ci [MSG_STATE_ALTGR] = "altgr", 10762306a36Sopenharmony_ci [MSG_STATE_SHIFT] = "shift", 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci /* Key names. */ 11062306a36Sopenharmony_ci [MSG_KEYNAME_ESC] = "escape", 11162306a36Sopenharmony_ci [MSG_KEYNAME_1] = "1", 11262306a36Sopenharmony_ci [MSG_KEYNAME_2] = "2", 11362306a36Sopenharmony_ci [MSG_KEYNAME_3] = "3", 11462306a36Sopenharmony_ci [MSG_KEYNAME_4] = "4", 11562306a36Sopenharmony_ci [MSG_KEYNAME_5] = "5", 11662306a36Sopenharmony_ci [MSG_KEYNAME_6] = "6", 11762306a36Sopenharmony_ci [MSG_KEYNAME_7] = "7", 11862306a36Sopenharmony_ci [MSG_KEYNAME_8] = "8", 11962306a36Sopenharmony_ci [MSG_KEYNAME_9] = "9", 12062306a36Sopenharmony_ci [MSG_KEYNAME_0] = "0", 12162306a36Sopenharmony_ci [MSG_KEYNAME_DASH] = "minus", 12262306a36Sopenharmony_ci [MSG_KEYNAME_EQUAL] = "equal", 12362306a36Sopenharmony_ci [MSG_KEYNAME_BS] = "back space", 12462306a36Sopenharmony_ci [MSG_KEYNAME_TAB] = "tab", 12562306a36Sopenharmony_ci [MSG_KEYNAME_Q] = "q", 12662306a36Sopenharmony_ci [MSG_KEYNAME_W] = "w", 12762306a36Sopenharmony_ci [MSG_KEYNAME_E] = "e", 12862306a36Sopenharmony_ci [MSG_KEYNAME_R] = "r", 12962306a36Sopenharmony_ci [MSG_KEYNAME_T] = "t", 13062306a36Sopenharmony_ci [MSG_KEYNAME_Y] = "y", 13162306a36Sopenharmony_ci [MSG_KEYNAME_U] = "u", 13262306a36Sopenharmony_ci [MSG_KEYNAME_I] = "i", 13362306a36Sopenharmony_ci [MSG_KEYNAME_O] = "o", 13462306a36Sopenharmony_ci [MSG_KEYNAME_P] = "p", 13562306a36Sopenharmony_ci [MSG_KEYNAME_LEFTBRACE] = "left brace", 13662306a36Sopenharmony_ci [MSG_KEYNAME_RIGHTBRACE] = "right brace", 13762306a36Sopenharmony_ci [MSG_KEYNAME_ENTER] = "enter", 13862306a36Sopenharmony_ci [MSG_KEYNAME_LEFTCTRL] = "left control", 13962306a36Sopenharmony_ci [MSG_KEYNAME_A] = "a", 14062306a36Sopenharmony_ci [MSG_KEYNAME_S] = "s", 14162306a36Sopenharmony_ci [MSG_KEYNAME_D] = "d", 14262306a36Sopenharmony_ci [MSG_KEYNAME_F] = "f", 14362306a36Sopenharmony_ci [MSG_KEYNAME_G] = "g", 14462306a36Sopenharmony_ci [MSG_KEYNAME_H] = "h", 14562306a36Sopenharmony_ci [MSG_KEYNAME_J] = "j", 14662306a36Sopenharmony_ci [MSG_KEYNAME_K] = "k", 14762306a36Sopenharmony_ci [MSG_KEYNAME_L] = "l", 14862306a36Sopenharmony_ci [MSG_KEYNAME_SEMICOLON] = "semicolon", 14962306a36Sopenharmony_ci [MSG_KEYNAME_SINGLEQUOTE] = "apostrophe", 15062306a36Sopenharmony_ci [MSG_KEYNAME_GRAVE] = "accent", 15162306a36Sopenharmony_ci [MSG_KEYNAME_LEFTSHFT] = "left shift", 15262306a36Sopenharmony_ci [MSG_KEYNAME_BACKSLASH] = "back slash", 15362306a36Sopenharmony_ci [MSG_KEYNAME_Z] = "z", 15462306a36Sopenharmony_ci [MSG_KEYNAME_X] = "x", 15562306a36Sopenharmony_ci [MSG_KEYNAME_C] = "c", 15662306a36Sopenharmony_ci [MSG_KEYNAME_V] = "v", 15762306a36Sopenharmony_ci [MSG_KEYNAME_B] = "b", 15862306a36Sopenharmony_ci [MSG_KEYNAME_N] = "n", 15962306a36Sopenharmony_ci [MSG_KEYNAME_M] = "m", 16062306a36Sopenharmony_ci [MSG_KEYNAME_COMMA] = "comma", 16162306a36Sopenharmony_ci [MSG_KEYNAME_DOT] = "dot", 16262306a36Sopenharmony_ci [MSG_KEYNAME_SLASH] = "slash", 16362306a36Sopenharmony_ci [MSG_KEYNAME_RIGHTSHFT] = "right shift", 16462306a36Sopenharmony_ci [MSG_KEYNAME_KPSTAR] = "keypad asterisk", 16562306a36Sopenharmony_ci [MSG_KEYNAME_LEFTALT] = "left alt", 16662306a36Sopenharmony_ci [MSG_KEYNAME_SPACE] = "space", 16762306a36Sopenharmony_ci [MSG_KEYNAME_CAPSLOCK] = "caps lock", 16862306a36Sopenharmony_ci [MSG_KEYNAME_F1] = "f1", 16962306a36Sopenharmony_ci [MSG_KEYNAME_F2] = "f2", 17062306a36Sopenharmony_ci [MSG_KEYNAME_F3] = "f3", 17162306a36Sopenharmony_ci [MSG_KEYNAME_F4] = "f4", 17262306a36Sopenharmony_ci [MSG_KEYNAME_F5] = "f5", 17362306a36Sopenharmony_ci [MSG_KEYNAME_F6] = "f6", 17462306a36Sopenharmony_ci [MSG_KEYNAME_F7] = "f7", 17562306a36Sopenharmony_ci [MSG_KEYNAME_F8] = "f8", 17662306a36Sopenharmony_ci [MSG_KEYNAME_F9] = "f9", 17762306a36Sopenharmony_ci [MSG_KEYNAME_F10] = "f10", 17862306a36Sopenharmony_ci [MSG_KEYNAME_NUMLOCK] = "num lock", 17962306a36Sopenharmony_ci [MSG_KEYNAME_SCROLLLOCK] = "scroll lock", 18062306a36Sopenharmony_ci [MSG_KEYNAME_KP7] = "keypad 7", 18162306a36Sopenharmony_ci [MSG_KEYNAME_KP8] = "keypad 8", 18262306a36Sopenharmony_ci [MSG_KEYNAME_KP9] = "keypad 9", 18362306a36Sopenharmony_ci [MSG_KEYNAME_KPMINUS] = "keypad minus", 18462306a36Sopenharmony_ci [MSG_KEYNAME_KP4] = "keypad 4", 18562306a36Sopenharmony_ci [MSG_KEYNAME_KP5] = "keypad 5", 18662306a36Sopenharmony_ci [MSG_KEYNAME_KP6] = "keypad 6", 18762306a36Sopenharmony_ci [MSG_KEYNAME_KPPLUS] = "keypad plus", 18862306a36Sopenharmony_ci [MSG_KEYNAME_KP1] = "keypad 1", 18962306a36Sopenharmony_ci [MSG_KEYNAME_KP2] = "keypad 2", 19062306a36Sopenharmony_ci [MSG_KEYNAME_KP3] = "keypad 3", 19162306a36Sopenharmony_ci [MSG_KEYNAME_KP0] = "keypad 0", 19262306a36Sopenharmony_ci [MSG_KEYNAME_KPDOT] = "keypad dot", 19362306a36Sopenharmony_ci [MSG_KEYNAME_103RD] = "103rd", 19462306a36Sopenharmony_ci [MSG_KEYNAME_F13] = "f13", 19562306a36Sopenharmony_ci [MSG_KEYNAME_102ND] = "102nd", 19662306a36Sopenharmony_ci [MSG_KEYNAME_F11] = "f11", 19762306a36Sopenharmony_ci [MSG_KEYNAME_F12] = "f12", 19862306a36Sopenharmony_ci [MSG_KEYNAME_F14] = "f14", 19962306a36Sopenharmony_ci [MSG_KEYNAME_F15] = "f15", 20062306a36Sopenharmony_ci [MSG_KEYNAME_F16] = "f16", 20162306a36Sopenharmony_ci [MSG_KEYNAME_F17] = "f17", 20262306a36Sopenharmony_ci [MSG_KEYNAME_F18] = "f18", 20362306a36Sopenharmony_ci [MSG_KEYNAME_F19] = "f19", 20462306a36Sopenharmony_ci [MSG_KEYNAME_F20] = "f20", 20562306a36Sopenharmony_ci [MSG_KEYNAME_KPENTER] = "keypad enter", 20662306a36Sopenharmony_ci [MSG_KEYNAME_RIGHTCTRL] = "right control", 20762306a36Sopenharmony_ci [MSG_KEYNAME_KPSLASH] = "keypad slash", 20862306a36Sopenharmony_ci [MSG_KEYNAME_SYSRQ] = "sysrq", 20962306a36Sopenharmony_ci [MSG_KEYNAME_RIGHTALT] = "right alt", 21062306a36Sopenharmony_ci [MSG_KEYNAME_LF] = "line feed", 21162306a36Sopenharmony_ci [MSG_KEYNAME_HOME] = "home", 21262306a36Sopenharmony_ci [MSG_KEYNAME_UP] = "up", 21362306a36Sopenharmony_ci [MSG_KEYNAME_PGUP] = "page up", 21462306a36Sopenharmony_ci [MSG_KEYNAME_LEFT] = "left", 21562306a36Sopenharmony_ci [MSG_KEYNAME_RIGHT] = "right", 21662306a36Sopenharmony_ci [MSG_KEYNAME_END] = "end", 21762306a36Sopenharmony_ci [MSG_KEYNAME_DOWN] = "down", 21862306a36Sopenharmony_ci [MSG_KEYNAME_PGDN] = "page down", 21962306a36Sopenharmony_ci [MSG_KEYNAME_INS] = "insert", 22062306a36Sopenharmony_ci [MSG_KEYNAME_DEL] = "delete", 22162306a36Sopenharmony_ci [MSG_KEYNAME_MACRO] = "macro", 22262306a36Sopenharmony_ci [MSG_KEYNAME_MUTE] = "mute", 22362306a36Sopenharmony_ci [MSG_KEYNAME_VOLDOWN] = "volume down", 22462306a36Sopenharmony_ci [MSG_KEYNAME_VOLUP] = "volume up", 22562306a36Sopenharmony_ci [MSG_KEYNAME_POWER] = "power", 22662306a36Sopenharmony_ci [MSG_KEYNAME_KPEQUAL] = "keypad equal", 22762306a36Sopenharmony_ci [MSG_KEYNAME_KPPLUSDASH] = "keypad plusminus", 22862306a36Sopenharmony_ci [MSG_KEYNAME_PAUSE] = "pause", 22962306a36Sopenharmony_ci [MSG_KEYNAME_F21] = "f21", 23062306a36Sopenharmony_ci [MSG_KEYNAME_F22] = "f22", 23162306a36Sopenharmony_ci [MSG_KEYNAME_F23] = "f23", 23262306a36Sopenharmony_ci [MSG_KEYNAME_F24] = "f24", 23362306a36Sopenharmony_ci [MSG_KEYNAME_KPCOMMA] = "keypad comma", 23462306a36Sopenharmony_ci [MSG_KEYNAME_LEFTMETA] = "left meta", 23562306a36Sopenharmony_ci [MSG_KEYNAME_RIGHTMETA] = "right meta", 23662306a36Sopenharmony_ci [MSG_KEYNAME_COMPOSE] = "compose", 23762306a36Sopenharmony_ci [MSG_KEYNAME_STOP] = "stop", 23862306a36Sopenharmony_ci [MSG_KEYNAME_AGAIN] = "again", 23962306a36Sopenharmony_ci [MSG_KEYNAME_PROPS] = "props", 24062306a36Sopenharmony_ci [MSG_KEYNAME_UNDO] = "undo", 24162306a36Sopenharmony_ci [MSG_KEYNAME_FRONT] = "front", 24262306a36Sopenharmony_ci [MSG_KEYNAME_COPY] = "copy", 24362306a36Sopenharmony_ci [MSG_KEYNAME_OPEN] = "open", 24462306a36Sopenharmony_ci [MSG_KEYNAME_PASTE] = "paste", 24562306a36Sopenharmony_ci [MSG_KEYNAME_FIND] = "find", 24662306a36Sopenharmony_ci [MSG_KEYNAME_CUT] = "cut", 24762306a36Sopenharmony_ci [MSG_KEYNAME_HELP] = "help", 24862306a36Sopenharmony_ci [MSG_KEYNAME_MENU] = "menu", 24962306a36Sopenharmony_ci [MSG_KEYNAME_CALC] = "calc", 25062306a36Sopenharmony_ci [MSG_KEYNAME_SETUP] = "setup", 25162306a36Sopenharmony_ci [MSG_KEYNAME_SLEEP] = "sleep", 25262306a36Sopenharmony_ci [MSG_KEYNAME_WAKEUP] = "wakeup", 25362306a36Sopenharmony_ci [MSG_KEYNAME_FILE] = "file", 25462306a36Sopenharmony_ci [MSG_KEYNAME_SENDFILE] = "send file", 25562306a36Sopenharmony_ci [MSG_KEYNAME_DELFILE] = "delete file", 25662306a36Sopenharmony_ci [MSG_KEYNAME_XFER] = "transfer", 25762306a36Sopenharmony_ci [MSG_KEYNAME_PROG1] = "prog1", 25862306a36Sopenharmony_ci [MSG_KEYNAME_PROG2] = "prog2", 25962306a36Sopenharmony_ci [MSG_KEYNAME_WWW] = "www", 26062306a36Sopenharmony_ci [MSG_KEYNAME_MSDOS] = "msdos", 26162306a36Sopenharmony_ci [MSG_KEYNAME_COFFEE] = "coffee", 26262306a36Sopenharmony_ci [MSG_KEYNAME_DIRECTION] = "direction", 26362306a36Sopenharmony_ci [MSG_KEYNAME_CYCLEWINDOWS] = "cycle windows", 26462306a36Sopenharmony_ci [MSG_KEYNAME_MAIL] = "mail", 26562306a36Sopenharmony_ci [MSG_KEYNAME_BOOKMARKS] = "bookmarks", 26662306a36Sopenharmony_ci [MSG_KEYNAME_COMPUTER] = "computer", 26762306a36Sopenharmony_ci [MSG_KEYNAME_BACK] = "back", 26862306a36Sopenharmony_ci [MSG_KEYNAME_FORWARD] = "forward", 26962306a36Sopenharmony_ci [MSG_KEYNAME_CLOSECD] = "close cd", 27062306a36Sopenharmony_ci [MSG_KEYNAME_EJECTCD] = "eject cd", 27162306a36Sopenharmony_ci [MSG_KEYNAME_EJECTCLOSE] = "eject close cd", 27262306a36Sopenharmony_ci [MSG_KEYNAME_NEXTSONG] = "next song", 27362306a36Sopenharmony_ci [MSG_KEYNAME_PLAYPAUSE] = "play pause", 27462306a36Sopenharmony_ci [MSG_KEYNAME_PREVSONG] = "previous song", 27562306a36Sopenharmony_ci [MSG_KEYNAME_STOPCD] = "stop cd", 27662306a36Sopenharmony_ci [MSG_KEYNAME_RECORD] = "record", 27762306a36Sopenharmony_ci [MSG_KEYNAME_REWIND] = "rewind", 27862306a36Sopenharmony_ci [MSG_KEYNAME_PHONE] = "phone", 27962306a36Sopenharmony_ci [MSG_KEYNAME_ISO] = "iso", 28062306a36Sopenharmony_ci [MSG_KEYNAME_CONFIG] = "config", 28162306a36Sopenharmony_ci [MSG_KEYNAME_HOMEPG] = "home page", 28262306a36Sopenharmony_ci [MSG_KEYNAME_REFRESH] = "refresh", 28362306a36Sopenharmony_ci [MSG_KEYNAME_EXIT] = "exit", 28462306a36Sopenharmony_ci [MSG_KEYNAME_MOVE] = "move", 28562306a36Sopenharmony_ci [MSG_KEYNAME_EDIT] = "edit", 28662306a36Sopenharmony_ci [MSG_KEYNAME_SCROLLUP] = "scroll up", 28762306a36Sopenharmony_ci [MSG_KEYNAME_SCROLLDN] = "scroll down", 28862306a36Sopenharmony_ci [MSG_KEYNAME_KPLEFTPAR] = "keypad left paren", 28962306a36Sopenharmony_ci [MSG_KEYNAME_KPRIGHTPAR] = "keypad right paren", 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci /* Function names. */ 29262306a36Sopenharmony_ci [MSG_FUNCNAME_ATTRIB_BLEEP_DEC] = "attribute bleep decrement", 29362306a36Sopenharmony_ci [MSG_FUNCNAME_ATTRIB_BLEEP_INC] = "attribute bleep increment", 29462306a36Sopenharmony_ci [MSG_FUNCNAME_BLEEPS_DEC] = "bleeps decrement", 29562306a36Sopenharmony_ci [MSG_FUNCNAME_BLEEPS_INC] = "bleeps increment", 29662306a36Sopenharmony_ci [MSG_FUNCNAME_CHAR_FIRST] = "character, first", 29762306a36Sopenharmony_ci [MSG_FUNCNAME_CHAR_LAST] = "character, last", 29862306a36Sopenharmony_ci [MSG_FUNCNAME_CHAR_CURRENT] = "character, say current", 29962306a36Sopenharmony_ci [MSG_FUNCNAME_CHAR_HEX_AND_DEC] = "character, say hex and decimal", 30062306a36Sopenharmony_ci [MSG_FUNCNAME_CHAR_NEXT] = "character, say next", 30162306a36Sopenharmony_ci [MSG_FUNCNAME_CHAR_PHONETIC] = "character, say phonetic", 30262306a36Sopenharmony_ci [MSG_FUNCNAME_CHAR_PREVIOUS] = "character, say previous", 30362306a36Sopenharmony_ci [MSG_FUNCNAME_CURSOR_PARK] = "cursor park", 30462306a36Sopenharmony_ci [MSG_FUNCNAME_CUT] = "cut", 30562306a36Sopenharmony_ci [MSG_FUNCNAME_EDIT_DELIM] = "edit delimiters", 30662306a36Sopenharmony_ci [MSG_FUNCNAME_EDIT_EXNUM] = "edit exnum", 30762306a36Sopenharmony_ci [MSG_FUNCNAME_EDIT_MOST] = "edit most", 30862306a36Sopenharmony_ci [MSG_FUNCNAME_EDIT_REPEATS] = "edit repeats", 30962306a36Sopenharmony_ci [MSG_FUNCNAME_EDIT_SOME] = "edit some", 31062306a36Sopenharmony_ci [MSG_FUNCNAME_GOTO] = "go to", 31162306a36Sopenharmony_ci [MSG_FUNCNAME_GOTO_BOTTOM] = "go to bottom edge", 31262306a36Sopenharmony_ci [MSG_FUNCNAME_GOTO_LEFT] = "go to left edge", 31362306a36Sopenharmony_ci [MSG_FUNCNAME_GOTO_RIGHT] = "go to right edge", 31462306a36Sopenharmony_ci [MSG_FUNCNAME_GOTO_TOP] = "go to top edge", 31562306a36Sopenharmony_ci [MSG_FUNCNAME_HELP] = "help", 31662306a36Sopenharmony_ci [MSG_FUNCNAME_LINE_SAY_CURRENT] = "line, say current", 31762306a36Sopenharmony_ci [MSG_FUNCNAME_LINE_SAY_NEXT] = "line, say next", 31862306a36Sopenharmony_ci [MSG_FUNCNAME_LINE_SAY_PREVIOUS] = "line, say previous", 31962306a36Sopenharmony_ci [MSG_FUNCNAME_LINE_SAY_WITH_INDENT] = "line, say with indent", 32062306a36Sopenharmony_ci [MSG_FUNCNAME_PASTE] = "paste", 32162306a36Sopenharmony_ci [MSG_FUNCNAME_PITCH_DEC] = "pitch decrement", 32262306a36Sopenharmony_ci [MSG_FUNCNAME_PITCH_INC] = "pitch increment", 32362306a36Sopenharmony_ci [MSG_FUNCNAME_PUNC_DEC] = "punctuation decrement", 32462306a36Sopenharmony_ci [MSG_FUNCNAME_PUNC_INC] = "punctuation increment", 32562306a36Sopenharmony_ci [MSG_FUNCNAME_PUNC_LEVEL_DEC] = "punc level decrement", 32662306a36Sopenharmony_ci [MSG_FUNCNAME_PUNC_LEVEL_INC] = "punc level increment", 32762306a36Sopenharmony_ci [MSG_FUNCNAME_QUIET] = "quiet", 32862306a36Sopenharmony_ci [MSG_FUNCNAME_RATE_DEC] = "rate decrement", 32962306a36Sopenharmony_ci [MSG_FUNCNAME_RATE_INC] = "rate increment", 33062306a36Sopenharmony_ci [MSG_FUNCNAME_READING_PUNC_DEC] = "reading punctuation decrement", 33162306a36Sopenharmony_ci [MSG_FUNCNAME_READING_PUNC_INC] = "reading punctuation increment", 33262306a36Sopenharmony_ci [MSG_FUNCNAME_SAY_ATTRIBUTES] = "say attributes", 33362306a36Sopenharmony_ci [MSG_FUNCNAME_SAY_FROM_LEFT] = "say from left", 33462306a36Sopenharmony_ci [MSG_FUNCNAME_SAY_FROM_TOP] = "say from top", 33562306a36Sopenharmony_ci [MSG_FUNCNAME_SAY_POSITION] = "say position", 33662306a36Sopenharmony_ci [MSG_FUNCNAME_SAY_SCREEN] = "say screen", 33762306a36Sopenharmony_ci [MSG_FUNCNAME_SAY_TO_BOTTOM] = "say to bottom", 33862306a36Sopenharmony_ci [MSG_FUNCNAME_SAY_TO_RIGHT] = "say to right", 33962306a36Sopenharmony_ci [MSG_FUNCNAME_SPEAKUP] = "speakup", 34062306a36Sopenharmony_ci [MSG_FUNCNAME_SPEAKUP_LOCK] = "speakup lock", 34162306a36Sopenharmony_ci [MSG_FUNCNAME_SPEAKUP_OFF] = "speakup off", 34262306a36Sopenharmony_ci [MSG_FUNCNAME_SPEECH_KILL] = "speech kill", 34362306a36Sopenharmony_ci [MSG_FUNCNAME_SPELL_DELAY_DEC] = "spell delay decrement", 34462306a36Sopenharmony_ci [MSG_FUNCNAME_SPELL_DELAY_INC] = "spell delay increment", 34562306a36Sopenharmony_ci [MSG_FUNCNAME_SPELL_WORD] = "spell word", 34662306a36Sopenharmony_ci [MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phonetically", 34762306a36Sopenharmony_ci [MSG_FUNCNAME_TONE_DEC] = "tone decrement", 34862306a36Sopenharmony_ci [MSG_FUNCNAME_TONE_INC] = "tone increment", 34962306a36Sopenharmony_ci [MSG_FUNCNAME_VOICE_DEC] = "voice decrement", 35062306a36Sopenharmony_ci [MSG_FUNCNAME_VOICE_INC] = "voice increment", 35162306a36Sopenharmony_ci [MSG_FUNCNAME_VOLUME_DEC] = "volume decrement", 35262306a36Sopenharmony_ci [MSG_FUNCNAME_VOLUME_INC] = "volume increment", 35362306a36Sopenharmony_ci [MSG_FUNCNAME_WINDOW_CLEAR] = "window, clear", 35462306a36Sopenharmony_ci [MSG_FUNCNAME_WINDOW_SAY] = "window, say", 35562306a36Sopenharmony_ci [MSG_FUNCNAME_WINDOW_SET] = "window, set", 35662306a36Sopenharmony_ci [MSG_FUNCNAME_WINDOW_SILENCE] = "window, silence", 35762306a36Sopenharmony_ci [MSG_FUNCNAME_WORD_SAY_CURRENT] = "word, say current", 35862306a36Sopenharmony_ci [MSG_FUNCNAME_WORD_SAY_NEXT] = "word, say next", 35962306a36Sopenharmony_ci [MSG_FUNCNAME_WORD_SAY_PREVIOUS] = "word, say previous", 36062306a36Sopenharmony_ci}; 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_cistatic struct msg_group_t all_groups[] = { 36362306a36Sopenharmony_ci { 36462306a36Sopenharmony_ci .name = "ctl_keys", 36562306a36Sopenharmony_ci .start = MSG_CTL_START, 36662306a36Sopenharmony_ci .end = MSG_CTL_END, 36762306a36Sopenharmony_ci }, 36862306a36Sopenharmony_ci { 36962306a36Sopenharmony_ci .name = "colors", 37062306a36Sopenharmony_ci .start = MSG_COLORS_START, 37162306a36Sopenharmony_ci .end = MSG_COLORS_END, 37262306a36Sopenharmony_ci }, 37362306a36Sopenharmony_ci { 37462306a36Sopenharmony_ci .name = "formatted", 37562306a36Sopenharmony_ci .start = MSG_FORMATTED_START, 37662306a36Sopenharmony_ci .end = MSG_FORMATTED_END, 37762306a36Sopenharmony_ci }, 37862306a36Sopenharmony_ci { 37962306a36Sopenharmony_ci .name = "function_names", 38062306a36Sopenharmony_ci .start = MSG_FUNCNAMES_START, 38162306a36Sopenharmony_ci .end = MSG_FUNCNAMES_END, 38262306a36Sopenharmony_ci }, 38362306a36Sopenharmony_ci { 38462306a36Sopenharmony_ci .name = "key_names", 38562306a36Sopenharmony_ci .start = MSG_KEYNAMES_START, 38662306a36Sopenharmony_ci .end = MSG_KEYNAMES_END, 38762306a36Sopenharmony_ci }, 38862306a36Sopenharmony_ci { 38962306a36Sopenharmony_ci .name = "announcements", 39062306a36Sopenharmony_ci .start = MSG_ANNOUNCEMENTS_START, 39162306a36Sopenharmony_ci .end = MSG_ANNOUNCEMENTS_END, 39262306a36Sopenharmony_ci }, 39362306a36Sopenharmony_ci { 39462306a36Sopenharmony_ci .name = "states", 39562306a36Sopenharmony_ci .start = MSG_STATES_START, 39662306a36Sopenharmony_ci .end = MSG_STATES_END, 39762306a36Sopenharmony_ci }, 39862306a36Sopenharmony_ci}; 39962306a36Sopenharmony_ci 40062306a36Sopenharmony_cistatic const int num_groups = ARRAY_SIZE(all_groups); 40162306a36Sopenharmony_ci 40262306a36Sopenharmony_cichar *spk_msg_get(enum msg_index_t index) 40362306a36Sopenharmony_ci{ 40462306a36Sopenharmony_ci return speakup_msgs[index]; 40562306a36Sopenharmony_ci} 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ci/* 40862306a36Sopenharmony_ci * Function: next_specifier 40962306a36Sopenharmony_ci * Finds the start of the next format specifier in the argument string. 41062306a36Sopenharmony_ci * Return value: pointer to start of format 41162306a36Sopenharmony_ci * specifier, or NULL if no specifier exists. 41262306a36Sopenharmony_ci */ 41362306a36Sopenharmony_cistatic char *next_specifier(char *input) 41462306a36Sopenharmony_ci{ 41562306a36Sopenharmony_ci int found = 0; 41662306a36Sopenharmony_ci char *next_percent = input; 41762306a36Sopenharmony_ci 41862306a36Sopenharmony_ci while (next_percent && !found) { 41962306a36Sopenharmony_ci next_percent = strchr(next_percent, '%'); 42062306a36Sopenharmony_ci if (next_percent) { 42162306a36Sopenharmony_ci /* skip over doubled percent signs */ 42262306a36Sopenharmony_ci while (next_percent[0] == '%' && 42362306a36Sopenharmony_ci next_percent[1] == '%') 42462306a36Sopenharmony_ci next_percent += 2; 42562306a36Sopenharmony_ci if (*next_percent == '%') 42662306a36Sopenharmony_ci found = 1; 42762306a36Sopenharmony_ci else if (*next_percent == '\0') 42862306a36Sopenharmony_ci next_percent = NULL; 42962306a36Sopenharmony_ci } 43062306a36Sopenharmony_ci } 43162306a36Sopenharmony_ci 43262306a36Sopenharmony_ci return next_percent; 43362306a36Sopenharmony_ci} 43462306a36Sopenharmony_ci 43562306a36Sopenharmony_ci/* Skip over 0 or more flags. */ 43662306a36Sopenharmony_cistatic char *skip_flags(char *input) 43762306a36Sopenharmony_ci{ 43862306a36Sopenharmony_ci while ((*input != '\0') && strchr(" 0+-#", *input)) 43962306a36Sopenharmony_ci input++; 44062306a36Sopenharmony_ci return input; 44162306a36Sopenharmony_ci} 44262306a36Sopenharmony_ci 44362306a36Sopenharmony_ci/* Skip over width.precision, if it exists. */ 44462306a36Sopenharmony_cistatic char *skip_width(char *input) 44562306a36Sopenharmony_ci{ 44662306a36Sopenharmony_ci while (isdigit(*input)) 44762306a36Sopenharmony_ci input++; 44862306a36Sopenharmony_ci if (*input == '.') { 44962306a36Sopenharmony_ci input++; 45062306a36Sopenharmony_ci while (isdigit(*input)) 45162306a36Sopenharmony_ci input++; 45262306a36Sopenharmony_ci } 45362306a36Sopenharmony_ci return input; 45462306a36Sopenharmony_ci} 45562306a36Sopenharmony_ci 45662306a36Sopenharmony_ci/* 45762306a36Sopenharmony_ci * Skip past the end of the conversion part. 45862306a36Sopenharmony_ci * Note that this code only accepts a handful of conversion specifiers: 45962306a36Sopenharmony_ci * c d s x and ld. Not accidental; these are exactly the ones used in 46062306a36Sopenharmony_ci * the default group of formatted messages. 46162306a36Sopenharmony_ci */ 46262306a36Sopenharmony_cistatic char *skip_conversion(char *input) 46362306a36Sopenharmony_ci{ 46462306a36Sopenharmony_ci if ((input[0] == 'l') && (input[1] == 'd')) 46562306a36Sopenharmony_ci input += 2; 46662306a36Sopenharmony_ci else if ((*input != '\0') && strchr("cdsx", *input)) 46762306a36Sopenharmony_ci input++; 46862306a36Sopenharmony_ci return input; 46962306a36Sopenharmony_ci} 47062306a36Sopenharmony_ci 47162306a36Sopenharmony_ci/* 47262306a36Sopenharmony_ci * Function: find_specifier_end 47362306a36Sopenharmony_ci * Return a pointer to the end of the format specifier. 47462306a36Sopenharmony_ci */ 47562306a36Sopenharmony_cistatic char *find_specifier_end(char *input) 47662306a36Sopenharmony_ci{ 47762306a36Sopenharmony_ci input++; /* Advance over %. */ 47862306a36Sopenharmony_ci input = skip_flags(input); 47962306a36Sopenharmony_ci input = skip_width(input); 48062306a36Sopenharmony_ci input = skip_conversion(input); 48162306a36Sopenharmony_ci return input; 48262306a36Sopenharmony_ci} 48362306a36Sopenharmony_ci 48462306a36Sopenharmony_ci/* 48562306a36Sopenharmony_ci * Function: compare_specifiers 48662306a36Sopenharmony_ci * Compare the format specifiers pointed to by *input1 and *input2. 48762306a36Sopenharmony_ci * Return true if they are the same, false otherwise. 48862306a36Sopenharmony_ci * Advance *input1 and *input2 so that they point to the character following 48962306a36Sopenharmony_ci * the end of the specifier. 49062306a36Sopenharmony_ci */ 49162306a36Sopenharmony_cistatic bool compare_specifiers(char **input1, char **input2) 49262306a36Sopenharmony_ci{ 49362306a36Sopenharmony_ci bool same = false; 49462306a36Sopenharmony_ci char *end1 = find_specifier_end(*input1); 49562306a36Sopenharmony_ci char *end2 = find_specifier_end(*input2); 49662306a36Sopenharmony_ci size_t length1 = end1 - *input1; 49762306a36Sopenharmony_ci size_t length2 = end2 - *input2; 49862306a36Sopenharmony_ci 49962306a36Sopenharmony_ci if ((length1 == length2) && !memcmp(*input1, *input2, length1)) 50062306a36Sopenharmony_ci same = true; 50162306a36Sopenharmony_ci 50262306a36Sopenharmony_ci *input1 = end1; 50362306a36Sopenharmony_ci *input2 = end2; 50462306a36Sopenharmony_ci return same; 50562306a36Sopenharmony_ci} 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_ci/* 50862306a36Sopenharmony_ci * Function: fmt_validate 50962306a36Sopenharmony_ci * Check that two format strings contain the same number of format specifiers, 51062306a36Sopenharmony_ci * and that the order of specifiers is the same in both strings. 51162306a36Sopenharmony_ci * Return true if the condition holds, false if it doesn't. 51262306a36Sopenharmony_ci */ 51362306a36Sopenharmony_cistatic bool fmt_validate(char *template, char *user) 51462306a36Sopenharmony_ci{ 51562306a36Sopenharmony_ci bool valid = true; 51662306a36Sopenharmony_ci bool still_comparing = true; 51762306a36Sopenharmony_ci char *template_ptr = template; 51862306a36Sopenharmony_ci char *user_ptr = user; 51962306a36Sopenharmony_ci 52062306a36Sopenharmony_ci while (still_comparing && valid) { 52162306a36Sopenharmony_ci template_ptr = next_specifier(template_ptr); 52262306a36Sopenharmony_ci user_ptr = next_specifier(user_ptr); 52362306a36Sopenharmony_ci if (template_ptr && user_ptr) { 52462306a36Sopenharmony_ci /* Both have at least one more specifier. */ 52562306a36Sopenharmony_ci valid = compare_specifiers(&template_ptr, &user_ptr); 52662306a36Sopenharmony_ci } else { 52762306a36Sopenharmony_ci /* No more format specifiers in one or both strings. */ 52862306a36Sopenharmony_ci still_comparing = false; 52962306a36Sopenharmony_ci /* See if one has more specifiers than the other. */ 53062306a36Sopenharmony_ci if (template_ptr || user_ptr) 53162306a36Sopenharmony_ci valid = false; 53262306a36Sopenharmony_ci } 53362306a36Sopenharmony_ci } 53462306a36Sopenharmony_ci return valid; 53562306a36Sopenharmony_ci} 53662306a36Sopenharmony_ci 53762306a36Sopenharmony_ci/* 53862306a36Sopenharmony_ci * Function: msg_set 53962306a36Sopenharmony_ci * Description: Add a user-supplied message to the user_messages array. 54062306a36Sopenharmony_ci * The message text is copied to a memory area allocated with kmalloc. 54162306a36Sopenharmony_ci * If the function fails, then user_messages is untouched. 54262306a36Sopenharmony_ci * Arguments: 54362306a36Sopenharmony_ci * - index: a message number, as found in i18n.h. 54462306a36Sopenharmony_ci * - text: text of message. Not NUL-terminated. 54562306a36Sopenharmony_ci * - length: number of bytes in text. 54662306a36Sopenharmony_ci * Failure conditions: 54762306a36Sopenharmony_ci * -EINVAL - Invalid format specifiers in formatted message or illegal index. 54862306a36Sopenharmony_ci * -ENOMEM - Unable to allocate memory. 54962306a36Sopenharmony_ci */ 55062306a36Sopenharmony_cissize_t spk_msg_set(enum msg_index_t index, char *text, size_t length) 55162306a36Sopenharmony_ci{ 55262306a36Sopenharmony_ci char *newstr = NULL; 55362306a36Sopenharmony_ci unsigned long flags; 55462306a36Sopenharmony_ci 55562306a36Sopenharmony_ci if ((index < MSG_FIRST_INDEX) || (index >= MSG_LAST_INDEX)) 55662306a36Sopenharmony_ci return -EINVAL; 55762306a36Sopenharmony_ci 55862306a36Sopenharmony_ci newstr = kmemdup_nul(text, length, GFP_KERNEL); 55962306a36Sopenharmony_ci if (!newstr) 56062306a36Sopenharmony_ci return -ENOMEM; 56162306a36Sopenharmony_ci 56262306a36Sopenharmony_ci if (index >= MSG_FORMATTED_START && 56362306a36Sopenharmony_ci index <= MSG_FORMATTED_END && 56462306a36Sopenharmony_ci !fmt_validate(speakup_default_msgs[index], newstr)) { 56562306a36Sopenharmony_ci kfree(newstr); 56662306a36Sopenharmony_ci return -EINVAL; 56762306a36Sopenharmony_ci } 56862306a36Sopenharmony_ci spin_lock_irqsave(&speakup_info.spinlock, flags); 56962306a36Sopenharmony_ci if (speakup_msgs[index] != speakup_default_msgs[index]) 57062306a36Sopenharmony_ci kfree(speakup_msgs[index]); 57162306a36Sopenharmony_ci speakup_msgs[index] = newstr; 57262306a36Sopenharmony_ci spin_unlock_irqrestore(&speakup_info.spinlock, flags); 57362306a36Sopenharmony_ci return 0; 57462306a36Sopenharmony_ci} 57562306a36Sopenharmony_ci 57662306a36Sopenharmony_ci/* 57762306a36Sopenharmony_ci * Find a message group, given its name. Return a pointer to the structure 57862306a36Sopenharmony_ci * if found, or NULL otherwise. 57962306a36Sopenharmony_ci */ 58062306a36Sopenharmony_cistruct msg_group_t *spk_find_msg_group(const char *group_name) 58162306a36Sopenharmony_ci{ 58262306a36Sopenharmony_ci struct msg_group_t *group = NULL; 58362306a36Sopenharmony_ci int i; 58462306a36Sopenharmony_ci 58562306a36Sopenharmony_ci for (i = 0; i < num_groups; i++) { 58662306a36Sopenharmony_ci if (!strcmp(all_groups[i].name, group_name)) { 58762306a36Sopenharmony_ci group = &all_groups[i]; 58862306a36Sopenharmony_ci break; 58962306a36Sopenharmony_ci } 59062306a36Sopenharmony_ci } 59162306a36Sopenharmony_ci return group; 59262306a36Sopenharmony_ci} 59362306a36Sopenharmony_ci 59462306a36Sopenharmony_civoid spk_reset_msg_group(struct msg_group_t *group) 59562306a36Sopenharmony_ci{ 59662306a36Sopenharmony_ci unsigned long flags; 59762306a36Sopenharmony_ci enum msg_index_t i; 59862306a36Sopenharmony_ci 59962306a36Sopenharmony_ci spin_lock_irqsave(&speakup_info.spinlock, flags); 60062306a36Sopenharmony_ci 60162306a36Sopenharmony_ci for (i = group->start; i <= group->end; i++) { 60262306a36Sopenharmony_ci if (speakup_msgs[i] != speakup_default_msgs[i]) 60362306a36Sopenharmony_ci kfree(speakup_msgs[i]); 60462306a36Sopenharmony_ci speakup_msgs[i] = speakup_default_msgs[i]; 60562306a36Sopenharmony_ci } 60662306a36Sopenharmony_ci spin_unlock_irqrestore(&speakup_info.spinlock, flags); 60762306a36Sopenharmony_ci} 60862306a36Sopenharmony_ci 60962306a36Sopenharmony_ci/* Called at initialization time, to establish default messages. */ 61062306a36Sopenharmony_civoid spk_initialize_msgs(void) 61162306a36Sopenharmony_ci{ 61262306a36Sopenharmony_ci memcpy(speakup_msgs, speakup_default_msgs, 61362306a36Sopenharmony_ci sizeof(speakup_default_msgs)); 61462306a36Sopenharmony_ci} 61562306a36Sopenharmony_ci 61662306a36Sopenharmony_ci/* Free user-supplied strings when module is unloaded: */ 61762306a36Sopenharmony_civoid spk_free_user_msgs(void) 61862306a36Sopenharmony_ci{ 61962306a36Sopenharmony_ci enum msg_index_t index; 62062306a36Sopenharmony_ci unsigned long flags; 62162306a36Sopenharmony_ci 62262306a36Sopenharmony_ci spin_lock_irqsave(&speakup_info.spinlock, flags); 62362306a36Sopenharmony_ci for (index = MSG_FIRST_INDEX; index < MSG_LAST_INDEX; index++) { 62462306a36Sopenharmony_ci if (speakup_msgs[index] != speakup_default_msgs[index]) { 62562306a36Sopenharmony_ci kfree(speakup_msgs[index]); 62662306a36Sopenharmony_ci speakup_msgs[index] = speakup_default_msgs[index]; 62762306a36Sopenharmony_ci } 62862306a36Sopenharmony_ci } 62962306a36Sopenharmony_ci spin_unlock_irqrestore(&speakup_info.spinlock, flags); 63062306a36Sopenharmony_ci} 631