Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

switch_event.c File Reference


Defines

#define MAX_DISPATCH   20
#define DISPATCH_QUEUE_LEN   5000
#define NUMBER_OF_QUEUES   3
#define ALLOC(size)   malloc(size)
#define DUP(str)   my_dup(str)
#define FREE(ptr)   switch_safe_free(ptr)
#define resize(l)

Functions

void switch_event_deliver (switch_event_t **event)
 Deliver an event to all of the registered event listeners.
switch_status_t switch_event_running (void)
 Determine if the event system has been initilized.
const char * switch_event_name (switch_event_types_t event)
 Render the name of an event id enumeration.
switch_status_t switch_name_event (const char *name, switch_event_types_t *type)
 return the event id that matches a given event name
switch_status_t switch_event_reserve_subclass_detailed (const char *owner, const char *subclass_name)
 Reserve a subclass name for private use with a custom event.
void switch_core_memory_reclaim_events (void)
switch_status_t switch_event_shutdown (void)
 Stop the eventing system.
switch_status_t switch_event_init (switch_memory_pool_t *pool)
 Start the eventing system.
switch_status_t switch_event_create_subclass (switch_event_t **event, switch_event_types_t event_id, const char *subclass_name)
 Create an event.
switch_status_t switch_event_set_priority (switch_event_t *event, switch_priority_t priority)
 Set the priority of an event.
char * switch_event_get_header (switch_event_t *event, char *header_name)
 Retrieve a header value from an event.
char * switch_event_get_body (switch_event_t *event)
 Retrieve the body value from an event.
switch_status_t switch_event_del_header (switch_event_t *event, const char *header_name)
switch_status_t switch_event_add_header (switch_event_t *event, switch_stack_t stack, const char *header_name, const char *fmt,...)
switch_status_t switch_event_add_header_string (switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
 Add a string header to an event.
switch_status_t switch_event_add_body (switch_event_t *event, const char *fmt,...)
void switch_event_destroy (switch_event_t **event)
 Destroy an event.
switch_status_t switch_event_dup (switch_event_t **event, switch_event_t *todup)
 Duplicate an event.
switch_status_t switch_event_serialize (switch_event_t *event, char **str, switch_bool_t encode)
 Render a string representation of an event sutable for printing or network transport.
switch_xml_t switch_event_xmlize (switch_event_t *event, const char *fmt,...)
switch_status_t switch_event_fire_detailed (const char *file, const char *func, int line, switch_event_t **event, void *user_data)
 Fire an event with full arguement list.
switch_status_t switch_event_bind (const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data)
 Bind an event callback to a specific event.
switch_status_t switch_event_create_pres_in_detailed (char *file, char *func, int line, const char *proto, const char *login, const char *from, const char *from_domain, const char *status, const char *event_type, const char *alt_event_type, int event_count, const char *unique_id, const char *channel_state, const char *answer_state, const char *call_direction)
char * switch_event_expand_headers (switch_event_t *event, const char *in)
char * switch_event_build_param_string (switch_event_t *event, const char *prefix, switch_hash_t *vars_map)


Define Documentation

#define ALLOC size   )     malloc(size)
 

#define DISPATCH_QUEUE_LEN   5000
 

#define DUP str   )     my_dup(str)
 

#define FREE ptr   )     switch_safe_free(ptr)
 

#define MAX_DISPATCH   20
 

#define NUMBER_OF_QUEUES   3
 

#define resize  ) 
 

Value:

{\
char *dp;\
olen += (len + l + block);\
cpos = c - data;\
if ((dp = realloc(data, olen))) {\
    data = dp;\
    c = data + cpos;\
    memset(c, 0, olen - cpos);\
 }}                           \


Function Documentation

switch_status_t switch_event_add_body switch_event_t event,
const char *  fmt,
  ...
 

00625 {
00626         int ret = 0;
00627         char *data;
00628 
00629         va_list ap;
00630         if (fmt) {
00631                 va_start(ap, fmt);
00632                 ret = switch_vasprintf(&data, fmt, ap);
00633                 va_end(ap);
00634 
00635                 if (ret == -1) {
00636                         return SWITCH_STATUS_GENERR;
00637                 } else {
00638                         switch_safe_free(event->body);
00639                         event->body = data;
00640                         return SWITCH_STATUS_SUCCESS;
00641                 }
00642         } else {
00643                 return SWITCH_STATUS_GENERR;
00644         }
00645 }

Here is the call graph for this function:

switch_status_t switch_event_add_header switch_event_t event,
switch_stack_t  stack,
const char *  header_name,
const char *  fmt,
  ...
 

00600 {
00601         int ret = 0;
00602         char *data;
00603         va_list ap;
00604 
00605         va_start(ap, fmt);
00606         ret = switch_vasprintf(&data, fmt, ap);
00607         va_end(ap);
00608 
00609         if (ret == -1) {
00610                 return SWITCH_STATUS_MEMERR;
00611         }
00612 
00613         return switch_event_base_add_header(event, stack, header_name, data);
00614 }

Here is the call graph for this function:

switch_status_t switch_event_create_pres_in_detailed char *  file,
char *  func,
int  line,
const char *  proto,
const char *  login,
const char *  from,
const char *  from_domain,
const char *  status,
const char *  event_type,
const char *  alt_event_type,
int  event_count,
const char *  unique_id,
const char *  channel_state,
const char *  answer_state,
const char *  call_direction
 

01008 {
01009     switch_event_t *pres_event;
01010 
01011         if (switch_event_create_subclass(&pres_event, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY) == SWITCH_STATUS_SUCCESS) {
01012                 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "proto", proto);
01013                 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "login", login);
01014                 switch_event_add_header(pres_event, SWITCH_STACK_TOP, "from", "%s@%s", from, from_domain);
01015                 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "status", status);
01016                 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "event_type", event_type);
01017                 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "alt_event_type", alt_event_type);
01018                 switch_event_add_header(pres_event, SWITCH_STACK_TOP, "event_count", "%d", event_count);
01019                 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "unique-id", alt_event_type);
01020                 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "channel-state", channel_state);
01021                 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "answer-state", answer_state);
01022                 switch_event_add_header_string(pres_event, SWITCH_STACK_TOP, "call-direction", call_direction);
01023                 switch_event_fire_detailed(file, func, line, &pres_event, NULL);
01024                 return SWITCH_STATUS_SUCCESS;
01025         }
01026         return SWITCH_STATUS_MEMERR;
01027 }

