import gcc 4.3.2 warning fixes from trunk, with a few changes specific to this branch

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@153710 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.1
Kevin P. Fleming 17 years ago
parent bdb5cf6f46
commit 1036849a42

@ -79,7 +79,9 @@ static int read_environment(void)
char *val; char *val;
/* Read environment */ /* Read environment */
for(;;) { for(;;) {
fgets(buf, sizeof(buf), stdin); if (!fgets(buf, sizeof(buf), stdin)) {
return -1;
}
if (feof(stdin)) if (feof(stdin))
return -1; return -1;
buf[strlen(buf) - 1] = '\0'; buf[strlen(buf) - 1] = '\0';
@ -130,7 +132,9 @@ static char *wait_result(void)
return NULL; return NULL;
} }
if (FD_ISSET(STDIN_FILENO, &fds)) { if (FD_ISSET(STDIN_FILENO, &fds)) {
fgets(astresp, sizeof(astresp), stdin); if (!fgets(astresp, sizeof(astresp), stdin)) {
return NULL;
}
if (feof(stdin)) { if (feof(stdin)) {
fprintf(stderr, "Got hungup on apparently\n"); fprintf(stderr, "Got hungup on apparently\n");
return NULL; return NULL;
@ -141,9 +145,10 @@ static char *wait_result(void)
} }
if (FD_ISSET(AUDIO_FILENO, &fds)) { if (FD_ISSET(AUDIO_FILENO, &fds)) {
res = read(AUDIO_FILENO, audiobuf, sizeof(audiobuf)); res = read(AUDIO_FILENO, audiobuf, sizeof(audiobuf));
if (res > 0) { if ((res > 0) && (sphinx_sock > -1)) {
if (sphinx_sock > -1) if (write(sphinx_sock, audiobuf, res) < 0) {
write(sphinx_sock, audiobuf, res); fprintf(stderr, "write() failed: %s\n", strerror(errno));
}
} }
} }
if ((sphinx_sock > -1) && FD_ISSET(sphinx_sock, &fds)) { if ((sphinx_sock > -1) && FD_ISSET(sphinx_sock, &fds)) {

@ -24,7 +24,9 @@ static int read_environment(void)
char *val; char *val;
/* Read environment */ /* Read environment */
for(;;) { for(;;) {
fgets(buf, sizeof(buf), stdin); if (!fgets(buf, sizeof(buf), stdin)) {
return -1;
}
if (feof(stdin)) if (feof(stdin))
return -1; return -1;
buf[strlen(buf) - 1] = '\0'; buf[strlen(buf) - 1] = '\0';
@ -68,7 +70,9 @@ static char *wait_result(void)
return NULL; return NULL;
} }
if (FD_ISSET(STDIN_FILENO, &fds)) { if (FD_ISSET(STDIN_FILENO, &fds)) {
fgets(astresp, sizeof(astresp), stdin); if (!fgets(astresp, sizeof(astresp), stdin)) {
return NULL;
}
if (feof(stdin)) { if (feof(stdin)) {
fprintf(stderr, "Got hungup on apparently\n"); fprintf(stderr, "Got hungup on apparently\n");
return NULL; return NULL;

@ -1369,7 +1369,9 @@ static struct adsi_script *compile_script(char *script)
/* Create "main" as first subroutine */ /* Create "main" as first subroutine */
getsubbyname(scr, "main", NULL, 0); getsubbyname(scr, "main", NULL, 0);
while (!feof(f)) { while (!feof(f)) {
fgets(buf, sizeof(buf), f); if (!fgets(buf, sizeof(buf), f)) {
continue;
}
if (!feof(f)) { if (!feof(f)) {
lineno++; lineno++;
/* Trim off trailing return */ /* Trim off trailing return */

@ -151,7 +151,9 @@ static int auth_exec(struct ast_channel *chan, void *data)
if (feof(f)) if (feof(f))
break; break;
fgets(buf, sizeof(buf), f); if (!fgets(buf, sizeof(buf), f)) {
continue;
}
if (ast_strlen_zero(buf)) if (ast_strlen_zero(buf))
continue; continue;

@ -34,6 +34,7 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$") ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <ctype.h> #include <ctype.h>
#include <errno.h>
#include "asterisk/paths.h" /* use ast_config_AST_MONITOR_DIR */ #include "asterisk/paths.h" /* use ast_config_AST_MONITOR_DIR */
#include "asterisk/file.h" #include "asterisk/file.h"
@ -264,8 +265,11 @@ static int spy_generate(struct ast_channel *chan, void *data, int len, int sampl
return -1; return -1;
} }
if (csth->fd) if (csth->fd) {
write(csth->fd, f->data.ptr, f->datalen); if (write(csth->fd, f->data.ptr, f->datalen) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
}
ast_frfree(f); ast_frfree(f);

@ -1822,10 +1822,16 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], ','); gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], ',');
if (gosub_argstart) { if (gosub_argstart) {
*gosub_argstart = 0; *gosub_argstart = 0;
asprintf(&gosub_args, "%s,s,1(%s)", opt_args[OPT_ARG_CALLEE_GOSUB], gosub_argstart + 1); if (asprintf(&gosub_args, "%s,s,1(%s)", opt_args[OPT_ARG_CALLEE_GOSUB], gosub_argstart + 1) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
gosub_args = NULL;
}
*gosub_argstart = ','; *gosub_argstart = ',';
} else { } else {
asprintf(&gosub_args, "%s,s,1", opt_args[OPT_ARG_CALLEE_GOSUB]); if (asprintf(&gosub_args, "%s,s,1", opt_args[OPT_ARG_CALLEE_GOSUB]) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
gosub_args = NULL;
}
} }
if (gosub_args) { if (gosub_args) {

@ -38,6 +38,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <signal.h> #include <signal.h>
#include <fcntl.h> #include <fcntl.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h>
#include "asterisk/file.h" #include "asterisk/file.h"
#include "asterisk/channel.h" #include "asterisk/channel.h"
@ -138,7 +139,11 @@ static int send_waveform_to_fd(char *waveform, int length, int fd)
*(waveform + x) = c; *(waveform + x) = c;
} }
#endif #endif
write(fd, waveform, length);
if (write(fd, waveform, length) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
close(fd); close(fd);
exit(0); exit(0);
} }
@ -411,17 +416,25 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
writecache = 1; writecache = 1;
strln = strlen(args.text); strln = strlen(args.text);
ast_debug(1, "line length : %d\n", strln); ast_debug(1, "line length : %d\n", strln);
write(fdesc, &strln, sizeof(strln)); if (write(fdesc,&strln,sizeof(int)) < 0) {
write(fdesc, args.text, strln); ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
if (write(fdesc,data,strln) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
seekpos = lseek(fdesc, 0, SEEK_CUR); seekpos = lseek(fdesc, 0, SEEK_CUR);
ast_debug(1, "Seek position : %d\n", seekpos); ast_debug(1, "Seek position : %d\n", seekpos);
} }
} else { } else {
read(fdesc, &strln, sizeof(strln)); if (read(fdesc,&strln,sizeof(int)) != sizeof(int)) {
ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
}
ast_debug(1, "Cache file exists, strln=%d, strlen=%d\n", strln, (int)strlen(args.text)); ast_debug(1, "Cache file exists, strln=%d, strlen=%d\n", strln, (int)strlen(args.text));
if (strlen(args.text) == strln) { if (strlen(args.text) == strln) {
ast_debug(1, "Size OK\n"); ast_debug(1, "Size OK\n");
read(fdesc, &bigstring, strln); if (read(fdesc,&bigstring,strln) != strln) {
ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
}
bigstring[strln] = 0; bigstring[strln] = 0;
if (strcmp(bigstring, args.text) == 0) { if (strcmp(bigstring, args.text) == 0) {
readcache = 1; readcache = 1;
@ -451,7 +464,9 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
if (writecache == 1) { if (writecache == 1) {
ast_debug(1, "Writing result to cache...\n"); ast_debug(1, "Writing result to cache...\n");
while ((strln = read(fd, buffer, 16384)) != 0) { while ((strln = read(fd, buffer, 16384)) != 0) {
write(fdesc, buffer, strln); if (write(fdesc,buffer,strln) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
} }
close(fd); close(fd);
close(fdesc); close(fdesc);

@ -3834,10 +3834,16 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
gosub_argstart = strchr(gosubexec, ','); gosub_argstart = strchr(gosubexec, ',');
if (gosub_argstart) { if (gosub_argstart) {
*gosub_argstart = 0; *gosub_argstart = 0;
asprintf(&gosub_args, "%s,s,1(%s)", gosubexec, gosub_argstart + 1); if (asprintf(&gosub_args, "%s,s,1(%s)", gosubexec, gosub_argstart + 1) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
gosub_args = NULL;
}
*gosub_argstart = '|'; *gosub_argstart = '|';
} else { } else {
asprintf(&gosub_args, "%s,s,1", gosubexec); if (asprintf(&gosub_args, "%s,s,1", gosubexec) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
gosub_args = NULL;
}
} }
if (gosub_args) { if (gosub_args) {
res = pbx_exec(qe->chan, application, gosub_args); res = pbx_exec(qe->chan, application, gosub_args);

@ -779,7 +779,9 @@ static void sms_log(sms_t * h, char status)
} }
*p++ = '\n'; *p++ = '\n';
*p = 0; *p = 0;
write(o, line, strlen(line)); if (write(o, line, strlen(line)) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
close(o); close(o);
} }
*h->oa = *h->da = h->udl = 0; *h->oa = *h->da = h->udl = 0;

@ -433,9 +433,15 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, char **arg
* call a Gosub for the CALLEE channel in Dial or Queue. * call a Gosub for the CALLEE channel in Dial or Queue.
*/ */
if (argc == 5) { if (argc == 5) {
asprintf(&gosub_args, "%s,%s,%d(%s)", argv[1], argv[2], priority + 1, argv[4]); if (asprintf(&gosub_args, "%s,%s,%d(%s)", argv[1], argv[2], priority + 1, argv[4]) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
gosub_args = NULL;
}
} else { } else {
asprintf(&gosub_args, "%s,%s,%d", argv[1], argv[2], priority + 1); if (asprintf(&gosub_args, "%s,%s,%d", argv[1], argv[2], priority + 1) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
gosub_args = NULL;
}
} }
if (gosub_args) { if (gosub_args) {

@ -865,7 +865,9 @@ static char *vm_check_password_shell(char *command, char *buf, size_t len)
} else if (pid) { } else if (pid) {
/* parent */ /* parent */
close(fds[1]); close(fds[1]);
read(fds[0], buf, len); if (read(fds[0], buf, len) < 0) {
ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
}
close(fds[0]); close(fds[0]);
} else { } else {
/* child */ /* child */
@ -5539,7 +5541,9 @@ static void adsi_message(struct ast_channel *chan, struct vm_state *vms)
f = fopen(fn2, "r"); f = fopen(fn2, "r");
if (f) { if (f) {
while (!feof(f)) { while (!feof(f)) {
fgets((char *)buf, sizeof(buf), f); if (!fgets((char *)buf, sizeof(buf), f)) {
continue;
}
if (!feof(f)) { if (!feof(f)) {
char *stringp=NULL; char *stringp=NULL;
stringp = (char *)buf; stringp = (char *)buf;

@ -10269,8 +10269,11 @@ static void dahdi_pri_message(struct pri *pri, char *s)
ast_mutex_lock(&pridebugfdlock); ast_mutex_lock(&pridebugfdlock);
if (pridebugfd >= 0) if (pridebugfd >= 0) {
write(pridebugfd, s, strlen(s)); if (write(pridebugfd, s, strlen(s)) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
}
ast_mutex_unlock(&pridebugfdlock); ast_mutex_unlock(&pridebugfdlock);
} }
@ -10305,8 +10308,11 @@ static void dahdi_pri_error(struct pri *pri, char *s)
ast_mutex_lock(&pridebugfdlock); ast_mutex_lock(&pridebugfdlock);
if (pridebugfd >= 0) if (pridebugfd >= 0) {
write(pridebugfd, s, strlen(s)); if (write(pridebugfd, s, strlen(s)) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
}
ast_mutex_unlock(&pridebugfdlock); ast_mutex_unlock(&pridebugfdlock);
} }
@ -11601,7 +11607,9 @@ static char *complete_span_helper(const char *line, const char *word, int pos, i
for (which = span = 0; span < NUM_SPANS; span++) { for (which = span = 0; span < NUM_SPANS; span++) {
if (pris[span].pri && ++which > state) { if (pris[span].pri && ++which > state) {
asprintf(&ret, "%d", span + 1); /* user indexes start from 1 */ if (asprintf(&ret, "%d", span + 1) < 0) { /* user indexes start from 1 */
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
}
break; break;
} }
} }

@ -1246,7 +1246,7 @@ static struct oh323_alias *realtime_alias(const char *alias)
static int update_common_options(struct ast_variable *v, struct call_options *options) static int update_common_options(struct ast_variable *v, struct call_options *options)
{ {
int tmp; int tmp = 0;
char *val, *opt; char *val, *opt;
if (!strcasecmp(v->name, "allow")) { if (!strcasecmp(v->name, "allow")) {

@ -6641,8 +6641,10 @@ static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
} }
/* Wake up waiters */ /* Wake up waiters */
for (x = 0; x < ARRAY_LEN(dp->waiters); x++) { for (x = 0; x < ARRAY_LEN(dp->waiters); x++) {
if (dp->waiters[x] > -1) if (dp->waiters[x] > -1) {
write(dp->waiters[x], "asdf", 4); if (write(dp->waiters[x], "asdf", 4) < 0) {
}
}
} }
} }
AST_LIST_TRAVERSE_SAFE_END; AST_LIST_TRAVERSE_SAFE_END;
@ -11700,8 +11702,11 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, const char *dat
systems without leaving it unavailable once the server comes back online */ systems without leaving it unavailable once the server comes back online */
dp->expiry.tv_sec = dp->orig.tv_sec + 60; dp->expiry.tv_sec = dp->orig.tv_sec + 60;
for (x = 0; x < ARRAY_LEN(dp->waiters); x++) { for (x = 0; x < ARRAY_LEN(dp->waiters); x++) {
if (dp->waiters[x] > -1) if (dp->waiters[x] > -1) {
write(dp->waiters[x], "asdf", 4); if (write(dp->waiters[x], "asdf", 4) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
}
} }
} }
} }

@ -1382,10 +1382,15 @@ static struct chan_oss_pvt *store_config(struct ast_config *cfg, char *ctg)
if (o->mixer_cmd) { if (o->mixer_cmd) {
char *cmd; char *cmd;
asprintf(&cmd, "mixer %s", o->mixer_cmd); if (asprintf(&cmd, "mixer %s", o->mixer_cmd) < 0) {
ast_log(LOG_WARNING, "running [%s]\n", cmd); ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
system(cmd); } else {
ast_free(cmd); ast_log(LOG_WARNING, "running [%s]\n", cmd);
if (system(cmd) < 0) {
ast_log(LOG_WARNING, "system() failed: %s\n", strerror(errno));
}
ast_free(cmd);
}
} }
/* if the config file requested to start the GUI, do it */ /* if the config file requested to start the GUI, do it */

@ -21366,8 +21366,9 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
if (!ast_strlen_zero(callback)) { /* build string from peer info */ if (!ast_strlen_zero(callback)) { /* build string from peer info */
char *reg_string; char *reg_string;
asprintf(&reg_string, "%s:%s@%s/%s", peer->username, peer->secret, peer->tohost, callback); if (asprintf(&reg_string, "%s:%s@%s/%s", peer->username, peer->secret, peer->tohost, callback) < 0) {
if (reg_string) { ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
} else if (reg_string) {
sip_register(reg_string, 0); /* XXX TODO: count in registry_count */ sip_register(reg_string, 0); /* XXX TODO: count in registry_count */
ast_free(reg_string); ast_free(reg_string);
} }

@ -126,7 +126,9 @@ static int gsm_seek(struct ast_filestream *fs, off_t sample_offset, int whence)
int i; int i;
fseeko(fs->f, 0, SEEK_END); fseeko(fs->f, 0, SEEK_END);
for (i=0; i< (offset - max) / GSM_FRAME_SIZE; i++) { for (i=0; i< (offset - max) / GSM_FRAME_SIZE; i++) {
fwrite(gsm_silence, 1, GSM_FRAME_SIZE, fs->f); if (!fwrite(gsm_silence, 1, GSM_FRAME_SIZE, fs->f)) {
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
}
} }
} }
return fseeko(fs->f, offset, SEEK_SET); return fseeko(fs->f, offset, SEEK_SET);

@ -225,8 +225,12 @@ static int ogg_vorbis_rewrite(struct ast_filestream *s,
while (!tmp->eos) { while (!tmp->eos) {
if (ogg_stream_flush(&tmp->os, &tmp->og) == 0) if (ogg_stream_flush(&tmp->os, &tmp->og) == 0)
break; break;
fwrite(tmp->og.header, 1, tmp->og.header_len, s->f); if (!fwrite(tmp->og.header, 1, tmp->og.header_len, s->f)) {
fwrite(tmp->og.body, 1, tmp->og.body_len, s->f); ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
}
if (!fwrite(tmp->og.body, 1, tmp->og.body_len, s->f)) {
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
}
if (ogg_page_eos(&tmp->og)) if (ogg_page_eos(&tmp->og))
tmp->eos = 1; tmp->eos = 1;
} }
@ -251,8 +255,12 @@ static void write_stream(struct vorbis_desc *s, FILE *f)
if (ogg_stream_pageout(&s->os, &s->og) == 0) { if (ogg_stream_pageout(&s->os, &s->og) == 0) {
break; break;
} }
fwrite(s->og.header, 1, s->og.header_len, f); if (!fwrite(s->og.header, 1, s->og.header_len, f)) {
fwrite(s->og.body, 1, s->og.body_len, f); ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
}
if (!fwrite(s->og.body, 1, s->og.body_len, f)) {
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
}
if (ogg_page_eos(&s->og)) { if (ogg_page_eos(&s->og)) {
s->eos = 1; s->eos = 1;
} }

@ -334,8 +334,11 @@ static void wav_close(struct ast_filestream *s)
} }
/* Pad to even length */ /* Pad to even length */
if (fs->bytes & 0x1) if (fs->bytes & 0x1) {
fwrite(&zero, 1, 1, s->f); if (!fwrite(&zero, 1, 1, s->f)) {
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
}
}
} }
static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext) static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)

@ -496,7 +496,9 @@ static int wav_seek(struct ast_filestream *fs, off_t sample_offset, int whence)
int i; int i;
fseek(fs->f, 0, SEEK_END); fseek(fs->f, 0, SEEK_END);
for (i=0; i< (offset - max) / MSGSM_FRAME_SIZE; i++) { for (i=0; i< (offset - max) / MSGSM_FRAME_SIZE; i++) {
fwrite(msgsm_silence, 1, MSGSM_FRAME_SIZE, fs->f); if (!fwrite(msgsm_silence, 1, MSGSM_FRAME_SIZE, fs->f)) {
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
}
} }
} }
s->secondhalf = 0; s->secondhalf = 0;

@ -628,6 +628,7 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu
{ {
const char *tmp; const char *tmp;
int i; int i;
int res;
if (!cfg || !catg) { if (!cfg || !catg) {
return EINVAL; return EINVAL;
@ -717,9 +718,13 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu
} }
if ((tmp = ast_variable_retrieve(cfg, catg, "prefix")) && !ast_strlen_zero(tmp)) { if ((tmp = ast_variable_retrieve(cfg, catg, "prefix")) && !ast_strlen_zero(tmp)) {
asprintf((char **)&((*query)->acf->name), "%s_%s", tmp, catg); if (asprintf((char **)&((*query)->acf->name), "%s_%s", tmp, catg) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
}
} else { } else {
asprintf((char **)&((*query)->acf->name), "ODBC_%s", catg); if (asprintf((char **)&((*query)->acf->name), "ODBC_%s", catg) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
}
} }
if (!((*query)->acf->name)) { if (!((*query)->acf->name)) {
@ -729,7 +734,10 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu
return ENOMEM; return ENOMEM;
} }
asprintf((char **)&((*query)->acf->syntax), "%s(<arg1>[...[,<argN>]])", (*query)->acf->name); if (asprintf((char **)&((*query)->acf->syntax), "%s(<arg1>[...[,<argN>]])", (*query)->acf->name) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
(*query)->acf->syntax = NULL;
}
if (!((*query)->acf->syntax)) { if (!((*query)->acf->syntax)) {
ast_free((char *)(*query)->acf->name); ast_free((char *)(*query)->acf->name);
@ -740,29 +748,31 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu
} }
(*query)->acf->synopsis = "Runs the referenced query with the specified arguments"; (*query)->acf->synopsis = "Runs the referenced query with the specified arguments";
res = 0;
if (!ast_strlen_zero((*query)->sql_read) && !ast_strlen_zero((*query)->sql_write)) { if (!ast_strlen_zero((*query)->sql_read) && !ast_strlen_zero((*query)->sql_write)) {
asprintf((char **)&((*query)->acf->desc), res = asprintf((char **)&((*query)->acf->desc),
"Runs the following query, as defined in func_odbc.conf, performing\n" "Runs the following query, as defined in func_odbc.conf, performing\n"
"substitution of the arguments into the query as specified by ${ARG1},\n" "substitution of the arguments into the query as specified by ${ARG1},\n"
"${ARG2}, ... ${ARGn}. When setting the function, the values are provided\n" "${ARG2}, ... ${ARGn}. When setting the function, the values are provided\n"
"either in whole as ${VALUE} or parsed as ${VAL1}, ${VAL2}, ... ${VALn}.\n" "either in whole as ${VALUE} or parsed as ${VAL1}, ${VAL2}, ... ${VALn}.\n"
"\nRead:\n%s\n\nWrite:\n%s\n", "\nRead:\n%s\n\nWrite:\n%s\n",
(*query)->sql_read, (*query)->sql_read,
(*query)->sql_write); (*query)->sql_write);
} else if (!ast_strlen_zero((*query)->sql_read)) { } else if (!ast_strlen_zero((*query)->sql_read)) {
asprintf((char **)&((*query)->acf->desc), res = asprintf((char **)&((*query)->acf->desc),
"Runs the following query, as defined in func_odbc.conf, performing\n" "Runs the following query, as defined in func_odbc.conf, performing\n"
"substitution of the arguments into the query as specified by ${ARG1},\n" "substitution of the arguments into the query as specified by ${ARG1},\n"
"${ARG2}, ... ${ARGn}. This function may only be read, not set.\n\nSQL:\n%s\n", "${ARG2}, ... ${ARGn}. This function may only be read, not set.\n\nSQL:\n%s\n",
(*query)->sql_read); (*query)->sql_read);
} else if (!ast_strlen_zero((*query)->sql_write)) { } else if (!ast_strlen_zero((*query)->sql_write)) {
asprintf((char **)&((*query)->acf->desc), res = asprintf((char **)&((*query)->acf->desc),
"Runs the following query, as defined in func_odbc.conf, performing\n" "Runs the following query, as defined in func_odbc.conf, performing\n"
"substitution of the arguments into the query as specified by ${ARG1},\n" "substitution of the arguments into the query as specified by ${ARG1},\n"
"${ARG2}, ... ${ARGn}. The values are provided either in whole as\n" "${ARG2}, ... ${ARGn}. The values are provided either in whole as\n"
"${VALUE} or parsed as ${VAL1}, ${VAL2}, ... ${VALn}.\n" "${VALUE} or parsed as ${VAL1}, ${VAL2}, ... ${VALn}.\n"
"This function may only be set.\nSQL:\n%s\n", "This function may only be set.\nSQL:\n%s\n",
(*query)->sql_write); (*query)->sql_write);
} else { } else {
ast_free((char *)(*query)->acf->syntax); ast_free((char *)(*query)->acf->syntax);
ast_free((char *)(*query)->acf->name); ast_free((char *)(*query)->acf->name);
@ -772,7 +782,13 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu
return EINVAL; return EINVAL;
} }
if (! ((*query)->acf->desc)) { if (res < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
(*query)->acf->desc = NULL;
}
if (!((*query)->acf->desc)) {
ast_free((char *)(*query)->acf->syntax); ast_free((char *)(*query)->acf->syntax);
ast_free((char *)(*query)->acf->name); ast_free((char *)(*query)->acf->name);
ast_free((*query)->acf); ast_free((*query)->acf);

@ -11,7 +11,7 @@
#define FLEX_SCANNER #define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 33 #define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0 #if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA #define FLEX_BETA
#endif #endif
@ -33,7 +33,7 @@
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if !defined __STDC_VERSION__ || __STDC_VERSION__ >= 199901L #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types. * if you want the limit (max/min) macros for int types.
@ -56,7 +56,6 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t; typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t; typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */ /* Limits of integral types. */
#ifndef INT8_MIN #ifndef INT8_MIN
@ -87,6 +86,8 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U) #define UINT32_MAX (4294967295U)
#endif #endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */ #endif /* ! FLEXINT_H */
#ifdef __cplusplus #ifdef __cplusplus
@ -96,11 +97,12 @@ typedef unsigned int flex_uint32_t;
#else /* ! __cplusplus */ #else /* ! __cplusplus */
#if __STDC__ /* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)
#define YY_USE_CONST #define YY_USE_CONST
#endif /* __STDC__ */ #endif /* defined (__STDC__) */
#endif /* ! __cplusplus */ #endif /* ! __cplusplus */
#ifdef YY_USE_CONST #ifdef YY_USE_CONST
@ -136,8 +138,6 @@ typedef void* yyscan_t;
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r #define yy_flex_debug yyg->yy_flex_debug_r
int ast_yylex_init (yyscan_t* scanner);
/* Enter a start condition. This macro really ought to take a parameter, /* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less * but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN. * definition of BEGIN.
@ -195,14 +195,9 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
/* The following is because we cannot portably get our hands on size_t
* (without autoconf's help, which isn't available because we want
* flex-generated scanners to compile on their own).
*/
#ifndef YY_TYPEDEF_YY_SIZE_T #ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T
typedef unsigned int yy_size_t; typedef size_t yy_size_t;
#endif #endif
#ifndef YY_STRUCT_YY_BUFFER_STATE #ifndef YY_STRUCT_YY_BUFFER_STATE
@ -2406,7 +2401,7 @@ int ast_yyget_column(yyscan_t yyscanner);
static int curlycount = 0; static int curlycount = 0;
static char *expr2_token_subst(const char *mess); static char *expr2_token_subst(const char *mess);
#line 2410 "ast_expr2f.c" #line 2403 "ast_expr2f.c"
#define INITIAL 0 #define INITIAL 0
#define var 1 #define var 1
@ -2470,6 +2465,10 @@ static int yy_init_globals (yyscan_t yyscanner );
# define yylloc yyg->yylloc_r # define yylloc yyg->yylloc_r
int ast_yylex_init (yyscan_t* scanner);
int ast_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
/* Accessor methods to globals. /* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */ These are made visible to non-reentrant scanners for convenience. */
@ -2549,7 +2548,7 @@ static int input (yyscan_t yyscanner );
/* This used to be an fputs(), but since the string might contain NUL's, /* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite(). * we now use fwrite().
*/ */
#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#endif #endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@ -2629,10 +2628,10 @@ YY_DECL
register int yy_act; register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
#line 127 "ast_expr2.fl" #line 125 "ast_expr2.fl"
#line 2636 "ast_expr2f.c" #line 2633 "ast_expr2f.c"
yylval = yylval_param; yylval = yylval_param;
@ -2715,132 +2714,132 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
YY_RULE_SETUP YY_RULE_SETUP
#line 129 "ast_expr2.fl" #line 127 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_OR;} { SET_COLUMNS; SET_STRING; return TOK_OR;}
YY_BREAK YY_BREAK
case 2: case 2:
YY_RULE_SETUP YY_RULE_SETUP
#line 130 "ast_expr2.fl" #line 128 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_AND;} { SET_COLUMNS; SET_STRING; return TOK_AND;}
YY_BREAK YY_BREAK
case 3: case 3:
YY_RULE_SETUP YY_RULE_SETUP
#line 131 "ast_expr2.fl" #line 129 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_EQ;} { SET_COLUMNS; SET_STRING; return TOK_EQ;}
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 132 "ast_expr2.fl" #line 130 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_OR;} { SET_COLUMNS; SET_STRING; return TOK_OR;}
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 133 "ast_expr2.fl" #line 131 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_AND;} { SET_COLUMNS; SET_STRING; return TOK_AND;}
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 134 "ast_expr2.fl" #line 132 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_EQ;} { SET_COLUMNS; SET_STRING; return TOK_EQ;}
YY_BREAK YY_BREAK
case 7: case 7:
YY_RULE_SETUP YY_RULE_SETUP
#line 135 "ast_expr2.fl" #line 133 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_EQTILDE;} { SET_COLUMNS; SET_STRING; return TOK_EQTILDE;}
YY_BREAK YY_BREAK
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 136 "ast_expr2.fl" #line 134 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_TILDETILDE;} { SET_COLUMNS; SET_STRING; return TOK_TILDETILDE;}
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 137 "ast_expr2.fl" #line 135 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_GT;} { SET_COLUMNS; SET_STRING; return TOK_GT;}
YY_BREAK YY_BREAK
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 138 "ast_expr2.fl" #line 136 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_LT;} { SET_COLUMNS; SET_STRING; return TOK_LT;}
YY_BREAK YY_BREAK
case 11: case 11:
YY_RULE_SETUP YY_RULE_SETUP
#line 139 "ast_expr2.fl" #line 137 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_GE;} { SET_COLUMNS; SET_STRING; return TOK_GE;}
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 140 "ast_expr2.fl" #line 138 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_LE;} { SET_COLUMNS; SET_STRING; return TOK_LE;}
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 141 "ast_expr2.fl" #line 139 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_NE;} { SET_COLUMNS; SET_STRING; return TOK_NE;}
YY_BREAK YY_BREAK
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 142 "ast_expr2.fl" #line 140 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_PLUS;} { SET_COLUMNS; SET_STRING; return TOK_PLUS;}
YY_BREAK YY_BREAK
case 15: case 15:
YY_RULE_SETUP YY_RULE_SETUP
#line 143 "ast_expr2.fl" #line 141 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_COMMA;} { SET_COLUMNS; SET_STRING; return TOK_COMMA;}
YY_BREAK YY_BREAK
case 16: case 16:
YY_RULE_SETUP YY_RULE_SETUP
#line 144 "ast_expr2.fl" #line 142 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_MINUS;} { SET_COLUMNS; SET_STRING; return TOK_MINUS;}
YY_BREAK YY_BREAK
case 17: case 17:
YY_RULE_SETUP YY_RULE_SETUP
#line 145 "ast_expr2.fl" #line 143 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_MULT;} { SET_COLUMNS; SET_STRING; return TOK_MULT;}
YY_BREAK YY_BREAK
case 18: case 18:
YY_RULE_SETUP YY_RULE_SETUP
#line 146 "ast_expr2.fl" #line 144 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_DIV;} { SET_COLUMNS; SET_STRING; return TOK_DIV;}
YY_BREAK YY_BREAK
case 19: case 19:
YY_RULE_SETUP YY_RULE_SETUP
#line 147 "ast_expr2.fl" #line 145 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_MOD;} { SET_COLUMNS; SET_STRING; return TOK_MOD;}
YY_BREAK YY_BREAK
case 20: case 20:
YY_RULE_SETUP YY_RULE_SETUP
#line 148 "ast_expr2.fl" #line 146 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_COND;} { SET_COLUMNS; SET_STRING; return TOK_COND;}
YY_BREAK YY_BREAK
case 21: case 21:
YY_RULE_SETUP YY_RULE_SETUP
#line 149 "ast_expr2.fl" #line 147 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_COMPL;} { SET_COLUMNS; SET_STRING; return TOK_COMPL;}
YY_BREAK YY_BREAK
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
#line 150 "ast_expr2.fl" #line 148 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_COLON;} { SET_COLUMNS; SET_STRING; return TOK_COLON;}
YY_BREAK YY_BREAK
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 151 "ast_expr2.fl" #line 149 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_COLONCOLON;} { SET_COLUMNS; SET_STRING; return TOK_COLONCOLON;}
YY_BREAK YY_BREAK
case 24: case 24:
YY_RULE_SETUP YY_RULE_SETUP
#line 152 "ast_expr2.fl" #line 150 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_LP;} { SET_COLUMNS; SET_STRING; return TOK_LP;}
YY_BREAK YY_BREAK
case 25: case 25:
YY_RULE_SETUP YY_RULE_SETUP
#line 153 "ast_expr2.fl" #line 151 "ast_expr2.fl"
{ SET_COLUMNS; SET_STRING; return TOK_RP;} { SET_COLUMNS; SET_STRING; return TOK_RP;}
YY_BREAK YY_BREAK
case 26: case 26:
YY_RULE_SETUP YY_RULE_SETUP
#line 154 "ast_expr2.fl" #line 152 "ast_expr2.fl"
{ {
/* gather the contents of ${} expressions, with trailing stuff, /* gather the contents of ${} expressions, with trailing stuff,
* into a single TOKEN. * into a single TOKEN.
@ -2853,24 +2852,24 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 27: case 27:
YY_RULE_SETUP YY_RULE_SETUP
#line 164 "ast_expr2.fl" #line 162 "ast_expr2.fl"
{} {}
YY_BREAK YY_BREAK
case 28: case 28:
/* rule 28 can match eol */ /* rule 28 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 165 "ast_expr2.fl" #line 163 "ast_expr2.fl"
{SET_COLUMNS; SET_STRING; return TOKEN;} {SET_COLUMNS; SET_STRING; return TOKEN;}
YY_BREAK YY_BREAK
case 29: case 29:
/* rule 29 can match eol */ /* rule 29 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 167 "ast_expr2.fl" #line 165 "ast_expr2.fl"
{/* what to do with eol */} {/* what to do with eol */}
YY_BREAK YY_BREAK
case 30: case 30:
YY_RULE_SETUP YY_RULE_SETUP
#line 168 "ast_expr2.fl" #line 166 "ast_expr2.fl"
{ {
SET_COLUMNS; SET_COLUMNS;
/* the original behavior of the expression parser was /* the original behavior of the expression parser was
@ -2883,7 +2882,7 @@ YY_RULE_SETUP
case 31: case 31:
/* rule 31 can match eol */ /* rule 31 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 177 "ast_expr2.fl" #line 175 "ast_expr2.fl"
{ {
SET_COLUMNS; SET_COLUMNS;
SET_STRING; SET_STRING;
@ -2893,7 +2892,7 @@ YY_RULE_SETUP
case 32: case 32:
/* rule 32 can match eol */ /* rule 32 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 184 "ast_expr2.fl" #line 182 "ast_expr2.fl"
{ {
curlycount--; curlycount--;
if (curlycount < 0) { if (curlycount < 0) {
@ -2907,7 +2906,7 @@ YY_RULE_SETUP
case 33: case 33:
/* rule 33 can match eol */ /* rule 33 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 194 "ast_expr2.fl" #line 192 "ast_expr2.fl"
{ {
curlycount++; curlycount++;
yymore(); yymore();
@ -2915,7 +2914,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 34: case 34:
YY_RULE_SETUP YY_RULE_SETUP
#line 200 "ast_expr2.fl" #line 198 "ast_expr2.fl"
{ {
BEGIN(0); BEGIN(0);
SET_COLUMNS; SET_COLUMNS;
@ -2926,7 +2925,7 @@ YY_RULE_SETUP
case 35: case 35:
/* rule 35 can match eol */ /* rule 35 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 207 "ast_expr2.fl" #line 205 "ast_expr2.fl"
{ {
char c = yytext[yyleng-1]; char c = yytext[yyleng-1];
BEGIN(0); BEGIN(0);
@ -2938,7 +2937,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 36: case 36:
YY_RULE_SETUP YY_RULE_SETUP
#line 216 "ast_expr2.fl" #line 214 "ast_expr2.fl"
{ {
curlycount = 0; curlycount = 0;
BEGIN(var); BEGIN(var);
@ -2946,7 +2945,7 @@ YY_RULE_SETUP
} }
YY_BREAK YY_BREAK
case YY_STATE_EOF(trail): case YY_STATE_EOF(trail):
#line 222 "ast_expr2.fl" #line 220 "ast_expr2.fl"
{ {
BEGIN(0); BEGIN(0);
SET_COLUMNS; SET_COLUMNS;
@ -2957,10 +2956,10 @@ case YY_STATE_EOF(trail):
YY_BREAK YY_BREAK
case 37: case 37:
YY_RULE_SETUP YY_RULE_SETUP
#line 230 "ast_expr2.fl" #line 228 "ast_expr2.fl"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 2964 "ast_expr2f.c" #line 2961 "ast_expr2f.c"
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(var): case YY_STATE_EOF(var):
yyterminate(); yyterminate();
@ -3217,6 +3216,14 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else else
ret_val = EOB_ACT_CONTINUE_SCAN; ret_val = EOB_ACT_CONTINUE_SCAN;
if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ast_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
}
yyg->yy_n_chars += number_to_move; yyg->yy_n_chars += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
@ -3640,7 +3647,9 @@ static void ast_yyensure_buffer_stack (yyscan_t yyscanner)
yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyalloc yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*) (num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner); , yyscanner);
if ( ! yyg->yy_buffer_stack )
YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" );
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_max = num_to_alloc;
@ -3658,6 +3667,8 @@ static void ast_yyensure_buffer_stack (yyscan_t yyscanner)
(yyg->yy_buffer_stack, (yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*) num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner); , yyscanner);
if ( ! yyg->yy_buffer_stack )
YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" );
/* zero only the new slots.*/ /* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
@ -3976,6 +3987,42 @@ int ast_yylex_init(yyscan_t* ptr_yy_globals)
return yy_init_globals ( *ptr_yy_globals ); return yy_init_globals ( *ptr_yy_globals );
} }
/* ast_yylex_init_extra has the same functionality as ast_yylex_init, but follows the
* convention of taking the scanner as the last argument. Note however, that
* this is a *pointer* to a scanner, as it will be allocated by this call (and
* is the reason, too, why this function also must handle its own declaration).
* The user defined value in the first argument will be available to ast_yyalloc in
* the yyextra field.
*/
int ast_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
{
struct yyguts_t dummy_yyguts;
ast_yyset_extra (yy_user_defined, &dummy_yyguts);
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
*ptr_yy_globals = (yyscan_t) ast_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
return 1;
}
/* By setting to 0xAA, we expose bugs in
yy_init_globals. Leave at 0x00 for releases. */
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
ast_yyset_extra (yy_user_defined, *ptr_yy_globals);
return yy_init_globals ( *ptr_yy_globals );
}
static int yy_init_globals (yyscan_t yyscanner) static int yy_init_globals (yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@ -4082,7 +4129,7 @@ void *ast_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables" #define YYTABLES_NAME "yytables"
#line 230 "ast_expr2.fl" #line 228 "ast_expr2.fl"

@ -1223,8 +1223,11 @@ static void hup_handler(int num)
if (restartnow) if (restartnow)
execvp(_argv[0], _argv); execvp(_argv[0], _argv);
sig_flags.need_reload = 1; sig_flags.need_reload = 1;
if (sig_alert_pipe[1] != -1) if (sig_alert_pipe[1] != -1) {
write(sig_alert_pipe[1], &a, sizeof(a)); if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) {
fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno));
}
}
signal(num, hup_handler); signal(num, hup_handler);
} }
@ -1439,8 +1442,11 @@ static void __quit_handler(int num)
{ {
int a = 0; int a = 0;
sig_flags.need_quit = 1; sig_flags.need_quit = 1;
if (sig_alert_pipe[1] != -1) if (sig_alert_pipe[1] != -1) {
write(sig_alert_pipe[1], &a, sizeof(a)); if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) {
fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno));
}
}
/* There is no need to restore the signal handler here, since the app /* There is no need to restore the signal handler here, since the app
* is going to exit */ * is going to exit */
} }
@ -1819,7 +1825,7 @@ static char *show_warranty(struct ast_cli_entry *e, int cmd, struct ast_cli_args
return NULL; return NULL;
} }
ast_cli(a->fd, warranty_lines); ast_cli(a->fd, "%s", warranty_lines);
return CLI_SUCCESS; return CLI_SUCCESS;
} }
@ -1856,7 +1862,7 @@ static char *show_license(struct ast_cli_entry *e, int cmd, struct ast_cli_args
return NULL; return NULL;
} }
ast_cli(a->fd, license_lines); ast_cli(a->fd, "%s", license_lines);
return CLI_SUCCESS; return CLI_SUCCESS;
} }
@ -1976,9 +1982,12 @@ static int ast_el_read_char(EditLine *editline, char *cp)
} }
/* Write over the CLI prompt */ /* Write over the CLI prompt */
if (!ast_opt_exec && !lastpos) if (!ast_opt_exec && !lastpos) {
write(STDOUT_FILENO, "\r", 1); if (write(STDOUT_FILENO, "\r", 1) < 0) {
write(STDOUT_FILENO, buf, res); }
}
if (write(STDOUT_FILENO, buf, res) < 0) {
}
if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (buf[res-2] == '\n'))) { if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (buf[res-2] == '\n'))) {
*cp = CC_REFRESH; *cp = CC_REFRESH;
return(1); return(1);
@ -2405,7 +2414,9 @@ static int ast_el_read_history(char *filename)
return ret; return ret;
while (!feof(f)) { while (!feof(f)) {
fgets(buf, sizeof(buf), f); if (!fgets(buf, sizeof(buf), f)) {
continue;
}
if (!strcmp(buf, "_HiStOrY_V2_\n")) if (!strcmp(buf, "_HiStOrY_V2_\n"))
continue; continue;
if (ast_all_zeros(buf)) if (ast_all_zeros(buf))
@ -2418,7 +2429,7 @@ static int ast_el_read_history(char *filename)
return ret; return ret;
} }
static void ast_remotecontrol(char * data) static void ast_remotecontrol(char *data)
{ {
char buf[80]; char buf[80];
int res; int res;
@ -2432,12 +2443,17 @@ static void ast_remotecontrol(char * data)
char *ebuf; char *ebuf;
int num = 0; int num = 0;
read(ast_consock, buf, sizeof(buf)); if (read(ast_consock, buf, sizeof(buf)) < 0) {
ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno));
return;
}
if (data) { if (data) {
char prefix[] = "cli quit after "; char prefix[] = "cli quit after ";
char *tmp = alloca(strlen(data) + strlen(prefix) + 1); char *tmp = alloca(strlen(data) + strlen(prefix) + 1);
sprintf(tmp, "%s%s", prefix, data); sprintf(tmp, "%s%s", prefix, data);
write(ast_consock, tmp, strlen(tmp) + 1); if (write(ast_consock, tmp, strlen(tmp) + 1) < 0) {
ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno));
}
} }
stringp = buf; stringp = buf;
hostname = strsep(&stringp, "/"); hostname = strsep(&stringp, "/");
@ -2497,7 +2513,9 @@ static void ast_remotecontrol(char * data)
/* Skip verbose lines */ /* Skip verbose lines */
if (*curline != 127) { if (*curline != 127) {
not_written = 0; not_written = 0;
write(STDOUT_FILENO, curline, nextline - curline); if (write(STDOUT_FILENO, curline, nextline - curline) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
} }
curline = nextline; curline = nextline;
} while (!ast_strlen_zero(curline)); } while (!ast_strlen_zero(curline));
@ -2822,7 +2840,8 @@ static void *monitor_sig_flags(void *unused)
sig_flags.need_quit = 0; sig_flags.need_quit = 0;
quit_handler(0, 0, 1, 0); quit_handler(0, 0, 1, 0);
} }
read(sig_alert_pipe[0], &a, sizeof(a)); if (read(sig_alert_pipe[0], &a, sizeof(a)) != sizeof(a)) {
}
} }
return NULL; return NULL;
@ -3251,7 +3270,9 @@ int main(int argc, char *argv[])
#if HAVE_WORKING_FORK #if HAVE_WORKING_FORK
if (ast_opt_always_fork || !ast_opt_no_fork) { if (ast_opt_always_fork || !ast_opt_no_fork) {
#ifndef HAVE_SBIN_LAUNCHD #ifndef HAVE_SBIN_LAUNCHD
daemon(1, 0); if (daemon(1, 0) < 0) {
ast_log(LOG_ERROR, "daemon() failed: %s\n", strerror(errno));
}
ast_mainpid = getpid(); ast_mainpid = getpid();
/* Blindly re-write pid file since we are forking */ /* Blindly re-write pid file since we are forking */
unlink(ast_config_AST_PID); unlink(ast_config_AST_PID);

@ -2273,8 +2273,11 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd)
break; break;
case AST_FRAME_VOICE: case AST_FRAME_VOICE:
/* Write audio if appropriate */ /* Write audio if appropriate */
if (audiofd > -1) if (audiofd > -1) {
write(audiofd, f->data.ptr, f->datalen); if (write(audiofd, f->data.ptr, f->datalen) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
}
default: default:
/* Ignore */ /* Ignore */
break; break;
@ -2421,7 +2424,9 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
goto done; goto done;
} }
} }
read(chan->alertpipe[0], &blah, sizeof(blah)); if (read(chan->alertpipe[0], &blah, sizeof(blah)) < 0) {
ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
}
} }
if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD) { if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD) {
@ -3888,7 +3893,10 @@ int ast_do_masquerade(struct ast_channel *original)
AST_LIST_INSERT_TAIL(&original->readq, current, frame_list); AST_LIST_INSERT_TAIL(&original->readq, current, frame_list);
if (original->alertpipe[1] > -1) { if (original->alertpipe[1] > -1) {
int poke = 0; int poke = 0;
write(original->alertpipe[1], &poke, sizeof(poke));
if (write(original->alertpipe[1], &poke, sizeof(poke)) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
} }
} }
} }

