![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
astobj.h File Reference
These macros expect to operate on two different object types, ASTOBJs and ASTOBJ_CONTAINERs. These are not actual types, as any struct can be converted into an ASTOBJ compatible object or container using the supplied macros.
Sample Usage:
struct sample_object { ASTOBJ_COMPONENTS(struct sample_object); }; struct sample_container { ASTOBJ_CONTAINER_COMPONENTS(struct sample_object); } super_container; void sample_object_destroy(struct sample_object *obj) { free(obj); } int init_stuff() { struct sample_object *obj1; struct sample_object *found_obj; obj1 = malloc(sizeof(struct sample_object)); ASTOBJ_CONTAINER_INIT(&super_container); ASTOBJ_INIT(obj1); ASTOBJ_WRLOCK(obj1); ast_copy_string(obj1->name, "obj1", sizeof(obj1->name)); ASTOBJ_UNLOCK(obj1); ASTOBJ_CONTAINER_LINK(&super_container, obj1); found_obj = ASTOBJ_CONTAINER_FIND(&super_container, "obj1"); if(found_obj) { printf("Found object: %s", found_obj->name); ASTOBJ_UNREF(found_obj,sample_object_destroy); } ASTOBJ_CONTAINER_DESTROYALL(&super_container,sample_object_destroy); ASTOBJ_CONTAINER_DESTROY(&super_container); return 0; }
Definition in file astobj.h.
#include <string.h>
#include "asterisk/lock.h"
#include "asterisk/compiler.h"
Include dependency graph for astobj.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | __ASTOBJ_HASH(type, hashes) type *next[1] |
| #define | ASTOBJ_COMPONENTS(type) |
| Add ASTOBJ components to a struct (with locking support). | |
| #define | ASTOBJ_COMPONENTS_FULL(type, namelen, hashes) |
| Add ASTOBJ components to a struct (with locking support). | |
| #define | ASTOBJ_COMPONENTS_NOLOCK(type) ASTOBJ_COMPONENTS_NOLOCK_FULL(type,ASTOBJ_DEFAULT_NAMELEN,1) |
| Add ASTOBJ components to a struct (without locking support). | |
| #define | ASTOBJ_COMPONENTS_NOLOCK_FULL(type, namelen, hashes) |
| Add ASTOBJ components to a struct (without locking support). | |
| #define | ASTOBJ_CONTAINER_COMPONENTS(type) |
| Create a container for ASTOBJs (with locking support). | |
| #define | ASTOBJ_CONTAINER_COMPONENTS_NOLOCK(type) ASTOBJ_CONTAINER_COMPONENTS_NOLOCK_FULL(type,1,ASTOBJ_DEFAULT_BUCKETS) |
| Create a container for ASTOBJs (without locking support). | |
| #define | ASTOBJ_CONTAINER_COMPONENTS_NOLOCK_FULL(type, hashes, buckets) type *head |
| Create a container for ASTOBJs (without locking support). | |
| #define | ASTOBJ_CONTAINER_DESTROY(container) ASTOBJ_CONTAINER_DESTROY_FULL(container,1,ASTOBJ_DEFAULT_BUCKETS) |
| Destroy a container. | |
| #define | ASTOBJ_CONTAINER_DESTROY_FULL(container, hashes, buckets) |
| Destroy a container. | |
| #define | ASTOBJ_CONTAINER_DESTROYALL(container, destructor) |
| Empty a container. | |
| #define | ASTOBJ_CONTAINER_DUMP(fd, s, slen, container) ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, s); } while(0)) |
| Dump information about all the objects in a container to a file descriptor. | |
| #define | ASTOBJ_CONTAINER_FIND(container, namestr) |
| Find an object in a container. | |
| #define | ASTOBJ_CONTAINER_FIND_FULL(container, data, field, hashfunc, hashoffset, comparefunc) |
| Find an object in a container. | |
| #define | ASTOBJ_CONTAINER_FIND_UNLINK(container, namestr) |
| Find and remove an object from a container. | |
| #define | ASTOBJ_CONTAINER_FIND_UNLINK_FULL(container, data, field, hashfunc, hashoffset, comparefunc) |
| Find and remove an object in a container. | |
| #define | ASTOBJ_CONTAINER_INIT(container) ASTOBJ_CONTAINER_INIT_FULL(container,1,ASTOBJ_DEFAULT_BUCKETS) |
| Initialize a container. | |
| #define | ASTOBJ_CONTAINER_INIT_FULL(container, hashes, buckets) |
| Initialize a container. | |
| #define | ASTOBJ_CONTAINER_LINK(container, newobj) ASTOBJ_CONTAINER_LINK_FULL(container,newobj,(newobj)->name,name,ASTOBJ_DEFAULT_HASH,0,strcasecmp) |
| Add an object to a container. | |
| #define | ASTOBJ_CONTAINER_LINK_END(container, newobj) |
| Add an object to the end of a container. | |
| #define | ASTOBJ_CONTAINER_LINK_FULL(container, newobj, data, field, hashfunc, hashoffset, comparefunc) |
| Add an object to a container. | |
| #define | ASTOBJ_CONTAINER_LINK_START(container, newobj) |
| Add an object to the front of a container. | |
| #define | ASTOBJ_CONTAINER_MARKALL(container) ASTOBJ_CONTAINER_TRAVERSE(container, 1, ASTOBJ_MARK(iterator)) |
| Mark all the objects in a container. | |
| #define | ASTOBJ_CONTAINER_PRUNE_MARKED(container, destructor) |
| Prune marked objects from a container. | |
| #define | ASTOBJ_CONTAINER_RDLOCK(container) ast_mutex_lock(&(container)->_lock) |
| Lock an ASTOBJ_CONTAINER for reading. | |
| #define | ASTOBJ_CONTAINER_TRAVERSE(container, continue, eval) |
| Iterate through the objects in a container. | |
| #define | ASTOBJ_CONTAINER_UNLINK(container, obj) |
| Remove an object from a container. | |
| #define | ASTOBJ_CONTAINER_UNLINK_START(container) |
| Remove an object from the front of a container. | |
| #define | ASTOBJ_CONTAINER_UNLOCK(container) ast_mutex_unlock(&(container)->_lock) |
| Unlock an ASTOBJ_CONTAINER. | |
| #define | ASTOBJ_CONTAINER_UNMARKALL(container) ASTOBJ_CONTAINER_TRAVERSE(container, 1, ASTOBJ_UNMARK(iterator)) |
| Unmark all the objects in a container. | |
| #define | ASTOBJ_CONTAINER_WRLOCK(container) ast_mutex_lock(&(container)->_lock) |
| Lock an ASTOBJ_CONTAINER for writing. | |
| #define | ASTOBJ_DEFAULT_BUCKETS 256 |
| #define | ASTOBJ_DEFAULT_HASH ast_strhash |
| #define | ASTOBJ_DEFAULT_NAMELEN 80 |
| #define | ASTOBJ_DUMP(s, slen, obj) snprintf((s),(slen),"name: %s\nobjflags: %d\nrefcount: %d\n\n", (obj)->name, (obj)->objflags, (obj)->refcount); |
| Dump information about an object into a string. | |
| #define | ASTOBJ_FLAG_MARKED (1 << 0) |
| #define | ASTOBJ_INIT(object) |
| Initialize an object. | |
| #define | ASTOBJ_MARK(object) |
| Mark an ASTOBJ by adding the ASTOBJ_FLAG_MARKED flag to its objflags mask. | |
| #define | ASTOBJ_RDLOCK(object) ast_mutex_lock(&(object)->_lock) |
| Lock an ASTOBJ for reading. | |
| #define | ASTOBJ_REF(object) |
| Increment an object reference count. | |
| #define | ASTOBJ_UNLOCK(object) ast_mutex_unlock(&(object)->_lock) |
| Unlock a locked object. | |
| #define | ASTOBJ_UNMARK(object) |
| Unmark an ASTOBJ by subtracting the ASTOBJ_FLAG_MARKED flag from its objflags mask. | |
| #define | ASTOBJ_UNREF(object, destructor) |
| Decrement the reference count on an object. | |
| #define | ASTOBJ_WRLOCK(object) ast_mutex_lock(&(object)->_lock) |
| Lock an ASTOBJ for writing. | |
|
|
|
|
|
Value: ASTOBJ_COMPONENTS_NOLOCK(type); \ ast_mutex_t _lock;
Sample Usage: struct sample_struct { ASTOBJ_COMPONENTS(struct sample_struct); }; |
|
|
Value: ASTOBJ_COMPONENTS_NOLOCK_FULL(type,namelen,hashes); \ ast_mutex_t _lock;
Sample Usage: struct sample_struct { ASTOBJ_COMPONENTS_FULL(struct sample_struct,1,1); }; |
|
|
Add ASTOBJ components to a struct (without locking support).
Sample Usage: struct sample_struct_componets { ASTOBJ_COMPONENTS_NOLOCK(struct sample_struct); }; |
|
|
Value: char name[namelen]; \ unsigned int refcount; \ unsigned int objflags; \ __ASTOBJ_HASH(type,hashes)
Sample Usage: struct sample_struct { ASTOBJ_COMPONENTS_NOLOCK_FULL(struct sample_struct,1,1); }; |
|
|
Value: Create a container for ASTOBJs (with locking support).
Sample Usage: struct sample_struct_container { ASTOBJ_CONTAINER_COMPONENTS(struct sample_struct); }; |
|
|
Create a container for ASTOBJs (without locking support).
Sample Usage: struct sample_struct_nolock_container { ASTOBJ_CONTAINER_COMPONENTS_NOLOCK(struct sample_struct); }; |
|
|
Create a container for ASTOBJs (without locking support).
Sample Usage: struct sample_struct_nolock_container { ASTOBJ_CONTAINER_COMPONENTS_NOLOCK_FULL(struct sample_struct,1,1); }; |
|
|
Destroy a container.
Definition at line 766 of file astobj.h. Referenced by aji_client_destroy(), ast_netsock_release(), ast_smdi_interface_destroy(), load_module(), and unload_module(). |
|
|
Value: do { \ ast_mutex_destroy(&(container)->_lock); \ } while(0)
|
|
|
Empty a container.
Definition at line 454 of file astobj.h. Referenced by aji_client_destroy(), ast_netsock_release(), ast_smdi_interface_destroy(), load_module(), and unload_module(). |
|
|
Dump information about all the objects in a container to a file descriptor.
Definition at line 815 of file astobj.h. Referenced by sip_show_objects(). |
|
|
Find an object in a container.
Definition at line 402 of file astobj.h. Referenced by aji_client_info_handler(), aji_create_buddy(), aji_create_client(), aji_dinfo_handler(), aji_handle_presence(), aji_register_query_handler(), aji_status_exec(), aji_test(), ast_aji_get_client(), ast_smdi_interface_find(), find_alias(), find_device(), find_gtalk(), find_jingle(), find_peer(), find_user(), gtalk_alloc(), gtalk_create_member(), jingle_alloc(), and jingle_create_member(). |
|
|
Find an object in a container.
Definition at line 429 of file astobj.h. Referenced by ast_aji_get_client(), find_device(), find_gtalk(), find_jingle(), find_peer(), and find_user(). |
|
|
Find and remove an object from a container.
|
|
|
Find and remove an object in a container.
Definition at line 552 of file astobj.h. Referenced by build_alias(), build_device(), build_peer(), and build_user(). |
|
|
Initialize a container.
Sample Usage: struct sample_struct_container { ASTOBJ_CONTAINER_COMPONENTS(struct sample_struct); } container; int func() { ASTOBJ_CONTAINER_INIT(&container); } Definition at line 753 of file astobj.h. Referenced by aji_create_client(), ast_netsock_init(), and load_module(). |
|
|
Value: do { \ ast_mutex_init(&(container)->_lock); \ } while(0)
Sample Usage: struct sample_struct_container { ASTOBJ_CONTAINER_COMPONENTS_FULL(struct sample_struct,1,1); } container; int func() { ASTOBJ_CONTAINER_INIT_FULL(&container,1,1); } |
|
|
Add an object to a container.
Definition at line 777 of file astobj.h. Referenced by aji_create_buddy(), aji_create_client(), ast_netsock_bindaddr(), register_verify(), reload_config(), and sip_register(). |
|
|
Add an object to the end of a container.
Definition at line 581 of file astobj.h. Referenced by ast_smdi_md_message_push(), and ast_smdi_mwi_message_push(). |
|
|
Add an object to a container.
|
|
|
Add an object to the front of a container.
Definition at line 611 of file astobj.h. Referenced by ast_smdi_md_message_putback(), and ast_smdi_mwi_message_putback(). |
|
|
Mark all the objects in a container.
Definition at line 783 of file astobj.h. Referenced by aji_create_client(), aji_reload(), and smdi_load(). |
|
|
Prune marked objects from a container.
Definition at line 652 of file astobj.h. Referenced by aji_reload(), and prune_peers(). |
|
|
Lock an ASTOBJ_CONTAINER for reading.
|
|
|
Iterate through the objects in a container.
eval statement. See the sample code for an example.Sample Usage: ASTOBJ_CONTAINER_TRAVERSE(&sample_container,1, { ASTOBJ_RDLOCK(iterator); printf("Currently iterating over '%s'\n", iterator->name); ASTOBJ_UNLOCK(iterator); } );
ASTOBJ_CONTAINER_TRAVERSE(&sample_container,1, sample_func(iterator)); Definition at line 377 of file astobj.h. Referenced by _sip_show_devices(), _sip_show_peers(), aji_do_debug(), aji_filter_roster(), aji_no_debug(), aji_pruneregister(), aji_reload(), aji_show_clients(), aji_test(), ast_netsock_find(), complete_sip_device(), complete_sip_peer(), complete_sip_user(), delete_aliases(), delete_users(), find_gtalk(), find_jingle(), get_destination(), sip_do_reload(), sip_poke_all_peers(), sip_prune_realtime(), sip_send_all_registers(), sip_show_inuse(), sip_show_registry(), sip_show_users(), and unload_module(). |
|
|
Remove an object from a container.
Definition at line 479 of file astobj.h. Referenced by expire_register(). |
|
|
Remove an object from the front of a container.
Definition at line 631 of file astobj.h. Referenced by ast_smdi_md_message_pop(), and ast_smdi_mwi_message_pop(). |
|
|
Unlock an ASTOBJ_CONTAINER.
|
|
|
Unmark all the objects in a container.
|
|
|
Lock an ASTOBJ_CONTAINER for writing.
Definition at line 281 of file astobj.h. Referenced by delete_aliases(), delete_users(), and sip_prune_realtime(). |
|
|
|
|
|
|
|
|
|
|
|
Dump information about an object into a string.
|
|
|
Definition at line 96 of file astobj.h. Referenced by build_device(), and build_peer(). |
|
|
Value: do { \ ast_mutex_init(&(object)->_lock); \ object->name[0] = '\0'; \ object->refcount = 1; \ } while(0)
Definition at line 265 of file astobj.h. Referenced by aji_create_buddy(), aji_create_client(), ast_netsock_bindaddr(), build_alias(), build_device(), build_peer(), build_user(), sip_register(), smdi_read(), temp_device(), and temp_peer(). |
|
|
Value: do { \ ASTOBJ_WRLOCK(object); \ (object)->objflags |= ASTOBJ_FLAG_MARKED; \ ASTOBJ_UNLOCK(object); \ } while(0)
Definition at line 242 of file astobj.h. Referenced by delete_aliases(), delete_users(), and sip_prune_realtime(). |
|
|
Lock an ASTOBJ for reading.
Definition at line 103 of file astobj.h. Referenced by _sip_show_devices(), _sip_show_peers(), aji_do_debug(), aji_filter_roster(), aji_no_debug(), aji_pruneregister(), aji_reload(), aji_show_clients(), aji_test(), ast_netsock_find(), delete_aliases(), delete_users(), get_destination(), sip_do_reload(), sip_prune_realtime(), sip_show_inuse(), sip_show_registry(), sip_show_users(), and unload_module(). |
|
|
Increment an object reference count.
Definition at line 202 of file astobj.h. Referenced by aji_act_hook(), aji_client_connect(), aji_client_info_handler(), aji_dinfo_handler(), aji_ditems_handler(), aji_filter_roster(), aji_log_hook(), aji_recv_loop(), aji_register_approve_handler(), aji_register_query_handler(), check_peer_ok(), device_ref(), gtalk_parser(), jingle_parser(), registry_addref(), sip_reg_timeout(), sip_reregister(), and transmit_register(). |
|
|
Unlock a locked object.
Definition at line 110 of file astobj.h. Referenced by _sip_show_devices(), _sip_show_peers(), aji_create_buddy(), aji_create_client(), aji_do_debug(), aji_filter_roster(), aji_handle_presence(), aji_no_debug(), aji_pruneregister(), aji_test(), ast_netsock_find(), ast_smdi_mwi_set(), ast_smdi_mwi_unset(), delete_aliases(), delete_users(), get_destination(), handle_request_subscribe(), sip_poke_all_peers(), sip_prune_realtime(), sip_send_all_registers(), sip_show_inuse(), sip_show_registry(), sip_show_users(), and unload_module(). |
|
|
Value: do { \ ASTOBJ_WRLOCK(object); \ (object)->objflags &= ~ASTOBJ_FLAG_MARKED; \ ASTOBJ_UNLOCK(object); \ } while(0)
Definition at line 252 of file astobj.h. Referenced by aji_create_buddy(), aji_create_client(), build_device(), and build_peer(). |
|
|
|
Lock an ASTOBJ for writing.
Definition at line 107 of file astobj.h. Referenced by aji_create_buddy(), aji_create_client(), aji_handle_presence(), ast_smdi_mwi_set(), ast_smdi_mwi_unset(), find_gtalk(), find_jingle(), handle_request_subscribe(), sip_poke_all_peers(), sip_send_all_registers(), and unload_module(). |