Put something in version.h for git
[asterisk-bristuff.git] / include / asterisk.h
blob20f5aa9d4f5360d78c85c1c9412e96a63d54bfe0
1 /*
2 * Asterisk -- A telephony toolkit for Linux.
4 * General Definitions for Asterisk top level program
5 *
6 * Copyright (C) 1999-2006, Digium, Inc.
8 * Mark Spencer <markster@digium.com>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
14 /*! \file
15 * \brief Asterisk main include file. File version handling, generic pbx functions.
18 #ifndef _ASTERISK_H
19 #define _ASTERISK_H
21 #include "asterisk/autoconfig.h"
23 #if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE_AEL) && defined(MALLOC_DEBUG)
24 #include "asterisk/astmm.h"
25 #endif
27 #include "asterisk/compat.h"
29 #include "asterisk/paths.h"
31 #define DEFAULT_LANGUAGE "en"
33 #define DEFAULT_SAMPLE_RATE 8000
34 #define DEFAULT_SAMPLES_PER_MS ((DEFAULT_SAMPLE_RATE)/1000)
35 #define setpriority __PLEASE_USE_ast_set_priority_INSTEAD_OF_setpriority__
36 #define sched_setscheduler __PLEASE_USE_ast_set_priority_INSTEAD_OF_sched_setscheduler__
38 /* provided in asterisk.c */
39 extern char ast_config_AST_CONFIG_DIR[PATH_MAX];
40 extern char ast_config_AST_CONFIG_FILE[PATH_MAX];
41 extern char ast_config_AST_MODULE_DIR[PATH_MAX];
42 extern char ast_config_AST_SPOOL_DIR[PATH_MAX];
43 extern char ast_config_AST_MONITOR_DIR[PATH_MAX];
44 extern char ast_config_AST_VAR_DIR[PATH_MAX];
45 extern char ast_config_AST_DATA_DIR[PATH_MAX];
46 extern char ast_config_AST_LOG_DIR[PATH_MAX];
47 extern char ast_config_AST_AGI_DIR[PATH_MAX];
48 extern char ast_config_AST_DB[PATH_MAX];
49 extern char ast_config_AST_KEY_DIR[PATH_MAX];
50 extern char ast_config_AST_PID[PATH_MAX];
51 extern char ast_config_AST_SOCKET[PATH_MAX];
52 extern char ast_config_AST_RUN_DIR[PATH_MAX];
53 extern char ast_config_AST_CTL_PERMISSIONS[PATH_MAX];
54 extern char ast_config_AST_CTL_OWNER[PATH_MAX];
55 extern char ast_config_AST_CTL_GROUP[PATH_MAX];
56 extern char ast_config_AST_CTL[PATH_MAX];
57 extern char ast_config_AST_SYSTEM_NAME[20];
59 int ast_set_priority(int); /*!< Provided by asterisk.c */
60 int load_modules(unsigned int); /*!< Provided by loader.c */
61 int load_pbx(void); /*!< Provided by pbx.c */
62 int init_logger(void); /*!< Provided by logger.c */
63 void close_logger(void); /*!< Provided by logger.c */
64 int reload_logger(int); /*!< Provided by logger.c */
65 int init_framer(void); /*!< Provided by frame.c */
66 int ast_term_init(void); /*!< Provided by term.c */
67 int astdb_init(void); /*!< Provided by db.c */
68 void ast_channels_init(void); /*!< Provided by channel.c */
69 void ast_builtins_init(void); /*!< Provided by cli.c */
70 int dnsmgr_init(void); /*!< Provided by dnsmgr.c */
71 void dnsmgr_start_refresh(void); /*!< Provided by dnsmgr.c */
72 int dnsmgr_reload(void); /*!< Provided by dnsmgr.c */
73 void threadstorage_init(void); /*!< Provided by threadstorage.c */
74 int astobj2_init(void); /*! Provided by astobj2.c */
75 void ast_autoservice_init(void); /*!< Provided by autoservice.c */
77 /* Many headers need 'ast_channel' to be defined */
78 struct ast_channel;
80 /* Many headers need 'ast_module' to be defined */
81 struct ast_module;
83 /*!
84 * \brief Reload asterisk modules.
85 * \param name the name of the module to reload
87 * This function reloads the specified module, or if no modules are specified,
88 * it will reload all loaded modules.
90 * \note Modules are reloaded using their reload() functions, not unloading
91 * them and loading them again.
93 * \return Zero if the specified module was not found, 1 if the module was
94 * found but cannot be reloaded, -1 if a reload operation is already in
95 * progress, and 2 if the specfied module was found and reloaded.
97 int ast_module_reload(const char *name);
99 /*!
100 * \brief Register a function to be executed before Asterisk exits.
101 * \param func The callback function to use.
103 * \return Zero on success, -1 on error.
105 int ast_register_atexit(void (*func)(void));
107 /*!
108 * \brief Unregister a function registered with ast_register_atexit().
109 * \param func The callback function to unregister.
111 void ast_unregister_atexit(void (*func)(void));
113 #if !defined(LOW_MEMORY)
115 * \brief Register the version of a source code file with the core.
116 * \param file the source file name
117 * \param version the version string (typically a CVS revision keyword string)
118 * \return nothing
120 * This function should not be called directly, but instead the
121 * ASTERISK_FILE_VERSION macro should be used to register a file with the core.
123 void ast_register_file_version(const char *file, const char *version);
126 * \brief Unregister a source code file from the core.
127 * \param file the source file name
128 * \return nothing
130 * This function should not be called directly, but instead the
131 * ASTERISK_FILE_VERSION macro should be used to automatically unregister
132 * the file when the module is unloaded.
134 void ast_unregister_file_version(const char *file);
137 * \brief Register/unregister a source code file with the core.
138 * \param file the source file name
139 * \param version the version string (typically a CVS revision keyword string)
141 * This macro will place a file-scope constructor and destructor into the
142 * source of the module using it; this will cause the version of this file
143 * to registered with the Asterisk core (and unregistered) at the appropriate
144 * times.
146 * Example:
148 * \code
149 * ASTERISK_FILE_VERSION(__FILE__, "\$Revision\$")
150 * \endcode
152 * \note The dollar signs above have been protected with backslashes to keep
153 * CVS from modifying them in this file; under normal circumstances they would
154 * not be present and CVS would expand the Revision keyword into the file's
155 * revision number.
157 #ifdef MTX_PROFILE
158 #define HAVE_MTX_PROFILE /* used in lock.h */
159 #define ASTERISK_FILE_VERSION(file, version) \
160 static int mtx_prof = -1; /* profile mutex */ \
161 static void __attribute__((constructor)) __register_file_version(void) \
163 mtx_prof = ast_add_profile("mtx_lock_" file, 0); \
164 ast_register_file_version(file, version); \
166 static void __attribute__((destructor)) __unregister_file_version(void) \
168 ast_unregister_file_version(file); \
170 #else /* !MTX_PROFILE */
171 #define ASTERISK_FILE_VERSION(file, version) \
172 static void __attribute__((constructor)) __register_file_version(void) \
174 ast_register_file_version(file, version); \
176 static void __attribute__((destructor)) __unregister_file_version(void) \
178 ast_unregister_file_version(file); \
180 #endif /* !MTX_PROFILE */
181 #else /* LOW_MEMORY */
182 #define ASTERISK_FILE_VERSION(file, x)
183 #endif /* LOW_MEMORY */
185 #if !defined(LOW_MEMORY)
187 * \brief support for event profiling
189 * (note, this must be documented a lot more)
190 * ast_add_profile allocates a generic 'counter' with a given name,
191 * which can be shown with the command 'show profile <name>'
193 * The counter accumulates positive or negative values supplied by
194 * ast_add_profile(), dividing them by the 'scale' value passed in the
195 * create call, and also counts the number of 'events'.
196 * Values can also be taked by the TSC counter on ia32 architectures,
197 * in which case you can mark the start of an event calling ast_mark(id, 1)
198 * and then the end of the event with ast_mark(id, 0).
199 * For non-i386 architectures, these two calls return 0.
201 int ast_add_profile(const char *, uint64_t scale);
202 int64_t ast_profile(int, int64_t);
203 int64_t ast_mark(int, int start1_stop0);
204 #else /* LOW_MEMORY */
205 #define ast_add_profile(a, b) 0
206 #define ast_profile(a, b) do { } while (0)
207 #define ast_mark(a, b) do { } while (0)
208 #endif /* LOW_MEMORY */
210 #endif /* _ASTERISK_H */