remove some more bad examples of using printf

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@37419 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2006-07-12 13:54:10 +00:00
parent fe1708f190
commit 648bc1828d
7 changed files with 26 additions and 103 deletions

View File

@@ -128,12 +128,6 @@ static pid_t spawn_ras(struct ast_channel *chan, char *args)
argv[argc++] = "zaptel.so"; argv[argc++] = "zaptel.so";
argv[argc++] = "stdin"; argv[argc++] = "stdin";
#if 0
for (x=0;x<argc;x++) {
fprintf(stderr, "Arg %d: %s\n", x, argv[x]);
}
#endif
/* Finally launch PPP */ /* Finally launch PPP */
execv(PPP_EXEC, argv); execv(PPP_EXEC, argv);
fprintf(stderr, "Failed to exec PPPD!\n"); fprintf(stderr, "Failed to exec PPPD!\n");

View File

@@ -734,15 +734,9 @@ static int ast_tryconnect(void)
Called by soft_hangup to interrupt the poll, read, or other Called by soft_hangup to interrupt the poll, read, or other
system call. We don't actually need to do anything though. system call. We don't actually need to do anything though.
Remember: Cannot EVER ast_log from within a signal handler Remember: Cannot EVER ast_log from within a signal handler
SLD: seems to be some pthread activity relating to the printf anyway:
which is leading to a deadlock?
*/ */
static void urg_handler(int num) static void urg_handler(int num)
{ {
#if 0
if (option_debug > 2)
printf("-- Asterisk Urgent handler\n");
#endif
signal(num, urg_handler); signal(num, urg_handler);
return; return;
} }
@@ -1000,46 +994,40 @@ static void consolehandler(char *s)
{ {
printf(term_end()); printf(term_end());
fflush(stdout); fflush(stdout);
/* Called when readline data is available */ /* Called when readline data is available */
if (s && !ast_all_zeros(s)) if (!ast_all_zeros(s))
ast_el_add_history(s); ast_el_add_history(s);
/* Give the console access to the shell */ /* The real handler for bang */
if (s) { if (s[0] == '!') {
/* The real handler for bang */ if (s[1])
if (s[0] == '!') { ast_safe_system(s+1);
if (s[1]) else
ast_safe_system(s+1); ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
else } else
ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
} else
ast_cli_command(STDOUT_FILENO, s); ast_cli_command(STDOUT_FILENO, s);
} else
fprintf(stdout, "\nUse \"quit\" to exit\n");
} }
static int remoteconsolehandler(char *s) static int remoteconsolehandler(char *s)
{ {
int ret = 0; int ret = 0;
/* Called when readline data is available */ /* Called when readline data is available */
if (s && !ast_all_zeros(s)) if (!ast_all_zeros(s))
ast_el_add_history(s); ast_el_add_history(s);
/* Give the console access to the shell */ /* The real handler for bang */
if (s) { if (s[0] == '!') {
/* The real handler for bang */ if (s[1])
if (s[0] == '!') { ast_safe_system(s+1);
if (s[1]) else
ast_safe_system(s+1); ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
else ret = 1;
ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh"); }
ret = 1; if ((strncasecmp(s, "quit", 4) == 0 || strncasecmp(s, "exit", 4) == 0) &&
} (s[4] == '\0' || isspace(s[4]))) {
if ((strncasecmp(s, "quit", 4) == 0 || strncasecmp(s, "exit", 4) == 0) && quit_handler(0, 0, 0, 0);
(s[4] == '\0' || isspace(s[4]))) { ret = 1;
quit_handler(0, 0, 0, 0); }
ret = 1;
}
} else
fprintf(stdout, "\nUse \"quit\" to exit\n");
return ret; return ret;
} }
@@ -2431,7 +2419,7 @@ int main(int argc, char *argv[])
consolehandler((char *)buf); consolehandler((char *)buf);
} else { } else {
if (write(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n", if (write(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n",
strlen("\nUse EXIT or QUIT to exit the asterisk console\n")) < 0) { strlen("\nUse EXIT or QUIT to exit the asterisk console\n")) < 0) {
/* Whoa, stdout disappeared from under us... Make /dev/null's */ /* Whoa, stdout disappeared from under us... Make /dev/null's */
int fd; int fd;
fd = open("/dev/null", O_RDWR); fd = open("/dev/null", O_RDWR);

View File

@@ -2182,10 +2182,7 @@ static void update_jbsched(struct chan_iax2_pvt *pvt) {
when = ast_tvdiff_ms(ast_tvnow(), pvt->rxcore); when = ast_tvdiff_ms(ast_tvnow(), pvt->rxcore);
/* fprintf(stderr, "now = %d, next=%d\n", when, jb_next(pvt->jb)); */
when = jb_next(pvt->jb) - when; when = jb_next(pvt->jb) - when;
/* fprintf(stderr, "when = %d\n", when); */
if(pvt->jbid > -1) ast_sched_del(sched, pvt->jbid); if(pvt->jbid > -1) ast_sched_del(sched, pvt->jbid);
@@ -2209,7 +2206,6 @@ static int get_from_jb(void *p)
struct timeval tv; struct timeval tv;
ast_mutex_lock(&iaxsl[pvt->callno]); ast_mutex_lock(&iaxsl[pvt->callno]);
/* fprintf(stderr, "get_from_jb called\n"); */
pvt->jbid = -1; pvt->jbid = -1;
gettimeofday(&tv,NULL); gettimeofday(&tv,NULL);
@@ -2224,7 +2220,6 @@ static int get_from_jb(void *p)
ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat)); ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat));
switch(ret) { switch(ret) {
case JB_OK: case JB_OK:
/*if(frame.type == JB_TYPE_VOICE && next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
fr = frame.data; fr = frame.data;
__do_deliver(fr); __do_deliver(fr);
break; break;
@@ -2232,10 +2227,7 @@ static int get_from_jb(void *p)
{ {
struct ast_frame af; struct ast_frame af;
/*if(next + 20 != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not %ld+20!\n", jb_next(pvt->jb), next); */
/* create an interpolation frame */ /* create an interpolation frame */
/*fprintf(stderr, "Making Interpolation frame\n"); */
af.frametype = AST_FRAME_VOICE; af.frametype = AST_FRAME_VOICE;
af.subclass = pvt->voiceformat; af.subclass = pvt->voiceformat;
af.datalen = 0; af.datalen = 0;
@@ -2253,7 +2245,6 @@ static int get_from_jb(void *p)
} }
break; break;
case JB_DROP: case JB_DROP:
/*if(next != jb_next(pvt->jb)) fprintf(stderr, "NEXT %ld is not next %ld!\n", jb_next(pvt->jb), next); */
iax2_frame_free(frame.data); iax2_frame_free(frame.data);
break; break;
case JB_NOFRAME: case JB_NOFRAME:
@@ -3637,9 +3628,6 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str
p->lastsent = ms; p->lastsent = ms;
if (voice) if (voice)
p->nextpred = p->nextpred + f->samples / 8; p->nextpred = p->nextpred + f->samples / 8;
#if 0
printf("TS: %s - %dms\n", voice ? "Audio" : "Control", ms);
#endif
return ms; return ms;
} }