@ -712,7 +712,8 @@ overflow_page(hashp)
#define OVMSG "HASH: Out of overflow pages. Increase page size\n" #define OVMSG "HASH: Out of overflow pages. Increase page size\n"
if (offset > SPLITMASK) { if (offset > SPLITMASK) {
if (++splitnum >= NCACHED) { if (++splitnum >= NCACHED) {
(void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); if (write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1) < 0) {
}
return (0); return (0);
} }
hashp->OVFL_POINT = splitnum; hashp->OVFL_POINT = splitnum;
@ -725,7 +726,8 @@ overflow_page(hashp)
if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) { if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) {
free_page++; free_page++;
if (free_page >= NCACHED) { if (free_page >= NCACHED) {
(void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); if (write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1) < 0) {
}
return (0); return (0);
} }
/* /*
@ -749,8 +751,8 @@ overflow_page(hashp)
offset++; offset++;
if (offset > SPLITMASK) { if (offset > SPLITMASK) {
if (++splitnum >= NCACHED) { if (++splitnum >= NCACHED) {
(void)write(STDERR_FILENO, OVMSG, if (write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1) < 0) {
sizeof(OVMSG) - 1); }
return (0); return (0);
} }
hashp->OVFL_POINT = splitnum; hashp->OVFL_POINT = splitnum;

@ -249,11 +249,18 @@ static char *build_filename(const char *filename, const char *ext)
if (!strcmp(ext, "wav49")) if (!strcmp(ext, "wav49"))
ext = "WAV"; ext = "WAV";
if (filename[0] == '/') if (filename[0] == '/') {
asprintf(&fn, "%s.%s", filename, ext); if (asprintf(&fn, "%s.%s", filename, ext) < 0) {
else ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
asprintf(&fn, "%s/sounds/%s.%s", fn = NULL;
ast_config_AST_DATA_DIR, filename, ext); }
} else {
if (asprintf(&fn, "%s/sounds/%s.%s",
ast_config_AST_DATA_DIR, filename, ext) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
fn = NULL;
}
}
return fn; return fn;
} }
@ -1187,8 +1194,11 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
break; break;
case AST_FRAME_VOICE: case AST_FRAME_VOICE:
/* Write audio if appropriate */ /* Write audio if appropriate */
if (audiofd > -1) if (audiofd > -1) {
write(audiofd, fr->data.ptr, fr->datalen); if (write(audiofd, fr->data.ptr, fr->datalen) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
}
default: default:
/* Ignore all others */ /* Ignore all others */
break; break;

@ -219,7 +219,9 @@ static struct ast_str *static_callback(struct ast_tcptls_session_instance *ser,
ast_get_version(), buf, (int) st.st_size, mtype); ast_get_version(), buf, (int) st.st_size, mtype);
while ((len = read(fd, buf, sizeof(buf))) > 0) { while ((len = read(fd, buf, sizeof(buf))) > 0) {
fwrite(buf, 1, len, ser->f); if (fwrite(buf, 1, len, ser->f) != len) {
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
}
} }
close(fd); close(fd);
@ -760,8 +762,12 @@ static void *httpd_helper_thread(void *data)
if (tmp) { if (tmp) {
fprintf(ser->f, "Content-length: %d\r\n", contentlength); fprintf(ser->f, "Content-length: %d\r\n", contentlength);
/* first write the header, then the body */ /* first write the header, then the body */
fwrite(out->str, 1, (tmp + 4 - out->str), ser->f); if (fwrite(out->str, 1, (tmp + 4 - out->str), ser->f) != tmp + 4 - out->str) {
fwrite(tmp + 4, 1, contentlength, ser->f); ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
}
if (fwrite(tmp + 4, 1, contentlength, ser->f) != contentlength ) {
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
}
} }
} }
ast_free(out); ast_free(out);

