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;
}
}
}
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;
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));
/* 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;
/* 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");
}
}
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");
}
}
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);
*
* \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
}
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];
#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 */
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)
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)
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);
}
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);
}
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,
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);
}
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");