# &develguide;

## Available Functions

### `register_dlgcb (dialog, type, cb, param, free_param_cb)`

Register a new callback to the dialog.

Meaning of the parameters is as follows:

- struct dlg_cell* dlg - dialog to register callback to. If maybe NULL only for DLG_CREATED callback type, which is not a per dialog type.

- int type - types of callbacks; more types may be register for the same callback function; only DLG_CREATED must be register alone. Possible types:

  - DLGCB_LOADED

  - DLGCB_SAVED

  - DLG_CREATED - called when a new dialog is created - it's a global type (not associated to any dialog)

  - DLG_FAILED - called when the dialog was negatively replied (non-2xx) - it's a per dialog type.

  - DLG_CONFIRMED - called when the dialog is confirmed (2xx replied) - it's a per dialog type.

  - DLG_REQ_WITHIN - called when the dialog matches a sequential request - it's a per dialog type.

  - DLG_TERMINATED - called when the dialog is terminated via BYE - it's a per dialog type.

  - DLG_EXPIRED - called when the dialog expires without receiving a BYE - it's a per dialog type.

  - DLGCB_EARLY - called when the dialog is created in an early state (18x replied) - it's a per dialog type.

  - DLGCB_RESPONSE_FWDED - called when the dialog matches a reply to the initial INVITE request - it's a per dialog type.

  - DLGCB_RESPONSE_WITHIN - called when the dialog matches a reply to a subsequent in dialog request - it's a per dialog type.

  - DLGCB_MI_CONTEXT - called when the mi dlg_list_ctx command is invoked - it's a per dialog type.

  - DLGCB_DESTROY

- dialog_cb cb - callback function to be called. Prototype is: void (dialog_cb) (struct dlg_cell* dlg, int type, struct dlg_cb_params * params);

- void *param - parameter to be passed to the callback function.

- param_free callback_param_free - callback function to be called to free the param. Prototype is: void (param_free_cb) (void *param);