Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / shell / shell_common / cmd_misc.cpp
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 #include <lib/shell/shell.h>
19
20 #include <lib/core/CHIPCore.h>
21 #include <lib/support/Base64.h>
22 #include <lib/support/CHIPArgParser.hpp>
23 #include <lib/support/CodeUtils.h>
24 #include <lib/support/RandUtils.h>
25
26 #include <inttypes.h>
27 #include <stdarg.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31
32 #include <ChipShellCollection.h>
33
34 using namespace chip;
35 using namespace chip::Shell;
36 using namespace chip::Logging;
37
38 int cmd_echo(int argc, char ** argv)
39 {
40     for (int i = 0; i < argc; i++)
41     {
42         streamer_printf(streamer_get(), "%s ", argv[i]);
43     }
44     streamer_printf(streamer_get(), "\n\r");
45     return 0;
46 }
47
48 int cmd_log(int argc, char ** argv)
49 {
50     for (int i = 0; i < argc; i++)
51     {
52         ChipLogProgress(chipTool, "%s", argv[i]);
53     }
54     return 0;
55 }
56
57 int cmd_rand(int argc, char ** argv)
58 {
59     streamer_printf(streamer_get(), "%d\n\r", GetRandU8());
60     return 0;
61 }
62
63 static shell_command_t cmds_misc[] = {
64     { &cmd_echo, "echo", "Echo back provided inputs" },
65     { &cmd_log, "log", "Logging utilities" },
66     { &cmd_rand, "rand", "Random number utilities" },
67 };
68
69 void cmd_misc_init()
70 {
71     shell_register(cmds_misc, ArraySize(cmds_misc));
72 }