Re: how to use the MACROs?

Aarno Syvänen <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
ww kirjoittaa torstaina, 18. heinäkuuta 2002, kello 04:29:i am puzzled 
by the macros used in the source code of kannel
> just like the difinition of the MSG and the State-machine
>  
> here is the source code in the wtls_state-decl.h
>  ROW(CREATING,
>     SEC_Exception_Req,
>     1,
>     {
>             info(0,"----------------begin a new 12 machine-----------");
>             /* Send off a T_Unitdata_Req containing an exception as 
> specified */
>             send_alert(event->u.SEC_Exception_Req.alert_level,
>                        event->u.SEC_Exception_Req.alert_desc, 
> wtls_machine);
>     },
>     CREATING)

This is directly from state table:

ROW(state,
          event,
          condition,
          action,
          state after action)

Condition 1 means always, {} means no action. Action is a normal C block.

>  the source code in the wtls.c
>  
> if(event->type == T_Unitdata_Ind)
>  {
> if( wtls_machine->encrypted )
>  {
>  info(0, "lyl: start pdu list ");
>  wtls_decrypt_pdu_list(wtls_machine, event->u.T_Unitdata_Ind.pdu_list);
>  }
>  info(0, "lyl: end pdu list ");
>  du_list);
>  }
> #define STATE_NAME(state)
>      #define ROW(wtls_state, event_type, condition, action, 
> next_state) \
>              if (wtls_machine->state == wtls_state && \
>                 event->type == event_type && \
>                 (condition)) { \
>                 action \
>                 wtls_machine->state = next_state; \
>                 debug("wap.wtls", 0, "WTLS %ld: New state %s", 
> wtls_machine->mid
> , #next_state); \
>              } else
>      #include "wtls_state-decl.h"
>              {
>                 error(0, "WTLS: handle_event: unhandled event!");
>                 debug("wap.wtls",0, "lyl: event->type = %d", 
> event->type);
>                 wap_event_destroy(event);
>                 return;
>              }

Do not touch code in wtls.c, edit wtls_state-decl,h instead. Either 
change
code in action part in normal way or add a new row to the state table 
(for
unhandled events).

Aarno
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.