Some style cleanup. The usage text now looks more like those from other shell commands.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11394 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b7624725ef
commit
a7c89acd59
@ -1,49 +1,51 @@
|
|||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
/*
|
||||||
//
|
* Copyright (c) 2004-2005, Haiku
|
||||||
// Copyright (c) 2004, Haiku
|
*
|
||||||
//
|
* This software is part of the Haiku distribution and is covered
|
||||||
// This software is part of the Haiku distribution and is covered
|
* by the MIT license.
|
||||||
// by the Haiku license.
|
*
|
||||||
//
|
* Author: Jérôme Duval
|
||||||
//
|
*/
|
||||||
// File: key_map.cpp
|
|
||||||
// Author: Jérôme Duval
|
|
||||||
// Description: keymap bin
|
|
||||||
// Created : July 30, 2004
|
|
||||||
//
|
|
||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "Keymap.h"
|
#include "Keymap.h"
|
||||||
|
|
||||||
|
|
||||||
static void usage(char *prog)
|
extern char *__progname;
|
||||||
|
static const char *sProgramName = __progname;
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
{
|
{
|
||||||
printf(
|
printf("usage: %s {-o output_file} -[d|l|r|c]\n"
|
||||||
"usage: %s {-o output_file} -[d|l|r|c] \n"
|
" -d dump key map to standard output\n"
|
||||||
" -d # dump key map to standard output\n"
|
" -l load key map from standard input\n"
|
||||||
" -l # load key map from standard input\n"
|
" -r restore system default key map\n"
|
||||||
" -r # restore system default key map\n"
|
" -c compile source keymap to binary\n"
|
||||||
" -c # compile source keymap to binary\n"
|
" -h compile source keymap to header\n"
|
||||||
" -h # compile source keymap to header\n"
|
" -o change output file to output_file (default:keymap.out)\n",
|
||||||
" -o # change output file to output_file (default:keymap.out)\n"
|
sProgramName);
|
||||||
, prog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char operation = ' ';
|
char operation = ' ';
|
||||||
entry_ref output_ref;
|
entry_ref outputRef;
|
||||||
get_ref_for_path("keymap.out", &output_ref);
|
get_ref_for_path("keymap.out", &outputRef);
|
||||||
int i;
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (strncmp(argv[i], "-", 1) == 0) {
|
if (strncmp(argv[i], "-", 1) == 0) {
|
||||||
if (strlen(argv[i]) > 1)
|
if (strlen(argv[i]) > 1)
|
||||||
operation = argv[i][1];
|
operation = argv[i][1];
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (operation == 'd') {
|
if (operation == 'd') {
|
||||||
Keymap keymap;
|
Keymap keymap;
|
||||||
if (keymap.LoadCurrent() != B_OK)
|
if (keymap.LoadCurrent() != B_OK)
|
||||||
@ -62,30 +64,30 @@ int main(int argc, char **argv)
|
|||||||
printf("Key map loaded.\n");
|
printf("Key map loaded.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (operation == 'o') {
|
if (operation == 'o') {
|
||||||
get_ref_for_path(argv[i], &output_ref);
|
get_ref_for_path(argv[i], &outputRef);
|
||||||
} else if (operation == 'c') {
|
} else if (operation == 'c') {
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
get_ref_for_path(argv[i], &ref);
|
get_ref_for_path(argv[i], &ref);
|
||||||
Keymap keymap;
|
Keymap keymap;
|
||||||
keymap.LoadSourceFromRef(ref);
|
keymap.LoadSourceFromRef(ref);
|
||||||
|
|
||||||
keymap.Save(output_ref);
|
keymap.Save(outputRef);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (operation == 'h') {
|
} else if (operation == 'h') {
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
get_ref_for_path(argv[i], &ref);
|
get_ref_for_path(argv[i], &ref);
|
||||||
Keymap keymap;
|
Keymap keymap;
|
||||||
keymap.LoadSourceFromRef(ref);
|
keymap.LoadSourceFromRef(ref);
|
||||||
|
|
||||||
keymap.SaveAsHeader(output_ref);
|
keymap.SaveAsHeader(outputRef);
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usage("/bin/keymap");
|
|
||||||
|
usage();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user