Sat Nov 1 06:28:23 2008

Asterisk developer's documentation


asterisk.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- A telephony toolkit for Linux.
00003  *
00004  * General Definitions for Asterisk top level program
00005  * 
00006  * Copyright (C) 1999-2006, Digium, Inc.
00007  *
00008  * Mark Spencer <markster@digium.com>
00009  *
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License
00012  */
00013 
00014 /*! \file
00015  * \brief Asterisk main include file. File version handling, generic pbx functions.
00016  */
00017 
00018 #ifndef _ASTERISK_H
00019 #define _ASTERISK_H
00020 
00021 #include "asterisk/autoconfig.h"
00022 
00023 #if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE_AEL) && defined(MALLOC_DEBUG)
00024 #include "asterisk/astmm.h"
00025 #endif
00026 
00027 #include "asterisk/compat.h"
00028 
00029 #include "asterisk/paths.h"
00030 
00031 #define DEFAULT_LANGUAGE "en"
00032 
00033 #define DEFAULT_SAMPLE_RATE 8000
00034 #define DEFAULT_SAMPLES_PER_MS  ((DEFAULT_SAMPLE_RATE)/1000)
00035 #define  setpriority __PLEASE_USE_ast_set_priority_INSTEAD_OF_setpriority__
00036 #define  sched_setscheduler   __PLEASE_USE_ast_set_priority_INSTEAD_OF_sched_setscheduler__
00037 
00038 /* provided in asterisk.c */
00039 extern char ast_config_AST_CONFIG_DIR[PATH_MAX];
00040 extern char ast_config_AST_CONFIG_FILE[PATH_MAX];
00041 extern char ast_config_AST_MODULE_DIR[PATH_MAX];
00042 extern char ast_config_AST_SPOOL_DIR[PATH_MAX];
00043 extern char ast_config_AST_MONITOR_DIR[PATH_MAX];
00044 extern char ast_config_AST_VAR_DIR[PATH_MAX];
00045 extern char ast_config_AST_DATA_DIR[PATH_MAX];
00046 extern char ast_config_AST_LOG_DIR[PATH_MAX];
00047 extern char ast_config_AST_AGI_DIR[PATH_MAX];
00048 extern char ast_config_AST_DB[PATH_MAX];
00049 extern char ast_config_AST_KEY_DIR[PATH_MAX];
00050 extern char ast_config_AST_PID[PATH_MAX];
00051 extern char ast_config_AST_SOCKET[PATH_MAX];
00052 extern char ast_config_AST_RUN_DIR[PATH_MAX];
00053 extern char ast_config_AST_CTL_PERMISSIONS[PATH_MAX];
00054 extern char ast_config_AST_CTL_OWNER[PATH_MAX];
00055 extern char ast_config_AST_CTL_GROUP[PATH_MAX];
00056 extern char ast_config_AST_CTL[PATH_MAX];
00057 extern char ast_config_AST_SYSTEM_NAME[20];
00058 
00059 int ast_set_priority(int);       /*!< Provided by asterisk.c */
00060 int load_modules(unsigned int);        /*!< Provided by loader.c */
00061 int load_pbx(void);           /*!< Provided by pbx.c */
00062 int init_logger(void);           /*!< Provided by logger.c */
00063 void close_logger(void);         /*!< Provided by logger.c */
00064 int reload_logger(int);          /*!< Provided by logger.c */
00065 int init_framer(void);           /*!< Provided by frame.c */
00066 int ast_term_init(void);         /*!< Provided by term.c */
00067 int astdb_init(void);            /*!< Provided by db.c */
00068 void ast_channels_init(void);       /*!< Provided by channel.c */
00069 void ast_builtins_init(void);       /*!< Provided by cli.c */
00070 int dnsmgr_init(void);           /*!< Provided by dnsmgr.c */ 
00071 void dnsmgr_start_refresh(void);    /*!< Provided by dnsmgr.c */
00072 int dnsmgr_reload(void);         /*!< Provided by dnsmgr.c */
00073 void threadstorage_init(void);         /*!< Provided by threadstorage.c */
00074 int astobj2_init(void);          /*! Provided by astobj2.c */
00075 void ast_autoservice_init(void);    /*!< Provided by autoservice.c */
00076 
00077 /* Many headers need 'ast_channel' to be defined */
00078 struct ast_channel;
00079 
00080 /* Many headers need 'ast_module' to be defined */
00081 struct ast_module;
00082 
00083 /*!
00084  * \brief Reload asterisk modules.
00085  * \param name the name of the module to reload
00086  *
00087  * This function reloads the specified module, or if no modules are specified,
00088  * it will reload all loaded modules.
00089  *
00090  * \note Modules are reloaded using their reload() functions, not unloading
00091  * them and loading them again.
00092  * 
00093  * \return Zero if the specified module was not found, 1 if the module was
00094  * found but cannot be reloaded, -1 if a reload operation is already in
00095  * progress, and 2 if the specfied module was found and reloaded.
00096  */
00097 int ast_module_reload(const char *name);
00098 
00099 /*!
00100  * \brief Register a function to be executed before Asterisk exits.
00101  * \param func The callback function to use.
00102  *
00103  * \return Zero on success, -1 on error.
00104  */
00105 int ast_register_atexit(void (*func)(void));
00106 
00107 /*!   
00108  * \brief Unregister a function registered with ast_register_atexit().
00109  * \param func The callback function to unregister.   
00110  */
00111 void ast_unregister_atexit(void (*func)(void));
00112 
00113 #if !defined(LOW_MEMORY)
00114 /*!
00115  * \brief Register the version of a source code file with the core.
00116  * \param file the source file name
00117  * \param version the version string (typically a CVS revision keyword string)
00118  * \return nothing
00119  *
00120  * This function should not be called directly, but instead the
00121  * ASTERISK_FILE_VERSION macro should be used to register a file with the core.
00122  */
00123 void ast_register_file_version(const char *file, const char *version);
00124 
00125 /*!
00126  * \brief Unregister a source code file from the core.
00127  * \param file the source file name
00128  * \return nothing
00129  *
00130  * This function should not be called directly, but instead the
00131  * ASTERISK_FILE_VERSION macro should be used to automatically unregister
00132  * the file when the module is unloaded.
00133  */
00134 void ast_unregister_file_version(const char *file);
00135 
00136 /*!
00137  * \brief Register/unregister a source code file with the core.
00138  * \param file the source file name
00139  * \param version the version string (typically a CVS revision keyword string)
00140  *
00141  * This macro will place a file-scope constructor and destructor into the
00142  * source of the module using it; this will cause the version of this file
00143  * to registered with the Asterisk core (and unregistered) at the appropriate
00144  * times.
00145  *
00146  * Example:
00147  *
00148  * \code
00149  * ASTERISK_FILE_VERSION(__FILE__, "\$Revision\$")
00150  * \endcode
00151  *
00152  * \note The dollar signs above have been protected with backslashes to keep
00153  * CVS from modifying them in this file; under normal circumstances they would
00154  * not be present and CVS would expand the Revision keyword into the file's
00155  * revision number.
00156  */
00157 #ifdef MTX_PROFILE
00158 #define  HAVE_MTX_PROFILE  /* used in lock.h */
00159 #define ASTERISK_FILE_VERSION(file, version) \
00160    static int mtx_prof = -1;       /* profile mutex */   \
00161    static void __attribute__((constructor)) __register_file_version(void) \
00162    { \
00163       mtx_prof = ast_add_profile("mtx_lock_" file, 0);   \
00164       ast_register_file_version(file, version); \
00165    } \
00166    static void __attribute__((destructor)) __unregister_file_version(void) \
00167    { \
00168       ast_unregister_file_version(file); \
00169    }
00170 #else /* !MTX_PROFILE */
00171 #define ASTERISK_FILE_VERSION(file, version) \
00172    static void __attribute__((constructor)) __register_file_version(void) \
00173    { \
00174       ast_register_file_version(file, version); \
00175    } \
00176    static void __attribute__((destructor)) __unregister_file_version(void) \
00177    { \
00178       ast_unregister_file_version(file); \
00179    }
00180 #endif /* !MTX_PROFILE */
00181 #else /* LOW_MEMORY */
00182 #define ASTERISK_FILE_VERSION(file, x)
00183 #endif /* LOW_MEMORY */
00184 
00185 #if !defined(LOW_MEMORY)
00186 /*!
00187  * \brief support for event profiling
00188  *
00189  * (note, this must be documented a lot more)
00190  * ast_add_profile allocates a generic 'counter' with a given name,
00191  * which can be shown with the command 'show profile <name>'
00192  *
00193  * The counter accumulates positive or negative values supplied by
00194  * ast_add_profile(), dividing them by the 'scale' value passed in the
00195  * create call, and also counts the number of 'events'.
00196  * Values can also be taked by the TSC counter on ia32 architectures,
00197  * in which case you can mark the start of an event calling ast_mark(id, 1)
00198  * and then the end of the event with ast_mark(id, 0).
00199  * For non-i386 architectures, these two calls return 0.
00200  */
00201 int ast_add_profile(const char *, uint64_t scale);
00202 int64_t ast_profile(int, int64_t);
00203 int64_t ast_mark(int, int start1_stop0);
00204 #else /* LOW_MEMORY */
00205 #define ast_add_profile(a, b) 0
00206 #define ast_profile(a, b) do { } while (0)
00207 #define ast_mark(a, b) do { } while (0)
00208 #endif /* LOW_MEMORY */
00209 
00210 #endif /* _ASTERISK_H */

Generated on Sat Nov 1 06:28:23 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.1