From afe73cff56de417ce21096476928f53a7515ddec Mon Sep 17 00:00:00 2001 From: Juergen Beisert Date: Fri, 19 Oct 2007 14:56:45 +0200 Subject: doc added and some reorganised --- common/env.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'common/env.c') diff --git a/common/env.c b/common/env.c index 62134bda33..1b092c94fe 100644 --- a/common/env.c +++ b/common/env.c @@ -20,6 +20,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/** + * @file + * @brief Environment support + */ + #include #include #include @@ -28,21 +33,36 @@ #include #include +/** + * Managment of a environment variable + */ struct variable_d { + /*! List management */ struct variable_d *next; + /*! variable length data */ char data[0]; }; #define VARIABLE_D_SIZE(name, value) (sizeof(struct variable_d) + strlen(name) + strlen(value) + 2) +/** + * FIXME + */ struct env_context { + /*! FIXME */ struct env_context *parent; + /*! FIXME */ struct variable_d *local; + /*! FIXME */ struct variable_d *global; }; static struct env_context *context; +/** + * Remove a list of environment variables + * @param[inout] v Variable anchor to remove + */ static void free_variables(struct variable_d *v) { struct variable_d *next; @@ -54,6 +74,9 @@ static void free_variables(struct variable_d *v) } } +/** + * FIXME + */ int env_push_context(void) { struct env_context *c = xzalloc(sizeof(struct env_context)); @@ -74,6 +97,9 @@ int env_push_context(void) late_initcall(env_push_context); +/** + * FIXME + */ int env_pop_context(void) { struct env_context *c = context; @@ -89,11 +115,21 @@ int env_pop_context(void) return -EINVAL; } +/** + * Return variable's value + * @param[in] var Variable of interest + * @return Value as text + */ static char *var_val(struct variable_d *var) { return &var->data[strlen(var->data) + 1]; } +/** + * Return variable's name + * @param[in] var Variable of interest + * @return Name as text + */ static char *var_name(struct variable_d *var) { return var->data; @@ -267,6 +303,17 @@ U_BOOT_CMD_START(printenv) " - print value of environment variable 'name'\n") U_BOOT_CMD_END +/** + * @page printenv_command printenv + * + * Usage: printenv [] + * + * Print environment variables. + * If was given, it prints out its content if the environment variable + * exists. + * Without the argument all current environment variables are printed. + */ + #ifdef CONFIG_SIMPLE_PARSER static int do_setenv ( cmd_tbl_t *cmdtp, int argc, char *argv[]) { @@ -291,6 +338,19 @@ U_BOOT_CMD_START(setenv) " - delete environment variable 'name'\n") U_BOOT_CMD_END +/** + * @page setenv_command setenv + * + * Usage: setenv [] + * + * Set environment variable to + * If no was given, the variable will be removed. + * + * This command can be replaced by using the simpler form: + * + * = + */ + #endif static int do_export ( cmd_tbl_t *cmdtp, int argc, char *argv[]) @@ -329,3 +389,11 @@ U_BOOT_CMD_START(export) U_BOOT_CMD_HELP(cmd_export_help) U_BOOT_CMD_END +/** + * @page export_command export + * + * Usage: export [=value]... + * + * Export an environment variable to subsequently executed scripts + */ + -- cgit v1.2.3