From bebe796c0bfd9cfca6851dce3d56158296d5b93f Mon Sep 17 00:00:00 2001 From: Alessandro Rubini <rubini@gnudd.com> Date: Thu, 28 Mar 2013 12:12:19 +0100 Subject: [PATCH] shell: remove environment commands The environment was drafted but not actually used, so this commit removes it. Signed-off-by: Alessandro Rubini <rubini@gnudd.com> Acked-by: Grzegorz Daniluk <grzegorz.daniluk@cern.ch> Acked-by: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> --- shell/environ.c | 133 ------------------------------------------------ shell/shell.c | 1 - shell/shell.mk | 1 - 3 files changed, 135 deletions(-) delete mode 100644 shell/environ.c diff --git a/shell/environ.c b/shell/environ.c deleted file mode 100644 index c1e8336a7..000000000 --- a/shell/environ.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This work is part of the White Rabbit project - * - * Copyright (C) 2012 CERN (www.cern.ch) - * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> - * - * Released according to the GNU GPL, version 2 or any later version. - */ -#include <stdio.h> -#include <string.h> -#include <errno.h> - -#include <wrc.h> -#include "shell.h" - -#define SH_ENVIRON_SIZE 256 - -/* Environment-related functions */ - -static char env_buf[SH_ENVIRON_SIZE]; - -void env_init() -{ - env_buf[0] = 0xff; -} - -static char *_env_get(const char *var) -{ - int i = 0; - while (i < SH_ENVIRON_SIZE && env_buf[i] != 0xff) { - if (env_buf[i] == 0xaa - && !strcasecmp((char *)env_buf + i + 1, var)) - return (char *)env_buf + i; - - i++; - } - - return NULL; -} - -char *env_get(const char *var) -{ - char *p = _env_get(var); - - if (!p) - return NULL; - - return p + 2 + strlen(p + 1); -} - -static int _env_end() -{ - int i; - for (i = 0; i < SH_ENVIRON_SIZE; i++) - if (env_buf[i] == 0xff) - return i; - return 0; -} - -int env_set(const char *var, const char *value) -{ - char *vstart = _env_get(var), *p; - int end; - - if (vstart) { /* entry already present? remove current and append at the end of environment */ - p = vstart + 1; - while (*p != 0xaa && *p != 0xff) - p++; - - memmove(vstart, p, SH_ENVIRON_SIZE - (p - env_buf)); - } - - end = _env_end(); - - if ((end + strlen(var) + strlen(value) + 3) >= SH_ENVIRON_SIZE) - return -ENOMEM; - - p = &env_buf[end]; - - *p++ = 0xaa; - memcpy(p, var, strlen(var) + 1); - p += strlen(var) + 1; - memcpy(p, value, strlen(value) + 1); - p += strlen(value) + 1; - *p++ = 0xff; - - p = env_buf; - - return 0; -} - -static int cmd_env(const char *args[]) -{ - char *p = env_buf; - - while (*p != 0xff) { - if (*p == 0xaa) - mprintf("%s=%s\n", p + 1, p + strlen(p + 1) + 2); - p++; - } - - return 0; -} - -DEFINE_WRC_COMMAND(env) = { - .name = "env", - .exec = cmd_env, -}; - - -static int cmd_saveenv(const char *args[]) -{ - - return -ENOTSUP; -} - -DEFINE_WRC_COMMAND(saveenv) = { - .name = "saveenv", - .exec = cmd_saveenv, -}; - -static int cmd_set(const char *args[]) -{ - if (!args[1]) - return -EINVAL; - - return env_set(args[0], args[1]); -} - -DEFINE_WRC_COMMAND(set) = { - .name = "set", - .exec = cmd_set, -}; diff --git a/shell/shell.c b/shell/shell.c index 8833dbafe..2519a9794 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -125,7 +125,6 @@ int shell_exec(const char *cmd) void shell_init() { - env_init(); cmd_len = cmd_pos = 0; state = SH_PROMPT; } diff --git a/shell/shell.mk b/shell/shell.mk index f43411eeb..7c7e29ec1 100644 --- a/shell/shell.mk +++ b/shell/shell.mk @@ -1,6 +1,5 @@ obj-y += \ shell/shell.o \ - shell/environ.o \ shell/cmd_version.o \ shell/cmd_pll.o \ shell/cmd_sfp.o \ -- GitLab