[Click] read handler with parameters

Eddie Kohler kohler at cs.ucla.edu
Tue Jan 15 20:41:23 EST 2008


The argument gets passed in as a single string.  You can parse multiple 
arguments out of it by, for example, separating at spaces, via cp_space_kparse.

Eddie


sam barker wrote:
> Hi Eddie,
> Thanks for the tip.I am able to pass a value.
> 
> Is it possible to for me to pass more that one argument through the 
> set_handler?
> 
> Cheers,
> Sam
> 
> On Jan 16, 2008 10:24 AM, Eddie Kohler <kohler at cs.ucla.edu 
> <mailto:kohler at cs.ucla.edu>> wrote:
> 
>     If you want your read handler to take parameters, you need to use
>     set_handler() and supply Handler::OP_READ | Handler::READ_PARAM.
> 
>     http://www.read.cs.ucla.edu/click/doxygen/classElement.html#4b0cd1711fb51b8aba0f2e01f3eba9c0
> 
>     Eddie
> 
> 
>     sam barker wrote:
>      > Hi Beyers,
>      > I tried it but got the error "read handlers does not take
>     parameters".
>      >
>      > Is there anyway way to call the read handler with
>     parameters.[Suppose if you
>      > want to return  a value  corresponding to the passed parameter]
>      >
>      > I was going through a manual called coding concepts which clearly
>     states
>      > that "You can't call a ReadHandler with arguments"
>      >
>      >
>      > Cheers,
>      > Sam
>      > On Jan 15, 2008 9:01 PM, Beyers Cronje < bcronje at gmail.com
>     <mailto:bcronje at gmail.com>> wrote:
>      >
>      >> Hi Sam,
>      >>
>      >> I've never passed a parameter to a read handler before, so this
>     might be
>      >> wrong....
>      >>
>      >> Your telnet command should be:
>      >>
>      >> read readelement_name.a_handle 1
>      >>
>      >> Also I believe the prototype of add_handlers is onle 'virtual void
>      >> add_handlers();'
>      >>
>      >> Beyers
>      >>
>      >> On Jan 15, 2008 4:11 AM, sam barker <sam.barker0 at gmail.com
>     <mailto:sam.barker0 at gmail.com>> wrote:
>      >>
>      >>> Hi All,
>      >>> I was trying out the read handler with a parameter and I seem
>     to be
>      >>> stuck.
>      >>>
>      >>> Basically I wan t to  pass an int parameter to my_func().
>      >>>
>      >>> After I telnet into the localhost how do I call the function?.
>      >>> I had used  read readelement_name.a_handle(1);
>      >>>
>      >>> The the partial code of my .cc file is below
>      >>>
>      >>>
>      >>> String readelement::handle(Element *e, void *thunk){
>      >>>    readelement * me = (readelement *) e;
>      >>>
>      >>>    int *i;
>      >>>    i=(int *)thunk;
>      >>>    return me->my_func(i);
>      >>> }
>      >>> void readelement::add_handlers(void * thunk){
>      >>>    add_read_handler("a_handle", &handle, (void *)thunk);
>      >>> }
>      >>>
>      >>> Regards,
>      >>> Sam
>      >>> _______________________________________________
>      >>> click mailing list
>      >>> click at amsterdam.lcs.mit.edu <mailto:click at amsterdam.lcs.mit.edu>
>      >>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>      >>>
>      >>
>      > _______________________________________________
>      > click mailing list
>      > click at amsterdam.lcs.mit.edu <mailto:click at amsterdam.lcs.mit.edu>
>      > https://amsterdam.lcs.mit.edu/mailman/listinfo/click
> 
> 


More information about the click mailing list