Prevent partitions from extending beyond end of container partition.
[AROS.git] / workbench / c / SetKeyboard.c
blob8f514d7b9d8df820b0ac48babff87f55ac44047d
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /******************************************************************************
11 NAME
13 SetKeyboard
15 SYNOPSIS
17 KEYMAP/A
19 LOCATION
23 FUNCTION
25 Set the keymap for the current shell.
27 INPUTS
29 KEYMAP -- the keymap to use with the current shell
31 RESULT
33 NOTES
35 To make a certain keymap be the default for all shells, use the
36 preferences input program so specify your default choice.
38 EXAMPLE
40 SetKeyboard s
42 Makes the current shell use the Swedish keymap.
44 BUGS
46 SEE ALSO
48 INTERNALS
50 HISTORY
52 ******************************************************************************/
55 #include <exec/exec.h>
56 #include <dos/dos.h>
57 #include <devices/keymap.h>
58 #include <devices/console.h>
59 #include <devices/keymap.h>
60 #include <proto/exec.h>
61 #include <proto/dos.h>
62 #include <proto/keymap.h>
63 #include <proto/kms.h>
65 #include <string.h>
66 #include <stdlib.h>
68 const TEXT version[] = "$VER: SetKeyboard 41.3 (03.03.2011)\n";
70 #define ARG_TEMPLATE "KEYMAP/A"
72 enum
74 ARG_NAME = 0,
75 NOOFARGS
78 AROS_ENTRY(__startup static ULONG, Start,
79 AROS_UFHA(char *, argstr, A0),
80 AROS_UFHA(ULONG, argsize, D0),
81 struct ExecBase *, SysBase)
83 AROS_USERFUNC_INIT
85 struct DosLibrary *DOSBase;
86 struct Library *KeymapBase;
87 struct KMSLibrary *KMSBase;
88 STRPTR err = NULL;
89 ULONG rc = RETURN_FAIL;
91 DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 36);
92 if (!DOSBase)
93 return RETURN_FAIL;
95 KeymapBase = OpenLibrary("keymap.library", 0);
96 if (KeymapBase)
98 KMSBase = (struct KMSLibrary *)OpenLibrary("kms.library", 0);
99 if (KMSBase)
101 IPTR args[NOOFARGS];
102 struct RDArgs *myargs = ReadArgs(ARG_TEMPLATE, args, 0);
104 if (myargs)
106 struct KeyMapNode *kmn = OpenKeymap((STRPTR)args[ARG_NAME]);
108 if (kmn)
110 SetKeyMapDefault(&kmn->kn_KeyMap);
111 rc = RETURN_OK;
115 if (rc != RETURN_OK)
116 PrintFault(IoErr(), "SetKeyboard");
118 if (myargs)
119 FreeArgs(myargs);
121 CloseLibrary(&KMSBase->kms_Lib);
123 else
124 err = "Can't opem kms.library!";
126 CloseLibrary(KeymapBase);
128 else
129 err = "Can't open keymap.library!";
131 if (err)
132 Printf("SetKeyboard: %s\n", err);
134 CloseLibrary(&DOSBase->dl_lib);
136 return rc;
138 AROS_USERFUNC_EXIT