diff options
author | Steve Murphy <murf@digium.com> | 2007-07-19 23:24:27 +0000 |
---|---|---|
committer | Steve Murphy <murf@digium.com> | 2007-07-19 23:24:27 +0000 |
commit | 0e969271ae14e976b873327bd721eba24947545a (patch) | |
tree | b7dc4ff6bdbb84391b8b226995daa5bb8fbde8b9 /include | |
parent | 7756ba661904d1147e42ce884d3ebb2f128233b5 (diff) |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/abstract_jb.h | 4 | ||||
-rw-r--r-- | include/asterisk/app.h | 11 | ||||
-rw-r--r-- | include/asterisk/cdr.h | 2 | ||||
-rw-r--r-- | include/asterisk/channel.h | 4 | ||||
-rw-r--r-- | include/asterisk/chanspy.h | 2 | ||||
-rw-r--r-- | include/asterisk/dundi.h | 2 | ||||
-rw-r--r-- | include/asterisk/features.h | 2 | ||||
-rw-r--r-- | include/asterisk/jabber.h | 4 | ||||
-rw-r--r-- | include/asterisk/module.h | 2 | ||||
-rw-r--r-- | include/asterisk/speech.h | 2 | ||||
-rw-r--r-- | include/asterisk/utils.h | 68 |
11 files changed, 89 insertions, 14 deletions
diff --git a/include/asterisk/abstract_jb.h b/include/asterisk/abstract_jb.h index 37ff5b9d3..145256fcf 100644 --- a/include/asterisk/abstract_jb.h +++ b/include/asterisk/abstract_jb.h @@ -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; }; diff --git a/include/asterisk/app.h b/include/asterisk/app.h index 76683d5eb..1fb0e04eb 100644 --- a/include/asterisk/app.h +++ b/include/asterisk/app.h @@ -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 */ diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h index f8d4b5d8d..cdbf35e09 100644 --- a/include/asterisk/cdr.h +++ b/include/asterisk/cdr.h @@ -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 */ diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 0a5b7c1a0..9bfc3dd4d 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -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; diff --git a/include/asterisk/chanspy.h b/include/asterisk/chanspy.h index f8a979dd5..8550210d0 100644 --- a/include/asterisk/chanspy.h +++ b/include/asterisk/chanspy.h @@ -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: diff --git a/include/asterisk/dundi.h b/include/asterisk/dundi.h index bc64576ef..e588338ae 100644 --- a/include/asterisk/dundi.h +++ b/include/asterisk/dundi.h @@ -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; diff --git a/include/asterisk/features.h b/include/asterisk/features.h index c59acca16..5e9d5f3d2 100644 --- a/include/asterisk/features.h +++ b/include/asterisk/features.h @@ -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]; diff --git a/include/asterisk/jabber.h b/include/asterisk/jabber.h index 028d0bc3a..53c3fbed5 100644 --- a/include/asterisk/jabber.h +++ b/include/asterisk/jabber.h @@ -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; diff --git a/include/asterisk/module.h b/include/asterisk/module.h index d75e2d4fc..d53e6086c 100644 --- a/include/asterisk/module.h +++ b/include/asterisk/module.h @@ -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 *); diff --git a/include/asterisk/speech.h b/include/asterisk/speech.h index b3b853bf2..02d056f33 100644 --- a/include/asterisk/speech.h +++ b/include/asterisk/speech.h @@ -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 */ diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index e87157f2f..f9fa0f47e 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -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; }; |