2 * Asterisk -- A telephony toolkit for Linux.
4 * General Definitions for Asterisk top level program
6 * Copyright (C) 1999-2005, Mark Spencer
8 * Mark Spencer <markster@digium.com>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
15 * \brief Asterisk main include file. File version handling, generic pbx functions.
18 #include "asterisk/compat.h"
23 #define DEFAULT_LANGUAGE "en"
25 #define DEFAULT_SAMPLE_RATE 8000
26 #define DEFAULT_SAMPLES_PER_MS ((DEFAULT_SAMPLE_RATE)/1000)
28 #define AST_CONFIG_MAX_PATH 255
30 /* provided in asterisk.c */
31 extern char ast_config_AST_CONFIG_DIR[AST_CONFIG_MAX_PATH];
32 extern char ast_config_AST_CONFIG_FILE[AST_CONFIG_MAX_PATH];
33 extern char ast_config_AST_MODULE_DIR[AST_CONFIG_MAX_PATH];
34 extern char ast_config_AST_SPOOL_DIR[AST_CONFIG_MAX_PATH];
35 extern char ast_config_AST_MONITOR_DIR[AST_CONFIG_MAX_PATH];
36 extern char ast_config_AST_VAR_DIR[AST_CONFIG_MAX_PATH];
37 extern char ast_config_AST_LOG_DIR[AST_CONFIG_MAX_PATH];
38 extern char ast_config_AST_AGI_DIR[AST_CONFIG_MAX_PATH];
39 extern char ast_config_AST_DB[AST_CONFIG_MAX_PATH];
40 extern char ast_config_AST_KEY_DIR[AST_CONFIG_MAX_PATH];
41 extern char ast_config_AST_PID[AST_CONFIG_MAX_PATH];
42 extern char ast_config_AST_SOCKET[AST_CONFIG_MAX_PATH];
43 extern char ast_config_AST_RUN_DIR[AST_CONFIG_MAX_PATH];
44 extern char ast_config_AST_CTL_PERMISSIONS[AST_CONFIG_MAX_PATH];
45 extern char ast_config_AST_CTL_OWNER[AST_CONFIG_MAX_PATH];
46 extern char ast_config_AST_CTL_GROUP[AST_CONFIG_MAX_PATH];
47 extern char ast_config_AST_CTL[AST_CONFIG_MAX_PATH];
48 extern char ast_config_AST_SYSTEM_NAME[20];
50 /* Provided by asterisk.c */
51 int ast_set_priority(int);
52 /* Provided by module.c */
53 int load_modules(const int preload_only);
54 /* Provided by pbx.c */
56 /* Provided by logger.c */
57 int init_logger(void);
58 void close_logger(void);
59 /* Provided by frame.c */
60 int init_framer(void);
61 /* Provided by logger.c */
62 int reload_logger(int);
63 /* Provided by term.c */
65 /* Provided by db.c */
67 /* Provided by channel.c */
68 void ast_channels_init(void);
69 /* Provided by cli.c */
70 void ast_builtins_init(void);
71 /* Provided by dnsmgr.c */
72 int dnsmgr_init(void);
73 void dnsmgr_start_refresh(void);
74 int dnsmgr_reload(void);
77 * \brief Register a function to be executed before Asterisk exits.
78 * \param func The callback function to use.
80 * \return Zero on success, -1 on error.
82 int ast_register_atexit(void (*func)(void));
85 * \brief Unregister a function registered with ast_register_atexit().
86 * \param func The callback function to unregister.
88 void ast_unregister_atexit(void (*func)(void));
91 * \brief Register the version of a source code file with the core.
92 * \param file the source file name
93 * \param version the version string (typically a CVS revision keyword string)
96 * This function should not be called directly, but instead the
97 * ASTERISK_FILE_VERSION macro should be used to register a file with the core.
99 void ast_register_file_version(const char *file, const char *version);
102 * \brief Unregister a source code file from the core.
103 * \param file the source file name
106 * This function should not be called directly, but instead the
107 * ASTERISK_FILE_VERSION macro should be used to automatically unregister
108 * the file when the module is unloaded.
110 void ast_unregister_file_version(const char *file);
113 * \brief support for event profiling
114 * (note, this must be documented a lot more)
115 * ast_add_profile allocates a generic 'counter' with a given name,
116 * which can be shown with the command 'show profile <name>'
118 * The counter accumulates positive or negative values supplied by
119 * ast_add_profile(), dividing them by the 'scale' value passed in the
120 * create call, and also counts the number of 'events'.
121 * Values can also be taked by the TSC counter on ia32 architectures,
122 * in which case you can mark the start of an event calling ast_mark(id, 1)
123 * and then the end of the event with ast_mark(id, 0).
124 * For non-i386 architectures, these two calls return 0.
126 int ast_add_profile(const char *, uint64_t scale);
127 int64_t ast_profile(int, int64_t);
128 int64_t ast_mark(int, int start1_stop0);
131 * \brief Register/unregister a source code file with the core.
132 * \param file the source file name
133 * \param version the version string (typically a CVS revision keyword string)
135 * This macro will place a file-scope constructor and destructor into the
136 * source of the module using it; this will cause the version of this file
137 * to registered with the Asterisk core (and unregistered) at the appropriate
143 * ASTERISK_FILE_VERSION(__FILE__, "\$Revision\$")
146 * \note The dollar signs above have been protected with backslashes to keep
147 * CVS from modifying them in this file; under normal circumstances they would
148 * not be present and CVS would expand the Revision keyword into the file's
151 #if defined(__GNUC__) && !defined(LOW_MEMORY)
153 #define HAVE_MTX_PROFILE /* used in lock.h */
154 #define ASTERISK_FILE_VERSION(file, version) \
155 static int mtx_prof = -1; /* profile mutex */ \
156 static void __attribute__((constructor)) __register_file_version(void) \
158 mtx_prof = ast_add_profile("mtx_lock_" file, 0); \
159 ast_register_file_version(file, version); \
161 static void __attribute__((destructor)) __unregister_file_version(void) \
163 ast_unregister_file_version(file); \
166 #define ASTERISK_FILE_VERSION(file, version) \
167 static void __attribute__((constructor)) __register_file_version(void) \
169 ast_register_file_version(file, version); \
171 static void __attribute__((destructor)) __unregister_file_version(void) \
173 ast_unregister_file_version(file); \
176 #elif !defined(LOW_MEMORY) /* ! __GNUC__ && ! LOW_MEMORY*/
177 #define ASTERISK_FILE_VERSION(file, x) static const char __file_version[] = x;
178 #else /* LOW_MEMORY */
179 #define ASTERISK_FILE_VERSION(file, x)
180 #endif /* __GNUC__ */
182 #endif /* _ASTERISK_H */