[asterisk-commits] tilghman: trunk r154260 - in /trunk: apps/ include/asterisk/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Nov 4 12:47:21 CST 2008
Author: tilghman
Date: Tue Nov 4 12:47:20 2008
New Revision: 154260
URL: http://svn.digium.com/view/asterisk?view=rev&rev=154260
Log:
Slightly optimize ast_devstate_str and rename global functions devstate2str and config_text_file_save to have an ast_ prefix
Modified:
trunk/apps/app_page.c
trunk/apps/app_queue.c
trunk/apps/app_voicemail.c
trunk/include/asterisk/config.h
trunk/include/asterisk/devicestate.h
trunk/main/config.c
trunk/main/devicestate.c
trunk/main/features.c
trunk/main/manager.c
Modified: trunk/apps/app_page.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_page.c?view=diff&rev=154260&r1=154259&r2=154260
==============================================================================
--- trunk/apps/app_page.c (original)
+++ trunk/apps/app_page.c Tue Nov 4 12:47:20 2008
@@ -178,9 +178,9 @@
if (ast_test_flag(&flags, PAGE_SKIP)) {
state = ast_device_state(tech);
if (state == AST_DEVICE_UNKNOWN) {
- ast_log(LOG_WARNING, "Destination '%s' has device state '%s'. Paging anyway.\n", tech, devstate2str(state));
+ ast_log(LOG_WARNING, "Destination '%s' has device state '%s'. Paging anyway.\n", tech, ast_devstate2str(state));
} else if (state != AST_DEVICE_NOT_INUSE) {
- ast_log(LOG_WARNING, "Destination '%s' has device state '%s'.\n", tech, devstate2str(state));
+ ast_log(LOG_WARNING, "Destination '%s' has device state '%s'.\n", tech, ast_devstate2str(state));
continue;
}
}
Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?view=diff&rev=154260&r1=154259&r2=154260
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Tue Nov 4 12:47:20 2008
@@ -1007,9 +1007,9 @@
}
if (found)
- ast_debug(1, "Device '%s' changed to state '%d' (%s)\n", sc->dev, sc->state, devstate2str(sc->state));
+ ast_debug(1, "Device '%s' changed to state '%d' (%s)\n", sc->dev, sc->state, ast_devstate2str(sc->state));
else
- ast_debug(3, "Device '%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", sc->dev, sc->state, devstate2str(sc->state));
+ ast_debug(3, "Device '%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", sc->dev, sc->state, ast_devstate2str(sc->state));
ast_free(sc);
return 0;
@@ -5692,7 +5692,7 @@
mem->dynamic ? " (dynamic)" : "",
mem->realtime ? " (realtime)" : "",
mem->paused ? " (paused)" : "",
- devstate2str(mem->status));
+ ast_devstate2str(mem->status));
if (mem->calls)
ast_str_append(&out, 0, " has taken %d calls (last was %ld secs ago)",
mem->calls, (long) (time(NULL) - mem->lastcall));
Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=154260&r1=154259&r2=154260
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Tue Nov 4 12:47:20 2008
@@ -1177,7 +1177,7 @@
/* save the results */
reset_user_pw(vmu->context, vmu->mailbox, newpassword);
ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
- config_text_file_save(VOICEMAIL_CONFIG, cfg, "AppVoicemail");
+ ast_config_text_file_save(VOICEMAIL_CONFIG, cfg, "AppVoicemail");
}
category = NULL;
var = NULL;
@@ -1207,7 +1207,7 @@
/* save the results and clean things up */
reset_user_pw(vmu->context, vmu->mailbox, newpassword);
ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
- config_text_file_save("users.conf", cfg, "AppVoicemail");
+ ast_config_text_file_save("users.conf", cfg, "AppVoicemail");
}
}
@@ -5928,7 +5928,7 @@
msg_cat = ast_category_get(msg_cfg, "message");
snprintf(duration_buf, 11, "%ld", *duration);
if (!ast_variable_update(msg_cat, "duration", duration_buf, NULL, 0)) {
- config_text_file_save(textfile, msg_cfg, "app_voicemail");
+ ast_config_text_file_save(textfile, msg_cfg, "app_voicemail");
}
}
Modified: trunk/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/config.h?view=diff&rev=154260&r1=154259&r2=154260
==============================================================================
--- trunk/include/asterisk/config.h (original)
+++ trunk/include/asterisk/config.h Tue Nov 4 12:47:20 2008
@@ -388,7 +388,8 @@
int ast_variable_update(struct ast_category *category, const char *variable,
const char *value, const char *match, unsigned int object);
-int config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator);
+int ast_config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator);
+int config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator) __attribute__ ((deprecated));
struct ast_config *ast_config_internal_load(const char *configfile, struct ast_config *cfg, struct ast_flags flags, const char *suggested_incl_file, const char *who_asked);
Modified: trunk/include/asterisk/devicestate.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/devicestate.h?view=diff&rev=154260&r1=154259&r2=154260
==============================================================================
--- trunk/include/asterisk/devicestate.h (original)
+++ trunk/include/asterisk/devicestate.h Tue Nov 4 12:47:20 2008
@@ -73,14 +73,15 @@
*
* \param devstate Current device state
*/
-const char *devstate2str(enum ast_device_state devstate);
+const char *devstate2str(enum ast_device_state devstate) attribute_pure __attribute__ ((deprecated));
+const char *ast_devstate2str(enum ast_device_state devstate) attribute_pure;
/*!
* \brief Convert device state to text string that is easier to parse
*
* \param devstate Current device state
*/
-const char *ast_devstate_str(enum ast_device_state devstate);
+const char *ast_devstate_str(enum ast_device_state devstate) attribute_pure;
/*!
* \brief Convert device state from text to integer value
Modified: trunk/main/config.c
URL: http://svn.digium.com/view/asterisk/trunk/main/config.c?view=diff&rev=154260&r1=154259&r2=154260
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Tue Nov 4 12:47:20 2008
@@ -1560,6 +1560,11 @@
int config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator)
{
+ return ast_config_text_file_save(configfile, cfg, generator);
+}
+
+int ast_config_text_file_save(const char *configfile, const struct ast_config *cfg, const char *generator)
+{
FILE *f;
char fn[256];
struct ast_variable *var;
Modified: trunk/main/devicestate.c
URL: http://svn.digium.com/view/asterisk/trunk/main/devicestate.c?view=diff&rev=154260&r1=154259&r2=154260
==============================================================================
--- trunk/main/devicestate.c (original)
+++ trunk/main/devicestate.c Tue Nov 4 12:47:20 2008
@@ -128,16 +128,16 @@
#include "asterisk/event.h"
/*! \brief Device state strings for printing */
-static const char *devstatestring[] = {
- /* 0 AST_DEVICE_UNKNOWN */ "Unknown", /*!< Valid, but unknown state */
- /* 1 AST_DEVICE_NOT_INUSE */ "Not in use", /*!< Not used */
- /* 2 AST_DEVICE IN USE */ "In use", /*!< In use */
- /* 3 AST_DEVICE_BUSY */ "Busy", /*!< Busy */
- /* 4 AST_DEVICE_INVALID */ "Invalid", /*!< Invalid - not known to Asterisk */
- /* 5 AST_DEVICE_UNAVAILABLE */ "Unavailable", /*!< Unavailable (not registred) */
- /* 6 AST_DEVICE_RINGING */ "Ringing", /*!< Ring, ring, ring */
- /* 7 AST_DEVICE_RINGINUSE */ "Ring+Inuse", /*!< Ring and in use */
- /* 8 AST_DEVICE_ONHOLD */ "On Hold" /*!< On Hold */
+static const char *devstatestring[][2] = {
+ { /* 0 AST_DEVICE_UNKNOWN */ "Unknown", "UNKNOWN" }, /*!< Valid, but unknown state */
+ { /* 1 AST_DEVICE_NOT_INUSE */ "Not in use", "NOT_INUSE" }, /*!< Not used */
+ { /* 2 AST_DEVICE IN USE */ "In use", "INUSE" }, /*!< In use */
+ { /* 3 AST_DEVICE_BUSY */ "Busy", "BUSY" }, /*!< Busy */
+ { /* 4 AST_DEVICE_INVALID */ "Invalid", "INVALID" }, /*!< Invalid - not known to Asterisk */
+ { /* 5 AST_DEVICE_UNAVAILABLE */ "Unavailable", "UNAVAILABLE" }, /*!< Unavailable (not registered) */
+ { /* 6 AST_DEVICE_RINGING */ "Ringing", "RINGING" }, /*!< Ring, ring, ring */
+ { /* 7 AST_DEVICE_RINGINUSE */ "Ring+Inuse", "RINGINUSE" }, /*!< Ring and in use */
+ { /* 8 AST_DEVICE_ONHOLD */ "On Hold" "ONHOLD" }, /*!< On Hold */
};
/*!\brief Mapping for channel states to device states */
@@ -204,9 +204,15 @@
static int getproviderstate(const char *provider, const char *address);
/*! \brief Find devicestate as text message for output */
+const char *ast_devstate2str(enum ast_device_state devstate)
+{
+ return devstatestring[devstate][0];
+}
+
+/* Deprecated interface (not prefixed with ast_) */
const char *devstate2str(enum ast_device_state devstate)
{
- return devstatestring[devstate];
+ return devstatestring[devstate][0];
}
enum ast_device_state ast_state_chan2dev(enum ast_channel_state chanstate)
@@ -221,40 +227,10 @@
return AST_DEVICE_UNKNOWN;
}
+/* Parseable */
const char *ast_devstate_str(enum ast_device_state state)
{
- const char *res = "UNKNOWN";
-
- switch (state) {
- case AST_DEVICE_UNKNOWN:
- break;
- case AST_DEVICE_NOT_INUSE:
- res = "NOT_INUSE";
- break;
- case AST_DEVICE_INUSE:
- res = "INUSE";
- break;
- case AST_DEVICE_BUSY:
- res = "BUSY";
- break;
- case AST_DEVICE_INVALID:
- res = "INVALID";
- break;
- case AST_DEVICE_UNAVAILABLE:
- res = "UNAVAILABLE";
- break;
- case AST_DEVICE_RINGING:
- res = "RINGING";
- break;
- case AST_DEVICE_RINGINUSE:
- res = "RINGINUSE";
- break;
- case AST_DEVICE_ONHOLD:
- res = "ONHOLD";
- break;
- }
-
- return res;
+ return devstatestring[state][1];
}
enum ast_device_state ast_devstate_val(const char *val)
@@ -478,7 +454,7 @@
state = _ast_device_state(device, 0);
- ast_debug(3, "Changing state for %s - state %d (%s)\n", device, state, devstate2str(state));
+ ast_debug(3, "Changing state for %s - state %d (%s)\n", device, state, ast_devstate2str(state));
devstate_event(device, state);
}
@@ -623,7 +599,7 @@
for (i = 0; i < collection->num_states; i++) {
ast_debug(1, "Adding per-server state of '%s' for '%s'\n",
- devstate2str(collection->states[i].state), device);
+ ast_devstate2str(collection->states[i].state), device);
ast_devstate_aggregate_add(&agg, collection->states[i].state);
}
@@ -645,13 +621,13 @@
if (state == old_state) {
/* No change since last reported device state */
ast_debug(1, "Aggregate state for device '%s' has not changed from '%s'\n",
- device, devstate2str(state));
+ device, ast_devstate2str(state));
return;
}
}
ast_debug(1, "Aggregate state for device '%s' has changed to '%s'\n",
- device, devstate2str(state));
+ device, ast_devstate2str(state));
event = ast_event_new(AST_EVENT_DEVICE_STATE,
AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, device,
Modified: trunk/main/features.c
URL: http://svn.digium.com/view/asterisk/trunk/main/features.c?view=diff&rev=154260&r1=154259&r2=154260
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Tue Nov 4 12:47:20 2008
@@ -459,7 +459,7 @@
static void notify_metermaids(const char *exten, char *context, enum ast_device_state state)
{
ast_debug(4, "Notification of state change to metermaids %s@%s\n to state '%s'",
- exten, context, devstate2str(state));
+ exten, context, ast_devstate2str(state));
ast_devstate_changed(state, "park:%s@%s", exten, context);
}
Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=154260&r1=154259&r2=154260
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Tue Nov 4 12:47:20 2008
@@ -1452,7 +1452,7 @@
result = handle_updates(s, m, cfg, dfn);
if (!result) {
ast_include_rename(cfg, sfn, dfn); /* change the include references from dfn to sfn, so things match up */
- res = config_text_file_save(dfn, cfg, "Manager");
+ res = ast_config_text_file_save(dfn, cfg, "Manager");
ast_config_destroy(cfg);
if (res) {
astman_send_error(s, m, "Save of config failed");
More information about the asterisk-commits
mailing list