summaryrefslogtreecommitdiff
path: root/avr/cmd_echo.c
diff options
context:
space:
mode:
authorLeo C2014-08-12 12:35:28 +0200
committerLeo C2014-08-12 12:35:28 +0200
commitd684c21619905153eff68c43927207248925f6c2 (patch)
treec4bfb04a20512679103c6ad39fd9885dea6d9e76 /avr/cmd_echo.c
parent9b6b4b31e8cb284ad6a68fe16d458e36bbfb46fa (diff)
downloadz180-stamp-d684c21619905153eff68c43927207248925f6c2.zip
New U-Boot like AVR main program.
Uses U-Boot source code taken from: git://git.denx.de/u-boot.git
Diffstat (limited to 'avr/cmd_echo.c')
-rw-r--r--avr/cmd_echo.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/avr/cmd_echo.c b/avr/cmd_echo.c
new file mode 100644
index 0000000..d142ab6
--- /dev/null
+++ b/avr/cmd_echo.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include "common.h"
+#include "command.h"
+
+
+int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ uint_fast8_t putnl = 1;
+
+ (void) cmdtp; (void) flag;
+
+ for (uint_fast8_t i = 1; i < argc; i++) {
+
+ uint_fast8_t backslash = 0;
+ char *p = argv[i];
+ char c;
+
+ if (i != 1)
+ putchar(' ');
+ while ((c = *p++) != '\0') {
+
+ if(backslash) {
+ backslash = 0;
+ if (c == 'c') {
+ putnl = 0;
+ continue;
+ } else
+ putchar('\\');
+ } else {
+ if (c == '\\') {
+ backslash = 1;
+ continue;
+ }
+ }
+ putchar(c);
+ }
+ }
+
+ if (putnl)
+ putchar('\n');
+
+ return 0;
+}
+
+#if 0
+U_BOOT_CMD(
+ echo, CONFIG_SYS_MAXARGS, 1, do_echo,
+ "echo args to console",
+ "[args..]\n"
+ " - echo args to console; \\c suppresses newline"
+);
+#endif