script_cb.h
caf80ae6
 /*
53c7e0f1
  * Copyright (C) 2001-2003 FhG Fokus
7dd0b342
  *
2266bb9c
  * This file is part of Kamailio, a free SIP server.
7dd0b342
  *
2266bb9c
  * Kamailio is free software; you can redistribute it and/or modify
7dd0b342
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version
  *
2266bb9c
  * Kamailio is distributed in the hope that it will be useful,
7dd0b342
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License 
  * along with this program; if not, write to the Free Software 
9e1ff448
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
2e89dc92
  *
2266bb9c
  */
 /*!
  * \file
  * \brief Kamailio core :: Script callbacks
  * \ingroup core
  * Module: \ref core
caf80ae6
  */
 
7b972206
 #ifndef _SCRIPT_CB_H_
 #define _SCRIPT_CB_H_
7dd0b342
 
caf80ae6
 #include "parser/msg_parser.h"
 
0a99f1b3
 typedef int (cb_function)(struct sip_msg *msg, unsigned int flags, void *param);
caf80ae6
 
2e89dc92
 
0a99f1b3
 #define PRE_SCRIPT_CB    (1<<30)
 #define POST_SCRIPT_CB   (1<<31)
caf80ae6
 
0a99f1b3
 /* Pre- and post-script callback flags. Use these flags to register
  * for the callbacks, and to check the type of the callback from the
  * functions.
  * (Power of 2 so more callbacks can be registered at once.)
  */
 enum script_cb_flag { REQUEST_CB=1, FAILURE_CB=2, ONREPLY_CB=4,
 			BRANCH_CB=8, ONSEND_CB=16, ERROR_CB=32,
0b79baec
 			LOCAL_CB=64, EVENT_CB=128, BRANCH_FAILURE_CB=256 };
0a99f1b3
 
 /* Callback types used for executing the callbacks.
  * Keep in sync with script_cb_flag!!!
  */
 enum script_cb_type { REQUEST_CB_TYPE=1, FAILURE_CB_TYPE, ONREPLY_CB_TYPE,
 			BRANCH_CB_TYPE, ONSEND_CB_TYPE, ERROR_CB_TYPE,
0b79baec
 			LOCAL_CB_TYPE, EVENT_CB_TYPE, BRANCH_FAILURE_CB_TYPE, MAX_CB_TYPE };
caf80ae6
 
 struct script_cb{
 	cb_function *cbf;
 	struct script_cb *next;
 	void *param;
 };
 
0a99f1b3
 /* Register pre- or post-script callbacks.
  * Returns -1 on error, 0 on success
  */
 int register_script_cb( cb_function f, unsigned int flags, void *param );
 
abb01fb4
 int init_script_cb(void);
 void destroy_script_cb(void);
caf80ae6
 
0a99f1b3
 /* Execute pre-script callbacks of a given type.
  * Returns 0 on error, 1 on success
  */
 int exec_pre_script_cb( struct sip_msg *msg, enum script_cb_type type);
2e89dc92
 
0a99f1b3
 /* Execute post-script callbacks of a given type.
  * Always returns 1, success.
  */
 int exec_post_script_cb( struct sip_msg *msg, enum script_cb_type type);
2e89dc92
 
7b972206
 #endif
caf80ae6