devicestate.c: Minor tweaks

* In ast_state_chan2dev() use ARRAY_LEN() instead of a sentinel value in
chan2dev[].

* Fix some comments in chan_iax2.c.
........

Merged revisions 422661 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422663 65c4cc65-6c06-0410-ace0-fbb531ad65f3
changes/42/42/1
Richard Mudgett 11 years ago
parent 2362d88a18
commit 5a1de68b9a

@ -5036,7 +5036,7 @@ reject:
* password field will be set to NULL. * password field will be set to NULL.
* *
* \note The dial string format is: * \note The dial string format is:
* [username[:password]@]peer[:port][/exten[@@context]][/options] * [username[:password]@]peer[:port][/exten[@context]][/options]
*/ */
static void parse_dial_string(char *data, struct parsed_dial_string *pds) static void parse_dial_string(char *data, struct parsed_dial_string *pds)
{ {
@ -5069,9 +5069,10 @@ static void parse_dial_string(char *data, struct parsed_dial_string *pds)
pds->peer = strsep(&data, ":"); pds->peer = strsep(&data, ":");
pds->port = data; pds->port = data;
/* check for a key name wrapped in [] in the secret position, if found, /*
move it to the key field instead * Check for a key name wrapped in [] in the password position.
*/ * If found, move it to the key field instead.
*/
if (pds->password && (pds->password[0] == '[')) { if (pds->password && (pds->password[0] == '[')) {
pds->key = ast_strip_quoted(pds->password, "[", "]"); pds->key = ast_strip_quoted(pds->password, "[", "]");
pds->password = NULL; pds->password = NULL;

@ -169,7 +169,7 @@ static const char * const devstatestring[][2] = {
{ /* 5 AST_DEVICE_UNAVAILABLE */ "Unavailable", "UNAVAILABLE" }, /*!< Unavailable (not registered) */ { /* 5 AST_DEVICE_UNAVAILABLE */ "Unavailable", "UNAVAILABLE" }, /*!< Unavailable (not registered) */
{ /* 6 AST_DEVICE_RINGING */ "Ringing", "RINGING" }, /*!< Ring, ring, ring */ { /* 6 AST_DEVICE_RINGING */ "Ringing", "RINGING" }, /*!< Ring, ring, ring */
{ /* 7 AST_DEVICE_RINGINUSE */ "Ring+Inuse", "RINGINUSE" }, /*!< Ring and in use */ { /* 7 AST_DEVICE_RINGINUSE */ "Ring+Inuse", "RINGINUSE" }, /*!< Ring and in use */
{ /* 8 AST_DEVICE_ONHOLD */ "On Hold", "ONHOLD" }, /*!< On Hold */ { /* 8 AST_DEVICE_ONHOLD */ "On Hold", "ONHOLD" }, /*!< On Hold */
}; };
/*!\brief Mapping for channel states to device states */ /*!\brief Mapping for channel states to device states */
@ -187,7 +187,6 @@ static const struct chan2dev {
{ AST_STATE_BUSY, AST_DEVICE_BUSY }, { AST_STATE_BUSY, AST_DEVICE_BUSY },
{ AST_STATE_DIALING_OFFHOOK, AST_DEVICE_INUSE }, { AST_STATE_DIALING_OFFHOOK, AST_DEVICE_INUSE },
{ AST_STATE_PRERING, AST_DEVICE_RINGING }, { AST_STATE_PRERING, AST_DEVICE_RINGING },
{ -100, -100 },
}; };
/*! \brief A device state provider (not a channel) */ /*! \brief A device state provider (not a channel) */
@ -251,7 +250,7 @@ enum ast_device_state ast_state_chan2dev(enum ast_channel_state chanstate)
{ {
int i; int i;
chanstate &= 0xFFFF; chanstate &= 0xFFFF;
for (i = 0; chan2dev[i].chan != -100; i++) { for (i = 0; i < ARRAY_LEN(chan2dev); i++) {
if (chan2dev[i].chan == chanstate) { if (chan2dev[i].chan == chanstate) {
return chan2dev[i].dev; return chan2dev[i].dev;
} }

Loading…
Cancel
Save