+ it = strchrnul(it, SUBST_CHAR);
+ }
+
+ /* return arg when no change */
+ if (!chg)
+ return arg;
+
+ /* allocates the result */
+ resu = malloc((it - arg) + dif + 1);
+ if (!resu) {
+ ERROR("out of memory");
+ return NULL;
+ }
+
+ /* instanciate the arguments */
+ wr = resu;
+ for (;;) {
+ it = strchrnul(arg, SUBST_CHAR);
+ wr = mempcpy(wr, arg, it - arg);
+ if (!*it)
+ break;
+ switch(*++it) {
+ case 'p': wr = stpcpy(wr, port); break;
+ case 't': wr = stpcpy(wr, token); break;
+ default: *wr++ = SUBST_CHAR;
+ case SUBST_CHAR: *wr++ = *it;
+ }
+ arg = ++it;
+ }
+
+ *wr = 0;
+ return resu;
+}
+
+static int instanciate_environ(const char *port, const char *token)
+{
+ extern char **environ;
+ char *repl;
+ int i;
+
+ /* instanciate the environment */
+ for (i = 0 ; environ[i] ; i++) {
+ repl = instanciate_string(environ[i], port, token);
+ if (!repl)
+ return -1;
+ environ[i] = repl;
+ }
+ return 0;
+}
+
+static int instanciate_command_args(const char *port, const char *token)
+{
+ char *repl;
+ int i;
+
+ /* instanciate the arguments */
+ for (i = 0 ; config->exec[i] ; i++) {
+ repl = instanciate_string(config->exec[i], port, token);
+ if (!repl)
+ return -1;
+ config->exec[i] = repl;