Sun Dec 18 20:55:51 2011

Asterisk developer's documentation


global_datastores.c File Reference

globally-accessible datastore information and callbacks More...

#include "asterisk.h"
#include "asterisk/global_datastores.h"
#include "asterisk/linkedlists.h"

Include dependency graph for global_datastores.c:

Go to the source code of this file.

Functions

static void dialed_interface_destroy (void *data)
static void * dialed_interface_duplicate (void *data)

Variables

struct ast_datastore_info dialed_interface_info


Detailed Description

globally-accessible datastore information and callbacks

Author:
Mark Michelson <mmichelson@digium.com>

Definition in file global_datastores.c.


Function Documentation

static void dialed_interface_destroy ( void *  data  )  [static]

Definition at line 33 of file global_datastores.c.

References ast_free, AST_LIST_HEAD, AST_LIST_HEAD_DESTROY, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, and di.

Referenced by dialed_interface_duplicate().

00034 {
00035    struct ast_dialed_interface *di = NULL;
00036    AST_LIST_HEAD(, ast_dialed_interface) *dialed_interface_list = data;
00037    
00038    if (!dialed_interface_list)
00039       return;
00040 
00041    AST_LIST_LOCK(dialed_interface_list);
00042    while ((di = AST_LIST_REMOVE_HEAD(dialed_interface_list, list)))
00043       ast_free(di);
00044    AST_LIST_UNLOCK(dialed_interface_list);
00045 
00046    AST_LIST_HEAD_DESTROY(dialed_interface_list);
00047    ast_free(dialed_interface_list);
00048 }

static void* dialed_interface_duplicate ( void *  data  )  [static]

Definition at line 50 of file global_datastores.c.

References ast_calloc, AST_LIST_HEAD, AST_LIST_HEAD_INIT, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, di, dialed_interface_destroy(), and ast_dialed_interface::interface.

00051 {
00052    struct ast_dialed_interface *di = NULL;
00053    AST_LIST_HEAD(, ast_dialed_interface) *old_list;
00054    AST_LIST_HEAD(, ast_dialed_interface) *new_list = NULL;
00055 
00056    if(!(old_list = data))
00057       return NULL;
00058 
00059    if(!(new_list = ast_calloc(1, sizeof(*new_list))))
00060       return NULL;
00061 
00062    AST_LIST_HEAD_INIT(new_list);
00063    AST_LIST_LOCK(old_list);
00064    AST_LIST_TRAVERSE(old_list, di, list) {
00065       struct ast_dialed_interface *di2 = ast_calloc(1, sizeof(*di2) + strlen(di->interface));
00066       if(!di2) {
00067          AST_LIST_UNLOCK(old_list);
00068          dialed_interface_destroy(new_list);
00069          return NULL;
00070       }
00071       strcpy(di2->interface, di->interface);
00072       AST_LIST_INSERT_TAIL(new_list, di2, list);
00073    }
00074    AST_LIST_UNLOCK(old_list);
00075 
00076    return new_list;
00077 }


Variable Documentation

Initial value:

 {
   .type ="dialed-interface",
   .destroy = dialed_interface_destroy,
   .duplicate = dialed_interface_duplicate,
}

Definition at line 79 of file global_datastores.c.

Referenced by try_calling().


Generated on Sun Dec 18 20:55:51 2011 for Asterisk - the Open Source PBX by  doxygen 1.5.6