ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/autoconfig.h
ifeq ($(AST_DEVMODE),yes)
- ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT)
+ ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2
endif
ifneq ($(findstring BSD,$(OSARCH)),)
if (!(cachedir = ast_variable_retrieve(cfg, "general", "cachedir"))) {
cachedir = "/tmp/";
}
+
+ data = ast_strdupa(vdata);
+ AST_STANDARD_APP_ARGS(args, data);
+
if (!(festivalcommand = ast_variable_retrieve(cfg, "general", "festivalcommand"))) {
- festivalcommand = "(tts_textasterisk \"%s\" 'file)(quit)\n";
+ const char *startcmd = "(tts_textasterisk \"";
+ const char *endcmd = "\" 'file)(quit)\n";
+
+ strln = strlen(startcmd) + strlen(args.text) + strlen(endcmd) + 1;
+ newfestivalcommand = alloca(strln);
+ snprintf(newfestivalcommand, strln, "%s%s%s", startcmd, args.text, endcmd);
+ festivalcommand = newfestivalcommand;
} else { /* This else parses the festivalcommand that we're sent from the config file for \n's, etc */
int i, j;
- newfestivalcommand = alloca(strlen(festivalcommand) + 1);
+ newfestivalcommand = alloca(strlen(festivalcommand) + strlen(args.text) + 1);
for (i = 0, j = 0; i < strlen(festivalcommand); i++) {
if (festivalcommand[i] == '\\' && festivalcommand[i + 1] == 'n') {
} else if (festivalcommand[i] == '\\') {
newfestivalcommand[j++] = festivalcommand[i + 1];
i++;
+ } else if (festivalcommand[i] == '%' && festivalcommand[i + 1] == 's') {
+ sprintf(&newfestivalcommand[j], "%s", args.text); /* we know it is big enough */
+ j += strlen(args.text);
+ i++;
} else
newfestivalcommand[j++] = festivalcommand[i];
}
festivalcommand = newfestivalcommand;
}
- data = ast_strdupa(vdata);
- AST_STANDARD_APP_ARGS(args, data);
-
if (args.interrupt && !strcasecmp(args.interrupt, "any"))
args.interrupt = AST_DIGIT_ANY;
} else {
ast_debug(1, "Passing text to festival...\n");
fs = fdopen(dup(fd), "wb");
- fprintf(fs, festivalcommand, args.text);
+
+ fprintf(fs, "%s", festivalcommand);
fflush(fs);
fclose(fs);
}
int hr, min, sec;
int i = 0, total = 0;
time_t now;
- char *header_format = "%-14s %-14s %-10s %-8s %-8s %-6s\n";
- char *data_format = "%-12.12s %4.4d %4.4s %02d:%02d:%02d %-8s %-6s\n";
char cmdline[1024] = "";
+#define MC_HEADER_FORMAT "%-14s %-14s %-10s %-8s %-8s %-6s\n"
+#define MC_DATA_FORMAT "%-12.12s %4.4d %4.4s %02d:%02d:%02d %-8s %-6s\n"
switch (cmd) {
case CLI_INIT:
return CLI_SUCCESS;
}
if (!concise)
- ast_cli(a->fd, header_format, "Conf Num", "Parties", "Marked", "Activity", "Creation", "Locked");
+ ast_cli(a->fd, MC_HEADER_FORMAT, "Conf Num", "Parties", "Marked", "Activity", "Creation", "Locked");
AST_LIST_TRAVERSE(&confs, cnf, list) {
if (cnf->markedusers == 0)
strcpy(cmdline, "N/A ");
min = ((now - cnf->start) % 3600) / 60;
sec = (now - cnf->start) % 60;
if (!concise)
- ast_cli(a->fd, data_format, cnf->confno, cnf->users, cmdline, hr, min, sec, cnf->isdynamic ? "Dynamic" : "Static", cnf->locked ? "Yes" : "No");
+ ast_cli(a->fd, MC_DATA_FORMAT, cnf->confno, cnf->users, cmdline, hr, min, sec, cnf->isdynamic ? "Dynamic" : "Static", cnf->locked ? "Yes" : "No");
else {
ast_cli(a->fd, "%s!%d!%d!%02d:%02d:%02d!%d!%d\n",
cnf->confno,
duration < global_vmminmessage ? "IGNORED" : "OK",
vmu->accountcode
);
- fprintf(txt, logbuf);
+ fprintf(txt, "%s", logbuf);
if (minivmlogfile) {
ast_mutex_lock(&minivmloglock);
- fprintf(minivmlogfile, logbuf);
+ fprintf(minivmlogfile, "%s", logbuf);
ast_mutex_unlock(&minivmloglock);
}
static char *handle_minivm_list_templates(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct minivm_template *this;
- char *output_format = "%-15s %-10s %-10s %-15.15s %-50s\n";
+#define HVLT_OUTPUT_FORMAT "%-15s %-10s %-10s %-15.15s %-50s\n"
int count = 0;
switch (cmd) {
AST_LIST_UNLOCK(&message_templates);
return CLI_FAILURE;
}
- ast_cli(a->fd, output_format, "Template name", "Charset", "Locale", "Attach media", "Subject");
- ast_cli(a->fd, output_format, "-------------", "-------", "------", "------------", "-------");
+ ast_cli(a->fd, HVLT_OUTPUT_FORMAT, "Template name", "Charset", "Locale", "Attach media", "Subject");
+ ast_cli(a->fd, HVLT_OUTPUT_FORMAT, "-------------", "-------", "------", "------------", "-------");
AST_LIST_TRAVERSE(&message_templates, this, list) {
- ast_cli(a->fd, output_format, this->name,
+ ast_cli(a->fd, HVLT_OUTPUT_FORMAT, this->name,
this->charset ? this->charset : "-",
this->locale ? this->locale : "-",
this->attachment ? "Yes" : "No",
static char *handle_minivm_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct minivm_account *vmu;
- char *output_format = "%-23s %-15s %-15s %-10s %-10s %-50s\n";
+#define HMSU_OUTPUT_FORMAT "%-23s %-15s %-15s %-10s %-10s %-50s\n"
int count = 0;
switch (cmd) {
AST_LIST_UNLOCK(&minivm_accounts);
return CLI_FAILURE;
}
- ast_cli(a->fd, output_format, "User", "E-Template", "P-template", "Zone", "Format", "Full name");
- ast_cli(a->fd, output_format, "----", "----------", "----------", "----", "------", "---------");
+ ast_cli(a->fd, HMSU_OUTPUT_FORMAT, "User", "E-Template", "P-template", "Zone", "Format", "Full name");
+ ast_cli(a->fd, HMSU_OUTPUT_FORMAT, "----", "----------", "----------", "----", "------", "---------");
AST_LIST_TRAVERSE(&minivm_accounts, vmu, list) {
char tmp[256] = "";
if ((a->argc == 3) || ((a->argc == 5) && !strcmp(a->argv[4], vmu->domain))) {
count++;
snprintf(tmp, sizeof(tmp), "%s@%s", vmu->username, vmu->domain);
- ast_cli(a->fd, output_format, tmp, vmu->etemplate ? vmu->etemplate : "-",
+ ast_cli(a->fd, HMSU_OUTPUT_FORMAT, tmp, vmu->etemplate ? vmu->etemplate : "-",
vmu->ptemplate ? vmu->ptemplate : "-",
vmu->zonetag ? vmu->zonetag : "-",
vmu->attachfmt ? vmu->attachfmt : "-",
static char *handle_minivm_show_zones(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct minivm_zone *zone;
- char *output_format = "%-15s %-20s %-45s\n";
+#define HMSZ_OUTPUT_FORMAT "%-15s %-20s %-45s\n"
char *res = CLI_SUCCESS;
switch (cmd) {
AST_LIST_LOCK(&minivm_zones);
if (!AST_LIST_EMPTY(&minivm_zones)) {
- ast_cli(a->fd, output_format, "Zone", "Timezone", "Message Format");
- ast_cli(a->fd, output_format, "----", "--------", "--------------");
+ ast_cli(a->fd, HMSZ_OUTPUT_FORMAT, "Zone", "Timezone", "Message Format");
+ ast_cli(a->fd, HMSZ_OUTPUT_FORMAT, "----", "--------", "--------------");
AST_LIST_TRAVERSE(&minivm_zones, zone, list) {
- ast_cli(a->fd, output_format, zone->name, zone->timezone, zone->msg_format);
+ ast_cli(a->fd, HMSZ_OUTPUT_FORMAT, zone->name, zone->timezone, zone->msg_format);
}
} else {
ast_cli(a->fd, "There are no voicemail zones currently defined\n");
while ((s = strsep(&buf, ",|"))) {
if (!q->sound_periodicannounce[i])
q->sound_periodicannounce[i] = ast_str_create(16);
- ast_str_set(&q->sound_periodicannounce[i], 0, s);
+ ast_str_set(&q->sound_periodicannounce[i], 0, "%s", s);
i++;
if (i == MAX_PERIODIC_ANNOUNCEMENTS)
break;
}
} else {
- ast_str_set(&q->sound_periodicannounce[0], 0, val);
+ ast_str_set(&q->sound_periodicannounce[0], 0, "%s", val);
}
} else if (!strcasecmp(param, "periodic-announce-frequency")) {
q->periodicannouncefrequency = atoi(val);
static char *pagersubject = NULL;
static char fromstring[100];
static char pagerfromstring[100];
-static char emailtitle[100];
static char charset[32] = "ISO-8859-1";
static unsigned char adsifdn[4] = "\x00\x00\x00\x0F";
ast_channel_free(ast);
} else
ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
- } else if (!ast_strlen_zero(emailtitle)) {
- fprintf(p, emailtitle, msgnum + 1, mailbox) ;
- fprintf(p, ENDL) ;
} else if (ast_test_flag((&globalflags), VM_PBXSKIP))
fprintf(p, "Subject: New message %d in mailbox %s" ENDL, msgnum + 1, mailbox);
else
static char *handle_voicemail_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ast_vm_user *vmu;
- char *output_format = "%-10s %-5s %-25s %-10s %6s\n";
+#define HVSU_OUTPUT_FORMAT "%-10s %-5s %-25s %-10s %6s\n"
const char *context = NULL;
int users_counter = 0;
return CLI_FAILURE;
}
if (a->argc == 3)
- ast_cli(a->fd, output_format, "Context", "Mbox", "User", "Zone", "NewMsg");
+ ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg");
else {
int count = 0;
AST_LIST_TRAVERSE(&users, vmu, list) {
count++;
}
if (count) {
- ast_cli(a->fd, output_format, "Context", "Mbox", "User", "Zone", "NewMsg");
+ ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg");
} else {
ast_cli(a->fd, "No such voicemail context \"%s\"\n", context);
AST_LIST_UNLOCK(&users);
snprintf(tmp, sizeof(tmp), "%s@%s", vmu->mailbox, ast_strlen_zero(vmu->context) ? "default" : vmu->context);
inboxcount(tmp, &newmsgs, &oldmsgs);
snprintf(count, sizeof(count), "%d", newmsgs);
- ast_cli(a->fd, output_format, vmu->context, vmu->mailbox, vmu->fullname, vmu->zonetag, count);
+ ast_cli(a->fd, HVSU_OUTPUT_FORMAT, vmu->context, vmu->mailbox, vmu->fullname, vmu->zonetag, count);
users_counter++;
}
}
static char *handle_voicemail_show_zones(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct vm_zone *zone;
- char *output_format = "%-15s %-20s %-45s\n";
+#define HVSZ_OUTPUT_FORMAT "%-15s %-20s %-45s\n"
char *res = CLI_SUCCESS;
switch (cmd) {
AST_LIST_LOCK(&zones);
if (!AST_LIST_EMPTY(&zones)) {
- ast_cli(a->fd, output_format, "Zone", "Timezone", "Message Format");
+ ast_cli(a->fd, HVSZ_OUTPUT_FORMAT, "Zone", "Timezone", "Message Format");
AST_LIST_TRAVERSE(&zones, zone, list) {
- ast_cli(a->fd, output_format, zone->name, zone->timezone, zone->msg_format);
+ ast_cli(a->fd, HVSZ_OUTPUT_FORMAT, zone->name, zone->timezone, zone->msg_format);
}
} else {
ast_cli(a->fd, "There are no voicemail zones currently defined\n");
}
memset(fromstring, 0, sizeof(fromstring));
memset(pagerfromstring, 0, sizeof(pagerfromstring));
- memset(emailtitle, 0, sizeof(emailtitle));
strcpy(charset, "ISO-8859-1");
if (emailbody) {
ast_free(emailbody);
memcpy(&adsisec[x], &tmpadsi[x], 1);
}
}
- if ((val = ast_variable_retrieve(cfg, "general", "adsiver")))
+ if ((val = ast_variable_retrieve(cfg, "general", "adsiver"))) {
if (atoi(val)) {
adsiver = atoi(val);
}
- if ((val = ast_variable_retrieve(cfg, "general", "emailtitle"))) {
- ast_log(LOG_NOTICE, "Keyword 'emailtitle' is DEPRECATED, please use 'emailsubject' instead.\n");
- ast_copy_string(emailtitle, val, sizeof(emailtitle));
}
if ((val = ast_variable_retrieve(cfg, "general", "emailsubject")))
emailsubject = ast_strdup(val);
return -1;
}
if (!column_string->used)
- ast_str_set(&column_string, 0, escaped);
+ ast_str_set(&column_string, 0, "%s", escaped);
else
ast_str_append(&column_string, 0, ",%s", escaped);
sqlite3_free(escaped);
ast_log(LOG_WARNING, "%s", data);
}
-static void jb_error_output(const char *fmt, ...)
+static void __attribute__((format (printf, 1, 2))) jb_error_output(const char *fmt, ...)
{
va_list args;
char buf[1024];
vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
- ast_log(LOG_ERROR, buf);
+ ast_log(LOG_ERROR, "%s", buf);
}
-static void jb_warning_output(const char *fmt, ...)
+static void __attribute__((format (printf, 1, 2))) jb_warning_output(const char *fmt, ...)
{
va_list args;
char buf[1024];
vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
- ast_log(LOG_WARNING, buf);
+ ast_log(LOG_WARNING, "%s", buf);
}
-static void jb_debug_output(const char *fmt, ...)
+static void __attribute__((format (printf, 1, 2))) jb_debug_output(const char *fmt, ...)
{
va_list args;
char buf[1024];
vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
- ast_verbose(buf);
+ ast_verbose("%s", buf);
}
/*!
{
int x;
int numchans = 0;
+#define ACN_FORMAT1 "%-25.25s %4d %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d\n"
+#define ACN_FORMAT2 "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n"
for (x=0;x<IAX_MAX_CALLS;x++) {
ast_mutex_lock(&iaxsl[x]);
if (iaxs[x]) {
int localjitter, localdelay, locallost, locallosspct, localdropped, localooo;
- char *fmt;
jb_info jbinfo;
if(ast_test_flag(iaxs[x], IAX_USEJITTERBUF)) {
localdropped = 0;
localooo = -1;
}
- if (limit_fmt)
- fmt = "%-25.25s %4d %4d %4d %5d %3d %5d %4d %6d %4d %4d %5d %3d %5d %4d %6d\n";
- else
- fmt = "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n";
if (s)
- astman_append(s, fmt,
+ astman_append(s, limit_fmt ? ACN_FORMAT1 : ACN_FORMAT2,
iaxs[x]->owner ? iaxs[x]->owner->name : "(None)",
iaxs[x]->pingtime,
localjitter,
iaxs[x]->remote_rr.ooo,
iaxs[x]->remote_rr.packets/1000);
else
- ast_cli(fd, fmt,
+ ast_cli(fd, limit_fmt ? ACN_FORMAT1 : ACN_FORMAT2,
iaxs[x]->owner ? iaxs[x]->owner->name : "(None)",
iaxs[x]->pingtime,
localjitter,
va_end(ap);
if (level == -1)
- ast_log(LOG_WARNING, buf);
+ ast_log(LOG_WARNING, "%s", buf);
else if (misdn_debug_only[port] ?
(level == 1 && misdn_debug[port]) || (level == misdn_debug[port])
}
/*! \brief Append to SIP dialog history with arg list */
-static void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
+static __attribute__((format (printf, 2, 0))) void append_history_va(struct sip_pvt *p, const char *fmt, va_list ap)
{
char buf[80], *c = buf; /* max history length */
struct sip_history *hist;
buf[0] = '\0';
if (ast_strlen_zero(data)) {
- ast_log(LOG_WARNING, synopsis);
+ ast_log(LOG_WARNING, "%s", synopsis);
return -1;
}
AST_STANDARD_APP_ARGS(args, data);
if (args.argc < 1) {
- ast_log(LOG_WARNING, synopsis);
+ ast_log(LOG_WARNING, "%s", synopsis);
return -1;
}
* descriptor.
*/
#define ASTOBJ_CONTAINER_DUMP(fd,s,slen,container) \
- ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, s); } while(0))
+ ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, "%s", s); } while(0))
#if defined(__cplusplus) || defined(c_plusplus)
}
\param fmt printf-style format string
\param ap varargs list of arguments for format
*/
-int ast_build_string_va(char **buffer, size_t *space, const char *fmt, va_list ap);
+int ast_build_string_va(char **buffer, size_t *space, const char *fmt, va_list ap) __attribute__((format (printf, 3, 0)));
/*!
* \brief Make sure something is true.
_ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)
AST_INLINE_API(
+__attribute__((format (printf, 5, 6)))
int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...),
{
int res;
_ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))
AST_INLINE_API(
+__attribute__((format (printf, 5, 0)))
int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap),
{
int res;
/*! \brief set jitterbuf conf */
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf);
-typedef void (*jb_output_function_t)(const char *fmt, ...);
+typedef void __attribute__((format (printf, 1, 2))) (*jb_output_function_t)(const char *fmt, ...);
void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg);
#ifdef __cplusplus
close(ast_consock);
if (!ast_opt_remote)
unlink(ast_config_AST_PID);
- printf(term_quit());
+ printf("%s", term_quit());
if (restart) {
if (option_verbose || ast_opt_console)
ast_verbose("Preparing for Asterisk restart...\n");
static void consolehandler(char *s)
{
- printf(term_end());
+ printf("%s", term_end());
fflush(stdout);
/* Called when readline data is available */
for (tries = 0; tries < 30 * reconnects_per_second; tries++) {
if (ast_tryconnect()) {
fprintf(stderr, "Reconnect succeeded after %.3f seconds\n", 1.0 / reconnects_per_second * tries);
- printf(term_quit());
+ printf("%s", term_quit());
WELCOME_MESSAGE;
if (!ast_opt_mute)
fdprint(ast_consock, "logger mute silent");
#endif
ast_term_init();
- printf(term_end());
+ printf("%s", term_end());
fflush(stdout);
if (ast_opt_console && !option_verbose)
quit_handler(0, 0, 0, 0);
exit(0);
}
- printf(term_quit());
+ printf("%s", term_quit());
ast_remotecontrol(NULL);
quit_handler(0, 0, 0, 0);
exit(0);
} else {
ast_log(LOG_ERROR, "Asterisk already running on %s. Use 'asterisk -r' to connect.\n", ast_config_AST_SOCKET);
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
} else if (ast_opt_remote || ast_opt_exec) {
ast_log(LOG_ERROR, "Unable to connect to remote asterisk (does %s exist?)\n", ast_config_AST_SOCKET);
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
/* Blindly write pid file since we couldn't connect */
initstate((unsigned int) getpid() * 65536 + (unsigned int) time(NULL), randompool, sizeof(randompool));
if (init_logger()) { /* Start logging subsystem */
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
ast_autoservice_init();
if (load_modules(1)) { /* Load modules, pre-load only */
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
if (dnsmgr_init()) { /* Initialize the DNS manager */
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
ast_channels_init();
if (init_manager()) {
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
if (ast_cdr_engine_init()) {
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
if (ast_device_state_engine_init()) {
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
ast_udptl_init();
if (ast_image_init()) {
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
if (ast_file_init()) {
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
if (load_pbx()) {
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
ast_features_init();
if (init_framer()) {
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
if (astdb_init()) {
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
if (ast_enum_init()) {
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
if (load_modules(0)) {
- printf(term_quit());
+ printf("%s", term_quit());
exit(1);
}
if (ast_opt_console && !option_verbose)
ast_verbose(" ]\n");
if (option_verbose || ast_opt_console)
- ast_verbose(term_color(tmp, "Asterisk Ready.\n", COLOR_BRWHITE, COLOR_BLACK, sizeof(tmp)));
+ ast_verbose("%s", term_color(tmp, "Asterisk Ready.\n", COLOR_BRWHITE, COLOR_BLACK, sizeof(tmp)));
if (ast_opt_no_fork)
consolethread = pthread_self();
return CLI_SHOWUSAGE;
buf = __ast_cli_generator(a->argv[2], a->argv[3], atoi(a->argv[4]), 0);
if (buf) {
- ast_cli(a->fd, buf);
+ ast_cli(a->fd, "%s", buf);
ast_free(buf);
} else
ast_cli(a->fd, "NULL\n");
{
int i;
struct ast_call_feature *feature;
- char format[] = "%-25s %-7s %-7s\n";
+#define HFS_FORMAT "%-25s %-7s %-7s\n"
switch (cmd) {
return NULL;
}
- ast_cli(a->fd, format, "Builtin Feature", "Default", "Current");
- ast_cli(a->fd, format, "---------------", "-------", "-------");
+ ast_cli(a->fd, HFS_FORMAT, "Builtin Feature", "Default", "Current");
+ ast_cli(a->fd, HFS_FORMAT, "---------------", "-------", "-------");
- ast_cli(a->fd, format, "Pickup", "*8", ast_pickup_ext()); /* default hardcoded above, so we'll hardcode it here */
+ ast_cli(a->fd, HFS_FORMAT, "Pickup", "*8", ast_pickup_ext()); /* default hardcoded above, so we'll hardcode it here */
ast_rwlock_rdlock(&features_lock);
for (i = 0; i < FEATURES_COUNT; i++)
- ast_cli(a->fd, format, builtin_features[i].fname, builtin_features[i].default_exten, builtin_features[i].exten);
+ ast_cli(a->fd, HFS_FORMAT, builtin_features[i].fname, builtin_features[i].default_exten, builtin_features[i].exten);
ast_rwlock_unlock(&features_lock);
ast_cli(a->fd, "\n");
- ast_cli(a->fd, format, "Dynamic Feature", "Default", "Current");
- ast_cli(a->fd, format, "---------------", "-------", "-------");
+ ast_cli(a->fd, HFS_FORMAT, "Dynamic Feature", "Default", "Current");
+ ast_cli(a->fd, HFS_FORMAT, "---------------", "-------", "-------");
if (AST_LIST_EMPTY(&feature_list))
ast_cli(a->fd, "(none)\n");
else {
AST_LIST_LOCK(&feature_list);
AST_LIST_TRAVERSE(&feature_list, feature, feature_entry)
- ast_cli(a->fd, format, feature->sname, "no def", feature->exten);
+ ast_cli(a->fd, HFS_FORMAT, feature->sname, "no def", feature->exten);
AST_LIST_UNLOCK(&feature_list);
}
ast_cli(a->fd, "\nCall parking\n");
/* if a hard clamp was requested, use it */
if ((jb->info.conf.max_jitterbuf) && ((jb->info.target - jb->info.min) > jb->info.conf.max_jitterbuf)) {
- jb_dbg("clamping target from %d to %d\n", (jb->info.target - jb->info.min), jb->info.conf.max_jitterbuf);
+ jb_dbg("clamping target from %ld to %ld\n", (jb->info.target - jb->info.min), jb->info.conf.max_jitterbuf);
jb->info.target = jb->info.min + jb->info.conf.max_jitterbuf;
}
{
struct manager_action *cur;
struct ast_str *authority;
- static const char *format = " %-15.15s %-15.15s %-55.55s\n";
+#define HSMC_FORMAT " %-15.15s %-15.15s %-55.55s\n"
switch (cmd) {
case CLI_INIT:
e->command = "manager show commands";
return NULL;
}
authority = ast_str_alloca(80);
- ast_cli(a->fd, format, "Action", "Privilege", "Synopsis");
- ast_cli(a->fd, format, "------", "---------", "--------");
+ ast_cli(a->fd, HSMC_FORMAT, "Action", "Privilege", "Synopsis");
+ ast_cli(a->fd, HSMC_FORMAT, "------", "---------", "--------");
AST_RWLIST_RDLOCK(&actions);
AST_RWLIST_TRAVERSE(&actions, cur, list)
- ast_cli(a->fd, format, cur->action, authority_to_str(cur->authority, &authority), cur->synopsis);
+ ast_cli(a->fd, HSMC_FORMAT, cur->action, authority_to_str(cur->authority, &authority), cur->synopsis);
AST_RWLIST_UNLOCK(&actions);
return CLI_SUCCESS;
{
struct mansession *s;
time_t now = time(NULL);
- static const char *format = " %-15.15s %-15.15s %-10.10s %-10.10s %-8.8s %-8.8s %-5.5s %-5.5s\n";
- static const char *format2 = " %-15.15s %-15.15s %-10d %-10d %-8d %-8d %-5.5d %-5.5d\n";
+#define HSMCONN_FORMAT1 " %-15.15s %-15.15s %-10.10s %-10.10s %-8.8s %-8.8s %-5.5s %-5.5s\n"
+#define HSMCONN_FORMAT2 " %-15.15s %-15.15s %-10d %-10d %-8d %-8d %-5.5d %-5.5d\n"
int count = 0;
switch (cmd) {
case CLI_INIT:
return NULL;
}
- ast_cli(a->fd, format, "Username", "IP Address", "Start", "Elapsed", "FileDes", "HttpCnt", "Read", "Write");
+ ast_cli(a->fd, HSMCONN_FORMAT1, "Username", "IP Address", "Start", "Elapsed", "FileDes", "HttpCnt", "Read", "Write");
AST_LIST_LOCK(&sessions);
AST_LIST_TRAVERSE(&sessions, s, list) {
- ast_cli(a->fd, format2, s->username, ast_inet_ntoa(s->sin.sin_addr), (int)(s->sessionstart), (int)(now - s->sessionstart), s->fd, s->inuse, s->readperm, s->writeperm);
+ ast_cli(a->fd, HSMCONN_FORMAT2, s->username, ast_inet_ntoa(s->sin.sin_addr), (int)(s->sessionstart), (int)(now - s->sessionstart), s->fd, s->inuse, s->readperm, s->writeperm);
count++;
}
AST_LIST_UNLOCK(&sessions);
if (format == FORMAT_XML || format == FORMAT_HTML)
xml_translate(&out, buf, params, format);
else
- ast_str_append(&out, 0, buf);
+ ast_str_append(&out, 0, "%s", buf);
munmap(buf, l);
}
} else if (format == FORMAT_XML || format == FORMAT_HTML) {
}
}
ast_str_append(&out, -1, "\n");
- ast_cli(a->fd, out->str);
+ ast_cli(a->fd, "%s", out->str);
}
AST_RWLIST_UNLOCK(&translators);
return CLI_SUCCESS;
return result;
}
+__attribute((format (printf, 4, 0)))
void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr,
struct ast_string_field_pool **pool_head,
const ast_string_field *ptr, const char *format, va_list ap1, va_list ap2)
mgr->used += needed;
}
+__attribute((format (printf, 4, 5)))
void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr,
struct ast_string_field_pool **pool_head,
const ast_string_field *ptr, const char *format, ...)
* ast_str_set_va(...)
* ast_str_append_va(...)
*/
+
+__attribute__((format (printf, 4, 0)))
int __ast_str_helper(struct ast_str **buf, size_t max_len,
int append, const char *fmt, va_list ap)
{
if (a->argc > e->args) {
command = find_command(a->argv + e->args, 1);
if (command) {
- ast_cli(a->fd, command->usage);
+ ast_cli(a->fd, "%s", command->usage);
ast_cli(a->fd, " Runs Dead : %s\n", command->dead ? "Yes" : "No");
} else {
if (find_command(a->argv + e->args, -1)) {
ast_str_append(&filter, 0, "(&");
if (table_config && table_config->additional_filter)
- ast_str_append(&filter, 0, table_config->additional_filter);
+ ast_str_append(&filter, 0, "%s", table_config->additional_filter);
if (table_config != base_table_config && base_table_config &&
base_table_config->additional_filter) {
- ast_str_append(&filter, 0, base_table_config->additional_filter);
+ ast_str_append(&filter, 0, "%s", base_table_config->additional_filter);
}
/* Create the first part of the query using the first parameter/value pairs we just extracted */
/* Create the filter with the table additional filter and the parameter/value pairs we were given */
ast_str_append(&filter, 0, "(&");
if (table_config && table_config->additional_filter) {
- ast_str_append(&filter, 0, table_config->additional_filter);
+ ast_str_append(&filter, 0, "%s", table_config->additional_filter);
}
if (table_config != base_table_config && base_table_config
&& base_table_config->additional_filter) {
- ast_str_append(&filter, 0, base_table_config->additional_filter);
+ ast_str_append(&filter, 0, "%s", base_table_config->additional_filter);
}
append_var_and_value_to_filter(&filter, table_config, attribute, lookup);
ast_str_append(&filter, 0, ")");
if (tz->nrringcadence)
j--;
ast_copy_string(buf + j, "\n", sizeof(buf) - j);
- ast_cli(a->fd, buf);
+ ast_cli(a->fd, "%s", buf);
for (ts = tz->tones; ts; ts = ts->next)
ast_cli(a->fd, "%-7.7s %-15.15s %s\n", tz->country, ts->name, ts->data);
break;
if (!ast_strlen_zero(args.exclude_mac) && !strcasecmp(user->macaddress, args.exclude_mac))
continue;
pbx_substitute_variables_varshead(user->headp, args.string, expand_buf, sizeof(expand_buf));
- ast_build_string(&buf, &len, expand_buf);
+ ast_build_string(&buf, &len, "%s", expand_buf);
}
AST_RWLIST_UNLOCK(&users);
static char *cli_realtime_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- char *header_format = "%30s %-30s\n";
+#define CRL_HEADER_FORMAT "%30s %-30s\n"
struct ast_variable *var=NULL;
switch (cmd) {
var = ast_load_realtime_all(a->argv[2], a->argv[3], a->argv[4], NULL);
if (var) {
- ast_cli(a->fd, header_format, "Column Name", "Column Value");
- ast_cli(a->fd, header_format, "--------------------", "--------------------");
+ ast_cli(a->fd, CRL_HEADER_FORMAT, "Column Name", "Column Value");
+ ast_cli(a->fd, CRL_HEADER_FORMAT, "--------------------", "--------------------");
while (var) {
- ast_cli(a->fd, header_format, var->name, var->value);
+ ast_cli(a->fd, CRL_HEADER_FORMAT, var->name, var->value);
var = var->next;
}
} else {
AST_LIST_TRAVERSE_SAFE_END;
}
-static void fdprintf(int fd, char *fmt, ...)
+
+static void __attribute__((format (printf, 2, 3))) fdprintf(int fd, char *fmt, ...)
{
char stuff[4096];
va_list ap;
return NULL;
}
-static int manager_action(char *action, char *fmt, ...)
+
+static int __attribute__((format (printf, 2, 3))) manager_action(char *action, char *fmt, ...)
{
struct ast_mansession *s;
char tmp[4096];
static void try_status(void)
{
struct message *m;
- manager_action("Status", "");
+ manager_action("Status", "%s", "");
m = wait_for_response(10000);
if (!m) {
show_message("Status Failed", "Timeout waiting for response");
* ast_str_set_va(...)
* ast_str_append_va(...)
*/
-int __ast_str_helper(struct ast_str **buf, size_t max_len,
+int __attribute__((format (printf, 4, 0))) __ast_str_helper(struct ast_str **buf, size_t max_len,
int append, const char *fmt, va_list ap)
{
int res, need;
_ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)
AST_INLINE_API(
+__attribute__((format (printf, 5, 6)))
int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...),
{
int res;
_ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))
AST_INLINE_API(
+__attribute__((format (printf, 5, 0)))
int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap),
{
int res;
va_end(vars);
}
-static void ast_verbose(const char *fmt, ...)
+static void __attribute__((format (printf, 1, 2))) ast_verbose(const char *fmt, ...)
{
va_list vars;
va_start(vars,fmt);
return TRUE; /* Input file done with, no errors. */
}
-int chat( const char *format, ...)
+int __attribute__((format (printf,1,2))) chat( const char *format, ...)
{
va_list ap;
int result = 0;
return result;
}
-
-int inform( const char *format, ...)
+int __attribute__((format (printf,1,2))) inform( const char *format, ...)
{
va_list ap;
int result = 0;
return result;
}
-int error( const char *format, ...)
+int __attribute__((format (printf,1,2))) error( const char *format, ...)
{
va_list ap;
int result;
return result;
}
-void fatalerror( const char *format, ...)
+void __attribute__((format (printf,1,2))) fatalerror( const char *format, ...)
{
va_list ap;
myexit( 1);
}
-int say( const char *format, ...)
+int __attribute__((format (printf,1,2))) say( const char *format, ...)
{
va_list ap;
int result;