Handlers filenames and syntax versions (bug 681)

Neven Has haski at sezampro.yu
Tue Oct 21 14:56:10 PDT 2003


On Tue, Oct 21, 2003 at 07:49:34AM -0700, Kevin P. Fleming wrote:
> Gerard Beekmans wrote:
> >A little selfish maybe, but that bug being fixed would really help
> >me out a lot. So consider this a personal request.
> >
> >What needs to be done to make this work? I'd be happy to put in
> >testing, many hours of it if needed.
> >
> 
> Not selfish, I've thought about using this as well. I also would like 
> to see variables (which the VoiceXML stuff referenced in the bug entry 
> has a link to) that can be set and tested, and lots of other stuff...
> 
> The "test" part could be implemented fairly straightforwardly (is that 
> a word?) at this point, but the "package" tests really need help from 
> the nALFS core and it will make more sense to work on that after the 
> handler structures have been redesigned and the interface between the 
> handlers and core is more clearly defined. That should happen this 
> weekend, if things go well.

Actually, it was already implemented by Vassili long time ago.  The
problem is with run-status flags, conditional execution and the way
nALFS chooses what elements to run.  I started to work on this by
improving backend<->frontend communication, and will continue as soon
as we complete the handler stuff you mention (bug 681).

And speaking of which, considering what we have been discussing and
your suggestion, how about:

    typedef enum handler_data_e {
        DATA_COMMAND, DATA_NAME, DATA_VERSION, DATA_FILE
    } handler_data_e;

    typedef char *(*data_function_f)(struct element_s *, handler_data_e data);
    typedef int (*handler_function_f)(struct element_s *);

    typedef struct handler_info_s {
        char *name;
        char *description;
        char *syntax_version;
        handler_function_f main;
        data_function_f alloc_data;
        char **parameters;
        int action;
    } handler_info_s;

and in handler:

    int main_ver2(element_s *el)
    {
        /* ... */
    }

    char *data_ver2(element_s *el, handler_data_e data)
    {
        /* ... */
    }


    int main_ver3(element_s *el)
    {
        /* ... */
    }

    char *data_ver3(element_s *el, handler_data_e data)
    {
        /* ... */
    }

    char *parameters_ver2[] = { "base", "command", "param", NULL };
    char *parameters_ver3[] = { "param", NULL };

    handler_info_s HANDLER_SYMBOL(info)[]  = {
        {
            .name = "execute",
            .description = "Execute",
            .syntax_version = "2.0",
            .main = main_ver2,
            .alloc_data = data_ver2,
            .parameters = parameters_ver2,
            .action = 1
        }, {
            .name = "execute",
            .description = "Execute",
            .syntax_version = "3.0",
            .main = main_ver3,
            .alloc_data = data_ver3,
            .parameters = parameters_ver3,
            .action = 1
        }, {
            .name = "execute",
            .description = "Execute",
            .syntax_version = "3.1",
            .main = main_ver3,
            .alloc_data = data_ver3,
            .parameters = parameters_ver3,
            .action = 1
        }, {
            NULL, NULL, NULL, NULL, NULL, NULL, 0
        }
    };

I've tested this with one handler, making necessary changes in
handlers.c (clearing a lot of mess by having to lookup only
handler_info).

So if we agree on this, I'll do it for every handler and finally
remove new_* files.


Neven




More information about the alfs-discuss mailing list