ARM: rework "arm reg" output for new mode
[openocd/ztw.git] / src / hello.c
blobdd33650dcf004272e6a969b61e31dd866f3584b5
1 /***************************************************************************
2 * Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 #include "log.h"
25 static COMMAND_HELPER(handle_hello_args, const char **sep, const char **name)
27 if (CMD_ARGC > 1)
29 LOG_ERROR("%s: too many arguments", CMD_NAME);
30 return ERROR_COMMAND_SYNTAX_ERROR;
32 if (1 == CMD_ARGC)
34 *sep = " ";
35 *name = CMD_ARGV[0];
37 else
38 *sep = *name = "";
40 return ERROR_OK;
42 COMMAND_HANDLER(handle_hello_command)
44 const char *sep, *name;
45 int retval = CALL_COMMAND_HANDLER(handle_hello_args, &sep, &name);
46 if (ERROR_OK == retval)
47 command_print(CMD_CTX, "Greetings%s%s!", sep, name);
48 return retval;
51 int hello_register_commands(struct command_context *cmd_ctx)
53 struct command *cmd = register_command(cmd_ctx, NULL, "hello",
54 &handle_hello_command, COMMAND_ANY,
55 "option");
56 return cmd ? ERROR_OK : -ENOMEM;