--- l2_spec.c 2001/11/07 16:43:07 1.3
+++ l2_spec.c 2001/11/30 09:44:47 1.4
@@ -40,10 +40,29 @@
extern int l2_spec_parse(void *);
/* build a channel tree according to a textual specification */
-l2_result_t l2_spec(l2_channel_t **ch, l2_env_t *env, const char *spec)
+l2_result_t l2_spec(l2_channel_t **ch, l2_env_t *env, const char *spec, ...)
+{
+ va_list ap;
+ l2_result_t rv;
+
+ /* pass-through to va_list-based variant */
+ va_start(ap, spec);
+ rv = l2_vspec(ch, env, spec, ap);
+ va_end(ap);
+
+ return rv;
+}
+
+/* build a channel tree according to a textual specification (va_list variant) */
+l2_result_t l2_vspec(l2_channel_t **ch, l2_env_t *env, const char *spec, va_list ap)
{
l2_spec_ctx_t ctx;
void *yyscan;
+ char *specstr;
+
+ /* on-the-fly create or take over specification string */
+ if ((specstr = l2_util_vasprintf(spec, ap)) == NULL)
+ return L2_ERR_ARG;
/* initialize scanner */
l2_spec_lex_init(&yyscan);
@@ -52,9 +71,9 @@
/* establish our own context which is passed
through the parser and scanner */
ctx.yyscan = yyscan;
- ctx.inputptr = spec;
- ctx.inputbuf = spec;
- ctx.inputlen = strlen(spec);
+ ctx.inputptr = specstr;
+ ctx.inputbuf = specstr;
+ ctx.inputlen = strlen(specstr);
ctx.env = env;
ctx.ch = NULL;
ctx.chTmp = NULL;
@@ -67,6 +86,9 @@
/* destroy scanner */
l2_spec_lex_destroy(yyscan);
+ /* destroy specification string */
+ free(specstr);
+
/* provide root/top-level channel as result */
*ch = ctx.ch;
|