@ -576,7 +576,9 @@ static int rotate_file(const char *filename)
char buf[512]; char buf[512];
pbx_builtin_setvar_helper(c, "filename", filename); pbx_builtin_setvar_helper(c, "filename", filename);
pbx_substitute_variables_helper(c, exec_after_rotate, buf, sizeof(buf)); pbx_substitute_variables_helper(c, exec_after_rotate, buf, sizeof(buf));
system(buf); if (system(buf) < 0) {
ast_log(LOG_WARNING, "system() failed for '%s': %s\n", buf, strerror(errno));
}
ast_channel_free(c); ast_channel_free(c);
} }
return res; return res;

@ -2211,7 +2211,9 @@ static int action_command(struct mansession *s, const struct message *m)
final_buf = ast_calloc(1, l + 1); final_buf = ast_calloc(1, l + 1);
if (buf) { if (buf) {
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
read(fd, buf, l); if (read(fd, buf, l) < 0) {
ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
}
buf[l] = '\0'; buf[l] = '\0';
if (final_buf) { if (final_buf) {
term_strip(final_buf, buf, l); term_strip(final_buf, buf, l);

@ -1066,8 +1066,11 @@ int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*st
a->start_routine = start_routine; a->start_routine = start_routine;
a->data = data; a->data = data;
start_routine = dummy_start; start_routine = dummy_start;
asprintf(&a->name, "%-20s started at [%5d] %s %s()", if (asprintf(&a->name, "%-20s started at [%5d] %s %s()",
start_fn, line, file, caller); start_fn, line, file, caller) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
a->name = NULL;
}
data = a; data = a;
} }
#endif /* !LOW_MEMORY */ #endif /* !LOW_MEMORY */

@ -492,10 +492,16 @@ static char *complete_dialplan_remove_extension(struct ast_cli_args *a)
if (++which > a->n) { if (++which > a->n) {
/* If there is an extension then return exten@context. */ /* If there is an extension then return exten@context. */
if (ast_get_extension_matchcid(e) && (!strchr(a->word, '@') || strchr(a->word, '/'))) { if (ast_get_extension_matchcid(e) && (!strchr(a->word, '@') || strchr(a->word, '/'))) {
asprintf(&ret, "%s/%s@%s", ast_get_extension_name(e), ast_get_extension_cidmatch(e), ast_get_context_name(c)); if (asprintf(&ret, "%s/%s@%s", ast_get_extension_name(e), ast_get_extension_cidmatch(e), ast_get_context_name(c)) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
ret = NULL;
}
break; break;
} else if (!ast_get_extension_matchcid(e) && !strchr(a->word, '/')) { } else if (!ast_get_extension_matchcid(e) && !strchr(a->word, '/')) {
asprintf(&ret, "%s@%s", ast_get_extension_name(e), ast_get_context_name(c)); if (asprintf(&ret, "%s@%s", ast_get_extension_name(e), ast_get_context_name(c)) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
ret = NULL;
}
break; break;
} }
} }

@ -2958,7 +2958,9 @@ static void destroy_trans(struct dundi_transaction *trans, int fromtimeout)
if (AST_LIST_EMPTY(&trans->parent->trans)) { if (AST_LIST_EMPTY(&trans->parent->trans)) {
/* Wake up sleeper */ /* Wake up sleeper */
if (trans->parent->pfds[1] > -1) { if (trans->parent->pfds[1] > -1) {
write(trans->parent->pfds[1], "killa!", 6); if (write(trans->parent->pfds[1], "killa!", 6) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
} }
} }
} }
@ -3725,7 +3727,10 @@ static int dundi_precache_internal(const char *context, const char *number, int
dr.expiration = dundi_cache_time; dr.expiration = dundi_cache_time;
dr.hmd = &hmd; dr.hmd = &hmd;
dr.pfds[0] = dr.pfds[1] = -1; dr.pfds[0] = dr.pfds[1] = -1;
pipe(dr.pfds); if (pipe(dr.pfds) < 0) {
ast_log(LOG_WARNING, "pipe() failed: %s\n", strerror(errno));
return -1;
}
build_transactions(&dr, ttl, 0, &foundcache, &skipped, 0, 1, 1, NULL, avoids, NULL); build_transactions(&dr, ttl, 0, &foundcache, &skipped, 0, 1, 1, NULL, avoids, NULL);
optimize_transactions(&dr, 0); optimize_transactions(&dr, 0);
foundanswers = 0; foundanswers = 0;

@ -946,7 +946,9 @@ static char *lua_read_extensions_file(lua_State *L, long *size)
return NULL; return NULL;
} }
fread(data, sizeof(char), *size, f); if (fread(data, sizeof(char), *size, f) != *size) {
ast_log(LOG_WARNING, "fread() failed: %s\n", strerror(errno));
}
fclose(f); fclose(f);
if (luaL_loadbuffer(L, data, *size, "extensions.lua") if (luaL_loadbuffer(L, data, *size, "extensions.lua")

@ -773,7 +773,9 @@ struct pval *ael2_parse(char *filename, int *errors)
my_file = strdup(filename); my_file = strdup(filename);
stat(filename, &stats); stat(filename, &stats);
buffer = (char*)malloc(stats.st_size+2); buffer = (char*)malloc(stats.st_size+2);
fread(buffer, 1, stats.st_size, fin); if (fread(buffer, 1, stats.st_size, fin) != stats.st_size) {
ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
}
buffer[stats.st_size]=0; buffer[stats.st_size]=0;
fclose(fin); fclose(fin);
@ -841,7 +843,9 @@ static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf,
struct stat stats; struct stat stats;
stat(fnamebuf2, &stats); stat(fnamebuf2, &stats);
buffer = (char*)malloc(stats.st_size+1); buffer = (char*)malloc(stats.st_size+1);
fread(buffer, 1, stats.st_size, in1); if (fread(buffer, 1, stats.st_size, in1) != stats.st_size) {
ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
}
buffer[stats.st_size] = 0; buffer[stats.st_size] = 0;
ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size); ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size);
fclose(in1); fclose(in1);