View File

@@ -354,9 +354,6 @@ int ast_modem_expect(struct ast_modem_pvt *p, char *result, int timeout)
} }
/* Read a response */ /* Read a response */
fgets(p->response, sizeof(p->response), p->f); fgets(p->response, sizeof(p->response), p->f);
#if 0
fprintf(stderr, "Modem said: %s", p->response);
#endif
if (!strncasecmp(p->response, result, strlen(result))) if (!strncasecmp(p->response, result, strlen(result)))
return 0; return 0;
} while(timeout > 0); } while(timeout > 0);

View File

@@ -3302,9 +3302,6 @@ static int zt_ring_phone(struct zt_pvt *p)
do { do {
x = ZT_RING; x = ZT_RING;
res = ioctl(p->subs[SUB_REAL].zfd, ZT_HOOK, &x); res = ioctl(p->subs[SUB_REAL].zfd, ZT_HOOK, &x);
#if 0
printf("Res: %d, error: %s\n", res, strerror(errno));
#endif
if (res) { if (res) {
switch(errno) { switch(errno) {
case EBUSY: case EBUSY:
@@ -5444,7 +5441,6 @@ static void *ss_thread(void *data)
} }
if (s1) ast_copy_string(exten, s1, sizeof(exten)); if (s1) ast_copy_string(exten, s1, sizeof(exten));
else ast_copy_string(exten, "911", sizeof(exten)); else ast_copy_string(exten, "911", sizeof(exten));
printf("E911: exten: %s, ANI: %s\n",exten, chan->cid.cid_ani);
} else } else
ast_log(LOG_WARNING, "Got a non-E911 input on channel %d. Assuming E&M Wink instead\n", p->channel); ast_log(LOG_WARNING, "Got a non-E911 input on channel %d. Assuming E&M Wink instead\n", p->channel);
} }
@@ -6290,9 +6286,6 @@ static int handle_init_event(struct zt_pvt *i, int event)
} }
} else } else
ast_log(LOG_WARNING, "Unable to create channel\n"); ast_log(LOG_WARNING, "Unable to create channel\n");
#if 0
printf("Created thread %ld detached in switch\n", threadid);
#endif
} }
break; break;
case SIG_FXSLS: case SIG_FXSLS:
@@ -6323,9 +6316,6 @@ static int handle_init_event(struct zt_pvt *i, int event)
} else if (!chan) { } else if (!chan) {
ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel); ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
} }
#if 0
printf("Created thread %ld detached in switch(2)\n", threadid);
#endif
break; break;
default: default:
ast_log(LOG_WARNING, "Don't know how to handle ring/answer with signalling %s on channel %d\n", sig2str(i->sig), i->channel); ast_log(LOG_WARNING, "Don't know how to handle ring/answer with signalling %s on channel %d\n", sig2str(i->sig), i->channel);
@@ -6513,14 +6503,8 @@ static void *do_monitor(void *data)
if (!found && ((i == last) || ((i == iflist) && !last))) { if (!found && ((i == last) || ((i == iflist) && !last))) {
last = i; last = i;
if (last) { if (last) {
#if 0
printf("Checking channel %d\n", last->channel);
#endif
if (!last->cidspill && !last->owner && !ast_strlen_zero(last->mailbox) && (thispass - last->onhooktime > 3) && if (!last->cidspill && !last->owner && !ast_strlen_zero(last->mailbox) && (thispass - last->onhooktime > 3) &&
(last->sig & __ZT_SIG_FXO)) { (last->sig & __ZT_SIG_FXO)) {
#if 0
printf("Channel %d has mailbox %s\n", last->channel, last->mailbox);
#endif
res = ast_app_has_voicemail(last->mailbox, NULL); res = ast_app_has_voicemail(last->mailbox, NULL);
if (last->msgstate != res) { if (last->msgstate != res) {
int x; int x;
@@ -6536,9 +6520,6 @@ static void *do_monitor(void *data)
ioctl(last->subs[SUB_REAL].zfd, ZT_ONHOOKTRANSFER, &x); ioctl(last->subs[SUB_REAL].zfd, ZT_ONHOOKTRANSFER, &x);
last->cidlen = vmwi_generate(last->cidspill, res, 1, AST_LAW(last)); last->cidlen = vmwi_generate(last->cidspill, res, 1, AST_LAW(last));
last->cidpos = 0; last->cidpos = 0;
#if 0
printf("Made %d bytes of message waiting for %d\n", last->cidlen, res);
#endif
last->msgstate = res; last->msgstate = res;
last->onhooktime = thispass; last->onhooktime = thispass;
} }
@@ -6690,9 +6671,6 @@ static int restart_monitor(void)
return -1; return -1;
} }
} }
#if 0
printf("Created thread %ld detached in restart monitor\n", monitor_thread);
#endif
ast_mutex_unlock(&monlock); ast_mutex_unlock(&monlock);
return 0; return 0;
} }
@@ -7844,9 +7822,6 @@ static void *do_idle_thread(void *vchan)
ast_frfree(f); ast_frfree(f);
ms = newms; ms = newms;
} }
#if 0
printf("Hanging up '%s'\n", chan->name);
#endif
/* Hangup the channel since nothing happend */ /* Hangup the channel since nothing happend */
ast_hangup(chan); ast_hangup(chan);
return NULL; return NULL;
@@ -8108,12 +8083,6 @@ static void *pri_dchannel(void *vpri)
} else if (pri->pvts[x] && pri->pvts[x]->owner && pri->pvts[x]->isidlecall) } else if (pri->pvts[x] && pri->pvts[x]->owner && pri->pvts[x]->isidlecall)
activeidles++; activeidles++;
} }
#if 0
printf("nextidle: %d, haveidles: %d, minunsed: %d\n",
nextidle, haveidles, minunused);
printf("nextidle: %d, haveidles: %d, ms: %ld, minunsed: %d\n",
nextidle, haveidles, ast_tvdiff_ms(ast_tvnow(), lastidle), minunused);
#endif
if (nextidle > -1) { if (nextidle > -1) {
if (ast_tvdiff_ms(ast_tvnow(), lastidle) > 1000) { if (ast_tvdiff_ms(ast_tvnow(), lastidle) > 1000) {
/* Don't create a new idle call more than once per second */ /* Don't create a new idle call more than once per second */
@@ -9783,7 +9752,7 @@ static int zap_show_status(int fd, int argc, char *argv[]) {
ctl = open("/dev/zap/ctl", O_RDWR); ctl = open("/dev/zap/ctl", O_RDWR);
if (ctl < 0) { if (ctl < 0) {
fprintf(stderr, "Unable to open /dev/zap/ctl: %s\n", strerror(errno)); ast_log(LOG_WARNING, "Unable to open /dev/zap/ctl: %s\n", strerror(errno));
ast_cli(fd, "No Zaptel interface found.\n"); ast_cli(fd, "No Zaptel interface found.\n");
return RESULT_FAILURE; return RESULT_FAILURE;
} }

View File

@@ -1823,11 +1823,6 @@ static int agi_handle_command(struct ast_channel *chan, AGI *agi, char *buf)
argc = MAX_ARGS; argc = MAX_ARGS;
parse_args(buf, &argc, argv); parse_args(buf, &argc, argv);
#if 0
{ int x;
for (x=0; x<argc; x++)
fprintf(stderr, "Got Arg%d: %s\n", x, argv[x]); }
#endif
c = find_command(argv, 0); c = find_command(argv, 0);
if (c) { if (c) {
res = c->handler(chan, agi, argc, argv); res = c->handler(chan, agi, argc, argv);

View File

@@ -399,14 +399,6 @@ static void base64_init(void)
base64[63] = '/'; base64[63] = '/';
b2a[(int)'+'] = 62; b2a[(int)'+'] = 62;
b2a[(int)'/'] = 63; b2a[(int)'/'] = 63;
#if 0
for (x=0;x<64;x++) {
if (b2a[(int)base64[x]] != x) {
fprintf(stderr, "!!! %d failed\n", x);
} else
fprintf(stderr, "--- %d passed\n", x);
}
#endif
} }
/*! \brief ast_uri_encode: Turn text string to URI-encoded %XX version ---*/ /*! \brief ast_uri_encode: Turn text string to URI-encoded %XX version ---*/