summaryrefslogtreecommitdiff
path: root/n/avr/modules/host/host.host.c
diff options
context:
space:
mode:
Diffstat (limited to 'n/avr/modules/host/host.host.c')
-rw-r--r--n/avr/modules/host/host.host.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/n/avr/modules/host/host.host.c b/n/avr/modules/host/host.host.c
index e3f5a32..bcfd7d2 100644
--- a/n/avr/modules/host/host.host.c
+++ b/n/avr/modules/host/host.host.c
@@ -1,7 +1,7 @@
-/* host.c */
+/* host.host.c */
/* avr.host - Host fonctions modules. {{{
*
- * Copyright (C) 2005 Nicolas Schodet
+ * Copyright (C) 2005-2006 Nicolas Schodet
*
* Robot APB Team/Efrei 2006.
* Web: http://assos.efrei.fr/robot/
@@ -23,27 +23,36 @@
*
* }}} */
#define _GNU_SOURCE
+#include "common.h"
#include "host.h"
#include <errno.h>
-#include <assert.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
+/* Saved arguments. Uninitialised global variables are set to 0 by the
+ * compiler. */
+static int host_saved_argc;
+static char **host_saved_argv;
+
/** Initialise host modules. */
void
host_init (int argc, char **argv)
{
+ host_saved_argc = argc;
+ host_saved_argv = argv;
}
/** Register a host integer. */
void
host_register_integer (const char *name, int val)
{
+ int r;
char sval[256];
/* Convert to string, and register the string. */
- assert (snprintf (sval, sizeof (sval), "%d", val) < (int) sizeof (sval));
+ r = snprintf (sval, sizeof (sval), "%d", val);
+ assert (r < (int) sizeof (sval));
host_register_string (name, sval);
}
@@ -51,7 +60,9 @@ host_register_integer (const char *name, int val)
void
host_register_string (const char *name, const char *val)
{
- assert (setenv (name, val, 1) == 0);
+ int r;
+ r = setenv (name, val, 1);
+ assert (r == 0);
}
/** Fetch a host integer, return -1 if non existant. */
@@ -73,7 +84,8 @@ host_fetch_string (const char *name)
void
host_reset (void)
{
- execlp (program_invocation_name, program_invocation_name, 0);
+ execv (program_invocation_name, host_saved_argv);
assert_perror (errno);
abort ();
}
+