@ -647,16 +647,16 @@ static const yytype_uint16 yyrline[] =
237, 238, 239, 242, 242, 248, 248, 255, 256, 257, 237, 238, 239, 242, 242, 248, 248, 255, 256, 257,
258, 261, 262, 263, 266, 267, 268, 269, 270, 271, 258, 261, 262, 263, 266, 267, 268, 269, 270, 271,
272, 273, 274, 277, 282, 286, 294, 299, 304, 313, 272, 273, 274, 277, 282, 286, 294, 299, 304, 313,
314, 315, 321, 326, 330, 338, 338, 342, 345, 348, 314, 315, 321, 331, 335, 343, 343, 347, 350, 353,
359, 360, 367, 368, 372, 376, 382, 383, 388, 396, 364, 365, 377, 378, 387, 396, 407, 408, 418, 431,
397, 401, 407, 416, 419, 420, 421, 424, 427, 430, 432, 441, 452, 461, 464, 465, 466, 469, 472, 475,
431, 432, 430, 438, 442, 443, 444, 445, 448, 448, 476, 477, 475, 483, 487, 488, 489, 490, 493, 493,
481, 482, 483, 484, 488, 491, 492, 495, 496, 499, 526, 527, 528, 529, 533, 536, 537, 540, 541, 544,
502, 506, 510, 514, 520, 521, 525, 528, 534, 534, 547, 551, 555, 559, 565, 566, 570, 573, 579, 579,
539, 547, 547, 558, 565, 568, 569, 572, 573, 576, 584, 592, 592, 603, 610, 613, 614, 617, 618, 621,
579, 580, 583, 587, 591, 597, 598, 601, 602, 603, 624, 625, 628, 632, 636, 642, 643, 646, 647, 648,
609, 614, 619, 620, 621, 623, 626, 627, 634, 635, 654, 659, 664, 665, 666, 677, 680, 681, 688, 689,
636, 639, 642 690, 693, 696
}; };
#endif #endif
@ -2406,19 +2406,24 @@ yyreduce:
case 52: case 52:
#line 321 "ael.y" #line 321 "ael.y"
{ {
asprintf(&(yyval.str), "%s:%s:%s", (yyvsp[(1) - (5)].str), (yyvsp[(3) - (5)].str), (yyvsp[(5) - (5)].str)); if (asprintf(&(yyval.str), "%s:%s:%s", (yyvsp[(1) - (5)].str), (yyvsp[(3) - (5)].str), (yyvsp[(5) - (5)].str)) < 0) {
free((yyvsp[(1) - (5)].str)); ast_log(LOG_WARNING, "asprintf() failed\n");
free((yyvsp[(3) - (5)].str)); (yyval.str) = NULL;
free((yyvsp[(5) - (5)].str)); ;} } else {
free((yyvsp[(1) - (5)].str));
free((yyvsp[(3) - (5)].str));
free((yyvsp[(5) - (5)].str));
}
;}
break; break;
case 53: case 53:
#line 326 "ael.y" #line 331 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str); ;} { (yyval.str) = (yyvsp[(1) - (1)].str); ;}
break; break;
case 54: case 54:
#line 330 "ael.y" #line 335 "ael.y"
{ {
(yyval.pval) = nword((yyvsp[(1) - (7)].str), &(yylsp[(1) - (7)])); (yyval.pval) = nword((yyvsp[(1) - (7)].str), &(yylsp[(1) - (7)]));
(yyval.pval)->next = nword((yyvsp[(3) - (7)].str), &(yylsp[(3) - (7)])); (yyval.pval)->next = nword((yyvsp[(3) - (7)].str), &(yylsp[(3) - (7)]));
@ -2427,31 +2432,31 @@ yyreduce:
break; break;
case 55: case 55:
#line 338 "ael.y" #line 343 "ael.y"
{ reset_parencount(parseio->scanner); ;} { reset_parencount(parseio->scanner); ;}
break; break;
case 56: case 56:
#line 338 "ael.y" #line 343 "ael.y"
{ (yyval.str) = (yyvsp[(3) - (4)].str); ;} { (yyval.str) = (yyvsp[(3) - (4)].str); ;}
break; break;
case 57: case 57:
#line 342 "ael.y" #line 347 "ael.y"
{ {
(yyval.pval)= npval2(PV_IF, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); (yyval.pval)= npval2(PV_IF, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)]));
(yyval.pval)->u1.str = (yyvsp[(2) - (2)].str); ;} (yyval.pval)->u1.str = (yyvsp[(2) - (2)].str); ;}
break; break;
case 58: case 58:
#line 345 "ael.y" #line 350 "ael.y"
{ {
(yyval.pval) = npval2(PV_RANDOM, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); (yyval.pval) = npval2(PV_RANDOM, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)]));
(yyval.pval)->u1.str=(yyvsp[(2) - (2)].str);;} (yyval.pval)->u1.str=(yyvsp[(2) - (2)].str);;}
break; break;
case 59: case 59:
#line 348 "ael.y" #line 353 "ael.y"
{ {
(yyval.pval) = npval2(PV_IFTIME, &(yylsp[(1) - (4)]), &(yylsp[(4) - (4)])); (yyval.pval) = npval2(PV_IFTIME, &(yylsp[(1) - (4)]), &(yylsp[(4) - (4)]));
(yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval); (yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval);
@ -2459,95 +2464,135 @@ yyreduce:
break; break;
case 60: case 60:
#line 359 "ael.y" #line 364 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str);;} { (yyval.str) = (yyvsp[(1) - (1)].str);;}
break; break;
case 61: case 61:
#line 360 "ael.y" #line 365 "ael.y"
{ {
asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)); if (asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)) < 0) {
free((yyvsp[(1) - (2)].str)); ast_log(LOG_WARNING, "asprintf() failed\n");
free((yyvsp[(2) - (2)].str)); (yyval.str) = NULL;
prev_word = (yyval.str);;} } else {
free((yyvsp[(1) - (2)].str));
free((yyvsp[(2) - (2)].str));
prev_word = (yyval.str);
}
;}
break; break;
case 62: case 62:
#line 367 "ael.y" #line 377 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str); ;} { (yyval.str) = (yyvsp[(1) - (1)].str); ;}
break; break;
case 63: case 63:
#line 368 "ael.y" #line 378 "ael.y"
{ {
asprintf(&((yyval.str)), "%s %s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)); if (asprintf(&((yyval.str)), "%s %s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)) < 0) {
free((yyvsp[(1) - (2)].str)); ast_log(LOG_WARNING, "asprintf() failed\n");
free((yyvsp[(2) - (2)].str)); ;} (yyval.str) = NULL;
} else {
free((yyvsp[(1) - (2)].str));
free((yyvsp[(2) - (2)].str));
}
;}
break; break;
case 64: case 64:
#line 372 "ael.y" #line 387 "ael.y"
{ {
asprintf(&((yyval.str)), "%s:%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)); if (asprintf(&((yyval.str)), "%s:%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)) < 0) {
free((yyvsp[(1) - (3)].str)); ast_log(LOG_WARNING, "asprintf() failed\n");
free((yyvsp[(3) - (3)].str)); ;} (yyval.str) = NULL;
} else {
free((yyvsp[(1) - (3)].str));
free((yyvsp[(3) - (3)].str));
}
;}
break; break;
case 65: case 65:
#line 376 "ael.y" #line 396 "ael.y"
{ /* there are often '&' in hints */ { /* there are often '&' in hints */
asprintf(&((yyval.str)), "%s&%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)); if (asprintf(&((yyval.str)), "%s&%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)) < 0) {
free((yyvsp[(1) - (3)].str)); ast_log(LOG_WARNING, "asprintf() failed\n");
free((yyvsp[(3) - (3)].str));;} (yyval.str) = NULL;
} else {
free((yyvsp[(1) - (3)].str));
free((yyvsp[(3) - (3)].str));
}
;}
break; break;
case 66: case 66:
#line 382 "ael.y" #line 407 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str);;} { (yyval.str) = (yyvsp[(1) - (1)].str);;}
break; break;
case 67: case 67:
#line 383 "ael.y" #line 408 "ael.y"
{ {
asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)); if (asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)) < 0) {
free((yyvsp[(1) - (2)].str)); ast_log(LOG_WARNING, "asprintf() failed\n");
free((yyvsp[(2) - (2)].str)); (yyval.str) = NULL;
prev_word = (yyval.str);;} } else {
free((yyvsp[(1) - (2)].str));
free((yyvsp[(2) - (2)].str));
prev_word = (yyval.str);
}
;}
break; break;
case 68: case 68:
#line 388 "ael.y" #line 418 "ael.y"
{ {
asprintf(&((yyval.str)), "%s%s%s", (yyvsp[(1) - (3)].str), (yyvsp[(2) - (3)].str), (yyvsp[(3) - (3)].str)); if (asprintf(&((yyval.str)), "%s%s%s", (yyvsp[(1) - (3)].str), (yyvsp[(2) - (3)].str), (yyvsp[(3) - (3)].str)) < 0) {
free((yyvsp[(1) - (3)].str)); ast_log(LOG_WARNING, "asprintf() failed\n");
free((yyvsp[(2) - (3)].str)); (yyval.str) = NULL;
free((yyvsp[(3) - (3)].str)); } else {
prev_word=(yyval.str);;} free((yyvsp[(1) - (3)].str));
free((yyvsp[(2) - (3)].str));
free((yyvsp[(3) - (3)].str));
prev_word=(yyval.str);
}
;}
break; break;
case 69: case 69:
#line 396 "ael.y" #line 431 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str);;} { (yyval.str) = (yyvsp[(1) - (1)].str);;}
break; break;
case 70: case 70:
#line 397 "ael.y" #line 432 "ael.y"
{ {
asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)); if (asprintf(&((yyval.str)), "%s%s", (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)) < 0) {
free((yyvsp[(1) - (2)].str)); ast_log(LOG_WARNING, "asprintf() failed\n");
free((yyvsp[(2) - (2)].str));;} (yyval.str) = NULL;
} else {
free((yyvsp[(1) - (2)].str));
free((yyvsp[(2) - (2)].str));
}
;}
break; break;
case 71: case 71:
#line 401 "ael.y" #line 441 "ael.y"
{ {
asprintf(&((yyval.str)), "%s:%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)); if (asprintf(&((yyval.str)), "%s:%s", (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)) < 0) {
free((yyvsp[(1) - (3)].str)); ast_log(LOG_WARNING, "asprintf() failed\n");
free((yyvsp[(3) - (3)].str));;} (yyval.str) = NULL;
} else {
free((yyvsp[(1) - (3)].str));
free((yyvsp[(3) - (3)].str));
}
;}
break; break;
case 72: case 72:
#line 407 "ael.y" #line 452 "ael.y"
{ {
(yyval.pval) = npval2(PV_SWITCH, &(yylsp[(1) - (5)]), &(yylsp[(5) - (5)])); (yyval.pval) = npval2(PV_SWITCH, &(yylsp[(1) - (5)]), &(yylsp[(5) - (5)]));
(yyval.pval)->u1.str = (yyvsp[(2) - (5)].str); (yyval.pval)->u1.str = (yyvsp[(2) - (5)].str);
@ -2555,60 +2600,60 @@ yyreduce:
break; break;
case 73: case 73:
#line 416 "ael.y" #line 461 "ael.y"
{ {
(yyval.pval) = npval2(PV_STATEMENTBLOCK, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)])); (yyval.pval) = npval2(PV_STATEMENTBLOCK, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.list = (yyvsp[(2) - (3)].pval); set_dads((yyval.pval),(yyvsp[(2) - (3)].pval));;} (yyval.pval)->u1.list = (yyvsp[(2) - (3)].pval); set_dads((yyval.pval),(yyvsp[(2) - (3)].pval));;}
break; break;
case 74: case 74:
#line 419 "ael.y" #line 464 "ael.y"
{ (yyval.pval) = (yyvsp[(1) - (1)].pval); ;} { (yyval.pval) = (yyvsp[(1) - (1)].pval); ;}
break; break;
case 75: case 75:
#line 420 "ael.y" #line 465 "ael.y"
{ (yyval.pval) = (yyvsp[(1) - (1)].pval); ;} { (yyval.pval) = (yyvsp[(1) - (1)].pval); ;}
break; break;
case 76: case 76:
#line 421 "ael.y" #line 466 "ael.y"
{ {
(yyval.pval) = npval2(PV_GOTO, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)])); (yyval.pval) = npval2(PV_GOTO, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.list = (yyvsp[(2) - (3)].pval);;} (yyval.pval)->u1.list = (yyvsp[(2) - (3)].pval);;}
break; break;
case 77: case 77:
#line 424 "ael.y" #line 469 "ael.y"
{ {
(yyval.pval) = npval2(PV_GOTO, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)])); (yyval.pval) = npval2(PV_GOTO, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.list = (yyvsp[(2) - (3)].pval);;} (yyval.pval)->u1.list = (yyvsp[(2) - (3)].pval);;}
break; break;
case 78: case 78:
#line 427 "ael.y" #line 472 "ael.y"
{ {
(yyval.pval) = npval2(PV_LABEL, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); (yyval.pval) = npval2(PV_LABEL, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)]));
(yyval.pval)->u1.str = (yyvsp[(1) - (2)].str); ;} (yyval.pval)->u1.str = (yyvsp[(1) - (2)].str); ;}
break; break;
case 79: case 79:
#line 430 "ael.y" #line 475 "ael.y"
{reset_semicount(parseio->scanner);;} {reset_semicount(parseio->scanner);;}
break; break;
case 80: case 80:
#line 431 "ael.y" #line 476 "ael.y"
{reset_semicount(parseio->scanner);;} {reset_semicount(parseio->scanner);;}
break; break;
case 81: case 81:
#line 432 "ael.y" #line 477 "ael.y"
{reset_parencount(parseio->scanner);;} {reset_parencount(parseio->scanner);;}
break; break;
case 82: case 82:
#line 432 "ael.y" #line 477 "ael.y"
{ /* XXX word_list maybe ? */ { /* XXX word_list maybe ? */
(yyval.pval) = npval2(PV_FOR, &(yylsp[(1) - (12)]), &(yylsp[(12) - (12)])); (yyval.pval) = npval2(PV_FOR, &(yylsp[(1) - (12)]), &(yylsp[(12) - (12)]));
(yyval.pval)->u1.for_init = (yyvsp[(4) - (12)].str); (yyval.pval)->u1.for_init = (yyvsp[(4) - (12)].str);
@ -2618,7 +2663,7 @@ yyreduce:
break; break;
case 83: case 83:
#line 438 "ael.y" #line 483 "ael.y"
{ {
(yyval.pval) = npval2(PV_WHILE, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)])); (yyval.pval) = npval2(PV_WHILE, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.str = (yyvsp[(2) - (3)].str); (yyval.pval)->u1.str = (yyvsp[(2) - (3)].str);
@ -2626,34 +2671,34 @@ yyreduce:
break; break;
case 84: case 84:
#line 442 "ael.y" #line 487 "ael.y"
{ (yyval.pval) = (yyvsp[(1) - (1)].pval); ;} { (yyval.pval) = (yyvsp[(1) - (1)].pval); ;}
break; break;
case 85: case 85:
#line 443 "ael.y" #line 488 "ael.y"
{ (yyval.pval) = update_last((yyvsp[(2) - (3)].pval), &(yylsp[(2) - (3)])); ;} { (yyval.pval) = update_last((yyvsp[(2) - (3)].pval), &(yylsp[(2) - (3)])); ;}
break; break;
case 86: case 86:
#line 444 "ael.y" #line 489 "ael.y"
{ (yyval.pval) = update_last((yyvsp[(1) - (2)].pval), &(yylsp[(2) - (2)])); ;} { (yyval.pval) = update_last((yyvsp[(1) - (2)].pval), &(yylsp[(2) - (2)])); ;}
break; break;
case 87: case 87:
#line 445 "ael.y" #line 490 "ael.y"
{ {
(yyval.pval)= npval2(PV_APPLICATION_CALL, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); (yyval.pval)= npval2(PV_APPLICATION_CALL, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)]));
(yyval.pval)->u1.str = (yyvsp[(1) - (2)].str);;} (yyval.pval)->u1.str = (yyvsp[(1) - (2)].str);;}
break; break;
case 88: case 88:
#line 448 "ael.y" #line 493 "ael.y"
{reset_semicount(parseio->scanner);;} {reset_semicount(parseio->scanner);;}
break; break;
case 89: case 89:
#line 448 "ael.y" #line 493 "ael.y"
{ {
char *bufx; char *bufx;
int tot=0; int tot=0;
@ -2690,22 +2735,22 @@ yyreduce:
break; break;
case 90: case 90:
#line 481 "ael.y" #line 526 "ael.y"
{ (yyval.pval) = npval2(PV_BREAK, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); ;} { (yyval.pval) = npval2(PV_BREAK, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); ;}
break; break;
case 91: case 91:
#line 482 "ael.y" #line 527 "ael.y"
{ (yyval.pval) = npval2(PV_RETURN, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); ;} { (yyval.pval) = npval2(PV_RETURN, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); ;}
break; break;
case 92: case 92:
#line 483 "ael.y" #line 528 "ael.y"
{ (yyval.pval) = npval2(PV_CONTINUE, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); ;} { (yyval.pval) = npval2(PV_CONTINUE, &(yylsp[(1) - (2)]), &(yylsp[(2) - (2)])); ;}
break; break;
case 93: case 93:
#line 484 "ael.y" #line 529 "ael.y"
{ {
(yyval.pval) = update_last((yyvsp[(1) - (3)].pval), &(yylsp[(2) - (3)])); (yyval.pval) = update_last((yyvsp[(1) - (3)].pval), &(yylsp[(2) - (3)]));
(yyval.pval)->u2.statements = (yyvsp[(2) - (3)].pval); set_dads((yyval.pval),(yyvsp[(2) - (3)].pval)); (yyval.pval)->u2.statements = (yyvsp[(2) - (3)].pval); set_dads((yyval.pval),(yyvsp[(2) - (3)].pval));
@ -2713,41 +2758,41 @@ yyreduce:
break; break;
case 94: case 94:
#line 488 "ael.y" #line 533 "ael.y"
{ (yyval.pval)=0; ;} { (yyval.pval)=0; ;}
break; break;
case 95: case 95:
#line 491 "ael.y" #line 536 "ael.y"
{ (yyval.pval) = (yyvsp[(2) - (2)].pval); ;} { (yyval.pval) = (yyvsp[(2) - (2)].pval); ;}
break; break;
case 96: case 96:
#line 492 "ael.y" #line 537 "ael.y"
{ (yyval.pval) = NULL ; ;} { (yyval.pval) = NULL ; ;}
break; break;
case 97: case 97:
#line 495 "ael.y" #line 540 "ael.y"
{ (yyval.pval) = nword((yyvsp[(1) - (1)].str), &(yylsp[(1) - (1)])); ;} { (yyval.pval) = nword((yyvsp[(1) - (1)].str), &(yylsp[(1) - (1)])); ;}
break; break;
case 98: case 98:
#line 496 "ael.y" #line 541 "ael.y"
{ {
(yyval.pval) = nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)])); (yyval.pval) = nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)]));
(yyval.pval)->next = nword((yyvsp[(3) - (3)].str), &(yylsp[(3) - (3)])); ;} (yyval.pval)->next = nword((yyvsp[(3) - (3)].str), &(yylsp[(3) - (3)])); ;}
break; break;
case 99: case 99:
#line 499 "ael.y" #line 544 "ael.y"
{ {
(yyval.pval) = nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)])); (yyval.pval) = nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)]));
(yyval.pval)->next = nword((yyvsp[(3) - (3)].str), &(yylsp[(3) - (3)])); ;} (yyval.pval)->next = nword((yyvsp[(3) - (3)].str), &(yylsp[(3) - (3)])); ;}
break; break;
case 100: case 100:
#line 502 "ael.y" #line 547 "ael.y"
{ {
(yyval.pval) = nword((yyvsp[(1) - (5)].str), &(yylsp[(1) - (5)])); (yyval.pval) = nword((yyvsp[(1) - (5)].str), &(yylsp[(1) - (5)]));
(yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)])); (yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)]));
@ -2755,7 +2800,7 @@ yyreduce:
break; break;
case 101: case 101:
#line 506 "ael.y" #line 551 "ael.y"
{ {
(yyval.pval) = nword((yyvsp[(1) - (5)].str), &(yylsp[(1) - (5)])); (yyval.pval) = nword((yyvsp[(1) - (5)].str), &(yylsp[(1) - (5)]));
(yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)])); (yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)]));
@ -2763,7 +2808,7 @@ yyreduce:
break; break;
case 102: case 102:
#line 510 "ael.y" #line 555 "ael.y"
{ {
(yyval.pval) = nword(strdup("default"), &(yylsp[(1) - (5)])); (yyval.pval) = nword(strdup("default"), &(yylsp[(1) - (5)]));
(yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)])); (yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)]));
@ -2771,7 +2816,7 @@ yyreduce:
break; break;
case 103: case 103:
#line 514 "ael.y" #line 559 "ael.y"
{ {
(yyval.pval) = nword(strdup("default"), &(yylsp[(1) - (5)])); (yyval.pval) = nword(strdup("default"), &(yylsp[(1) - (5)]));
(yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)])); (yyval.pval)->next = nword((yyvsp[(3) - (5)].str), &(yylsp[(3) - (5)]));
@ -2779,24 +2824,24 @@ yyreduce:
break; break;
case 104: case 104:
#line 520 "ael.y" #line 565 "ael.y"
{ (yyval.str) = strdup("1"); ;} { (yyval.str) = strdup("1"); ;}
break; break;
case 105: case 105:
#line 521 "ael.y" #line 566 "ael.y"
{ (yyval.str) = (yyvsp[(2) - (2)].str); ;} { (yyval.str) = (yyvsp[(2) - (2)].str); ;}
break; break;
case 106: case 106:
#line 525 "ael.y" #line 570 "ael.y"
{ /* ext[, pri] default 1 */ { /* ext[, pri] default 1 */
(yyval.pval) = nword((yyvsp[(1) - (2)].str), &(yylsp[(1) - (2)])); (yyval.pval) = nword((yyvsp[(1) - (2)].str), &(yylsp[(1) - (2)]));
(yyval.pval)->next = nword((yyvsp[(2) - (2)].str), &(yylsp[(2) - (2)])); ;} (yyval.pval)->next = nword((yyvsp[(2) - (2)].str), &(yylsp[(2) - (2)])); ;}
break; break;
case 107: case 107:
#line 528 "ael.y" #line 573 "ael.y"
{ /* context, ext, pri */ { /* context, ext, pri */
(yyval.pval) = nword((yyvsp[(4) - (4)].str), &(yylsp[(4) - (4)])); (yyval.pval) = nword((yyvsp[(4) - (4)].str), &(yylsp[(4) - (4)]));
(yyval.pval)->next = nword((yyvsp[(1) - (4)].str), &(yylsp[(1) - (4)])); (yyval.pval)->next = nword((yyvsp[(1) - (4)].str), &(yylsp[(1) - (4)]));
@ -2804,12 +2849,12 @@ yyreduce:
break; break;
case 108: case 108:
#line 534 "ael.y" #line 579 "ael.y"
{reset_argcount(parseio->scanner);;} {reset_argcount(parseio->scanner);;}
break; break;
case 109: case 109:
#line 534 "ael.y" #line 579 "ael.y"
{ {
/* XXX original code had @2 but i think we need @5 */ /* XXX original code had @2 but i think we need @5 */
(yyval.pval) = npval2(PV_MACRO_CALL, &(yylsp[(1) - (5)]), &(yylsp[(5) - (5)])); (yyval.pval) = npval2(PV_MACRO_CALL, &(yylsp[(1) - (5)]), &(yylsp[(5) - (5)]));
@ -2818,19 +2863,19 @@ yyreduce:
break; break;
case 110: case 110:
#line 539 "ael.y" #line 584 "ael.y"
{ {
(yyval.pval)= npval2(PV_MACRO_CALL, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)])); (yyval.pval)= npval2(PV_MACRO_CALL, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.str = (yyvsp[(1) - (3)].str); ;} (yyval.pval)->u1.str = (yyvsp[(1) - (3)].str); ;}
break; break;
case 111: case 111:
#line 547 "ael.y" #line 592 "ael.y"
{reset_argcount(parseio->scanner);;} {reset_argcount(parseio->scanner);;}
break; break;
case 112: case 112:
#line 547 "ael.y" #line 592 "ael.y"
{ {
if (strcasecmp((yyvsp[(1) - (3)].str),"goto") == 0) { if (strcasecmp((yyvsp[(1) - (3)].str),"goto") == 0) {
(yyval.pval) = npval2(PV_GOTO, &(yylsp[(1) - (3)]), &(yylsp[(2) - (3)])); (yyval.pval) = npval2(PV_GOTO, &(yylsp[(1) - (3)]), &(yylsp[(2) - (3)]));
@ -2843,7 +2888,7 @@ yyreduce:
break; break;
case 113: case 113:
#line 558 "ael.y" #line 603 "ael.y"
{ {
(yyval.pval) = update_last((yyvsp[(1) - (3)].pval), &(yylsp[(3) - (3)])); (yyval.pval) = update_last((yyvsp[(1) - (3)].pval), &(yylsp[(3) - (3)]));
if( (yyval.pval)->type == PV_GOTO ) if( (yyval.pval)->type == PV_GOTO )
@ -2854,49 +2899,49 @@ yyreduce:
break; break;
case 114: case 114:
#line 565 "ael.y" #line 610 "ael.y"
{ (yyval.pval) = update_last((yyvsp[(1) - (2)].pval), &(yylsp[(2) - (2)])); ;} { (yyval.pval) = update_last((yyvsp[(1) - (2)].pval), &(yylsp[(2) - (2)])); ;}
break; break;
case 115: case 115:
#line 568 "ael.y" #line 613 "ael.y"
{ (yyval.str) = (yyvsp[(1) - (1)].str) ;} { (yyval.str) = (yyvsp[(1) - (1)].str) ;}
break; break;
case 116: case 116:
#line 569 "ael.y" #line 614 "ael.y"
{ (yyval.str) = strdup(""); ;} { (yyval.str) = strdup(""); ;}
break; break;
case 117: case 117:
#line 572 "ael.y" #line 617 "ael.y"
{ (yyval.pval) = nword((yyvsp[(1) - (1)].str), &(yylsp[(1) - (1)])); ;} { (yyval.pval) = nword((yyvsp[(1) - (1)].str), &(yylsp[(1) - (1)])); ;}
break; break;
case 118: case 118:
#line 573 "ael.y" #line 618 "ael.y"
{ {
(yyval.pval)= npval(PV_WORD,0/*@1.first_line*/,0/*@1.last_line*/,0/* @1.first_column*/, 0/*@1.last_column*/); (yyval.pval)= npval(PV_WORD,0/*@1.first_line*/,0/*@1.last_line*/,0/* @1.first_column*/, 0/*@1.last_column*/);
(yyval.pval)->u1.str = strdup(""); ;} (yyval.pval)->u1.str = strdup(""); ;}
break; break;
case 119: case 119:
#line 576 "ael.y" #line 621 "ael.y"
{ (yyval.pval) = linku1((yyvsp[(1) - (3)].pval), nword((yyvsp[(3) - (3)].str), &(yylsp[(3) - (3)]))); ;} { (yyval.pval) = linku1((yyvsp[(1) - (3)].pval), nword((yyvsp[(3) - (3)].str), &(yylsp[(3) - (3)]))); ;}
break; break;
case 120: case 120:
#line 579 "ael.y" #line 624 "ael.y"
{ (yyval.pval) = NULL; ;} { (yyval.pval) = NULL; ;}
break; break;
case 121: case 121:
#line 580 "ael.y" #line 625 "ael.y"
{ (yyval.pval) = linku1((yyvsp[(1) - (2)].pval), (yyvsp[(2) - (2)].pval)); ;} { (yyval.pval) = linku1((yyvsp[(1) - (2)].pval), (yyvsp[(2) - (2)].pval)); ;}
break; break;
case 122: case 122:
#line 583 "ael.y" #line 628 "ael.y"
{ {
(yyval.pval) = npval2(PV_CASE, &(yylsp[(1) - (4)]), &(yylsp[(3) - (4)])); /* XXX 3 or 4 ? */ (yyval.pval) = npval2(PV_CASE, &(yylsp[(1) - (4)]), &(yylsp[(3) - (4)])); /* XXX 3 or 4 ? */
(yyval.pval)->u1.str = (yyvsp[(2) - (4)].str); (yyval.pval)->u1.str = (yyvsp[(2) - (4)].str);
@ -2904,7 +2949,7 @@ yyreduce:
break; break;
case 123: case 123:
#line 587 "ael.y" #line 632 "ael.y"
{ {
(yyval.pval) = npval2(PV_DEFAULT, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)])); (yyval.pval) = npval2(PV_DEFAULT, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));
(yyval.pval)->u1.str = NULL; (yyval.pval)->u1.str = NULL;
@ -2912,7 +2957,7 @@ yyreduce:
break; break;
case 124: case 124:
#line 591 "ael.y" #line 636 "ael.y"
{ {
(yyval.pval) = npval2(PV_PATTERN, &(yylsp[(1) - (4)]), &(yylsp[(4) - (4)])); /* XXX@3 or @4 ? */ (yyval.pval) = npval2(PV_PATTERN, &(yylsp[(1) - (4)]), &(yylsp[(4) - (4)])); /* XXX@3 or @4 ? */
(yyval.pval)->u1.str = (yyvsp[(2) - (4)].str); (yyval.pval)->u1.str = (yyvsp[(2) - (4)].str);
@ -2920,27 +2965,27 @@ yyreduce:
break; break;
case 125: case 125:
#line 597 "ael.y" #line 642 "ael.y"
{ (yyval.pval) = NULL; ;} { (yyval.pval) = NULL; ;}
break; break;
case 126: case 126:
#line 598 "ael.y" #line 643 "ael.y"
{ (yyval.pval) = linku1((yyvsp[(1) - (2)].pval), (yyvsp[(2) - (2)].pval)); ;} { (yyval.pval) = linku1((yyvsp[(1) - (2)].pval), (yyvsp[(2) - (2)].pval)); ;}
break; break;
case 127: case 127:
#line 601 "ael.y" #line 646 "ael.y"
{(yyval.pval)=(yyvsp[(1) - (1)].pval);;} {(yyval.pval)=(yyvsp[(1) - (1)].pval);;}
break; break;
case 128: case 128:
#line 602 "ael.y" #line 647 "ael.y"
{ (yyval.pval)=(yyvsp[(1) - (1)].pval);;} { (yyval.pval)=(yyvsp[(1) - (1)].pval);;}
break; break;
case 129: case 129:
#line 603 "ael.y" #line 648 "ael.y"
{ {
(yyval.pval) = npval2(PV_CATCH, &(yylsp[(1) - (5)]), &(yylsp[(5) - (5)])); (yyval.pval) = npval2(PV_CATCH, &(yylsp[(1) - (5)]), &(yylsp[(5) - (5)]));
(yyval.pval)->u1.str = (yyvsp[(2) - (5)].str); (yyval.pval)->u1.str = (yyvsp[(2) - (5)].str);
@ -2948,47 +2993,56 @@ yyreduce:
break; break;
case 130: case 130:
#line 609 "ael.y" #line 654 "ael.y"
{ {
(yyval.pval) = npval2(PV_SWITCHES, &(yylsp[(1) - (4)]), &(yylsp[(2) - (4)])); (yyval.pval) = npval2(PV_SWITCHES, &(yylsp[(1) - (4)]), &(yylsp[(2) - (4)]));
(yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval); set_dads((yyval.pval),(yyvsp[(3) - (4)].pval));;} (yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval); set_dads((yyval.pval),(yyvsp[(3) - (4)].pval));;}
break; break;
case 131: case 131:
#line 614 "ael.y" #line 659 "ael.y"
{ {
(yyval.pval) = npval2(PV_ESWITCHES, &(yylsp[(1) - (4)]), &(yylsp[(2) - (4)])); (yyval.pval) = npval2(PV_ESWITCHES, &(yylsp[(1) - (4)]), &(yylsp[(2) - (4)]));
(yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval); set_dads((yyval.pval),(yyvsp[(3) - (4)].pval));;} (yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval); set_dads((yyval.pval),(yyvsp[(3) - (4)].pval));;}
break; break;
case 132: case 132:
#line 619 "ael.y" #line 664 "ael.y"
{ (yyval.pval) = NULL; ;} { (yyval.pval) = NULL; ;}
break; break;
case 133: case 133:
#line 620 "ael.y" #line 665 "ael.y"
{ (yyval.pval) = linku1(nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)])), (yyvsp[(3) - (3)].pval)); ;} { (yyval.pval) = linku1(nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)])), (yyvsp[(3) - (3)].pval)); ;}
break; break;
case 134: case 134:
#line 621 "ael.y" #line 666 "ael.y"
{ char *x; asprintf(&x,"%s@%s", (yyvsp[(1) - (5)].str),(yyvsp[(3) - (5)].str)); free((yyvsp[(1) - (5)].str)); free((yyvsp[(3) - (5)].str)); {
(yyval.pval) = linku1(nword(x, &(yylsp[(1) - (5)])), (yyvsp[(5) - (5)].pval));;} char *x;
if (asprintf(&x,"%s@%s", (yyvsp[(1) - (5)].str), (yyvsp[(3) - (5)].str)) < 0) {
ast_log(LOG_WARNING, "asprintf() failed\n");
(yyval.pval) = NULL;
} else {
free((yyvsp[(1) - (5)].str));
free((yyvsp[(3) - (5)].str));
(yyval.pval) = linku1(nword(x, &(yylsp[(1) - (5)])), (yyvsp[(5) - (5)].pval));
}
;}
break; break;
case 135: case 135:
#line 623 "ael.y" #line 677 "ael.y"
{(yyval.pval)=(yyvsp[(2) - (2)].pval);;} {(yyval.pval)=(yyvsp[(2) - (2)].pval);;}
break; break;
case 136: case 136:
#line 626 "ael.y" #line 680 "ael.y"
{ (yyval.pval) = nword((yyvsp[(1) - (1)].str), &(yylsp[(1) - (1)])); ;} { (yyval.pval) = nword((yyvsp[(1) - (1)].str), &(yylsp[(1) - (1)])); ;}
break; break;
case 137: case 137:
#line 627 "ael.y" #line 681 "ael.y"
{ {
(yyval.pval) = nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)])); (yyval.pval) = nword((yyvsp[(1) - (3)].str), &(yylsp[(1) - (3)]));
(yyval.pval)->u2.arglist = (yyvsp[(3) - (3)].pval); (yyval.pval)->u2.arglist = (yyvsp[(3) - (3)].pval);
@ -2996,36 +3050,36 @@ yyreduce:
break; break;
case 138: case 138:
#line 634 "ael.y" #line 688 "ael.y"
{ (yyval.pval) = (yyvsp[(1) - (2)].pval); ;} { (yyval.pval) = (yyvsp[(1) - (2)].pval); ;}
break; break;
case 139: case 139:
#line 635 "ael.y" #line 689 "ael.y"
{ (yyval.pval) = linku1((yyvsp[(1) - (3)].pval), (yyvsp[(2) - (3)].pval)); ;} { (yyval.pval) = linku1((yyvsp[(1) - (3)].pval), (yyvsp[(2) - (3)].pval)); ;}
break; break;
case 140: case 140:
#line 636 "ael.y" #line 690 "ael.y"
{(yyval.pval)=(yyvsp[(1) - (2)].pval);;} {(yyval.pval)=(yyvsp[(1) - (2)].pval);;}
break; break;
case 141: case 141:
#line 639 "ael.y" #line 693 "ael.y"
{ {
(yyval.pval) = npval2(PV_INCLUDES, &(yylsp[(1) - (4)]), &(yylsp[(4) - (4)])); (yyval.pval) = npval2(PV_INCLUDES, &(yylsp[(1) - (4)]), &(yylsp[(4) - (4)]));
(yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval);set_dads((yyval.pval),(yyvsp[(3) - (4)].pval));;} (yyval.pval)->u1.list = (yyvsp[(3) - (4)].pval);set_dads((yyval.pval),(yyvsp[(3) - (4)].pval));;}
break; break;
case 142: case 142:
#line 642 "ael.y" #line 696 "ael.y"
{ {
(yyval.pval) = npval2(PV_INCLUDES, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));;} (yyval.pval) = npval2(PV_INCLUDES, &(yylsp[(1) - (3)]), &(yylsp[(3) - (3)]));;}
break; break;
/* Line 1267 of yacc.c. */ /* Line 1267 of yacc.c. */
#line 3029 "ael.tab.c" #line 3083 "ael.tab.c"
default: break; default: break;
} }
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@ -3245,7 +3299,7 @@ yyreturn:
} }
#line 647 "ael.y" #line 701 "ael.y"
static char *token_equivs1[] = static char *token_equivs1[] =

