mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-17 07:18:15 +00:00
Code cleanup of res_smdi
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@74705 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -94,8 +94,7 @@ int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox)
|
|||||||
FILE *file;
|
FILE *file;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
file = fopen(iface->name, "w");
|
if (!(file = fopen(iface->name, "w"))) {
|
||||||
if(!file) {
|
|
||||||
ast_log(LOG_ERROR, "Error opening SMDI interface %s (%s) for writing\n", iface->name, strerror(errno));
|
ast_log(LOG_ERROR, "Error opening SMDI interface %s (%s) for writing\n", iface->name, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -104,7 +103,7 @@ int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox)
|
|||||||
|
|
||||||
fprintf(file, "OP:MWI ");
|
fprintf(file, "OP:MWI ");
|
||||||
|
|
||||||
for(i = 0; i < iface->msdstrip; i++)
|
for (i = 0; i < iface->msdstrip; i++)
|
||||||
fprintf(file, "0");
|
fprintf(file, "0");
|
||||||
|
|
||||||
fprintf(file, "%s!\x04", mailbox);
|
fprintf(file, "%s!\x04", mailbox);
|
||||||
@@ -125,8 +124,7 @@ int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox)
|
|||||||
FILE *file;
|
FILE *file;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
file = fopen(iface->name, "w");
|
if (!(file = fopen(iface->name, "w"))) {
|
||||||
if(!file) {
|
|
||||||
ast_log(LOG_ERROR, "Error opening SMDI interface %s (%s) for writing\n", iface->name, strerror(errno));
|
ast_log(LOG_ERROR, "Error opening SMDI interface %s (%s) for writing\n", iface->name, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -135,7 +133,7 @@ int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox)
|
|||||||
|
|
||||||
fprintf(file, "RMV:MWI ");
|
fprintf(file, "RMV:MWI ");
|
||||||
|
|
||||||
for(i = 0; i < iface->msdstrip; i++)
|
for (i = 0; i < iface->msdstrip; i++)
|
||||||
fprintf(file, "0");
|
fprintf(file, "0");
|
||||||
|
|
||||||
fprintf(file, "%s!\x04", mailbox);
|
fprintf(file, "%s!\x04", mailbox);
|
||||||
@@ -225,11 +223,10 @@ struct ast_smdi_md_message *ast_smdi_md_message_pop(struct ast_smdi_interface *i
|
|||||||
*/
|
*/
|
||||||
extern struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout)
|
extern struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout)
|
||||||
{
|
{
|
||||||
struct timeval start;
|
struct timeval start = ast_tvnow();
|
||||||
long diff = 0;
|
long diff = 0;
|
||||||
struct ast_smdi_md_message *msg;
|
struct ast_smdi_md_message *msg;
|
||||||
|
|
||||||
start = ast_tvnow();
|
|
||||||
while (diff < timeout) {
|
while (diff < timeout) {
|
||||||
|
|
||||||
if ((msg = ast_smdi_md_message_pop(iface)))
|
if ((msg = ast_smdi_md_message_pop(iface)))
|
||||||
@@ -255,11 +252,10 @@ extern struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_inte
|
|||||||
extern struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_interface *iface)
|
extern struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_interface *iface)
|
||||||
{
|
{
|
||||||
struct ast_smdi_mwi_message *mwi_msg = ASTOBJ_CONTAINER_UNLINK_START(&iface->mwi_q);
|
struct ast_smdi_mwi_message *mwi_msg = ASTOBJ_CONTAINER_UNLINK_START(&iface->mwi_q);
|
||||||
struct timeval now;
|
struct timeval now = ast_tvnow();
|
||||||
long elapsed = 0;
|
long elapsed = 0;
|
||||||
|
|
||||||
/* purge old messages */
|
/* purge old messages */
|
||||||
now = ast_tvnow();
|
|
||||||
while (mwi_msg) {
|
while (mwi_msg) {
|
||||||
elapsed = ast_tvdiff_ms(now, mwi_msg->timestamp);
|
elapsed = ast_tvdiff_ms(now, mwi_msg->timestamp);
|
||||||
|
|
||||||
@@ -293,11 +289,10 @@ extern struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_int
|
|||||||
*/
|
*/
|
||||||
extern struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait(struct ast_smdi_interface *iface, int timeout)
|
extern struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait(struct ast_smdi_interface *iface, int timeout)
|
||||||
{
|
{
|
||||||
struct timeval start;
|
struct timeval start = ast_tvnow();
|
||||||
long diff = 0;
|
long diff = 0;
|
||||||
struct ast_smdi_mwi_message *msg;
|
struct ast_smdi_mwi_message *msg;
|
||||||
|
|
||||||
start = ast_tvnow();
|
|
||||||
while (diff < timeout) {
|
while (diff < timeout) {
|
||||||
|
|
||||||
if ((msg = ast_smdi_mwi_message_pop(iface)))
|
if ((msg = ast_smdi_mwi_message_pop(iface)))
|
||||||
@@ -529,9 +524,7 @@ static int smdi_load(int reload)
|
|||||||
int msdstrip = 0; /* strip zero digits */
|
int msdstrip = 0; /* strip zero digits */
|
||||||
long msg_expiry = SMDI_MSG_EXPIRY_TIME;
|
long msg_expiry = SMDI_MSG_EXPIRY_TIME;
|
||||||
|
|
||||||
conf = ast_config_load(config_file);
|
if (!(conf = ast_config_load(config_file))) {
|
||||||
|
|
||||||
if (!conf) {
|
|
||||||
if (reload)
|
if (reload)
|
||||||
ast_log(LOG_NOTICE, "Unable to reload config %s: SMDI untouched\n", config_file);
|
ast_log(LOG_NOTICE, "Unable to reload config %s: SMDI untouched\n", config_file);
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user