After some study, thought, comparing, etc. I've backed out the previous universal mod to make ast_flags a 64 bit thing. Instead, I added a 64-bit version of ast_flags (ast_flags64), and 64-bit versions of the test-flag, set-flag, etc. macros, and an app_parse_options64 routine, and I use these in app_dial alone, to eliminate the 30-option limit it had grown to meet. There is room now for 32 more options and flags. I was heavily tempted to implement some of the other ideas that were presented, but this solution does not intro any new versions of dial, doesn't have a different API, has a minimal/zero impact on code outside of dial, and doesn't seriously (I hope) affect the code structure of dial. It's the best I can think of right now. My goal was NOT to rewrite dial. I leave that to a future, coordinated effort.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@75983 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Steve Murphy
2007-07-19 23:24:27 +00:00
parent 7756ba6619
commit 0e969271ae
28 changed files with 250 additions and 135 deletions

View File

@@ -55,7 +55,7 @@ enum {
struct ast_jb_conf
{
/*! \brief Combination of the AST_JB_ENABLED, AST_JB_FORCED and AST_JB_LOG flags. */
uint64_t flags;
unsigned int flags;
/*! \brief Max size of the jitterbuffer implementation. */
long max_size;
/*! \brief Resynchronization threshold of the jitterbuffer implementation. */
@@ -98,7 +98,7 @@ struct ast_jb
/*! \brief File for frame timestamp tracing. */
FILE *logfile;
/*! \brief Jitterbuffer internal state flags. */
uint64_t flags;
unsigned int flags;
};

View File

@@ -425,6 +425,17 @@ struct ast_app_option {
*/
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr);
/*!
\brief Parses a string containing application options and sets flags/arguments.
\param options The array of possible options declared with AST_APP_OPTIONS
\param flags The 64-bit flag structure to have option flags set
\param args The array of argument pointers to hold arguments found
\param optstr The string containing the options to be parsed
\return zero for success, non-zero if an error occurs
\sa AST_APP_OPTIONS
*/
int ast_app_parse_options64(const struct ast_app_option *options, struct ast_flags64 *flags, char **args, char *optstr);
/*! \brief Present a dialtone and collect a certain length extension.
\return Returns 1 on valid extension entered, -1 on hangup, or 0 on invalid extension.
\note Note that if 'collect' holds digits already, new digits will be appended, so be sure it's initialized properly */

View File

@@ -83,7 +83,7 @@ struct ast_cdr {
/*! What account number to use */
char accountcode[AST_MAX_ACCOUNT_CODE];
/*! flags */
uint64_t flags;
unsigned int flags;
/*! Unique Channel Identifier */
char uniqueid[32];
/*! User field */

View File

@@ -468,7 +468,7 @@ struct ast_channel {
(see \ref AstChanVar ) */
ast_group_t callgroup; /*!< Call group for call pickups */
ast_group_t pickupgroup; /*!< Pickup group - which calls groups can be picked up? */
uint64_t flags; /*!< channel flags of AST_FLAG_ type */
unsigned int flags; /*!< channel flags of AST_FLAG_ type */
unsigned short transfercapability; /*!< ISDN Transfer Capbility - AST_FLAG_DIGITAL is not enough */
AST_LIST_HEAD_NOLOCK(, ast_frame) readq;
int alertpipe[2];
@@ -567,7 +567,7 @@ struct ast_bridge_config {
const char *end_sound;
const char *start_sound;
int firstpass;
uint64_t flags;
unsigned int flags;
};
struct chanmon;

View File

@@ -61,7 +61,7 @@ struct ast_channel_spy {
struct ast_channel *chan;
struct ast_channel_spy_queue read_queue;
struct ast_channel_spy_queue write_queue;
uint64_t flags;
unsigned int flags;
enum chanspy_states status;
const char *type;
/* The volume adjustment values are very straightforward:

View File

@@ -192,7 +192,7 @@ struct dundi_peer_status {
#define DEFAULT_MAXMS 2000
struct dundi_result {
uint64_t flags;
unsigned int flags;
int weight;
int expiration;
int techint;

View File

@@ -39,7 +39,7 @@ struct ast_call_feature {
char exten[FEATURE_MAX_LEN];
char default_exten[FEATURE_MAX_LEN];
int (*operation)(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense);
uint64_t flags;
unsigned int flags;
char app[FEATURE_APP_LEN];
char app_args[FEATURE_APP_ARGS_LEN];
char moh_class[FEATURE_MOH_LEN];

View File

@@ -102,7 +102,7 @@ struct aji_buddy {
char channel[160];
struct aji_resource *resources;
enum aji_btype btype;
uint64_t flags;
unsigned int flags;
};
struct aji_buddy_container {
@@ -137,7 +137,7 @@ struct aji_client {
int timeout;
int message_timeout;
int authorized;
uint64_t flags;
unsigned int flags;
int component; /* 0 client, 1 component */
struct aji_buddy_container buddies;
AST_LIST_HEAD(messages,aji_message) messages;

View File

@@ -215,7 +215,7 @@ struct ast_module_info {
*/
const char *key;
uint64_t flags;
unsigned int flags;
};
void ast_module_register(const struct ast_module_info *);

View File

@@ -51,7 +51,7 @@ struct ast_speech {
/*! Structure lock */
ast_mutex_t lock;
/*! Set flags */
uint64_t flags;
unsigned int flags;
/*! Processing sound (used when engine is processing audio and getting results) */
char *processing_sound;
/*! Current state of structure */

View File

@@ -50,7 +50,7 @@
your variable.
The flag macros below use a set of compiler tricks to verify
that the caller is using an "unsigned long long" variable to hold
that the caller is using an "unsigned int" variable to hold
the flags, and nothing else. If the caller uses any other
type of variable, a warning message similar to this:
@@ -64,7 +64,7 @@
\endverbatim
*/
extern uint64_t __unsigned_int_flags_dummy;
extern unsigned int __unsigned_int_flags_dummy;
#define ast_test_flag(p,flag) ({ \
typeof ((p)->flags) __p = (p)->flags; \
@@ -115,6 +115,64 @@ extern uint64_t __unsigned_int_flags_dummy;
(p)->flags |= (value); \
} while (0)
/* The following 64-bit flag code can most likely be erased after app_dial
is reorganized to either reduce the large number of options, or handle
them in some other way. At the time of this writing, app_dial would be
the only user of 64-bit option flags */
extern uint64_t __unsigned_int_flags_dummy64;
#define ast_test_flag64(p,flag) ({ \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
((p)->flags & (flag)); \
})
#define ast_set_flag64(p,flag) do { \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
((p)->flags |= (flag)); \
} while(0)
#define ast_clear_flag64(p,flag) do { \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
((p)->flags &= ~(flag)); \
} while(0)
#define ast_copy_flags64(dest,src,flagz) do { \
typeof ((dest)->flags) __d = (dest)->flags; \
typeof ((src)->flags) __s = (src)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__d == &__x); \
(void) (&__s == &__x); \
(dest)->flags &= ~(flagz); \
(dest)->flags |= ((src)->flags & (flagz)); \
} while (0)
#define ast_set2_flag64(p,value,flag) do { \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
if (value) \
(p)->flags |= (flag); \
else \
(p)->flags &= ~(flag); \
} while (0)
#define ast_set_flags_to64(p,flag,value) do { \
typeof ((p)->flags) __p = (p)->flags; \
typeof (__unsigned_int_flags_dummy64) __x = 0; \
(void) (&__p == &__x); \
(p)->flags &= ~(flag); \
(p)->flags |= (value); \
} while (0)
/* Non-type checking variations for non-unsigned int flags. You
should only use non-unsigned int flags where required by
protocol etc and if you know what you're doing :) */
@@ -146,6 +204,12 @@ extern uint64_t __unsigned_int_flags_dummy;
/*! \brief Structure used to handle boolean flags
*/
struct ast_flags {
unsigned int flags;
};
/*! \brief Structure used to handle a large number of boolean flags == used only in app_dial?
*/
struct ast_flags64 {
uint64_t flags;
};