@ -319,10 +319,15 @@ statements : /* empty */ { $$ = NULL; }
* detect the '-' but only the ':' as separator * detect the '-' but only the ':' as separator
*/ */
timerange: word3_list COLON word3_list COLON word3_list { timerange: word3_list COLON word3_list COLON word3_list {
asprintf(&$$, "%s:%s:%s", $1, $3, $5); if (asprintf(&$$, "%s:%s:%s", $1, $3, $5) < 0) {
free($1); ast_log(LOG_WARNING, "asprintf() failed\n");
free($3); $$ = NULL;
free($5); } } else {
free($1);
free($3);
free($5);
}
}
| word { $$ = $1; } | word { $$ = $1; }
; ;
@ -358,50 +363,90 @@ if_like_head : KW_IF test_expr {
word_list : word { $$ = $1;} word_list : word { $$ = $1;}
| word word { | word word {
asprintf(&($$), "%s%s", $1, $2); if (asprintf(&($$), "%s%s", $1, $2) < 0) {
free($1); ast_log(LOG_WARNING, "asprintf() failed\n");
free($2); $$ = NULL;
prev_word = $$;} } else {
free($1);
free($2);
prev_word = $$;
}
}
; ;
hint_word : word { $$ = $1; } hint_word : word { $$ = $1; }
| hint_word word { | hint_word word {
asprintf(&($$), "%s %s", $1, $2); if (asprintf(&($$), "%s %s", $1, $2) < 0) {
free($1); ast_log(LOG_WARNING, "asprintf() failed\n");
free($2); } $$ = NULL;
} else {
free($1);
free($2);
}
}
| hint_word COLON word { | hint_word COLON word {
asprintf(&($$), "%s:%s", $1, $3); if (asprintf(&($$), "%s:%s", $1, $3) < 0) {
free($1); ast_log(LOG_WARNING, "asprintf() failed\n");
free($3); } $$ = NULL;
} else {
free($1);
free($3);
}
}
| hint_word AMPER word { /* there are often '&' in hints */ | hint_word AMPER word { /* there are often '&' in hints */
asprintf(&($$), "%s&%s", $1, $3); if (asprintf(&($$), "%s&%s", $1, $3) < 0) {
free($1); ast_log(LOG_WARNING, "asprintf() failed\n");
free($3);} $$ = NULL;
} else {
free($1);
free($3);
}
}
;
word3_list : word { $$ = $1;} word3_list : word { $$ = $1;}
| word word { | word word {
asprintf(&($$), "%s%s", $1, $2); if (asprintf(&($$), "%s%s", $1, $2) < 0) {
free($1); ast_log(LOG_WARNING, "asprintf() failed\n");
free($2); $$ = NULL;
prev_word = $$;} } else {
free($1);
free($2);
prev_word = $$;
}
}
| word word word { | word word word {
asprintf(&($$), "%s%s%s", $1, $2, $3); if (asprintf(&($$), "%s%s%s", $1, $2, $3) < 0) {
free($1); ast_log(LOG_WARNING, "asprintf() failed\n");
free($2); $$ = NULL;
free($3); } else {
prev_word=$$;} free($1);
free($2);
free($3);
prev_word=$$;
}
}
; ;
goto_word : word { $$ = $1;} goto_word : word { $$ = $1;}
| word word { | word word {
asprintf(&($$), "%s%s", $1, $2); if (asprintf(&($$), "%s%s", $1, $2) < 0) {
free($1); ast_log(LOG_WARNING, "asprintf() failed\n");
free($2);} $$ = NULL;
} else {
free($1);
free($2);
}
}
| goto_word COLON word { | goto_word COLON word {
asprintf(&($$), "%s:%s", $1, $3); if (asprintf(&($$), "%s:%s", $1, $3) < 0) {
free($1); ast_log(LOG_WARNING, "asprintf() failed\n");
free($3);} $$ = NULL;
} else {
free($1);
free($3);
}
}
; ;
switch_statement : KW_SWITCH test_expr LC case_statements RC { switch_statement : KW_SWITCH test_expr LC case_statements RC {
@ -618,8 +663,17 @@ eswitches : KW_ESWITCHES LC switchlist RC {
switchlist : /* empty */ { $$ = NULL; } switchlist : /* empty */ { $$ = NULL; }
| word SEMI switchlist { $$ = linku1(nword($1, &@1), $3); } | word SEMI switchlist { $$ = linku1(nword($1, &@1), $3); }
| word AT word SEMI switchlist { char *x; asprintf(&x,"%s@%s", $1,$3); free($1); free($3); | word AT word SEMI switchlist {
$$ = linku1(nword(x, &@1), $5);} char *x;
if (asprintf(&x,"%s@%s", $1, $3) < 0) {
ast_log(LOG_WARNING, "asprintf() failed\n");
$$ = NULL;
} else {
free($1);
free($3);
$$ = linku1(nword(x, &@1), $5);
}
}
| error switchlist {$$=$2;} | error switchlist {$$=$2;}
; ;

@ -9,7 +9,7 @@
#define FLEX_SCANNER #define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 33 #define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0 #if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA #define FLEX_BETA
#endif #endif
@ -32,7 +32,7 @@
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if __STDC_VERSION__ >= 199901L #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types. * if you want the limit (max/min) macros for int types.
@ -55,7 +55,6 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t; typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t; typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t; typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */ /* Limits of integral types. */
#ifndef INT8_MIN #ifndef INT8_MIN
@ -86,6 +85,8 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U) #define UINT32_MAX (4294967295U)
#endif #endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */ #endif /* ! FLEXINT_H */
#ifdef __cplusplus #ifdef __cplusplus
@ -95,11 +96,12 @@ typedef unsigned int flex_uint32_t;
#else /* ! __cplusplus */ #else /* ! __cplusplus */
#if __STDC__ /* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)
#define YY_USE_CONST #define YY_USE_CONST
#endif /* __STDC__ */ #endif /* defined (__STDC__) */
#endif /* ! __cplusplus */ #endif /* ! __cplusplus */
#ifdef YY_USE_CONST #ifdef YY_USE_CONST
@ -135,8 +137,6 @@ typedef void* yyscan_t;
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r #define yy_flex_debug yyg->yy_flex_debug_r
int ael_yylex_init (yyscan_t* scanner);
/* Enter a start condition. This macro really ought to take a parameter, /* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less * but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN. * definition of BEGIN.
@ -194,14 +194,9 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
/* The following is because we cannot portably get our hands on size_t
* (without autoconf's help, which isn't available because we want
* flex-generated scanners to compile on their own).
*/
#ifndef YY_TYPEDEF_YY_SIZE_T #ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T
typedef unsigned int yy_size_t; typedef size_t yy_size_t;
#endif #endif
#ifndef YY_STRUCT_YY_BUFFER_STATE #ifndef YY_STRUCT_YY_BUFFER_STATE
@ -950,7 +945,7 @@ static void pbcwhere(const char *text, int *line, int *col )
#define STORE_POS #define STORE_POS
#define STORE_LOC #define STORE_LOC
#endif #endif
#line 953 "ael_lex.c" #line 948 "ael_lex.c"
#define INITIAL 0 #define INITIAL 0
#define paren 1 #define paren 1
@ -1019,6 +1014,10 @@ static int yy_init_globals (yyscan_t yyscanner );
# define yylloc yyg->yylloc_r # define yylloc yyg->yylloc_r
int ael_yylex_init (yyscan_t* scanner);
int ael_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
/* Accessor methods to globals. /* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */ These are made visible to non-reentrant scanners for convenience. */
@ -1098,7 +1097,7 @@ static int input (yyscan_t yyscanner );
/* This used to be an fputs(), but since the string might contain NUL's, /* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite(). * we now use fwrite().
*/ */
#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#endif #endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@ -1163,9 +1162,11 @@ static int input (yyscan_t yyscanner );
#ifndef YY_DECL #ifndef YY_DECL
#define YY_DECL_IS_OURS 1 #define YY_DECL_IS_OURS 1
extern int ael_yylex (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); extern int ael_yylex \
(YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
#define YY_DECL int ael_yylex (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) #define YY_DECL int ael_yylex \
(YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
#endif /* !YY_DECL */ #endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng /* Code executed at the beginning of each rule, after yytext and yyleng
@ -1195,7 +1196,7 @@ YY_DECL
#line 208 "ael.flex" #line 208 "ael.flex"
#line 1198 "ael_lex.c" #line 1199 "ael_lex.c"
yylval = yylval_param; yylval = yylval_param;
@ -2000,7 +2001,7 @@ YY_RULE_SETUP
#line 622 "ael.flex" #line 622 "ael.flex"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 2003 "ael_lex.c" #line 2004 "ael_lex.c"
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
{ {
@ -2231,7 +2232,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
/* Read in more data. */ /* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
yyg->yy_n_chars, num_to_read ); yyg->yy_n_chars, (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
} }
@ -2255,6 +2256,14 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else else
ret_val = EOB_ACT_CONTINUE_SCAN; ret_val = EOB_ACT_CONTINUE_SCAN;
if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ael_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
}
yyg->yy_n_chars += number_to_move; yyg->yy_n_chars += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
@ -2683,7 +2692,9 @@ static void ael_yyensure_buffer_stack (yyscan_t yyscanner)
yyg->yy_buffer_stack = (struct yy_buffer_state**)ael_yyalloc yyg->yy_buffer_stack = (struct yy_buffer_state**)ael_yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*) (num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner); , yyscanner);
if ( ! yyg->yy_buffer_stack )
YY_FATAL_ERROR( "out of dynamic memory in ael_yyensure_buffer_stack()" );
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_max = num_to_alloc;
@ -2701,6 +2712,8 @@ static void ael_yyensure_buffer_stack (yyscan_t yyscanner)
(yyg->yy_buffer_stack, (yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*) num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner); , yyscanner);
if ( ! yyg->yy_buffer_stack )
YY_FATAL_ERROR( "out of dynamic memory in ael_yyensure_buffer_stack()" );
/* zero only the new slots.*/ /* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
@ -2745,7 +2758,7 @@ YY_BUFFER_STATE ael_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yys
/** Setup the input buffer state to scan a string. The next call to ael_yylex() will /** Setup the input buffer state to scan a string. The next call to ael_yylex() will
* scan from a @e copy of @a str. * scan from a @e copy of @a str.
* @param str a NUL-terminated string to scan * @param yystr a NUL-terminated string to scan
* @param yyscanner The scanner object. * @param yyscanner The scanner object.
* @return the newly allocated buffer state object. * @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use * @note If you want to scan bytes that may contain NUL values, then use
@ -3019,6 +3032,42 @@ int ael_yylex_init(yyscan_t* ptr_yy_globals)
return yy_init_globals ( *ptr_yy_globals ); return yy_init_globals ( *ptr_yy_globals );
} }
/* ael_yylex_init_extra has the same functionality as ael_yylex_init, but follows the
* convention of taking the scanner as the last argument. Note however, that
* this is a *pointer* to a scanner, as it will be allocated by this call (and
* is the reason, too, why this function also must handle its own declaration).
* The user defined value in the first argument will be available to ael_yyalloc in
* the yyextra field.
*/
int ael_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
{
struct yyguts_t dummy_yyguts;
ael_yyset_extra (yy_user_defined, &dummy_yyguts);
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
*ptr_yy_globals = (yyscan_t) ael_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
return 1;
}
/* By setting to 0xAA, we expose bugs in
yy_init_globals. Leave at 0x00 for releases. */
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
ael_yyset_extra (yy_user_defined, *ptr_yy_globals);
return yy_init_globals ( *ptr_yy_globals );
}
static int yy_init_globals (yyscan_t yyscanner) static int yy_init_globals (yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@ -3281,7 +3330,9 @@ struct pval *ael2_parse(char *filename, int *errors)
my_file = strdup(filename); my_file = strdup(filename);
stat(filename, &stats); stat(filename, &stats);
buffer = (char*)malloc(stats.st_size+2); buffer = (char*)malloc(stats.st_size+2);
fread(buffer, 1, stats.st_size, fin); if (fread(buffer, 1, stats.st_size, fin) != stats.st_size) {
ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
}
buffer[stats.st_size]=0; buffer[stats.st_size]=0;
fclose(fin); fclose(fin);
@ -3349,7 +3400,9 @@ static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf,
struct stat stats; struct stat stats;
stat(fnamebuf2, &stats); stat(fnamebuf2, &stats);
buffer = (char*)malloc(stats.st_size+1); buffer = (char*)malloc(stats.st_size+1);
fread(buffer, 1, stats.st_size, in1); if (fread(buffer, 1, stats.st_size, in1) != stats.st_size) {
ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
}
buffer[stats.st_size] = 0; buffer[stats.st_size] = 0;
ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size); ast_log(LOG_NOTICE," --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size);
fclose(in1); fclose(in1);

@ -2642,7 +2642,8 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi
/* If it's voice, write it to the audio pipe */ /* If it's voice, write it to the audio pipe */
if ((agi->audio > -1) && (f->frametype == AST_FRAME_VOICE)) { if ((agi->audio > -1) && (f->frametype == AST_FRAME_VOICE)) {
/* Write, ignoring errors */ /* Write, ignoring errors */
write(agi->audio, f->data.ptr, f->datalen); if (write(agi->audio, f->data.ptr, f->datalen) < 0) {
}
} }
ast_frfree(f); ast_frfree(f);
} }

@ -660,7 +660,10 @@ static struct sqlite_cache_tables *find_table(const char *tablename)
} }
/* Table structure not cached; build the structure now */ /* Table structure not cached; build the structure now */
asprintf(&sql, sql_table_structure, tablename); if (asprintf(&sql, sql_table_structure, tablename) < 0) {
ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
sql = NULL;
}
if (!(tblptr = ast_calloc(1, sizeof(*tblptr) + strlen(tablename) + 1))) { if (!(tblptr = ast_calloc(1, sizeof(*tblptr) + strlen(tablename) + 1))) {
AST_RWLIST_UNLOCK(&sqlite_tables); AST_RWLIST_UNLOCK(&sqlite_tables);
ast_log(LOG_ERROR, "Memory error. Cannot cache table '%s'\n", tablename); ast_log(LOG_ERROR, "Memory error. Cannot cache table '%s'\n", tablename);

@ -106,7 +106,11 @@ static int pw_cb(char *buf, int size, int rwflag, void *userdata)
snprintf(prompt, sizeof(prompt), ">>>> passcode for %s key '%s': ", snprintf(prompt, sizeof(prompt), ">>>> passcode for %s key '%s': ",
key->ktype == AST_KEY_PRIVATE ? "PRIVATE" : "PUBLIC", key->name); key->ktype == AST_KEY_PRIVATE ? "PRIVATE" : "PUBLIC", key->name);
write(key->outfd, prompt, strlen(prompt)); if (write(key->outfd, prompt, strlen(prompt)) < 0) {
ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
key->infd = -2;
return -1;
}
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
tmp = ast_hide_password(key->infd); tmp = ast_hide_password(key->infd);
memset(buf, 0, size); memset(buf, 0, size);
@ -177,7 +181,9 @@ static struct ast_key *try_load_key(const char *dir, const char *fname, int ifd,
while(!feof(f)) { while(!feof(f)) {
/* Calculate a "whatever" quality md5sum of the key */ /* Calculate a "whatever" quality md5sum of the key */
char buf[256] = ""; char buf[256] = "";
fgets(buf, sizeof(buf), f); if (!fgets(buf, sizeof(buf), f)) {
continue;
}
if (!feof(f)) if (!feof(f))
MD5Update(&md5, (unsigned char *) buf, strlen(buf)); MD5Update(&md5, (unsigned char *) buf, strlen(buf));
} }

@ -222,8 +222,14 @@ static struct ast_str *http_post_callback(struct ast_tcptls_session_instance *se
if (content_len < res) { if (content_len < res) {
res = content_len; res = content_len;
} }
fread(buf, 1, res, ser->f); if (fread(buf, 1, res, ser->f) != res) {
fwrite(buf, 1, res, f); ast_log(LOG_WARNING, "fread() failed: %s\n", strerror(errno));
continue;
}
if (fwrite(buf, 1, res, f) != res) {
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
continue;
}
} }
if (fseek(f, SEEK_SET, 0)) { if (fseek(f, SEEK_SET, 0)) {

@ -987,8 +987,7 @@ static int aji_act_hook(void *data, int type, iks *node)
sprintf(secret, "%s%s", pak->id, client->password); sprintf(secret, "%s%s", pak->id, client->password);
ast_sha1_hash(shasum, secret); ast_sha1_hash(shasum, secret);
handshake = NULL; handshake = NULL;
asprintf(&handshake, "<handshake>%s</handshake>", shasum); if (asprintf(&handshake, "<handshake>%s</handshake>", shasum) >= 0) {
if (handshake) {
aji_send_raw(client, handshake); aji_send_raw(client, handshake);
ast_free(handshake); ast_free(handshake);
handshake = NULL; handshake = NULL;
@ -2755,8 +2754,7 @@ static int aji_create_client(char *label, struct ast_variable *var, int debug)
} }
if (!strchr(client->user, '/') && !client->component) { /*client */ if (!strchr(client->user, '/') && !client->component) { /*client */
resource = NULL; resource = NULL;
asprintf(&resource, "%s/asterisk", client->user); if (asprintf(&resource, "%s/asterisk", client->user) >= 0) {
if (resource) {
client->jid = iks_id_new(client->stack, resource); client->jid = iks_id_new(client->stack, resource);
ast_free(resource); ast_free(resource);
} }
@ -2772,8 +2770,7 @@ static int aji_create_client(char *label, struct ast_variable *var, int debug)
} }
if (!strchr(client->user, '/') && !client->component) { /*client */ if (!strchr(client->user, '/') && !client->component) { /*client */
resource = NULL; resource = NULL;
asprintf(&resource, "%s/asterisk", client->user); if (asprintf(&resource, "%s/asterisk", client->user) >= 0) {
if (resource) {
client->jid = iks_id_new(client->stack, resource); client->jid = iks_id_new(client->stack, resource);
ast_free(resource); ast_free(resource);
} }

@ -512,7 +512,10 @@ static int spawn_mp3(struct mohclass *class)
ast_close_fds_above_n(STDERR_FILENO); ast_close_fds_above_n(STDERR_FILENO);
/* Child */ /* Child */
chdir(class->dir); if (chdir(class->dir) < 0) {
ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno));
_exit(1);
}
if (ast_test_flag(class, MOH_CUSTOM)) { if (ast_test_flag(class, MOH_CUSTOM)) {
execv(argv[0], argv); execv(argv[0], argv);
} else { } else {
@ -924,8 +927,14 @@ static int moh_scan_files(struct mohclass *class) {
class->total_files = 0; class->total_files = 0;
dirnamelen = strlen(class->dir) + 2; dirnamelen = strlen(class->dir) + 2;
getcwd(path, sizeof(path)); if (!getcwd(path, sizeof(path))) {
chdir(class->dir); ast_log(LOG_WARNING, "getcwd() failed: %s\n", strerror(errno));
return -1;
}
if (chdir(class->dir) < 0) {
ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno));
return -1;
}
while ((files_dirent = readdir(files_DIR))) { while ((files_dirent = readdir(files_DIR))) {
/* The file name must be at least long enough to have the file type extension */ /* The file name must be at least long enough to have the file type extension */
if ((strlen(files_dirent->d_name) < 4)) if ((strlen(files_dirent->d_name) < 4))
@ -962,7 +971,10 @@ static int moh_scan_files(struct mohclass *class) {
} }
closedir(files_DIR); closedir(files_DIR);
chdir(path); if (chdir(path) < 0) {
ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno));
return -1;
}
if (ast_test_flag(class, MOH_SORTALPHA)) if (ast_test_flag(class, MOH_SORTALPHA))
qsort(&class->filearray[0], class->total_files, sizeof(char *), moh_sort_compare); qsort(&class->filearray[0], class->total_files, sizeof(char *), moh_sort_compare);
return class->total_files; return class->total_files;

@ -447,7 +447,9 @@ static struct ast_str *phoneprov_callback(struct ast_tcptls_session_instance *se
ast_get_version(), buf, len, route->file->mime_type); ast_get_version(), buf, len, route->file->mime_type);
while ((len = read(fd, buf, sizeof(buf))) > 0) { while ((len = read(fd, buf, sizeof(buf))) > 0) {
fwrite(buf, 1, len, ser->f); if (fwrite(buf, 1, len, ser->f) != len) {
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
}
} }
close(fd); close(fd);

@ -82,7 +82,9 @@ int main(int argc, char *argv[])
if (utime(argv[1], NULL)) { if (utime(argv[1], NULL)) {
/* Recreate the file if it doesn't exist */ /* Recreate the file if it doesn't exist */
if ((fd = open(argv[1], O_RDWR | O_TRUNC | O_CREAT, 0777)) > -1) { if ((fd = open(argv[1], O_RDWR | O_TRUNC | O_CREAT, 0777)) > -1) {
write(fd, explanation, strlen(explanation)); if (write(fd, explanation, strlen(explanation)) < 0) {
exit(1);
}
close(fd); close(fd);
} else { } else {
exit(1); exit(1);

@ -151,10 +151,14 @@ static void __attribute__((format (printf, 2, 3))) fdprintf(int fd, char *fmt, .
{ {
char stuff[4096]; char stuff[4096];
va_list ap; va_list ap;
int res;
va_start(ap, fmt); va_start(ap, fmt);
vsnprintf(stuff, sizeof(stuff), fmt, ap); vsnprintf(stuff, sizeof(stuff), fmt, ap);
va_end(ap); va_end(ap);
write(fd, stuff, strlen(stuff)); if ((res = write(fd, stuff, strlen(stuff))) < 0) {
fprintf(stderr, "write() failed: %s\n", strerror(errno));
}
} }
static char *get_header(struct message *m, char *var) static char *get_header(struct message *m, char *var)
@ -418,13 +422,16 @@ static int __attribute__((format (printf, 2, 3))) manager_action(char *action, c
struct ast_mansession *s; struct ast_mansession *s;
char tmp[4096]; char tmp[4096];
va_list ap; va_list ap;
int res;
s = &session; s = &session;
fdprintf(s->fd, "Action: %s\r\n", action); fdprintf(s->fd, "Action: %s\r\n", action);
va_start(ap, fmt); va_start(ap, fmt);
vsnprintf(tmp, sizeof(tmp), fmt, ap); vsnprintf(tmp, sizeof(tmp), fmt, ap);
va_end(ap); va_end(ap);
write(s->fd, tmp, strlen(tmp)); if ((res = write(s->fd, tmp, strlen(tmp))) < 0) {
fprintf(stderr, "write() failed: %s\n", strerror(errno));
}
fdprintf(s->fd, "\r\n"); fdprintf(s->fd, "\r\n");
return 0; return 0;
} }

@ -59,14 +59,14 @@ int getremainingfilelength( FILE *anyin, long *result)
{ {
long i; long i;
i = ftell (anyin); i = ftell(anyin);
if (i == -1) return FALSE; if (i == -1) return FALSE;
if (fseek (anyin, 0, SEEK_END) == -1) return FALSE; if (fseek(anyin, 0, SEEK_END) == -1) return FALSE;
*result = ftell (anyin); *result = ftell(anyin);
if (*result == -1) return FALSE; if (*result == -1) return FALSE;
(*result) -= i; (*result) -= i;
(*result) /= samplewidth; (*result) /= samplewidth;
if (fseek (anyin, i, SEEK_SET) == -1) return FALSE; if (fseek(anyin, i, SEEK_SET) == -1) return FALSE;
return TRUE; return TRUE;
} }
@ -81,31 +81,39 @@ void readpkheader( FILE *anyin)
for (i = 0; i < 11; i++) for (i = 0; i < 11; i++)
{ {
fread( &tempint, 4, 1, anyin); if (!fread( &tempint, 4, 1, anyin)) {
printf( "%d: %d, ", i, tempint); return;
}
printf( "%d: %d, ", i, tempint);
} }
printf( "\n"); printf( "\n");
fread( blood, 1, 8, anyin); if (!fread( blood, 1, 8, anyin)) {
return;
}
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
printf( "%d ", blood[i]); printf( "%d ", blood[i]);
printf( "\n"); printf( "\n");
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
for (x = 128; x > 0; x /= 2) for (x = 128; x > 0; x /= 2)
printf((blood[i] & x) == 0? "0 ":"1 "); printf((blood[i] & x) == 0? "0 ":"1 ");
printf(i%4==3? "\n":"| "); printf(i%4==3? "\n":"| ");
} }
printf( "\n"); printf( "\n");
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
fread( &tempint, 4, 1, anyin); if (!fread( &tempint, 4, 1, anyin)) {
printf( "%d: %d, ", i, tempint); return;
}
printf( "%d: %d, ", i, tempint);
} }
printf( "\n"); printf( "\n");
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
fread( &tempushort, 2, 1, anyin); if (!fread( &tempushort, 2, 1, anyin)) {
printf( "%d: %d, ", i, tempushort); return;
}
printf( "%d: %d, ", i, tempushort);
} }
printf( "\n"); printf( "\n");
} }
@ -125,59 +133,81 @@ void readwavheader( FILE *anyin)
iswav = FALSE; iswav = FALSE;
if (ftell(anyin) == -1) /* If we cannot seek this file */ if (ftell(anyin) == -1) /* If we cannot seek this file */
{ {
nowav = TRUE; /* -> Pretend this is no wav-file */ nowav = TRUE; /* -> Pretend this is no wav-file */
chat("File not seekable: not checking for WAV-header.\n"); chat("File not seekable: not checking for WAV-header.\n");
} }
else else
{ {
/* Expect four bytes "RIFF" and four bytes filelength */ /* Expect four bytes "RIFF" and four bytes filelength */
fread (str, 1, 8, anyin); /* 0 */ if (!fread(str, 1, 8, anyin)) { /* 0 */
str[4] = '\0'; return;
if (strcmp(str, "RIFF") != 0) nowav = TRUE; }
/* Expect eight bytes "WAVEfmt " */ str[4] = '\0';
fread (str, 1, 8, anyin); /* 8 */ if (strcmp(str, "RIFF") != 0) nowav = TRUE;
str[8] = '\0'; /* Expect eight bytes "WAVEfmt " */
if (strcmp(str, "WAVEfmt ") != 0) nowav = TRUE; if (!fread(str, 1, 8, anyin)) { /* 8 */
/* Expect length of fmt data, which should be 16 */ return;
fread (&tempuint, 4, 1, anyin); /* 16 */ }
if (tempuint != 16) nowav = TRUE; str[8] = '\0';
/* Expect format tag, which should be 1 for pcm */ if (strcmp(str, "WAVEfmt ") != 0) nowav = TRUE;
fread (&tempushort, 2, 1, anyin); /* 20 */ /* Expect length of fmt data, which should be 16 */
if (tempushort != 1) if (!fread(&tempuint, 4, 1, anyin)) { /* 16 */
nowav = TRUE; return;
/* Expect number of channels */ }
fread (&cn, 2, 1, anyin); /* 20 */ if (tempuint != 16) nowav = TRUE;
if (cn != 1 && cn != 2) nowav = TRUE; /* Expect format tag, which should be 1 for pcm */
/* Read samplefrequency */ if (!fread(&tempushort, 2, 1, anyin)) { /* 20 */
fread (&sf, 4, 1, anyin); /* 24 */ return;
/* Read bytes per second: Should be samplefreq * channels * 2 */ }
fread (&tempuint, 4, 1, anyin); /* 28 */ if (tempushort != 1)
if (tempuint != sf * cn * 2) nowav = TRUE; nowav = TRUE;
/* read bytes per frame: Should be channels * 2 */ /* Expect number of channels */
fread (&tempushort, 2, 1, anyin); /* 32 */ if (!fread(&cn, 2, 1, anyin)) { /* 20 */
if (tempushort != cn * 2) nowav = TRUE; return;
/* Read bits per sample: Should be 16 */ }
fread (&tempushort, 2, 1, anyin); /* 34 */ if (cn != 1 && cn != 2) nowav = TRUE;
if (tempushort != 16) nowav = TRUE; /* Read samplefrequency */
fread (str, 4, 1, anyin); /* 36 */ if (!fread(&sf, 4, 1, anyin)) { /* 24 */
str[4] = '\0'; return;
if (strcmp(str, "data") != 0) nowav = TRUE; }
fread (&tempuint, 4, 1, anyin); /* 40 */ /* Read bytes per second: Should be samplefreq * channels * 2 */
if (nowav) if (!fread(&tempuint, 4, 1, anyin)) { /* 28 */
{ return;
fseek (anyin, 0, SEEK_SET); /* Back to beginning of file */ }
chat("File has no WAV header.\n"); if (tempuint != sf * cn * 2) nowav = TRUE;
} /* read bytes per frame: Should be channels * 2 */
else if (!fread(&tempushort, 2, 1, anyin)) { /* 32 */
{ return;
samplefrequency = sf; }
channels = cn; if (tempushort != cn * 2) nowav = TRUE;
chat ("Read WAV header: %d channels, samplefrequency %d.\n", /* Read bits per sample: Should be 16 */
channels, samplefrequency); if (!fread(&tempushort, 2, 1, anyin)) { /* 34 */
iswav = TRUE; return;
} }
} if (tempushort != 16) nowav = TRUE;
if (!fread(str, 4, 1, anyin)) { /* 36 */
return;
}
str[4] = '\0';
if (strcmp(str, "data") != 0) nowav = TRUE;
if (!fread(&tempuint, 4, 1, anyin)) { /* 40 */
return;
}
if (nowav)
{
fseek(anyin, 0, SEEK_SET); /* Back to beginning of file */
chat("File has no WAV header.\n");
}
else
{
samplefrequency = sf;
channels = cn;
chat("Read WAV header: %d channels, samplefrequency %d.\n",
channels, samplefrequency);
iswav = TRUE;
}
}
return; return;
} }
@ -192,36 +222,62 @@ void makewavheader( void)
unsigned short tempushort; unsigned short tempushort;
/* If fseek fails, don't create the header. */ /* If fseek fails, don't create the header. */
if (fseek (out, 0, SEEK_END) != -1) if (fseek(out, 0, SEEK_END) != -1)
{ {
filelength = ftell (out); filelength = ftell(out);
chat ("filelength %d, ", filelength); chat("filelength %d, ", filelength);
fseek (out, 0, SEEK_SET); fseek(out, 0, SEEK_SET);
fwrite ("RIFF", 1, 4, out); /* 0 */ if (!fwrite("RIFF", 1, 4, out)) { /* 0 */
tempuint = filelength - 8; fwrite (&tempuint, 4, 1, out); /* 4 */ return;
fwrite ("WAVEfmt ", 1, 8, out); /* 8 */ }
/* length of fmt data 16 bytes */ tempuint = filelength - 8;
tempuint = 16; if (!fwrite(&tempuint, 4, 1, out)) { /* 4 */
fwrite (&tempuint, 4, 1, out); /* 16 */ return;
/* Format tag: 1 for pcm */ }
tempushort = 1; if (!fwrite("WAVEfmt ", 1, 8, out)) { /* 8 */
fwrite (&tempushort, 2, 1, out); /* 20 */ return;
chat ("%d channels\n", channels); }
fwrite (&channels, 2, 1, out); /* length of fmt data 16 bytes */
chat ("samplefrequency %d\n", samplefrequency); tempuint = 16;
fwrite (&samplefrequency, 4, 1, out); /* 24 */ if (!fwrite(&tempuint, 4, 1, out)) { /* 16 */
/* Bytes per second */ return;
tempuint = channels * samplefrequency * 2; }
fwrite (&tempuint, 4, 1, out); /* 28 */ /* Format tag: 1 for pcm */
/* Block align */ tempushort = 1;
tempushort = 2 * channels; if (!fwrite(&tempushort, 2, 1, out)) { /* 20 */
fwrite (&tempushort, 2, 1, out); /* 32 */ return;
/* Bits per sample */ }
tempushort = 16; chat("%d channels\n", channels);
fwrite (&tempushort, 2, 1, out); /* 34 */ if (!fwrite(&channels, 2, 1, out)) {
fwrite ("data", 4, 1, out); /* 36 */ return;
tempuint = filelength - 44; fwrite (&tempuint, 4, 1, out); /* 40 */ }
} chat("samplefrequency %d\n", samplefrequency);
if (!fwrite(&samplefrequency, 4, 1, out)) { /* 24 */
return;
}
/* Bytes per second */
tempuint = channels * samplefrequency * 2;
if (!fwrite(&tempuint, 4, 1, out)) { /* 28 */
return;
}
/* Block align */
tempushort = 2 * channels;
if (!fwrite(&tempushort, 2, 1, out)) { /* 32 */
return;
}
/* Bits per sample */
tempushort = 16;
if (!fwrite(&tempushort, 2, 1, out)) { /* 34 */
return;
}
if (!fwrite("data", 4, 1, out)) { /* 36 */
return;
}
tempuint = filelength - 44;
if (!fwrite(&tempuint, 4, 1, out)) { /* 40 */
return;
}
}
return; return;
} }
@ -870,10 +926,10 @@ int myexit (int value)
case 0: case 0:
if (wavout) if (wavout)
makewavheader(); /* Writes a fully informed .WAV header */ makewavheader(); /* Writes a fully informed .WAV header */
chat ("Success!\n"); chat("Success!\n");
break; break;
default: default:
chat ("Failure.\n"); chat("Failure.\n");
break; break;
} }
exit (value); exit (value);
@ -903,7 +959,9 @@ int workloop( FILE *theinfile, FILE *theoutfile,
/* Call the routine that does the work */ /* Call the routine that does the work */
if (!work (buffer, nowlength)) /* On error, stop. */ if (!work (buffer, nowlength)) /* On error, stop. */
return FALSE; return FALSE;
fwrite(buffer, sizeof(short), nowlength, theoutfile); if (!fwrite(buffer, sizeof(short), nowlength, theoutfile)) {
return FALSE;
}
if (ferror( theoutfile) != 0) if (ferror( theoutfile) != 0)
fatalperror("Error writing to output file"); fatalperror("Error writing to output file");
} }

