aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-04 18:47:20 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-04 18:47:20 +0000
commitcf7ea7664658597f38d3a04fc1cd3a7ff12e7de1 (patch)
treedf27b5cee1f68180fcf72f85f287bb8ddccdecd6
parent09c66cfa267d36b7ec4cb3450b14498de35d3b16 (diff)
Slightly optimize ast_devstate_str and rename global functions devstate2str and config_text_file_save to have an ast_ prefix
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@154260 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_page.c4
-rw-r--r--apps/app_queue.c6
-rw-r--r--apps/app_voicemail.c6
-rw-r--r--include/asterisk/config.h3
-rw-r--r--include/asterisk/devicestate.h5
-rw-r--r--main/config.c5
-rw-r--r--main/devicestate.c70
-rw-r--r--main/features.c2
-rw-r--r--main/manager.c2
9 files changed, 43 insertions, 60 deletions
diff --git a/apps/app_page.c b/apps/app_page.c
index 89559b119..ddebbf0ac 100644
--- a/apps/app_page.c
+++ b/apps/app_page.c
@@ -178,9 +178,9 @@ static int page_exec(struct ast_channel *chan, void *data)
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;
}
}
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 81e822355..eef55f55b 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -1007,9 +1007,9 @@ static int handle_statechange(void *datap)
}
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 @@ static char *__queues_show(struct mansession *s, int fd, int argc, char **argv)
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));
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 3338de8ab..f888f3e67 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1177,7 +1177,7 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
/* 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 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
/* 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 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu,
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");
}
}
diff --git a/include/asterisk/config.h b/include/asterisk/config.h
index de42f2563..15157e239 100644
--- a/include/asterisk/config.h
+++ b/include/asterisk/config.h
@@ -388,7 +388,8 @@ int ast_variable_delete(struct ast_category *category, const char *variable, con
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);
diff --git a/include/asterisk/devicestate.h b/include/asterisk/devicestate.h
index b202d02a3..bacf54648 100644
--- a/include/asterisk/devicestate.h
+++ b/include/asterisk/devicestate.h
@@ -73,14 +73,15 @@ enum ast_device_state ast_state_chan2dev(enum ast_channel_state chanstate);
*
* \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
diff --git a/main/config.c b/main/config.c
index b3abe2730..c4d6e6f31 100644
--- a/main/config.c
+++ b/main/config.c
@@ -1560,6 +1560,11 @@ static void insert_leading_blank_lines(FILE *fp, struct inclfile *fi, struct ast
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;
diff --git a/main/devicestate.c b/main/devicestate.c
index 1601ee12c..ca739cdfe 100644
--- a/main/devicestate.c
+++ b/main/devicestate.c
@@ -128,16 +128,16 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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 @@ struct {
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 @@ enum ast_device_state ast_state_chan2dev(enum ast_channel_state chanstate)
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 @@ static void do_state_change(const char *device)
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 @@ static void process_collection(const char *device, struct change_collection *col
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 @@ static void process_collection(const char *device, struct change_collection *col
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,
diff --git a/main/features.c b/main/features.c
index adf5086aa..cc43fad68 100644
--- a/main/features.c
+++ b/main/features.c
@@ -459,7 +459,7 @@ static const char *findparkinglotname(struct ast_channel *chan)
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);
}
diff --git a/main/manager.c b/main/manager.c
index e7fd926f0..8f4917309 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -1452,7 +1452,7 @@ static int action_updateconfig(struct mansession *s, const struct message *m)
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");