make CLI output use singular/plural when appropriate (bug #4654)
authorKevin P. Fleming <kpfleming@digium.com>
Thu, 7 Jul 2005 22:32:20 +0000 (22:32 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Thu, 7 Jul 2005 22:32:20 +0000 (22:32 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6047 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_groupcount.c
apps/app_read.c
apps/app_realtime.c
cdr.c
channels/chan_iax2.c
cli.c
loader.c
pbx/pbx_spool.c
res/res_features.c

index d9a841f..ab31a39 100755 (executable)
@@ -202,7 +202,7 @@ static int group_show_channels(int fd, int argc, char *argv[])
        if (havepattern)
                regfree(&regexbuf);
 
-       ast_cli(fd, "%d active channel(s)\n", numchans);
+       ast_cli(fd, "%d active channel%s\n", numchans, (numchans != 1) ? "s" : "");
        return RESULT_SUCCESS;
 }
 
index 0f0ab37..0884c0d 100755 (executable)
@@ -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");
                                        }
index d4ded9c..3398019 100755 (executable)
@@ -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 9961222..0b04c8a 100755 (executable)
--- 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) {
index 003f136..e1ceeda 100755 (executable)
@@ -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 a5a970d..f027dd6 100755 (executable)
--- 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;
 }
index ec85851..ab1c0d4 100755 (executable)
--- 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);
index 1087cb4..b4cc381 100755 (executable)
@@ -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;
index 65fa79b..cfda605 100755 (executable)
@@ -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);