@ -114,7 +114,9 @@ static int load_config(void)
return -1; return -1;
} }
while(!feof(f)) { while(!feof(f)) {
fgets(buf, sizeof(buf), f); if (!fgets(buf, sizeof(buf), f)) {
continue;
}
if (!feof(f)) { if (!feof(f)) {
lineno++; lineno++;
val = strchr(buf, '#'); val = strchr(buf, '#');
@ -682,7 +684,10 @@ int main(int argc, char *argv[])
} }
if (needfork) { if (needfork) {
#ifndef HAVE_SBIN_LAUNCHD #ifndef HAVE_SBIN_LAUNCHD
daemon(0,0); if (daemon(0,0) < 0) {
fprintf(stderr, "daemon() failed: %s\n", strerror(errno));
exit(1);
}
#else #else
fprintf(stderr, "Mac OS X detected. Use 'launchd -d muted -f' to launch.\n"); fprintf(stderr, "Mac OS X detected. Use 'launchd -d muted -f' to launch.\n");
exit(1); exit(1);

@ -150,10 +150,10 @@ int main( int argcount, char *args[])
for (; i < maxk; i++) for (; i < maxk; i++)
stereosample[2 * i + 1] = 0; stereosample[2 * i + 1] = 0;
fwrite(stereosample, sizeof(*leftsample), 2 * maxk, out); if (!fwrite(stereosample, sizeof(*leftsample), 2 * maxk, out)) {
if (ferror( out) != 0) fatalerror("Error writing to file '%s': %s\n",
fatalerror("Error writing to file '%s': %s\n", outfilename, strerror(errno));
outfilename, strerror(errno)); }
} }
/* That was an endless loop. This point is never reached. */ /* That was an endless loop. This point is never reached. */
} }

@ -112,8 +112,11 @@ int main(int argc, char *argv[])
select(2, NULL, &wfds, NULL, &tv); select(2, NULL, &wfds, NULL, &tv);
if (FD_ISSET(1, &wfds)) if (FD_ISSET(1, &wfds)) {
write(1, buf, res); if (write(1, buf, res) < 1) {
break;
}
}
} }
close(s); close(s);

Loading…
Cancel
Save