Here is the call graph for this function:

switch_xml_t switch_event_xmlize switch_event_t event,
const char *  fmt,
  ...
 

00848 {
00849         switch_event_header_t *hp;
00850         char *data = NULL, *body = NULL;
00851         int ret = 0;
00852         switch_xml_t xml = NULL;
00853         uint32_t off = 0;
00854         va_list ap;
00855 
00856         if (!(xml = switch_xml_new("event"))) {
00857                 return xml;
00858         }
00859 
00860         if (fmt) {
00861                 va_start(ap, fmt);
00862 #ifdef HAVE_VASPRINTF
00863                 ret = vasprintf(&data, fmt, ap);
00864 #else
00865                 data = (char *) malloc(2048);
00866                 if (!data) return NULL;
00867                 ret = vsnprintf(data, 2048, fmt, ap);
00868 #endif
00869                 va_end(ap);
00870                 if (ret == -1) {
00871 #ifndef HAVE_VASPRINTF
00872                         free(data);
00873 #endif
00874                         return NULL;
00875                 }
00876         }
00877 
00878         for (hp = event->headers; hp; hp = hp->next) {
00879                 add_xml_header(xml, hp->name, hp->value, off++);
00880         }
00881 
00882         if (!switch_strlen_zero(data)) {
00883                 body = data;
00884         } else if (event->body) {
00885                 body = event->body;
00886         }
00887 
00888         if (body) {
00889                 int blen = (int) strlen(body);
00890                 char blena[25];
00891                 switch_snprintf(blena, sizeof(blena), "%d", blen);
00892                 if (blen) {
00893                         switch_xml_t xbody = NULL;
00894 
00895                         add_xml_header(xml, "Content-Length", blena, off++);
00896                         if ((xbody = switch_xml_add_child_d(xml, "body", off++))) {
00897                                 switch_xml_set_txt_d(xbody, body);
00898                         }
00899                 }
00900         }
00901 
00902         if (data) {
00903                 free(data);
00904         }
00905 
00906         return xml;
00907 }

Here is the call graph for this function:


Generated on Mon May 26 22:06:52 2008 for FreeSWITCH by  doxygen 1.3.9.1