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
This commit is contained in:
Kevin P. Fleming
2005-07-07 22:32:20 +00:00
parent f1a18b8066
commit f268ea2b3c
9 changed files with 17 additions and 17 deletions

View File

@@ -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;
}

View File

@@ -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");
}

View File

@@ -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;
}

8
cdr.c
View File

@@ -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) {

View File

@@ -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;

6
cli.c
View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);