From 4e9a51d78ffa0696cf7d14ff0292ca8863689f70 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 11 Jun 2008 10:48:50 +0000 Subject: Merged connection profiles from http://svn.openvpn.net/projects/openvpn/test/conn git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@2993 e7ae566f-a301-0410-adde-c780ea21d3b5 --- misc.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'misc.c') diff --git a/misc.c b/misc.c index 5f0ec12..0ac1250 100644 --- a/misc.c +++ b/misc.c @@ -940,6 +940,7 @@ setenv_str_ex (struct env_set *es, { const char *str = construct_name_value (name_tmp, val_tmp, &gc); env_set_add (es, str); + /*msg (M_INFO, "SETENV_ES '%s'", str);*/ } else env_set_del (es, name_tmp); @@ -974,6 +975,38 @@ setenv_str_ex (struct env_set *es, gc_free (&gc); } +/* + * Setenv functions that append an integer index to the name + */ +static const char * +setenv_format_indexed_name (const char *name, const int i, struct gc_arena *gc) +{ + struct buffer out = alloc_buf_gc (strlen (name) + 16, gc); + if (i >= 0) + buf_printf (&out, "%s_%d", name, i); + else + buf_printf (&out, "%s", name); + return BSTR (&out); +} + +void +setenv_int_i (struct env_set *es, const char *name, const int value, const int i) +{ + struct gc_arena gc = gc_new (); + const char *name_str = setenv_format_indexed_name (name, i, &gc); + setenv_int (es, name_str, value); + gc_free (&gc); +} + +void +setenv_str_i (struct env_set *es, const char *name, const char *value, const int i) +{ + struct gc_arena gc = gc_new (); + const char *name_str = setenv_format_indexed_name (name, i, &gc); + setenv_str (es, name_str, value); + gc_free (&gc); +} + /* * taken from busybox networking/ifupdown.c */ -- cgit v1.2.3