]> git.sur5r.net Git - openocd/blob - src/hello.c
armv4_5_common_t -> struct arm
[openocd] / src / hello.c
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  ***************************************************************************/
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 #include "log.h"
24
25 static COMMAND_HELPER(handle_hello_args, const char **sep, const char **name)
26 {
27         if (argc > 1)
28         {
29                 LOG_ERROR("%s: too many arguments", CMD_NAME);
30                 return ERROR_COMMAND_SYNTAX_ERROR;
31         }
32         if (1 == argc)
33         {
34                 *sep = " ";
35                 *name = args[0];
36         }
37         else
38                 *sep = *name = "";
39
40         return ERROR_OK;
41 }
42 COMMAND_HANDLER(handle_hello_command)
43 {
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;
49 }
50
51 int hello_register_commands(struct command_context_s *cmd_ctx)
52 {
53         struct command_s *cmd = register_command(cmd_ctx, NULL, "hello",
54                         &handle_hello_command, COMMAND_ANY,
55                         "option");
56         return cmd ? ERROR_OK : -ENOMEM;
57 }