aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk
diff options
context:
space:
mode:
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/abstract_jb.h1
-rw-r--r--include/asterisk/autoconfig.h.in81
-rw-r--r--include/asterisk/cdr.h6
-rw-r--r--include/asterisk/compiler.h28
-rw-r--r--include/asterisk/dns.h2
-rw-r--r--include/asterisk/file.h9
-rw-r--r--include/asterisk/indications.h3
-rw-r--r--include/asterisk/linkedlists.h15
-rw-r--r--include/asterisk/lock.h2
-rw-r--r--include/asterisk/module.h309
-rw-r--r--include/asterisk/monitor.h2
-rw-r--r--include/asterisk/srv.h2
-rw-r--r--include/asterisk/translate.h13
-rw-r--r--include/asterisk/utils.h10
14 files changed, 199 insertions, 284 deletions
diff --git a/include/asterisk/abstract_jb.h b/include/asterisk/abstract_jb.h
index 6cfaea924..fc2bf5c90 100644
--- a/include/asterisk/abstract_jb.h
+++ b/include/asterisk/abstract_jb.h
@@ -40,7 +40,6 @@ extern "C" {
struct ast_channel;
struct ast_frame;
-
/* Configuration flags */
enum {
AST_JB_ENABLED = (1 << 0),
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index ae041bf31..2f12438a6 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -23,12 +23,6 @@
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
-/* Define according to your operating system type. */
-#undef Darwin
-
-/* Define according to your operating system type. */
-#undef FreeBSD
-
/* Define to 1 if you have the `alarm' function. */
#undef HAVE_ALARM
@@ -51,6 +45,22 @@
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
+/* Define to 1 if your GCC C compiler supports the 'always_inline' attribute.
+ */
+#undef HAVE_ATTRIBUTE_always_inline
+
+/* Define to 1 if your GCC C compiler supports the 'const' attribute. */
+#undef HAVE_ATTRIBUTE_const
+
+/* Define to 1 if your GCC C compiler supports the 'malloc' attribute. */
+#undef HAVE_ATTRIBUTE_malloc
+
+/* Define to 1 if your GCC C compiler supports the 'pure' attribute. */
+#undef HAVE_ATTRIBUTE_pure
+
+/* Define to 1 if your GCC C compiler supports the 'unused' attribute. */
+#undef HAVE_ATTRIBUTE_unused
+
/* Define to 1 if you have the `bzero' function. */
#undef HAVE_BZERO
@@ -112,6 +122,9 @@
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
+/* Define to indicate the ${GNUTLS_DESCRIP} library */
+#undef HAVE_GNUTLS
+
/* Define to indicate the GSM library */
#undef HAVE_GSM
@@ -137,6 +150,9 @@
/* Define to 1 if you have the `isascii' function. */
#undef HAVE_ISASCII
+/* Define to indicate the ${ISDNNET_DESCRIP} library */
+#undef HAVE_ISDNNET
+
/* Define to 1 if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
@@ -152,10 +168,6 @@
/* Define to 1 if you have the `localtime_r' function. */
#undef HAVE_LOCALTIME_R
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#undef HAVE_MALLOC
-
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
@@ -171,6 +183,9 @@
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
+/* Define to indicate the ${MISDN_DESCRIP} library */
+#undef HAVE_MISDN
+
/* Define to 1 if you have the `mkdir' function. */
#undef HAVE_MKDIR
@@ -243,13 +258,12 @@
/* Define to indicate the ${RADIUS_DESCRIP} library */
#undef HAVE_RADIUS
-/* Define to 1 if your system has a GNU libc compatible `realloc' function,
- and to 0 otherwise. */
-#undef HAVE_REALLOC
-
/* Define to 1 if you have the `regcomp' function. */
#undef HAVE_REGCOMP
+/* Define to 1 if your system has the re-entrant resolver functions. */
+#undef HAVE_RES_NINIT
+
/* Define to 1 if you have the `re_comp' function. */
#undef HAVE_RE_COMP
@@ -351,6 +365,9 @@
/* Define to 1 if `st_blksize' is member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
+/* Define to indicate the ${SUPPSERV_DESCRIP} library */
+#undef HAVE_SUPPSERV
+
/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
@@ -456,15 +473,6 @@
slash. */
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
-/* Define according to your operating system type. */
-#undef Linux
-
-/* Define according to your operating system type. */
-#undef NetBSD
-
-/* Define according to your operating system type. */
-#undef OpenBSD
-
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
@@ -480,18 +488,6 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
-/* Define this to be the name of the CPU of your system. */
-#undef PBX_CPU
-
-/* Define this to be the name of the OS of your system. */
-#undef PBX_OS
-
-/* Define this to be the canonical name (cpu-vendor-os) of your system. */
-#undef PBX_PLATFORM
-
-/* Define this to be the name of the vendor of your system. */
-#undef PBX_VENDOR
-
/* Define to 1 if the C compiler supports function prototypes. */
#undef PROTOTYPES
@@ -526,21 +522,12 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* Define according to your operating system type. */
-#undef SunOS
-
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
-/* Define according to your operating system type. */
-#undef Unix
-
-/* Define according to your operating system type. */
-#undef Win32
-
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
@@ -570,9 +557,6 @@
#undef inline
#endif
-/* Define to rpl_malloc if the replacement function should be used. */
-#undef malloc
-
/* Define to `int' if <sys/types.h> does not define. */
#undef mode_t
@@ -582,9 +566,6 @@
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
-/* Define to rpl_realloc if the replacement function should be used. */
-#undef realloc
-
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h
index 33413bc34..e6fbe96ff 100644
--- a/include/asterisk/cdr.h
+++ b/include/asterisk/cdr.h
@@ -47,8 +47,6 @@
#include "asterisk/channel.h"
#include "asterisk/utils.h"
-struct ast_channel;
-
/*! Responsible for call detail data */
struct ast_cdr {
/*! Caller*ID with text */
@@ -145,14 +143,14 @@ int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan);
* Used to register a Call Detail Record handler.
* Returns -1 on error, 0 on success.
*/
-int ast_cdr_register(char *name, char *desc, ast_cdrbe be);
+int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be);
/*! Unregister a CDR handling engine */
/*!
* \param name name of CDR handler to unregister
* Unregisters a CDR by it's name
*/
-void ast_cdr_unregister(char *name);
+void ast_cdr_unregister(const char *name);
/*! Start a call */
/*!
diff --git a/include/asterisk/compiler.h b/include/asterisk/compiler.h
index 575a1b2d3..a6e08f92d 100644
--- a/include/asterisk/compiler.h
+++ b/include/asterisk/compiler.h
@@ -23,16 +23,34 @@
#ifndef _ASTERISK_COMPILER_H
#define _ASTERISK_COMPILER_H
-#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
-#define __builtin_expect(exp, c) (exp)
-#define force_inline inline
-#define attribute_pure
-#else
+#if HAVE_ATTRIBUTE_always_inline
#define force_inline inline __attribute__((always_inline))
+#else
+#define force_inline inline
+#endif
+
+#if HAVE_ATTRIBUTE_pure
#define attribute_pure __attribute__((pure))
+#else
+#define attribute_pure
#endif
+#if HAVE_ATTRIBUTE_const
#define attribute_const __attribute__((const))
+#else
+#define attribute_const
+#endif
+
+#if HAVE_ATTRIBUTE_unused
#define attribute_unused __attribute__((unused))
+#else
+#define attribute_unused
+#endif
+
+#if HAVE_ATTRIBUTE_malloc
+#define attribute_malloc __attribute__((malloc))
+#else
+#define attribute_malloc
+#endif
#endif /* _ASTERISK_COMPILER_H */
diff --git a/include/asterisk/dns.h b/include/asterisk/dns.h
index 60209509d..64cf68c10 100644
--- a/include/asterisk/dns.h
+++ b/include/asterisk/dns.h
@@ -24,8 +24,6 @@
#ifndef _ASTERISK_DNS_H
#define _ASTERISK_DNS_H
-struct ast_channel;
-
/*! \brief Perform DNS lookup (used by DNS, enum and SRV lookups)
\param context
\param dname Domain name to lookup (host, SRV domain, TXT record name)
diff --git a/include/asterisk/file.h b/include/asterisk/file.h
index 2c2517e42..bf7efef89 100644
--- a/include/asterisk/file.h
+++ b/include/asterisk/file.h
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
*
@@ -106,7 +106,7 @@ struct ast_format {
int buf_size; /*! size of frame buffer, if any, aligned to 8 bytes. */
int desc_size; /*! size of private descriptor, if any */
- struct module_symbols *module;
+ struct ast_module *module;
};
/*
@@ -138,10 +138,11 @@ struct ast_filestream {
#define SEEK_FORCECUR 10
/*! Register a new file format capability
- * Adds a format to asterisk's format abilities.
+ * Adds a format to Asterisk's format abilities.
* returns 0 on success, -1 on failure
*/
-int ast_format_register(const struct ast_format *f);
+int __ast_format_register(const struct ast_format *f, struct ast_module *mod);
+#define ast_format_register(f) __ast_format_register(f, ast_module_info->self)
/*! Unregisters a file format */
/*!
diff --git a/include/asterisk/indications.h b/include/asterisk/indications.h
index 188baa29b..a6c1d7c9d 100644
--- a/include/asterisk/indications.h
+++ b/include/asterisk/indications.h
@@ -34,9 +34,6 @@
#include "asterisk/lock.h"
-/* forward reference */
-struct ast_channel;
-
struct tone_zone_sound {
struct tone_zone_sound *next; /* next element */
const char *name; /* Identifing name */
diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h
index bef63e0c0..fe09610ff 100644
--- a/include/asterisk/linkedlists.h
+++ b/include/asterisk/linkedlists.h
@@ -28,7 +28,7 @@
*/
/*!
- \brief Attempts to lock a list.
+ \brief Locks a list.
\param head This is a pointer to the list head structure
This macro attempts to place an exclusive lock in the
@@ -39,6 +39,17 @@
ast_mutex_lock(&(head)->lock)
/*!
+ \brief Locks a list, without blocking if the list is locked.
+ \param head This is a pointer to the list head structure
+
+ This macro attempts to place an exclusive lock in the
+ list head structure pointed to by head.
+ Returns non-zero on success, 0 on failure
+*/
+#define AST_LIST_TRYLOCK(head) \
+ ast_mutex_trylock(&(head)->lock)
+
+/*!
\brief Attempts to unlock a list.
\param head This is a pointer to the list head structure
@@ -209,7 +220,7 @@ struct { \
/*!
\brief Returns the last entry contained in a list.
- \param head This is a pointer to the list tail structure
+ \param head This is a pointer to the list head structure
*/
#define AST_LIST_LAST(head) ((head)->last)
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index 3ffb32e8e..c38f77c27 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -815,8 +815,6 @@ AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
#define ast_channel_trylock(x) ast_mutex_trylock(&x->lock)
#else
-struct ast_channel;
-
/*! \brief Lock AST channel (and print debugging output)
\note You need to enable DEBUG_CHANNEL_LOCKS for this function */
int ast_channel_lock(struct ast_channel *chan);
diff --git a/include/asterisk/module.h b/include/asterisk/module.h
index 2b94bae26..4ce6e9460 100644
--- a/include/asterisk/module.h
+++ b/include/asterisk/module.h
@@ -4,6 +4,8 @@
* Copyright (C) 1999 - 2006, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
+ * Kevin P. Fleming <kpfleming@digium.com>
+ * Luigi Rizzo <rizzo@icir.org>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
@@ -26,19 +28,12 @@
#ifndef _ASTERISK_MODULE_H
#define _ASTERISK_MODULE_H
-#ifdef STATIC_MODULE
-#error STATIC_MODULE should not be defined
-#endif
-#define STATIC_MODULE --- this is an error
-#define LOCAL_USER_DECL /* --- this is an error --- */
-
#include "asterisk/utils.h"
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
-
/*! \brief The text the key() function should return. */
#define ASTERISK_GPL_KEY \
"This paragraph is copyright (c) 2006 by Digium, Inc. \
@@ -55,24 +50,31 @@ express written permission of Digium, Inc. is prohibited.\n"
#define AST_MODULE_CONFIG "modules.conf" /*!< \brief Module configuration file */
-enum unload_mode {
- AST_FORCE_SOFT = 0, /*! Softly unload a module, only if not in use */
- AST_FORCE_FIRM = 1, /*! Firmly unload a module, even if in use */
- AST_FORCE_HARD = 2, /*! as FIRM, plus dlclose() on the module. Not recommended
+enum ast_module_unload_mode {
+ AST_FORCE_SOFT = 0, /*!< Softly unload a module, only if not in use */
+ AST_FORCE_FIRM = 1, /*!< Firmly unload a module, even if in use */
+ AST_FORCE_HARD = 2, /*!< as FIRM, plus dlclose() on the module. Not recommended
as it may cause crashes */
};
+enum ast_module_load_result {
+ AST_MODULE_LOAD_SUCCESS = 0, /*!< Module loaded and configured */
+ AST_MODULE_LOAD_DECLINE = 1, /*!< Module is not configured */
+ AST_MODULE_LOAD_SKIP = 2, /*!< Module was skipped for some reason */
+ AST_MODULE_LOAD_FAILURE = -1, /*!< Module could not be loaded properly */
+};
+
/*!
* \brief Load a module.
- * \param resource_name The filename of the module to load.
+ * \param resource_name The name of the module to load.
*
* This function is run by the PBX to load the modules. It performs
* all loading and initilization tasks. Basically, to load a module, just
* give it the name of the module and it will do the rest.
*
- * \return Zero on success, -1 on error.
+ * \return See possible enum values for ast_module_load_result.
*/
-int ast_load_resource(const char *resource_name);
+enum ast_module_load_result ast_load_resource(const char *resource_name);
/*!
* \brief Unloads a module.
@@ -82,11 +84,11 @@ int ast_load_resource(const char *resource_name);
* This function unloads a module. It will only unload modules that are not in
* use (usecount not zero), unless #AST_FORCE_FIRM or #AST_FORCE_HARD is
* specified. Setting #AST_FORCE_FIRM or #AST_FORCE_HARD will unload the
- * module regardless of consequences (NOT_RECOMMENDED).
+ * module regardless of consequences (NOT RECOMMENDED).
*
* \return Zero on success, -1 on error.
*/
-int ast_unload_resource(const char *resource_name, enum unload_mode);
+int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode);
/*!
* \brief Notify when usecount has been changed.
@@ -150,208 +152,123 @@ int ast_loader_unregister(int (*updater)(void));
*/
char *ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, int needsreload);
-/* Local user routines keep track of which channels are using a given module
- resource. They can help make removing modules safer, particularly if
- they're in use at the time they have been requested to be removed */
+/* Opaque type for module handles generated by the loader */
-struct localuser {
- struct localuser *next;
- struct ast_channel *chan;
-};
+struct ast_module;
-struct module_symbols; /* forward declaration */
-struct localuser *ast_localuser_add(struct module_symbols *, struct ast_channel *);
-void ast_localuser_remove(struct module_symbols *, struct localuser *);
-void ast_hangup_localusers(struct module_symbols *);
+/* User count routines keep track of which channels are using a given module
+ resource. They can help make removing modules safer, particularly if
+ they're in use at the time they have been requested to be removed */
-/* XXX deprecated macros, only for backward compatibility */
-#define LOCAL_USER_ADD(u) do { u = ast_localuser_add(__mod_desc, chan); } while (0)
-#define LOCAL_USER_REMOVE(u) ast_localuser_remove(__mod_desc, u)
-#define STANDARD_HANGUP_LOCALUSERS ast_hangup_localusers(__mod_desc)
+struct ast_module_user;
+struct ast_module_user_list;
/*! \page ModMngmnt The Asterisk Module management interface
- * \par The following is part of the new module management code.
*
* All modules must implement the module API (load, unload...)
* whose functions are exported through fields of a "struct module_symbol";
- *
- * Modules exporting extra symbols (data or functions), should list
- * them into an array of struct symbol_entry:
- * struct symbol_entry exported_symbols[]
- * of symbols, with a NULL name on the last entry
- *
- * Functions should be added with MOD_FUNC(name),
- * data structures with MOD_DATA(_name).
- * The array in turn is referenced by struct module_symbols.
- * (Typically, a module will export only a single symbol, which points
- * to a record containing all the methods. This is the API of the module,
- * and should be known to the module's clients as well.
- *
- * \par Connections to symbols in other modules
- * Modules that require symbols supplied by other modules should
- * provide an array
- * struct symbol_entry required_symbols[]
- * of symbols, with a NULL name on the last entry, containing the
- * name of the desired symbol.
- * For good measure, we also provide the size in both caller and calle
- * to figure out if there is a mismatch (not terribly useful because most
- * objects are a single word, but still... )
- * The symbol can be added to the array with MOD_WANT(symbol) macro.
- * required_symbols is also pointed by through struct module_symbols.
- *
- * Typically, the whole interface exported by a module should be
- * in a single structure named after the module, as follows.
- * Say the module high level name is 'foo', then we should have
- * - in include/asterisk/foo.h
- * struct foo_interface {
- * int (*f)(int, char *); -- first function exported
- * const char (*g)(int); -- second function exported
- * char *buf;
- * ... -- other fields
- * }
- * - in the module exporting the interface, e.g. res/res_foo.c
- * static int f(int, char *);
- * static const char *g(int);
- * const char buf[BUFSZ];
- * struct foo_interface foo = {
- * .f = f,
- * .g = g,
- * .buf = buf,
- * }
- *
- * \note NOTE: symbol names are 'global' in this module namespace, so it
- * will be wiser to name exported symbols with a prefix indicating the module
- * supplying it, e.g. foo_f, foo_g, foo_buf. Internally to the module,
- * symbols are still static so they can keep short and meaningful names.
- * The macros MOD_FIELD and METHOD_BASE() below help setting these entries.
- *
- * MOD_FIELD(f1), -- field and function name are the same
- * METHOD_BASE(foo_, f1), -- field and function name differ by a prefix
- * .f1 = function_name, -- generic case
- * }
- *
- * Note that the loader requires that no fields of exported_symbols
- * are NULL, because that is used as an indication of the end of the array.
- *
- * \par Module states
- * Modules can be in a number of different states, as below:
- * - \b MS_FAILED attempt to load failed. This is final.
- * - \b MS_NEW just added to the list, symbols unresolved.
- * - \b MS_RESOLVED all symbols resolved, but supplier modules not active yet.
- * - \b MS_CANLOAD all symbols resolved and suppliers are all active
- * (or we are in a cyclic dependency and we are breaking a loop)
- * - \b MS_ACTIVE load() returned successfully.
- *
- *
- * \par Module Types
- * For backward compatibility, we have 3 types of loadable modules:
- *
- * - \b MOD_0 these are the 'old style' modules, which export a number
- * of callbacks, and their full interface, as globally visible
- * symbols. The module needs to be loaded with RTLD_LAZY and
- * RTLD_GLOBAL to make symbols visible to other modules, and
- * to avoid load failures due to cross dependencies.
- *
- * - \b MOD_1 almost as above, but the generic callbacks are all into a
- * a structure, mod_data. Same load requirements as above.
- *
- * - \b MOD_2 this is the 'new style' format for modules. The module must
- * explictly declare which simbols are exported and which
- * symbols from other modules are used, and the code in this
- * loader will implement appropriate checks to load the modules
- * in the correct order. Also this allows to load modules
- * with RTLD_NOW and RTLD_LOCAL so there is no chance of run-time
- * bugs due to unresolved symbols or name conflicts.
*/
-struct symbol_entry {
- const char *name;
- void *value;
- int size;
- struct module *src; /* module sourcing it, filled by loader */
+enum ast_module_flags {
+ AST_MODFLAG_DEFAULT = 0,
+ AST_MODFLAG_GLOBAL_SYMBOLS = (1 << 0),
};
-/*
- * Constructors for symbol_entry values
- */
-#define MOD_FUNC(f) { .name = #f, .value = f, .size = sizeof(f) }
-#define MOD_DATA(d) { .name = #d, .value = &d, .size = sizeof(_name) }
-#define MOD_WANT(s) { .name = #s, .value = &s, 0 } /* required symbols */
+struct ast_module_info {
-/*
- * Constructors for fields of foo_interface
- */
-#define MOD_FIELD(f) . ## f = f
-#define METHOD_BASE(_base, _name) . ## _name = _base ## _name
+ /* The 'self' pointer for a module; it will be set by the loader before
+ it calls the module's load_module() entrypoint, and used by various
+ other macros that need to identify the module.
+ */
-/*
- * Each 'registerable' entity has a pointer in the
- * struct ast_registry, which points to an array of objects of
- * the same type. The ast_*_register() function will be able to
- * derive the size of these entries.
- */
-struct ast_registry {
- struct ast_cli_entry *clis;
-};
+ struct ast_module *self;
+ enum ast_module_load_result (*load)(void); /* register stuff etc. Optional. */
+ int (*reload)(void); /* config etc. Optional. */
+ int (*unload)(void); /* unload. called with the module locked */
+ const char *name; /* name of the module for loader reference and CLI commands */
+ const char *description; /* user friendly description of the module. */
-struct module_symbols {
- /* load, reload and unload receive as argument a pointer to a module descriptor
- * to be stored locally and used for local calls and so on.
- * They all return 0 on success, non zero (-1) on failure.
+ /*!
+ * This holds the ASTERISK_GPL_KEY, signifiying that you agree to the terms of
+ * the Asterisk license as stated in the ASTERISK_GPL_KEY. Your module will not
+ * load if it does not return the EXACT key string.
*/
- int (*load_module)(void *); /* register stuff etc. Optional. */
+ const char *key;
+ unsigned int flags;
+};
- int (*reload)(void *); /* reload config etc. Optional. */
+void ast_module_register(const struct ast_module_info *);
+void ast_module_unregister(const struct ast_module_info *);
- int (*unload_module)(void *); /* unload. called with the module locked */
+struct ast_module_user *__ast_module_user_add(struct ast_module *, struct ast_channel *);
+void __ast_module_user_remove(struct ast_module *, struct ast_module_user *);
+void __ast_module_user_hangup_all(struct ast_module *);
- const char *(*description)(void); /* textual id of the module. */
+#define ast_module_user_add(chan) __ast_module_user_add(ast_module_info->self, chan)
+#define ast_module_user_remove(user) __ast_module_user_remove(ast_module_info->self, user)
+#define ast_module_user_hangup_all() __ast_module_user_hangup_all(ast_module_info->self)
- /*!
- * This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of
- * the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does
- * not return the EXACT message:
- */
- const char *(*key)(void); /*! the asterisk key */
-
- enum module_flags {
- MOD_0 = 0x0, /* old module style */
- MOD_1 = 0x1, /* old style, but symbols here */
- MOD_2 = 0x2, /* new style, exported symbols */
- MOD_MASK = 0xf, /* mask for module types */
- NO_USECOUNT = 0x10, /* do not track usecount */
- NO_UNLOAD = 0x20, /* only forced unload allowed */
- DO_LOCALUSERS = 0x40, /* track localusers */
- } flags;
- /* the following two fields should go in the astobj. */
- ast_mutex_t lock;
- int usecnt; /* number of active clients */
-
- /* list of clients */
- struct localuser *lu_head;
- struct ast_registry *reg; /* list of things to register. */
- struct symbol_entry *exported_symbols;
- struct symbol_entry *required_symbols;
-};
-
-#ifndef MOD_LOADER /* the loader does not use these */
-struct module_symbols mod_data; /* forward declaration */
-static struct module_symbols *__mod_desc __attribute__ ((__unused__)) = &mod_data; /* used by localuser */
-
-#define STD_MOD(t, reload_fn, exp, req) \
-struct module_symbols mod_data = { \
- .load_module = load_module, \
- .unload_module = unload_module, \
- .description = description, \
- .key = key, \
- .reload = reload_fn, \
- .flags = t, \
- .exported_symbols = exp, \
- .required_symbols = req \
-};
+struct ast_module *ast_module_ref(struct ast_module *);
+void ast_module_unref(struct ast_module *);
-#define STD_MOD1 STD_MOD(MOD_1, NULL, NULL, NULL)
+#if defined(__cplusplus) || defined(c_plusplus)
+#define AST_MODULE_INFO(keystr, flags_to_set, desc, load_func, unload_func, reload_func) \
+ static struct ast_module_info __mod_info = { \
+ NULL, \
+ load_func, \
+ unload_func, \
+ reload_func, \
+ AST_MODULE, \
+ desc, \
+ keystr, \
+ flags_to_set \
+ }; \
+ static void __attribute__ ((constructor)) __reg_module(void) \
+ { \
+ ast_module_register(&__mod_info); \
+ } \
+ static void __attribute__ ((destructor)) __unreg_module(void) \
+ { \
+ ast_module_unregister(&__mod_info); \
+ } \
+ const static __attribute__((unused)) struct ast_module_info *ast_module_info = &__mod_info
+
+#define AST_MODULE_INFO_STANDARD(keystr, desc) \
+ AST_MODULE_INFO(keystr, AST_MODFLAG_DEFAULT, desc, \
+ load_module, \
+ unload_module, \
+ NULL \
+ )
+#else
+/* forward declare this pointer in modules, so that macro/function
+ calls that need it can get it, since it will actually be declared
+ and populated at the end of the module's source file... */
+const static __attribute__((unused)) struct ast_module_info *ast_module_info;
+
+#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...) \
+ static struct ast_module_info __mod_info = { \
+ .name = AST_MODULE, \
+ .flags = flags_to_set, \
+ .description = desc, \
+ .key = keystr, \
+ fields \
+ }; \
+ static void __attribute__ ((constructor)) __reg_module(void) \
+ { \
+ ast_module_register(&__mod_info); \
+ } \
+ static void __attribute__ ((destructor)) __unreg_module(void) \
+ { \
+ ast_module_unregister(&__mod_info); \
+ } \
+ const static struct ast_module_info *ast_module_info = &__mod_info
+
+#define AST_MODULE_INFO_STANDARD(keystr, desc) \
+ AST_MODULE_INFO(keystr, AST_MODFLAG_DEFAULT, desc, \
+ .load = load_module, \
+ .unload = unload_module, \
+ )
#endif
#if defined(__cplusplus) || defined(c_plusplus)
diff --git a/include/asterisk/monitor.h b/include/asterisk/monitor.h
index d55a761ec..7cddaf56b 100644
--- a/include/asterisk/monitor.h
+++ b/include/asterisk/monitor.h
@@ -25,8 +25,6 @@
#include "asterisk/channel.h"
-struct ast_channel;
-
enum AST_MONITORING_STATE {
AST_MONITOR_RUNNING,
AST_MONITOR_PAUSED
diff --git a/include/asterisk/srv.h b/include/asterisk/srv.h
index 08dcac0f2..2a98c69f6 100644
--- a/include/asterisk/srv.h
+++ b/include/asterisk/srv.h
@@ -23,8 +23,6 @@
#ifndef _ASTERISK_SRV_H
#define _ASTERISK_SRV_H
-struct ast_channel;
-
/*!
\file srv.h
\brief Support for DNS SRV records, used in to locate SIP services.
diff --git a/include/asterisk/translate.h b/include/asterisk/translate.h
index ed6f6275b..07c0ae1c2 100644
--- a/include/asterisk/translate.h
+++ b/include/asterisk/translate.h
@@ -101,13 +101,13 @@ struct ast_translator {
*/
int buf_size;
- int desc_size; /*!< size of private descriptor in pvt->pvt, if any */
- int plc_samples; /*!< set to the plc block size if used, 0 otherwise */
- int useplc; /*!< current status of plc, changed at runtime */
+ int desc_size; /*!< size of private descriptor in pvt->pvt, if any */
+ int plc_samples; /*!< set to the plc block size if used, 0 otherwise */
+ int useplc; /*!< current status of plc, changed at runtime */
- void *module; /*!< opaque reference to the parent module */
+ struct ast_module *module; /* opaque reference to the parent module */
- int cost; /*!< Cost in milliseconds for encoding/decoding 1 second of sound */
+ int cost; /*!< Cost in milliseconds for encoding/decoding 1 second of sound */
AST_LIST_ENTRY(ast_translator) list; /*!< link field */
};
@@ -155,7 +155,8 @@ struct ast_trans_pvt;
* \param module handle to the module that owns this translator
* \return 0 on success, -1 on failure
*/
-int ast_register_translator(struct ast_translator *t, void *module);
+int __ast_register_translator(struct ast_translator *t, struct ast_module *module);
+#define ast_register_translator(t) __ast_register_translator(t, ast_module_info->self)
/*!
* \brief Unregister a translator
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index ea8b352fb..d037e9991 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -303,7 +303,7 @@ static void ast_free(void *ptr)
_ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
AST_INLINE_API(
-void * __attribute__((malloc)) _ast_malloc(size_t len, const char *file, int lineno, const char *func),
+void * attribute_malloc _ast_malloc(size_t len, const char *file, int lineno, const char *func),
{
void *p;
@@ -328,7 +328,7 @@ void * __attribute__((malloc)) _ast_malloc(size_t len, const char *file, int lin
_ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
AST_INLINE_API(
-void * __attribute__((malloc)) _ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func),
+void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func),
{
void *p;
@@ -353,7 +353,7 @@ void * __attribute__((malloc)) _ast_calloc(size_t num, size_t len, const char *f
_ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
AST_INLINE_API(
-void * __attribute__((malloc)) _ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
+void * attribute_malloc _ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
{
void *newp;
@@ -382,7 +382,7 @@ void * __attribute__((malloc)) _ast_realloc(void *p, size_t len, const char *fil
_ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)
AST_INLINE_API(
-char * __attribute__((malloc)) _ast_strdup(const char *str, const char *file, int lineno, const char *func),
+char * attribute_malloc _ast_strdup(const char *str, const char *file, int lineno, const char *func),
{
char *newstr = NULL;
@@ -413,7 +413,7 @@ char * __attribute__((malloc)) _ast_strdup(const char *str, const char *file, in
_ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
AST_INLINE_API(
-char * __attribute__((malloc)) _ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func),
+char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func),
{
char *newstr = NULL;