summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2006-02-01 23:05:28 +0000
committerKevin P. Fleming <kpfleming@digium.com>2006-02-01 23:05:28 +0000
commita16ae226b685a8c434ec4f7eecf4ee8864fde4c7 (patch)
tree86a6664b5cba70b924fdd1cef2ecbf93226e7d58 /include
parentf246b9fc64ea8843f419947045574edb2681f9a2 (diff)
use string fields for some stuff in ast_channel
const-ify some more APIs remove 'type' field from ast_channel, in favor of the one in the channel's tech structure allow string field module users to specify the 'chunk size' for pool allocations update chan_alsa to be compatible with recent const-ification patches git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9060 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/cdr.h70
-rw-r--r--include/asterisk/channel.h22
-rw-r--r--include/asterisk/frame.h2
-rw-r--r--include/asterisk/image.h2
-rw-r--r--include/asterisk/musiconhold.h13
-rw-r--r--include/asterisk/stringfields.h22
6 files changed, 62 insertions, 69 deletions
diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h
index 6598b3806..5d2322c01 100644
--- a/include/asterisk/cdr.h
+++ b/include/asterisk/cdr.h
@@ -96,29 +96,29 @@ struct ast_cdr {
struct ast_cdr *next;
};
-extern void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur);
-extern int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int recur);
-extern int ast_cdr_serialize_variables(struct ast_cdr *cdr, char *buf, size_t size, char delim, char sep, int recur);
-extern void ast_cdr_free_vars(struct ast_cdr *cdr, int recur);
-extern int ast_cdr_copy_vars(struct ast_cdr *to_cdr, struct ast_cdr *from_cdr);
+void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur);
+int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int recur);
+int ast_cdr_serialize_variables(struct ast_cdr *cdr, char *buf, size_t size, char delim, char sep, int recur);
+void ast_cdr_free_vars(struct ast_cdr *cdr, int recur);
+int ast_cdr_copy_vars(struct ast_cdr *to_cdr, struct ast_cdr *from_cdr);
typedef int (*ast_cdrbe)(struct ast_cdr *cdr);
/*! \brief Allocate a CDR record
* Returns a malloc'd ast_cdr structure, returns NULL on error (malloc failure)
*/
-extern struct ast_cdr *ast_cdr_alloc(void);
+struct ast_cdr *ast_cdr_alloc(void);
/*! \brief Duplicate a record
* Returns a malloc'd ast_cdr structure, returns NULL on error (malloc failure)
*/
-extern struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr);
+struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr);
/*! \brief Free a CDR record
* \param cdr ast_cdr structure to free
* Returns nothing important
*/
-extern void ast_cdr_free(struct ast_cdr *cdr);
+void ast_cdr_free(struct ast_cdr *cdr);
/*! \brief Initialize based on a channel
* \param cdr Call Detail Record to use for channel
@@ -126,7 +126,7 @@ extern void ast_cdr_free(struct ast_cdr *cdr);
* Initializes a CDR and associates it with a particular channel
* Return is negligible. (returns 0 by default)
*/
-extern int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan);
+int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan);
/*! Initialize based on a channel */
/*!
@@ -135,7 +135,7 @@ extern int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan);
* Initializes a CDR and associates it with a particular channel
* Return is negligible. (returns 0 by default)
*/
-extern int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan);
+int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan);
/*! Register a CDR handling engine */
/*!
@@ -145,14 +145,14 @@ extern int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan);
* Used to register a Call Detail Record handler.
* Returns -1 on error, 0 on success.
*/
-extern int ast_cdr_register(char *name, char *desc, ast_cdrbe be);
+int ast_cdr_register(char *name, char *desc, ast_cdrbe be);
/*! Unregister a CDR handling engine */
/*!
* \param name name of CDR handler to unregister
* Unregisters a CDR by it's name
*/
-extern void ast_cdr_unregister(char *name);
+void ast_cdr_unregister(char *name);
/*! Start a call */
/*!
@@ -160,28 +160,28 @@ extern void ast_cdr_unregister(char *name);
* Starts all CDR stuff necessary for monitoring a call
* Returns nothing important
*/
-extern void ast_cdr_start(struct ast_cdr *cdr);
+void ast_cdr_start(struct ast_cdr *cdr);
/*! Answer a call */
/*!
* \param cdr the cdr you wish to associate with the call
* Starts all CDR stuff necessary for doing CDR when answering a call
*/
-extern void ast_cdr_answer(struct ast_cdr *cdr);
+void ast_cdr_answer(struct ast_cdr *cdr);
/*! Busy a call */
/*!
* \param cdr the cdr you wish to associate with the call
* Returns nothing important
*/
-extern void ast_cdr_busy(struct ast_cdr *cdr);
+void ast_cdr_busy(struct ast_cdr *cdr);
/*! Fail a call */
/*!
* \param cdr the cdr you wish to associate with the call
* Returns nothing important
*/
-extern void ast_cdr_failed(struct ast_cdr *cdr);
+void ast_cdr_failed(struct ast_cdr *cdr);
/*! Save the result of the call based on the AST_CAUSE_* */
/*!
@@ -189,7 +189,7 @@ extern void ast_cdr_failed(struct ast_cdr *cdr);
* Returns nothing important
* \param cause the AST_CAUSE_*
*/
-extern int ast_cdr_disposition(struct ast_cdr *cdr, int cause);
+int ast_cdr_disposition(struct ast_cdr *cdr, int cause);
/*! End a call */
/*!
@@ -197,7 +197,7 @@ extern int ast_cdr_disposition(struct ast_cdr *cdr, int cause);
* Registers the end of call time in the cdr structure.
* Returns nothing important
*/
-extern void ast_cdr_end(struct ast_cdr *cdr);
+void ast_cdr_end(struct ast_cdr *cdr);
/*! Detaches the detail record for posting (and freeing) either now or at a
* later time in bulk with other records during batch mode operation */
@@ -206,7 +206,7 @@ extern void ast_cdr_end(struct ast_cdr *cdr);
* Prevents the channel thread from blocking on the CDR handling
* Returns nothing
*/
-extern void ast_cdr_detach(struct ast_cdr *cdr);
+void ast_cdr_detach(struct ast_cdr *cdr);
/*! Spawns (possibly) a new thread to submit a batch of CDRs to the backend engines */
/*!
@@ -214,7 +214,7 @@ extern void ast_cdr_detach(struct ast_cdr *cdr);
* Blocks the asterisk shutdown procedures until the CDR data is submitted.
* Returns nothing
*/
-extern void ast_cdr_submit_batch(int shutdown);
+void ast_cdr_submit_batch(int shutdown);
/*! Set the destination channel, if there was one */
/*!
@@ -223,7 +223,7 @@ extern void ast_cdr_submit_batch(int shutdown);
* Sets the destination channel the CDR is applied to
* Returns nothing
*/
-extern void ast_cdr_setdestchan(struct ast_cdr *cdr, char *chan);
+void ast_cdr_setdestchan(struct ast_cdr *cdr, const char *chan);
/*! Set the last executed application */
/*!
@@ -233,7 +233,7 @@ extern void ast_cdr_setdestchan(struct ast_cdr *cdr, char *chan);
* Changes the value of the last executed app
* Returns nothing
*/
-extern void ast_cdr_setapp(struct ast_cdr *cdr, char *app, char *data);
+void ast_cdr_setapp(struct ast_cdr *cdr, char *app, char *data);
/*! Convert a string to a detail record AMA flag */
/*!
@@ -241,7 +241,7 @@ extern void ast_cdr_setapp(struct ast_cdr *cdr, char *app, char *data);
* Converts the string form of the flag to the binary form.
* Returns the binary form of the flag
*/
-extern int ast_cdr_amaflags2int(const char *flag);
+int ast_cdr_amaflags2int(const char *flag);
/*! Disposition to a string */
/*!
@@ -249,7 +249,7 @@ extern int ast_cdr_amaflags2int(const char *flag);
* Converts the binary form of a disposition to string form.
* Returns a pointer to the string form
*/
-extern char *ast_cdr_disp2str(int disposition);
+char *ast_cdr_disp2str(int disposition);
/*! Reset the detail record, optionally posting it first */
/*!
@@ -257,7 +257,7 @@ extern char *ast_cdr_disp2str(int disposition);
* \param flags |AST_CDR_FLAG_POSTED whether or not to post the cdr first before resetting it
* |AST_CDR_FLAG_LOCKED whether or not to reset locked CDR's
*/
-extern void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *flags);
+void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *flags);
/*! Flags to a string */
/*!
@@ -265,33 +265,33 @@ extern void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *flags);
* Converts binary flags to string flags
* Returns string with flag name
*/
-extern char *ast_cdr_flags2str(int flags);
+char *ast_cdr_flags2str(int flags);
-extern int ast_cdr_setaccount(struct ast_channel *chan, const char *account);
-extern int ast_cdr_setamaflags(struct ast_channel *chan, const char *amaflags);
+int ast_cdr_setaccount(struct ast_channel *chan, const char *account);
+int ast_cdr_setamaflags(struct ast_channel *chan, const char *amaflags);
-extern int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield);
-extern int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield);
+int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield);
+int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield);
/* Update CDR on a channel */
-extern int ast_cdr_update(struct ast_channel *chan);
+int ast_cdr_update(struct ast_channel *chan);
extern int ast_default_amaflags;
extern char ast_default_accountcode[AST_MAX_ACCOUNT_CODE];
-extern struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr);
+struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr);
/*! Reload the configuration file cdr.conf and start/stop CDR scheduling thread */
-extern void ast_cdr_engine_reload(void);
+void ast_cdr_engine_reload(void);
/*! Load the configuration file cdr.conf and possibly start the CDR scheduling thread */
-extern int ast_cdr_engine_init(void);
+int ast_cdr_engine_init(void);
/*! Submit any remaining CDRs and prepare for shutdown */
-extern void ast_cdr_engine_term(void);
+void ast_cdr_engine_term(void);
#endif /* _ASTERISK_CDR_H */
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index c31afe071..f95faffea 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -113,6 +113,7 @@ extern "C" {
#include "asterisk/cdr.h"
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
+#include "asterisk/stringfields.h"
#define MAX_LANGUAGE 20
@@ -266,24 +267,23 @@ struct ast_channel_spy_list;
* this structure is changed. XXX
*/
struct ast_channel {
- /*! ASCII unique channel name */
- char name[AST_CHANNEL_NAME];
-
/*! Technology (point to channel driver) */
const struct ast_channel_tech *tech;
/*! Private data used by the technology driver */
void *tech_pvt;
- /*! Language requested for voice prompts */
- char language[MAX_LANGUAGE];
- /*! Type of channel */
- const char *type;
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(name); /*! ASCII unique channel name */
+ AST_STRING_FIELD(language); /*! Language requested for voice prompts */
+ AST_STRING_FIELD(musicclass); /*! Default music class */
+ AST_STRING_FIELD(accountcode); /*! Account code for billing */
+ AST_STRING_FIELD(call_forward); /*! Where to forward to if asked to dial on this interface */
+ );
+
/*! File descriptor for channel -- Drivers will poll on these file descriptors, so at least one must be non -1. */
int fds[AST_MAX_FDS];
- /*! Default music class */
- char musicclass[MAX_MUSICCLASS];
/*! Music State*/
void *music_state;
/*! Current generator data if there is any */
@@ -372,14 +372,10 @@ struct ast_channel {
struct ast_pbx *pbx;
/*! Set BEFORE PBX is started to determine AMA flags */
int amaflags;
- /*! Account code for billing */
- char accountcode[AST_MAX_ACCOUNT_CODE];
/*! Call Detail Record */
struct ast_cdr *cdr;
/*! Whether or not ADSI is detected on CPE */
int adsicpe;
- /*! Where to forward to if asked to dial on this interface */
- char call_forward[AST_MAX_EXTENSION];
/*! Tone zone as set in indications.conf */
struct tone_zone *zone;
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index 4835e1646..a1fcf8e0b 100644
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -441,7 +441,7 @@ extern struct ast_frame *ast_smoother_read(struct ast_smoother *s);
#define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 1)
#endif
-extern void ast_frame_dump(char *name, struct ast_frame *f, char *prefix);
+extern void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix);
/*! \brief Initialize a codec preference to "no preference" */
extern void ast_codec_pref_init(struct ast_codec_pref *pref);
diff --git a/include/asterisk/image.h b/include/asterisk/image.h
index 56e080ece..32953363e 100644
--- a/include/asterisk/image.h
+++ b/include/asterisk/image.h
@@ -68,7 +68,7 @@ extern int ast_send_image(struct ast_channel *chan, char *filename);
* Make an image from a filename ??? No estoy positivo
* Returns an ast_frame on success, NULL on failure
*/
-extern struct ast_frame *ast_read_image(char *filename, char *preflang, int format);
+extern struct ast_frame *ast_read_image(char *filename, const char *preflang, int format);
/*! Register image format */
/*!
diff --git a/include/asterisk/musiconhold.h b/include/asterisk/musiconhold.h
index 8a0bf6417..a3b231722 100644
--- a/include/asterisk/musiconhold.h
+++ b/include/asterisk/musiconhold.h
@@ -28,16 +28,17 @@ extern "C" {
#endif
/*! Turn on music on hold on a given channel */
-extern int ast_moh_start(struct ast_channel *chan, char *mclass);
+int ast_moh_start(struct ast_channel *chan, const char *mclass);
/*! Turn off music on hold on a given channel */
-extern void ast_moh_stop(struct ast_channel *chan);
+void ast_moh_stop(struct ast_channel *chan);
-extern void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, char *),
- void (*stop_ptr)(struct ast_channel *),
- void (*cleanup_ptr)(struct ast_channel *));
+void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, const char *),
+ void (*stop_ptr)(struct ast_channel *),
+ void (*cleanup_ptr)(struct ast_channel *));
-extern void ast_uninstall_music_functions(void);
+void ast_uninstall_music_functions(void);
+
void ast_moh_cleanup(struct ast_channel *chan);
#if defined(__cplusplus) || defined(c_plusplus)
diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h
index 22e066d21..4fb87e4b2 100644
--- a/include/asterisk/stringfields.h
+++ b/include/asterisk/stringfields.h
@@ -168,11 +168,6 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
int index, const char *format, ...);
/*!
- The default amount of storage to be allocated for a field pool.
-*/
-#define AST_STRING_FIELD_DEFAULT_POOL 512
-
-/*!
\brief Declare a string field
\param name The field name
*/
@@ -194,7 +189,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
\return the number of fields in the structure's definition
*/
#define ast_string_field_count(x) \
- (offsetof(typeof(*x), __end_field) - offsetof(typeof(*x), __begin_field)) / sizeof(ast_string_field)
+ (offsetof(typeof(*(x)), __end_field) - offsetof(typeof(*(x)), __begin_field)) / sizeof(ast_string_field)
/*!
\brief Get the index of a field in a structure
@@ -209,10 +204,11 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
/*!
\brief Initialize a field pool and fields
\param x Pointer to a structure containing fields
+ \param size Amount of storage to allocate
\return 0 on failure, non-zero on success
*/
-#define ast_string_field_init(x) \
- __ast_string_field_init(&x->__field_mgr, AST_STRING_FIELD_DEFAULT_POOL, &x->__begin_field[0], ast_string_field_count(x))
+#define ast_string_field_init(x, size) \
+ __ast_string_field_init(&(x)->__field_mgr, size, &(x)->__begin_field[0], ast_string_field_count(x))
/*!
\brief Set a field to a simple string value
@@ -222,8 +218,8 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
\return nothing
*/
#define ast_string_field_index_set(x, index, data) do { \
- if ((x->__begin_field[index] = __ast_string_field_alloc_space(&x->__field_mgr, strlen(data) + 1, &x->__begin_field[0], ast_string_field_count(x)))) \
- strcpy((char *) x->__begin_field[index], data); \
+ if (((x)->__begin_field[index] = __ast_string_field_alloc_space(&(x)->__field_mgr, strlen(data) + 1, &(x)->__begin_field[0], ast_string_field_count(x)))) \
+ strcpy((char *) (x)->__begin_field[index], data); \
} while (0)
/*!
@@ -245,7 +241,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
\return nothing
*/
#define ast_string_field_index_build(x, index, fmt, args...) \
- __ast_string_field_index_build(&x->__field_mgr, &x->__begin_field[0], ast_string_field_count(x), index, fmt, args)
+ __ast_string_field_index_build(&(x)->__field_mgr, &(x)->__begin_field[0], ast_string_field_count(x), index, fmt, args)
/*!
\brief Set a field to a complex (built) value
@@ -269,7 +265,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
pointer is just changed to point to an empty string.
*/
#define ast_string_field_index_free(x, index) do { \
- x->__begin_field[index] = __ast_string_field_empty; \
+ (x)->__begin_field[index] = __ast_string_field_empty; \
} while(0)
/*!
@@ -299,7 +295,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
struct ast_string_field_pool *this, *prev; \
for (index = 0; index < ast_string_field_count(x); index ++) \
ast_string_field_index_free(x, index); \
- for (this = x->__field_mgr.pool; this; this = prev) { \
+ for (this = (x)->__field_mgr.pool; this; this = prev) { \
prev = this->prev; \
free(this); \
} \