25#if defined(OPTIONAL_API) 
   47struct optional_api_user {
 
   49    ast_optional_fn *optional_ref;
 
   69#define USER_OPTIONAL_REF_CMP(ele, value) (ele->optional_ref == value) 
   70#define OPTIONAL_API_SYMNAME_CMP(ele, value) (!strcmp(ele->symname, value)) 
   77static void optional_api_user_destroy(
struct optional_api_user *
user)
 
   93static struct optional_api_user *optional_api_user_create(
 
   94    ast_optional_fn *optional_ref, ast_optional_fn stub, 
const char *module)
 
   96    struct optional_api_user *
user;
 
   97    size_t size = 
sizeof(*user) + strlen(module) + 1;
 
  106    user->optional_ref = optional_ref;
 
  108    strcpy(
user->module, module); 
 
  118static void optional_api_destroy(
struct optional_api *api)
 
  134static struct optional_api *optional_api_create(
const char *symname)
 
  136    struct optional_api *api;
 
  138    api = 
ast_calloc(1, 
sizeof(*api) + strlen(symname) + 1);
 
  146    strcpy(api->symname, symname); 
 
  158static struct optional_api *get_api(
const char *symname)
 
  160    struct optional_api **api;
 
  169    return optional_api_create(symname);
 
  181static void optional_api_user_relink(
struct optional_api_user *
user,
 
  182    struct optional_api *api)
 
  184    if (api->impl && *
user->optional_ref != api->impl) {
 
  185        *
user->optional_ref = api->impl;
 
  186    } 
else if (!api->impl && *
user->optional_ref != 
user->stub) {
 
  198static void optional_api_set_impl(
struct optional_api *api,
 
  199    ast_optional_fn impl)
 
  208        optional_api_destroy(api);
 
  212void ast_optional_api_provide(
const char *symname, ast_optional_fn impl)
 
  214    struct optional_api *api;
 
  216    api = get_api(symname);
 
  218        optional_api_set_impl(api, impl);
 
  222void ast_optional_api_unprovide(
const char *symname, ast_optional_fn impl)
 
  224    struct optional_api *api;
 
  226    api = get_api(symname);
 
  228        optional_api_set_impl(api, 0);
 
  232void ast_optional_api_use(
const char *symname, ast_optional_fn *optional_ref,
 
  233    ast_optional_fn stub, 
const char *module)
 
  235    struct optional_api_user *
user;
 
  236    struct optional_api *api;
 
  238    api = get_api(symname);
 
  243    user = optional_api_user_create(optional_ref, stub, module);
 
  250        optional_api_user_relink(
user, api);
 
  252        optional_api_user_destroy(
user);
 
  257void ast_optional_api_unuse(
const char *symname, ast_optional_fn *optional_ref,
 
  260    struct optional_api *api;
 
  262    api = get_api(symname);
 
  266            optional_api_destroy(api);
 
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()
Optional API function macros.
structure to hold users read from phoneprov_users.conf
list of users found in the config file
void DO_CRASH_NORETURN ast_do_crash(void)
Force a crash if DO_CRASH is defined.
Vector container support.
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_REMOVE_CMP_UNORDERED(vec, value, cmp, cleanup)
Remove an element from a vector that matches the given comparison.
#define AST_VECTOR_GET_CMP(vec, value, cmp)
Get an element from a vector that matches the given comparison.
#define AST_VECTOR_ELEM_DEFAULT_CMP(elem, value)
Default comparator for AST_VECTOR_REMOVE_ELEM_UNORDERED()
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
#define AST_VECTOR(name, type)
Define a vector structure.