From f268ea2b3c1ec5e3718dddea2aeaed0329eeaa24 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" <kpfleming@digium.com> Date: Thu, 7 Jul 2005 22:32:20 +0000 Subject: [PATCH] make CLI output use singular/plural when appropriate (bug #4654) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6047 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_groupcount.c | 2 +- apps/app_read.c | 2 +- apps/app_realtime.c | 2 +- cdr.c | 8 ++++---- channels/chan_iax2.c | 6 +++--- cli.c | 6 +++--- loader.c | 2 +- pbx/pbx_spool.c | 4 ++-- res/res_features.c | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/app_groupcount.c b/apps/app_groupcount.c index d9a841f5d8..ab31a3942a 100755 --- a/apps/app_groupcount.c +++ b/apps/app_groupcount.c @@ -202,7 +202,7 @@ static int group_show_channels(int fd, int argc, char *argv[]) if (havepattern) regfree(®exbuf); - ast_cli(fd, "%d active channel(s)\n", numchans); + ast_cli(fd, "%d active channel%s\n", numchans, (numchans != 1) ? "s" : ""); return RESULT_SUCCESS; } diff --git a/apps/app_read.c b/apps/app_read.c index 0f0ab3752e..0884c0d8b8 100755 --- a/apps/app_read.c +++ b/apps/app_read.c @@ -159,7 +159,7 @@ static int read_exec(struct ast_channel *chan, void *data) tries--; if (option_verbose > 2) { if (tries) - ast_verbose(VERBOSE_PREFIX_3 "User entered nothing, %d chance(s) left\n", tries); + ast_verbose(VERBOSE_PREFIX_3 "User entered nothing, %d chance%s left\n", tries, (tries != 1) ? "s" : ""); else ast_verbose(VERBOSE_PREFIX_3 "User entered nothing.\n"); } diff --git a/apps/app_realtime.c b/apps/app_realtime.c index d4ded9c208..339801954b 100755 --- a/apps/app_realtime.c +++ b/apps/app_realtime.c @@ -92,7 +92,7 @@ static int cli_update_realtime(int fd, int argc, char **argv) { return RESULT_SUCCESS; } - ast_cli(fd, "Updated %d RealTime record(s).\n", res); + ast_cli(fd, "Updated %d RealTime record%s.\n", res, (res != 1) ? "s" : ""); return RESULT_SUCCESS; } diff --git a/cdr.c b/cdr.c index 99612226b6..0b04c8a335 100755 --- a/cdr.c +++ b/cdr.c @@ -1052,10 +1052,10 @@ static int handle_cli_status(int fd, int argc, char *argv[]) nextbatchtime = ast_sched_when(sched, cdr_sched); ast_cli(fd, "CDR safe shut down: %s\n", batchsafeshutdown ? "enabled" : "disabled"); ast_cli(fd, "CDR batch threading model: %s\n", batchscheduleronly ? "scheduler only" : "scheduler plus separate threads"); - ast_cli(fd, "CDR current batch size: %d record(s)\n", cnt); - ast_cli(fd, "CDR maximum batch size: %d record(s)\n", batchsize); - ast_cli(fd, "CDR maximum batch time: %d second(s)\n", batchtime); - ast_cli(fd, "CDR next scheduled batch processing time: %ld second(s)\n", nextbatchtime); + ast_cli(fd, "CDR current batch size: %d record%s\n", cnt, (cnt != 1) ? "s" : ""); + ast_cli(fd, "CDR maximum batch size: %d record%s\n", batchsize, (batchsize != 1) ? "s" : ""); + ast_cli(fd, "CDR maximum batch time: %d second%s\n", batchtime, (batchtime != 1) ? "s" : ""); + ast_cli(fd, "CDR next scheduled batch processing time: %ld second%s\n", nextbatchtime, (nextbatchtime != 1) ? "s" : ""); } AST_LIST_LOCK(&be_list); AST_LIST_TRAVERSE(&be_list, beitem, list) { diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 003f1368d2..e1ceedaa9f 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -4348,7 +4348,7 @@ static int iax2_show_channels(int fd, int argc, char *argv[]) } ast_mutex_unlock(&iaxsl[x]); } - ast_cli(fd, "%d active IAX channel(s)\n", numchans); + ast_cli(fd, "%d active IAX channel%s\n", numchans, (numchans != 1) ? "s" : ""); return RESULT_SUCCESS; #undef FORMAT #undef FORMAT2 @@ -4443,7 +4443,7 @@ static int iax2_show_netstats(int fd, int argc, char *argv[]) ast_cli(fd, " -------- LOCAL --------------------- -------- REMOTE --------------------\n"); ast_cli(fd, "Channel RTT Jit Del Lost %% Drop OOO Kpkts Jit Del Lost %% Drop OOO Kpkts\n"); numchans = ast_cli_netstats(fd, 1); - ast_cli(fd, "%d active IAX channel(s)\n", numchans); + ast_cli(fd, "%d active IAX channel%s\n", numchans, (numchans != 1) ? "s" : ""); return RESULT_SUCCESS; } @@ -5887,7 +5887,7 @@ static int timing_read(int *id, int fd, short events, void *cbdata) } else { res = send_trunk(tpeer, &now); if (iaxtrunkdebug) - ast_verbose(" - Trunk peer (%s:%d) has %d call chunk(s) in transit, %d bytes backloged and has hit a high water mark of %d bytes\n", ast_inet_ntoa(iabuf, sizeof(iabuf), tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), res, tpeer->trunkdatalen, tpeer->trunkdataalloc); + ast_verbose(" - Trunk peer (%s:%d) has %d call chunk%s in transit, %d bytes backloged and has hit a high water mark of %d bytes\n", ast_inet_ntoa(iabuf, sizeof(iabuf), tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), res, (res != 1) ? "s" : "", tpeer->trunkdatalen, tpeer->trunkdataalloc); } totalcalls += res; res = 0; diff --git a/cli.c b/cli.c index a5a970dc2e..f027dd6db5 100755 --- a/cli.c +++ b/cli.c @@ -430,11 +430,11 @@ static int handle_chanlist(int fd, int argc, char *argv[]) ast_mutex_unlock(&c->lock); } if(!concise) { - ast_cli(fd, "%d active channel(s)\n", numchans); + ast_cli(fd, "%d active channel%s\n", numchans, (numchans!=1) ? "s" : ""); if (option_maxcalls) - ast_cli(fd, "%d of %d max active call(s) (%5.2f%% of capacity)\n", ast_active_calls(), option_maxcalls, ((float)ast_active_calls() / (float)option_maxcalls) * 100.0); + ast_cli(fd, "%d of %d max active call%s (%5.2f%% of capacity)\n", ast_active_calls(), option_maxcalls, (ast_active_calls()!=1) ? "s" : "", ((float)ast_active_calls() / (float)option_maxcalls) * 100.0); else - ast_cli(fd, "%d active call(s)\n", ast_active_calls()); + ast_cli(fd, "%d active call%s\n", ast_active_calls(), (ast_active_calls()!=1) ? "s" : ""); } return RESULT_SUCCESS; } diff --git a/loader.c b/loader.c index ec85851909..ab1c0d40f6 100755 --- a/loader.c +++ b/loader.c @@ -365,7 +365,7 @@ static int __load_resource(const char *resource_name, const struct ast_config *c errors++; } if (errors) { - ast_log(LOG_WARNING, "%d error(s) loading module %s, aborted\n", errors, fn); + ast_log(LOG_WARNING, "%d error%s loading module %s, aborted\n", errors, (errors != 1) ? "s" : "", fn); dlclose(m->lib); free(m); ast_mutex_unlock(&modlock); diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c index 1087cb4b04..b4cc381424 100755 --- a/pbx/pbx_spool.c +++ b/pbx/pbx_spool.c @@ -235,7 +235,7 @@ static void *attempt_thread(void *data) ast_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason); if (o->retries >= o->maxretries + 1) { /* Max retries exceeded */ - ast_log(LOG_EVENT, "Queued call to %s/%s expired without completion after %d attempt(s)\n", o->tech, o->dest, o->retries - 1); + ast_log(LOG_EVENT, "Queued call to %s/%s expired without completion after %d attempt%s\n", o->tech, o->dest, o->retries - 1, ((o->retries - 1) != 1) ? "s" : ""); unlink(o->fn); } else { /* Notate that the call is still active */ @@ -294,7 +294,7 @@ static int scan_service(char *fn, time_t now, time_t atime) now += o->retrytime; return now; } else { - ast_log(LOG_EVENT, "Queued call to %s/%s expired without completion after %d attempt(s)\n", o->tech, o->dest, o->retries - 1); + ast_log(LOG_EVENT, "Queued call to %s/%s expired without completion after %d attempt%s\n", o->tech, o->dest, o->retries - 1, ((o->retries - 1) != 1) ? "s" : ""); free(o); unlink(fn); return 0; diff --git a/res/res_features.c b/res/res_features.c index 65fa79b7db..cfda60587f 100755 --- a/res/res_features.c +++ b/res/res_features.c @@ -1680,7 +1680,7 @@ static int handle_parkedcalls(int fd, int argc, char *argv[]) cur = cur->next; numparked++; } - ast_cli(fd, "%d parked call(s).\n",numparked); + ast_cli(fd, "%d parked call%s.\n", numparked, (numparked != 1) ? "s" : ""); ast_mutex_unlock(&parking_lock); -- GitLab