added binary keymap loading. Now you can type 'keymap -b /etc/Keymap/French'

it also checks for binary version number in case you try to load anything else (who knows ...)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11517 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2005-03-01 14:30:29 +00:00
parent c7cbf33821
commit e6d5cc8d84
2 changed files with 18 additions and 3 deletions

View File

@ -266,6 +266,9 @@ Keymap::Load(entry_ref &ref)
for (uint32 i=0; i<sizeof(fKeys)/4; i++)
((uint32*)&fKeys)[i] = B_BENDIAN_TO_HOST_INT32(((uint32*)&fKeys)[i]);
if (fKeys.version != 3)
return B_ERROR;
if (file.Read(&fCharsSize, sizeof(uint32)) < (ssize_t)sizeof(uint32)) {
return B_BAD_VALUE;
}

View File

@ -21,9 +21,10 @@ static const char *sProgramName = __progname;
static void
usage(void)
{
printf("usage: %s {-o output_file} -[d|l|r|c]\n"
printf("usage: %s {-o output_file} -[d|l|r|c|b input_file]\n"
" -d dump key map to standard output\n"
" -l load key map from standard input\n"
" -b load binary key map from file\n"
" -r restore system default key map\n"
" -c compile source keymap to binary\n"
" -h compile source keymap to header\n"
@ -91,6 +92,17 @@ main(int argc, char **argv)
keymap.Dump();
keymap.SaveAsHeader(outputRef);
return 0;
} else if (operation == 'b') {
entry_ref ref;
get_ref_for_path(argv[i], &ref);
Keymap keymap;
if (keymap.Load(ref)!=B_OK) {
printf("error when loading the keymap\n");
return 1;
}
keymap.SaveAsCurrent();
printf("Key map loaded.\n");
return 0;
} else
break;
}