Update of /cvsroot/toxine/toxine/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17595/src
Modified Files:
commands.c
Log Message:
add setenv command, fix typo. (patch from Harald Barth <haba AT pdc DOT kth DOT se>)
Index: commands.c
===================================================================
RCS file: /cvsroot/toxine/toxine/src/commands.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- commands.c 23 Jul 2004 12:51:39 -0000 1.84
+++ commands.c 2 Aug 2005 09:05:45 -0000 1.85
@@ -181,6 +181,7 @@
static void do_pause(commands_t *, toxine_t *, void *);
static void do_jump(commands_t *, toxine_t *, void *);
static void do_seek(commands_t *, toxine_t *, void *);
+static void do_setenv(commands_t *, toxine_t *, void *);
static void do_shell(commands_t *, toxine_t *, void *);
static void do_version(commands_t *, toxine_t *, void *);
static void do_help(commands_t *, toxine_t *, void *);
@@ -403,6 +404,10 @@
"set watchdog <[yes | no | 1 | 0 | on | off]>\n"
"set watchdog timeout <secs>"
},
+ { "setenv", OPTIONAL_ARGS, do_setenv,
+ "Change the environment of the current process.",
+ "setenv variable value"
+ },
{ "shell", OPTIONAL_ARGS, do_shell,
"Execute a shell, or a command if an argument to this command is given.",
"shell [command]"
@@ -1472,6 +1477,22 @@
}
/*
+ * Set environment
+ */
+static void do_setenv(commands_t *command, toxine_t *tox, void *data) {
+ int retval;
+
+ if(tox->command.num_args == 2) {
+ retval = setenv(toxine_get_arg(tox, 1), toxine_get_arg(tox, 2), 1);
+ if (retval != 0)
+ pinfo("setenv failed\n");
+ }
+ else
+ pinfo("setenv wrong number of args (%d).\n", tox->command.num_args);
+}
+
+
+/*
* Execute a shell command (or a shell itself)
*/
static void do_shell(commands_t *command, toxine_t *tox, void *data) {
@@ -1484,7 +1505,7 @@
int i;
for(i = 0; i < num_args; i++)
- sprintf(buffer, "%s %s", buffer, (toxine_get_arg(tox, (i+1))));
+ snprintf(buffer, 2048, "%s %s", buffer, (toxine_get_arg(tox, (i+1))));
}
else
sprintf(buffer, "%s", "/bin/sh --login");
|