Fix a bunch of places where \arg was used instead of \param. Using \arg
[asterisk-bristuff.git] / include / asterisk.h
blob9d5c1ae8a50fd68199709a35eb822cf62dbaf387
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 /* The include of 'autoconfig.h' is not necessary for any modules that
22 are part of the Asterisk source tree, because the top-level Makefile
23 will forcibly include that header in all compilations before all
24 other headers (even system headers). However, leaving this here will
25 help out-of-tree module builders, and doesn't cause any harm for the
26 in-tree modules.
28 #include "asterisk/autoconfig.h"
30 #include "asterisk/compat.h"
32 #include "asterisk/logger.h"
34 /* Default to allowing the umask or filesystem ACLs to determine actual file
35 * creation permissions
37 #ifndef AST_DIR_MODE
38 #define AST_DIR_MODE 0777
39 #endif
40 #ifndef AST_FILE_MODE
41 #define AST_FILE_MODE 0666
42 #endif
44 #define DEFAULT_LANGUAGE "en"
46 #define DEFAULT_SAMPLE_RATE 8000
47 #define DEFAULT_SAMPLES_PER_MS ((DEFAULT_SAMPLE_RATE)/1000)
48 #define setpriority __PLEASE_USE_ast_set_priority_INSTEAD_OF_setpriority__
49 #define sched_setscheduler __PLEASE_USE_ast_set_priority_INSTEAD_OF_sched_setscheduler__
51 int ast_set_priority(int); /*!< Provided by asterisk.c */
53 /*!
54 * \brief Register a function to be executed before Asterisk exits.
55 * \param func The callback function to use.
57 * \retval 0 on success.
58 * \retval -1 on error.
60 int ast_register_atexit(void (*func)(void));
62 /*!
63 * \brief Unregister a function registered with ast_register_atexit().
64 * \param func The callback function to unregister.
66 void ast_unregister_atexit(void (*func)(void));
68 #if !defined(LOW_MEMORY)
69 /*!
70 * \brief Register the version of a source code file with the core.
71 * \param file the source file name
72 * \param version the version string (typically a CVS revision keyword string)
73 * \return nothing
75 * This function should not be called directly, but instead the
76 * ASTERISK_FILE_VERSION macro should be used to register a file with the core.
78 void ast_register_file_version(const char *file, const char *version);
80 /*!
81 * \brief Unregister a source code file from the core.
82 * \param file the source file name
83 * \return nothing
85 * This function should not be called directly, but instead the
86 * ASTERISK_FILE_VERSION macro should be used to automatically unregister
87 * the file when the module is unloaded.
89 void ast_unregister_file_version(const char *file);
91 /*! \brief Find version for given module name
92 * \param file Module name (i.e. chan_sip.so)
93 * \return version string or NULL if the module is not found
95 const char *ast_file_version_find(const char *file);
98 /*!
99 * \brief Register/unregister a source code file with the core.
100 * \param file the source file name
101 * \param version the version string (typically a CVS revision keyword string)
103 * This macro will place a file-scope constructor and destructor into the
104 * source of the module using it; this will cause the version of this file
105 * to registered with the Asterisk core (and unregistered) at the appropriate
106 * times.
108 * Example:
110 * \code
111 * ASTERISK_FILE_VERSION(__FILE__, "\$Revision\$")
112 * \endcode
114 * \note The dollar signs above have been protected with backslashes to keep
115 * CVS from modifying them in this file; under normal circumstances they would
116 * not be present and CVS would expand the Revision keyword into the file's
117 * revision number.
119 #ifdef MTX_PROFILE
120 #define HAVE_MTX_PROFILE /* used in lock.h */
121 #define ASTERISK_FILE_VERSION(file, version) \
122 static int mtx_prof = -1; /* profile mutex */ \
123 static void __attribute__((constructor)) __register_file_version(void) \
125 mtx_prof = ast_add_profile("mtx_lock_" file, 0); \
126 ast_register_file_version(file, version); \
128 static void __attribute__((destructor)) __unregister_file_version(void) \
130 ast_unregister_file_version(file); \
132 #else /* !MTX_PROFILE */
133 #define ASTERISK_FILE_VERSION(file, version) \
134 static void __attribute__((constructor)) __register_file_version(void) \
136 ast_register_file_version(file, version); \
138 static void __attribute__((destructor)) __unregister_file_version(void) \
140 ast_unregister_file_version(file); \
142 #endif /* !MTX_PROFILE */
143 #else /* LOW_MEMORY */
144 #define ASTERISK_FILE_VERSION(file, x)
145 #endif /* LOW_MEMORY */
147 #if !defined(LOW_MEMORY)
149 * \brief support for event profiling
151 * (note, this must be documented a lot more)
152 * ast_add_profile allocates a generic 'counter' with a given name,
153 * which can be shown with the command 'show profile <name>'
155 * The counter accumulates positive or negative values supplied by
156 * ast_add_profile(), dividing them by the 'scale' value passed in the
157 * create call, and also counts the number of 'events'.
158 * Values can also be taked by the TSC counter on ia32 architectures,
159 * in which case you can mark the start of an event calling ast_mark(id, 1)
160 * and then the end of the event with ast_mark(id, 0).
161 * For non-i386 architectures, these two calls return 0.
163 int ast_add_profile(const char *, uint64_t scale);
164 int64_t ast_profile(int, int64_t);
165 int64_t ast_mark(int, int start1_stop0);
166 #else /* LOW_MEMORY */
167 #define ast_add_profile(a, b) 0
168 #define ast_profile(a, b) do { } while (0)
169 #define ast_mark(a, b) do { } while (0)
170 #endif /* LOW_MEMORY */
172 /*! \brief
173 * Definition of various structures that many asterisk files need,
174 * but only because they need to know that the type exists.
178 struct ast_channel;
179 struct ast_frame;
180 struct ast_module;
181 struct ast_variable;
182 struct ast_str;
184 #endif /* _ASTERISK_H */