change ast_strlen_zero to also check for the string to be defined

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6862 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2005-10-26 18:54:24 +00:00
parent b5326f99fc
commit a736096e0b
12 changed files with 65 additions and 65 deletions

14
app.c
View File

@@ -393,7 +393,7 @@ int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, in
int res = -1; int res = -1;
int autoclose = 0; int autoclose = 0;
if (fd < 0) { if (fd < 0) {
if (!filename || ast_strlen_zero(filename)) if (ast_strlen_zero(filename))
return -1; return -1;
autoclose = 1; autoclose = 1;
if (filename[0] == '/') if (filename[0] == '/')
@@ -998,7 +998,7 @@ int ast_app_group_split_group(char *data, char *group, int group_max, char *cate
char tmp[256]; char tmp[256];
char *grp=NULL, *cat=NULL; char *grp=NULL, *cat=NULL;
if (data && !ast_strlen_zero(data)) { if (!ast_strlen_zero(data)) {
ast_copy_string(tmp, data, sizeof(tmp)); ast_copy_string(tmp, data, sizeof(tmp));
grp = tmp; grp = tmp;
cat = strchr(tmp, '@'); cat = strchr(tmp, '@');
@@ -1008,7 +1008,7 @@ int ast_app_group_split_group(char *data, char *group, int group_max, char *cate
} }
} }
if (grp && !ast_strlen_zero(grp)) if (!ast_strlen_zero(grp))
ast_copy_string(group, grp, group_max); ast_copy_string(group, grp, group_max);
else else
res = -1; res = -1;
@@ -1043,10 +1043,10 @@ int ast_app_group_get_count(char *group, char *category)
char cat[80]; char cat[80];
char *s; char *s;
if (group == NULL || ast_strlen_zero(group)) if (ast_strlen_zero(group))
return 0; return 0;
s = (category && !ast_strlen_zero(category)) ? category : GROUP_CATEGORY_PREFIX; s = (!ast_strlen_zero(category)) ? category : GROUP_CATEGORY_PREFIX;
ast_copy_string(cat, s, sizeof(cat)); ast_copy_string(cat, s, sizeof(cat));
chan = NULL; chan = NULL;
@@ -1069,14 +1069,14 @@ int ast_app_group_match_get_count(char *groupmatch, char *category)
char cat[80]; char cat[80];
char *s; char *s;
if (!groupmatch || ast_strlen_zero(groupmatch)) if (ast_strlen_zero(groupmatch))
return 0; return 0;
/* if regex compilation fails, return zero matches */ /* if regex compilation fails, return zero matches */
if (regcomp(&regexbuf, groupmatch, REG_EXTENDED | REG_NOSUB)) if (regcomp(&regexbuf, groupmatch, REG_EXTENDED | REG_NOSUB))
return 0; return 0;
s = (category && !ast_strlen_zero(category)) ? category : GROUP_CATEGORY_PREFIX; s = (!ast_strlen_zero(category)) ? category : GROUP_CATEGORY_PREFIX;
ast_copy_string(cat, s, sizeof(cat)); ast_copy_string(cat, s, sizeof(cat));
chan = NULL; chan = NULL;

View File

@@ -1704,7 +1704,7 @@ static void ast_remotecontrol(char * data)
for(;;) { for(;;) {
ebuf = (char *)el_gets(el, &num); ebuf = (char *)el_gets(el, &num);
if (ebuf && !ast_strlen_zero(ebuf)) { if (!ast_strlen_zero(ebuf)) {
if (ebuf[strlen(ebuf)-1] == '\n') if (ebuf[strlen(ebuf)-1] == '\n')
ebuf[strlen(ebuf)-1] = '\0'; ebuf[strlen(ebuf)-1] = '\0';
if (!remoteconsolehandler(ebuf)) { if (!remoteconsolehandler(ebuf)) {

View File

@@ -429,7 +429,7 @@ static int callerid_genmsg(char *msg, int size, char *number, char *name, int fl
tm.tm_mday, tm.tm_hour, tm.tm_min); tm.tm_mday, tm.tm_hour, tm.tm_min);
size -= res; size -= res;
ptr += res; ptr += res;
if (!number || ast_strlen_zero(number) || (flags & CID_UNKNOWN_NUMBER)) { if (ast_strlen_zero(number) || (flags & CID_UNKNOWN_NUMBER)) {
/* Indicate number not known */ /* Indicate number not known */
res = snprintf(ptr, size, "\004\001O"); res = snprintf(ptr, size, "\004\001O");
size -= res; size -= res;
@@ -453,7 +453,7 @@ static int callerid_genmsg(char *msg, int size, char *number, char *name, int fl
size -= i; size -= i;
} }
if (!name || ast_strlen_zero(name) || (flags & CID_UNKNOWN_NAME)) { if (ast_strlen_zero(name) || (flags & CID_UNKNOWN_NAME)) {
/* Indicate name not known */ /* Indicate name not known */
res = snprintf(ptr, size, "\010\001O"); res = snprintf(ptr, size, "\010\001O");
size -= res; size -= res;
@@ -617,7 +617,7 @@ void ast_shrink_phone_number(char *n)
int ast_isphonenumber(char *n) int ast_isphonenumber(char *n)
{ {
int x; int x;
if (!n || ast_strlen_zero(n)) if (ast_strlen_zero(n))
return 0; return 0;
for (x=0;n[x];x++) for (x=0;n[x];x++)
if (!strchr("0123456789*#+", n[x])) if (!strchr("0123456789*#+", n[x]))
@@ -649,8 +649,7 @@ int ast_callerid_parse(char *instr, char **name, char **location)
while(!ast_strlen_zero(instr) && (instr[strlen(instr) - 1] < 33)) while(!ast_strlen_zero(instr) && (instr[strlen(instr) - 1] < 33))
instr[strlen(instr) - 1] = '\0'; instr[strlen(instr) - 1] = '\0';
/* And leading spaces */ /* And leading spaces */
while(**name && (**name < 33)) *name = ast_skip_blanks(*name);
(*name)++;
return 0; return 0;
} }
} else { } else {
@@ -675,9 +674,9 @@ int ast_callerid_parse(char *instr, char **name, char **location)
static int __ast_callerid_generate(unsigned char *buf, char *name, char *number, int callwaiting, int codec) static int __ast_callerid_generate(unsigned char *buf, char *name, char *number, int callwaiting, int codec)
{ {
if (name && ast_strlen_zero(name)) if (ast_strlen_zero(name))
name = NULL; name = NULL;
if (number && ast_strlen_zero(number)) if (ast_strlen_zero(number))
number = NULL; number = NULL;
return callerid_generate(buf, number, name, 0, callwaiting, codec); return callerid_generate(buf, number, name, 0, callwaiting, codec);
} }

2
cdr.c
View File

@@ -179,7 +179,7 @@ static const char *ast_cdr_getvar_internal(struct ast_cdr *cdr, const char *name
struct ast_var_t *variables; struct ast_var_t *variables;
struct varshead *headp; struct varshead *headp;
if (!name || ast_strlen_zero(name)) if (ast_strlen_zero(name))
return NULL; return NULL;
while (cdr) { while (cdr) {

View File

@@ -631,7 +631,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
} }
if (process_buf) { if (process_buf) {
char *buf = ast_strip(process_buf); char *buf = ast_strip(process_buf);
if (!ast_strlen_zero(buf)) if (!ast_strlen_zero(buf)) {
if (process_text_line(cfg, &cat, buf, lineno, filename)) { if (process_text_line(cfg, &cat, buf, lineno, filename)) {
cfg = NULL; cfg = NULL;
break; break;
@@ -639,6 +639,7 @@ static struct ast_config *config_text_file_load(const char *database, const char
} }
} }
} }
}
fclose(f); fclose(f);
} else { /* can't open file */ } else { /* can't open file */
if (option_debug) if (option_debug)

6
db.c
View File

@@ -400,8 +400,8 @@ struct ast_db_entry *ast_db_gettree(const char *family, const char *keytree)
struct ast_db_entry *last = NULL; struct ast_db_entry *last = NULL;
struct ast_db_entry *cur, *ret=NULL; struct ast_db_entry *cur, *ret=NULL;
if (family && !ast_strlen_zero(family)) { if (!ast_strlen_zero(family)) {
if (keytree && !ast_strlen_zero(keytree)) { if (!ast_strlen_zero(keytree)) {
/* Family and key tree */ /* Family and key tree */
snprintf(prefix, sizeof(prefix), "/%s/%s", family, prefix); snprintf(prefix, sizeof(prefix), "/%s/%s", family, prefix);
} else { } else {
@@ -557,7 +557,7 @@ static int manager_dbget(struct mansession *s, struct message *m)
return 0; return 0;
} }
if (id && !ast_strlen_zero(id)) if (!ast_strlen_zero(id))
snprintf(idText, sizeof(idText) ,"ActionID: %s\r\n", id); snprintf(idText, sizeof(idText) ,"ActionID: %s\r\n", id);
res = ast_db_get(family, key, tmp, sizeof(tmp)); res = ast_db_get(family, key, tmp, sizeof(tmp));

View File

@@ -82,7 +82,7 @@ struct ast_dnsmgr_entry *ast_dnsmgr_get(const char *name, struct in_addr *result
{ {
struct ast_dnsmgr_entry *entry; struct ast_dnsmgr_entry *entry;
if (!name || !result || ast_strlen_zero(name)) if (!result || ast_strlen_zero(name))
return NULL; return NULL;
entry = calloc(1, sizeof(*entry) + strlen(name)); entry = calloc(1, sizeof(*entry) + strlen(name));
@@ -112,7 +112,7 @@ void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry)
int ast_dnsmgr_lookup(const char *name, struct in_addr *result, struct ast_dnsmgr_entry **dnsmgr) int ast_dnsmgr_lookup(const char *name, struct in_addr *result, struct ast_dnsmgr_entry **dnsmgr)
{ {
if (!name || ast_strlen_zero(name) || !result || !dnsmgr) if (ast_strlen_zero(name) || !result || !dnsmgr)
return -1; return -1;
if (*dnsmgr && !strcasecmp((*dnsmgr)->name, name)) if (*dnsmgr && !strcasecmp((*dnsmgr)->name, name))

6
file.c
View File

@@ -489,7 +489,7 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
if (chan->generator) if (chan->generator)
ast_deactivate_generator(chan); ast_deactivate_generator(chan);
} }
if (preflang && !ast_strlen_zero(preflang)) { if (!ast_strlen_zero(preflang)) {
ast_copy_string(filename3, filename, sizeof(filename3)); ast_copy_string(filename3, filename, sizeof(filename3));
endpart = strrchr(filename3, '/'); endpart = strrchr(filename3, '/');
if (endpart) { if (endpart) {
@@ -538,7 +538,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
char lang2[MAX_LANGUAGE]; char lang2[MAX_LANGUAGE];
/* XXX H.263 only XXX */ /* XXX H.263 only XXX */
char *fmt = "h263"; char *fmt = "h263";
if (preflang && !ast_strlen_zero(preflang)) { if (!ast_strlen_zero(preflang)) {
snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename); snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename);
fmts = ast_fileexists(filename2, fmt, NULL); fmts = ast_fileexists(filename2, fmt, NULL);
if (fmts < 1) { if (fmts < 1) {
@@ -739,7 +739,7 @@ int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
char *c; char *c;
char lang2[MAX_LANGUAGE]; char lang2[MAX_LANGUAGE];
int res = -1; int res = -1;
if (preflang && !ast_strlen_zero(preflang)) { if (!ast_strlen_zero(preflang)) {
/* Insert the language between the last two parts of the path */ /* Insert the language between the last two parts of the path */
ast_copy_string(tmp, filename, sizeof(tmp)); ast_copy_string(tmp, filename, sizeof(tmp));
c = strrchr(tmp, '/'); c = strrchr(tmp, '/');

View File

@@ -32,7 +32,7 @@
static inline int ast_strlen_zero(const char *s) static inline int ast_strlen_zero(const char *s)
{ {
return (*s == '\0'); return (!s || (*s == '\0'));
} }
/*! /*!

View File

@@ -348,7 +348,7 @@ void astman_send_error(struct mansession *s, struct message *m, char *error)
char *id = astman_get_header(m,"ActionID"); char *id = astman_get_header(m,"ActionID");
ast_cli(s->fd, "Response: Error\r\n"); ast_cli(s->fd, "Response: Error\r\n");
if (id && !ast_strlen_zero(id)) if (!ast_strlen_zero(id))
ast_cli(s->fd, "ActionID: %s\r\n",id); ast_cli(s->fd, "ActionID: %s\r\n",id);
ast_cli(s->fd, "Message: %s\r\n\r\n", error); ast_cli(s->fd, "Message: %s\r\n\r\n", error);
} }
@@ -358,7 +358,7 @@ void astman_send_response(struct mansession *s, struct message *m, char *resp, c
char *id = astman_get_header(m,"ActionID"); char *id = astman_get_header(m,"ActionID");
ast_cli(s->fd, "Response: %s\r\n", resp); ast_cli(s->fd, "Response: %s\r\n", resp);
if (id && !ast_strlen_zero(id)) if (!ast_strlen_zero(id))
ast_cli(s->fd, "ActionID: %s\r\n",id); ast_cli(s->fd, "ActionID: %s\r\n",id);
if (msg) if (msg)
ast_cli(s->fd, "Message: %s\r\n\r\n", msg); ast_cli(s->fd, "Message: %s\r\n\r\n", msg);
@@ -433,7 +433,7 @@ static int ast_strings_to_mask(char *string)
if (x) { if (x) {
ret = x; ret = x;
} else if (!string || ast_strlen_zero(string)) { } else if (ast_strlen_zero(string)) {
ret = -1; ret = -1;
} else if (ast_false(string)) { } else if (ast_false(string)) {
ret = 0; ret = 0;
@@ -517,7 +517,7 @@ static int authenticate(struct mansession *s, struct message *m)
} else if (ha) } else if (ha)
ast_free_ha(ha); ast_free_ha(ha);
if (!strcasecmp(authtype, "MD5")) { if (!strcasecmp(authtype, "MD5")) {
if (key && !ast_strlen_zero(key) && s->challenge) { if (!ast_strlen_zero(key) && s->challenge) {
int x; int x;
int len=0; int len=0;
char md5key[256] = ""; char md5key[256] = "";
@@ -584,7 +584,7 @@ static int action_listcommands(struct mansession *s, struct message *m)
char temp[BUFSIZ]; char temp[BUFSIZ];
char *id = astman_get_header(m,"ActionID"); char *id = astman_get_header(m,"ActionID");
if (id && !ast_strlen_zero(id)) if (!ast_strlen_zero(id))
snprintf(idText,256,"ActionID: %s\r\n",id); snprintf(idText,256,"ActionID: %s\r\n",id);
ast_cli(s->fd, "Response: Success\r\n%s", idText); ast_cli(s->fd, "Response: Success\r\n%s", idText);
ast_mutex_lock(&actionlock); ast_mutex_lock(&actionlock);
@@ -729,7 +729,7 @@ static int action_getvar(struct mansession *s, struct message *m)
ast_mutex_unlock(&c->lock); ast_mutex_unlock(&c->lock);
ast_cli(s->fd, "Response: Success\r\n" ast_cli(s->fd, "Response: Success\r\n"
"Variable: %s\r\nValue: %s\r\n" ,varname,varval2); "Variable: %s\r\nValue: %s\r\n" ,varname,varval2);
if (id && !ast_strlen_zero(id)) if (!ast_strlen_zero(id))
ast_cli(s->fd, "ActionID: %s\r\n",id); ast_cli(s->fd, "ActionID: %s\r\n",id);
ast_cli(s->fd, "\r\n"); ast_cli(s->fd, "\r\n");
@@ -748,10 +748,10 @@ static int action_status(struct mansession *s, struct message *m)
char bridge[256]; char bridge[256];
struct timeval now = ast_tvnow(); struct timeval now = ast_tvnow();
long elapsed_seconds=0; long elapsed_seconds=0;
int all = !name || ast_strlen_zero(name); /* set if we want all channels */ int all = ast_strlen_zero(name); /* set if we want all channels */
astman_send_ack(s, m, "Channel status will follow"); astman_send_ack(s, m, "Channel status will follow");
if (id && !ast_strlen_zero(id)) if (!ast_strlen_zero(id))
snprintf(idText,256,"ActionID: %s\r\n",id); snprintf(idText,256,"ActionID: %s\r\n",id);
if (all) if (all)
c = ast_channel_walk_locked(NULL); c = ast_channel_walk_locked(NULL);
@@ -847,7 +847,7 @@ static int action_redirect(struct mansession *s, struct message *m)
int pi = 0; int pi = 0;
int res; int res;
if (!name || ast_strlen_zero(name)) { if (ast_strlen_zero(name)) {
astman_send_error(s, m, "Channel not specified"); astman_send_error(s, m, "Channel not specified");
return 0; return 0;
} }
@@ -898,7 +898,7 @@ static int action_command(struct mansession *s, struct message *m)
char *cmd = astman_get_header(m, "Command"); char *cmd = astman_get_header(m, "Command");
char *id = astman_get_header(m, "ActionID"); char *id = astman_get_header(m, "ActionID");
ast_cli(s->fd, "Response: Follows\r\nPrivilege: Command\r\n"); ast_cli(s->fd, "Response: Follows\r\nPrivilege: Command\r\n");
if (id && !ast_strlen_zero(id)) if (!ast_strlen_zero(id))
ast_cli(s->fd, "ActionID: %s\r\n", id); ast_cli(s->fd, "ActionID: %s\r\n", id);
/* FIXME: Wedge a ActionID response in here, waiting for later changes */ /* FIXME: Wedge a ActionID response in here, waiting for later changes */
ast_cli_command(s->fd, cmd); ast_cli_command(s->fd, cmd);
@@ -1037,7 +1037,7 @@ static int action_originate(struct mansession *s, struct message *m)
res = -1; res = -1;
} else { } else {
memset(fast, 0, sizeof(struct fast_originate_helper)); memset(fast, 0, sizeof(struct fast_originate_helper));
if (id && !ast_strlen_zero(id)) if (!ast_strlen_zero(id))
snprintf(fast->idtext, sizeof(fast->idtext), "ActionID: %s\r\n", id); snprintf(fast->idtext, sizeof(fast->idtext), "ActionID: %s\r\n", id);
ast_copy_string(fast->tech, tech, sizeof(fast->tech)); ast_copy_string(fast->tech, tech, sizeof(fast->tech));
ast_copy_string(fast->data, data, sizeof(fast->data)); ast_copy_string(fast->data, data, sizeof(fast->data));
@@ -1093,11 +1093,11 @@ static int action_mailboxstatus(struct mansession *s, struct message *m)
char *id = astman_get_header(m,"ActionID"); char *id = astman_get_header(m,"ActionID");
char idText[256] = ""; char idText[256] = "";
int ret; int ret;
if (!mailbox || ast_strlen_zero(mailbox)) { if (ast_strlen_zero(mailbox)) {
astman_send_error(s, m, "Mailbox not specified"); astman_send_error(s, m, "Mailbox not specified");
return 0; return 0;
} }
if (id && !ast_strlen_zero(id)) if (!ast_strlen_zero(id))
snprintf(idText,256,"ActionID: %s\r\n",id); snprintf(idText,256,"ActionID: %s\r\n",id);
ret = ast_app_has_voicemail(mailbox, NULL); ret = ast_app_has_voicemail(mailbox, NULL);
ast_cli(s->fd, "Response: Success\r\n" ast_cli(s->fd, "Response: Success\r\n"
@@ -1125,12 +1125,12 @@ static int action_mailboxcount(struct mansession *s, struct message *m)
char *id = astman_get_header(m,"ActionID"); char *id = astman_get_header(m,"ActionID");
char idText[256] = ""; char idText[256] = "";
int newmsgs = 0, oldmsgs = 0; int newmsgs = 0, oldmsgs = 0;
if (!mailbox || ast_strlen_zero(mailbox)) { if (ast_strlen_zero(mailbox)) {
astman_send_error(s, m, "Mailbox not specified"); astman_send_error(s, m, "Mailbox not specified");
return 0; return 0;
} }
ast_app_messagecount(mailbox, &newmsgs, &oldmsgs); ast_app_messagecount(mailbox, &newmsgs, &oldmsgs);
if (id && !ast_strlen_zero(id)) { if (!ast_strlen_zero(id)) {
snprintf(idText,256,"ActionID: %s\r\n",id); snprintf(idText,256,"ActionID: %s\r\n",id);
} }
ast_cli(s->fd, "Response: Success\r\n" ast_cli(s->fd, "Response: Success\r\n"
@@ -1163,15 +1163,15 @@ static int action_extensionstate(struct mansession *s, struct message *m)
char idText[256] = ""; char idText[256] = "";
char hint[256] = ""; char hint[256] = "";
int status; int status;
if (!exten || ast_strlen_zero(exten)) { if (ast_strlen_zero(exten)) {
astman_send_error(s, m, "Extension not specified"); astman_send_error(s, m, "Extension not specified");
return 0; return 0;
} }
if (!context || ast_strlen_zero(context)) if (ast_strlen_zero(context))
context = "default"; context = "default";
status = ast_extension_state(NULL, context, exten); status = ast_extension_state(NULL, context, exten);
ast_get_hint(hint, sizeof(hint) - 1, NULL, 0, NULL, context, exten); ast_get_hint(hint, sizeof(hint) - 1, NULL, 0, NULL, context, exten);
if (id && !ast_strlen_zero(id)) { if (!ast_strlen_zero(id)) {
snprintf(idText,256,"ActionID: %s\r\n",id); snprintf(idText,256,"ActionID: %s\r\n",id);
} }
ast_cli(s->fd, "Response: Success\r\n" ast_cli(s->fd, "Response: Success\r\n"
@@ -1231,7 +1231,7 @@ static int process_message(struct mansession *s, struct message *m)
astman_send_error(s, m, "Missing action in request"); astman_send_error(s, m, "Missing action in request");
return 0; return 0;
} }
if (id && !ast_strlen_zero(id)) { if (!ast_strlen_zero(id)) {
snprintf(idText,256,"ActionID: %s\r\n",id); snprintf(idText,256,"ActionID: %s\r\n",id);
} }
if (!s->authenticated) { if (!s->authenticated) {
@@ -1239,7 +1239,7 @@ static int process_message(struct mansession *s, struct message *m)
char *authtype; char *authtype;
authtype = astman_get_header(m, "AuthType"); authtype = astman_get_header(m, "AuthType");
if (!strcasecmp(authtype, "MD5")) { if (!strcasecmp(authtype, "MD5")) {
if (!s->challenge || ast_strlen_zero(s->challenge)) if (ast_strlen_zero(s->challenge))
snprintf(s->challenge, sizeof(s->challenge), "%d", rand()); snprintf(s->challenge, sizeof(s->challenge), "%d", rand());
ast_mutex_lock(&s->__lock); ast_mutex_lock(&s->__lock);
ast_cli(s->fd, "Response: Success\r\n" ast_cli(s->fd, "Response: Success\r\n"

34
pbx.c
View File

@@ -4528,9 +4528,9 @@ int ast_explicit_goto(struct ast_channel *chan, const char *context, const char
if (!chan) if (!chan)
return -1; return -1;
if (context && !ast_strlen_zero(context)) if (!ast_strlen_zero(context))
ast_copy_string(chan->context, context, sizeof(chan->context)); ast_copy_string(chan->context, context, sizeof(chan->context));
if (exten && !ast_strlen_zero(exten)) if (!ast_strlen_zero(exten))
ast_copy_string(chan->exten, exten, sizeof(chan->exten)); ast_copy_string(chan->exten, exten, sizeof(chan->exten));
if (priority > -1) { if (priority > -1) {
chan->priority = priority; chan->priority = priority;
@@ -4566,8 +4566,8 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
tmpchan->writeformat = chan->writeformat; tmpchan->writeformat = chan->writeformat;
/* Setup proper location */ /* Setup proper location */
ast_explicit_goto(tmpchan, ast_explicit_goto(tmpchan,
(context && !ast_strlen_zero(context)) ? context : chan->context, (!ast_strlen_zero(context)) ? context : chan->context,
(exten && !ast_strlen_zero(exten)) ? exten : chan->exten, (!ast_strlen_zero(exten)) ? exten : chan->exten,
priority); priority);
/* Masquerade into temp channel */ /* Masquerade into temp channel */
@@ -5053,7 +5053,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
chan = ast_channel_alloc(0); chan = ast_channel_alloc(0);
if (chan) { if (chan) {
ast_copy_string(chan->name, "OutgoingSpoolFailed", sizeof(chan->name)); ast_copy_string(chan->name, "OutgoingSpoolFailed", sizeof(chan->name));
if (context && !ast_strlen_zero(context)) if (!ast_strlen_zero(context))
ast_copy_string(chan->context, context, sizeof(chan->context)); ast_copy_string(chan->context, context, sizeof(chan->context));
ast_copy_string(chan->exten, "failed", sizeof(chan->exten)); ast_copy_string(chan->exten, "failed", sizeof(chan->exten));
chan->priority = 1; chan->priority = 1;
@@ -5142,7 +5142,7 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
if (locked_channel) if (locked_channel)
*locked_channel = NULL; *locked_channel = NULL;
if (!app || ast_strlen_zero(app)) { if (ast_strlen_zero(app)) {
res = -1; res = -1;
goto outgoing_app_cleanup; goto outgoing_app_cleanup;
} }
@@ -5496,7 +5496,7 @@ static int pbx_builtin_prefix(struct ast_channel *chan, void *data)
{ {
char newexten[AST_MAX_EXTENSION]; char newexten[AST_MAX_EXTENSION];
if (!data || ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_DEBUG, "Ignoring, since there is no prefix to add\n"); ast_log(LOG_DEBUG, "Ignoring, since there is no prefix to add\n");
return 0; return 0;
} }
@@ -5511,7 +5511,7 @@ static int pbx_builtin_suffix(struct ast_channel *chan, void *data)
{ {
char newexten[AST_MAX_EXTENSION]; char newexten[AST_MAX_EXTENSION];
if (!data || ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_DEBUG, "Ignoring, since there is no suffix to add\n"); ast_log(LOG_DEBUG, "Ignoring, since there is no suffix to add\n");
return 0; return 0;
} }
@@ -5528,7 +5528,7 @@ static int pbx_builtin_gotoiftime(struct ast_channel *chan, void *data)
char *s, *ts; char *s, *ts;
struct ast_timing timing; struct ast_timing timing;
if (!data || ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n <time range>|<days of week>|<days of month>|<months>?[[context|]extension|]priority\n"); ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n <time range>|<days of week>|<days of month>|<months>?[[context|]extension|]priority\n");
return -1; return -1;
} }
@@ -5556,7 +5556,7 @@ static int pbx_builtin_execiftime(struct ast_channel *chan, void *data)
struct ast_app *app; struct ast_app *app;
const char *usage = "ExecIfTime requires an argument:\n <time range>|<days of week>|<days of month>|<months>?<appname>[|<appargs>]"; const char *usage = "ExecIfTime requires an argument:\n <time range>|<days of week>|<days of month>|<months>?<appname>[|<appargs>]";
if (!data || ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "%s\n", usage); ast_log(LOG_WARNING, "%s\n", usage);
return -1; return -1;
} }
@@ -5943,7 +5943,7 @@ int pbx_builtin_setvar(struct ast_channel *chan, void *data)
int global = 0; int global = 0;
int x; int x;
if (!data || ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Set requires at least one variable name/value pair.\n"); ast_log(LOG_WARNING, "Set requires at least one variable name/value pair.\n");
return 0; return 0;
} }
@@ -5981,7 +5981,7 @@ int pbx_builtin_importvar(struct ast_channel *chan, void *data)
char tmp[VAR_BUF_SIZE]=""; char tmp[VAR_BUF_SIZE]="";
char *s; char *s;
if (!data || ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Ignoring, since there is no variable to set\n"); ast_log(LOG_WARNING, "Ignoring, since there is no variable to set\n");
return 0; return 0;
} }
@@ -6012,7 +6012,7 @@ static int pbx_builtin_setglobalvar(struct ast_channel *chan, void *data)
char *value; char *value;
char *stringp = NULL; char *stringp = NULL;
if (!data || ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Ignoring, since there is no variable to set\n"); ast_log(LOG_WARNING, "Ignoring, since there is no variable to set\n");
return 0; return 0;
} }
@@ -6067,7 +6067,7 @@ static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
int rc; int rc;
char *stringp=NULL; char *stringp=NULL;
if (!data || ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Ignoring, since there is no variable to check\n"); ast_log(LOG_WARNING, "Ignoring, since there is no variable to check\n");
return 0; return 0;
} }
@@ -6079,7 +6079,7 @@ static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
branch2=strsep(&stringp,""); branch2=strsep(&stringp,"");
branch = pbx_checkcondition(condition) ? branch1 : branch2; branch = pbx_checkcondition(condition) ? branch1 : branch2;
if ((branch==NULL) || ast_strlen_zero(branch)) { if (ast_strlen_zero(branch)) {
ast_log(LOG_DEBUG, "Not taking any branch\n"); ast_log(LOG_DEBUG, "Not taking any branch\n");
return(0); return(0);
} }
@@ -6097,7 +6097,7 @@ static int pbx_builtin_saynumber(struct ast_channel *chan, void *data)
char *options = (char *) NULL; char *options = (char *) NULL;
if (!data || ast_strlen_zero((char *)data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "SayNumber requires an argument (number)\n"); ast_log(LOG_WARNING, "SayNumber requires an argument (number)\n");
return -1; return -1;
} }
@@ -6387,7 +6387,7 @@ int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
int ipri; int ipri;
int mode = 0; int mode = 0;
if (!goto_string || ast_strlen_zero(goto_string)) { if (ast_strlen_zero(goto_string)) {
ast_log(LOG_WARNING, "Goto requires an argument (optional context|optional extension|priority)\n"); ast_log(LOG_WARNING, "Goto requires an argument (optional context|optional extension|priority)\n");
return -1; return -1;
} }

View File

@@ -570,7 +570,7 @@ int ast_build_string(char **buffer, size_t *space, const char *fmt, ...)
int ast_true(const char *s) int ast_true(const char *s)
{ {
if (!s || ast_strlen_zero(s)) if (ast_strlen_zero(s))
return 0; return 0;
/* Determine if this is a true value */ /* Determine if this is a true value */
@@ -587,7 +587,7 @@ int ast_true(const char *s)
int ast_false(const char *s) int ast_false(const char *s)
{ {
if (!s || ast_strlen_zero(s)) if (ast_strlen_zero(s))
return 0; return 0;
/* Determine if this is a false value */ /* Determine if this is a false value */