Codename Pineapple

Home page | Mailing list | Docs

Last updated: Sat Feb 3 05:00:32 2007

Asterisk developer's documentation :: Codename Pineapple


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

Asterisk is a trademark for Digium, inc.. | Edvina.net | Asterisk.org | This documentation was generated with Doxygen