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:
Axel Dörfler 2005-02-16 20:58:42 +00:00
parent b7624725ef
commit a7c89acd59

View File

@ -1,49 +1,51 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
//
// Copyright (c) 2004, Haiku
//
// This software is part of the Haiku distribution and is covered
// by the Haiku license.
//
//
// File: key_map.cpp
// Author: Jérôme Duval
// Description: keymap bin
// Created : July 30, 2004
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
/*
* Copyright (c) 2004-2005, Haiku
*
* This software is part of the Haiku distribution and is covered
* by the MIT license.
*
* Author: Jérôme Duval
*/
#include <stdio.h>
#include <string.h>
#include "Keymap.h"
static void usage(char *prog)
extern char *__progname;
static const char *sProgramName = __progname;
static void
usage(void)
{
printf(
"usage: %s {-o output_file} -[d|l|r|c] \n"
" -d # dump key map to standard output\n"
" -l # load key map from standard input\n"
" -r # restore system default key map\n"
" -c # compile source keymap to binary\n"
" -h # compile source keymap to header\n"
" -o # change output file to output_file (default:keymap.out)\n"
, prog);
printf("usage: %s {-o output_file} -[d|l|r|c]\n"
" -d dump key map to standard output\n"
" -l load key map from standard input\n"
" -r restore system default key map\n"
" -c compile source keymap to binary\n"
" -h compile source keymap to header\n"
" -o change output file to output_file (default:keymap.out)\n",
sProgramName);
}
int main(int argc, char **argv)
int
main(int argc, char **argv)
{
char operation = ' ';
entry_ref output_ref;
get_ref_for_path("keymap.out", &output_ref);
int i;
for (i = 1; i < argc; i++) {
entry_ref outputRef;
get_ref_for_path("keymap.out", &outputRef);
for (int i = 1; i < argc; i++) {
if (strncmp(argv[i], "-", 1) == 0) {
if (strlen(argv[i]) > 1)
operation = argv[i][1];
else
break;
if (operation == 'd') {
Keymap keymap;
if (keymap.LoadCurrent() != B_OK)
@ -62,17 +64,16 @@ int main(int argc, char **argv)
printf("Key map loaded.\n");
return 0;
}
} else {
if (operation == 'o') {
get_ref_for_path(argv[i], &output_ref);
get_ref_for_path(argv[i], &outputRef);
} else if (operation == 'c') {
entry_ref ref;
get_ref_for_path(argv[i], &ref);
Keymap keymap;
keymap.LoadSourceFromRef(ref);
keymap.Save(output_ref);
keymap.Save(outputRef);
return 0;
} else if (operation == 'h') {
entry_ref ref;
@ -80,12 +81,13 @@ int main(int argc, char **argv)
Keymap keymap;
keymap.LoadSourceFromRef(ref);
keymap.SaveAsHeader(output_ref);
keymap.SaveAsHeader(outputRef);
return 0;
} else
break;
}
}
usage("/bin/keymap");
usage();
return 1;
}