silc_fsm_alloc
SYNOPSIS
SilcFSM silc_fsm_alloc(void *fsm_context, SilcFSMDestructor destructor, void *destructor_context, SilcSchedule schedule);
DESCRIPTION
Allocates SILC Finite State Machine context. The `destructor' with `destructor_context' will be called when the machines finishes. The caller must free the returned context with silc_fsm_free. The `fsm_context' is delivered to every FSM state function. The `schedule' is the caller's scheduler and the FSM will be run in the scheduler. If `schedule' is NULL this will call silc_schedule_get_global to try get global scheduler. Returns NULL on error or if system is out of memory and sets silc_errno.
EXAMPLE
SilcAsyncOperation silc_async_call(Callback callback, void *cb_context) { SilcAsyncOperation op; SilcFSM fsm; ... // Allocate async operation so that caller can control us, like abort op = silc_async_alloc(silc_async_call_abort, NULL, ourcontext); // Start FSM fsm = silc_fsm_alloc(ourcontext, fsm_destructor, ourcontext, schedule); silc_fsm_start(fsm, first_state); ... // Return async operation for upper layer return op; }