- Constify the format string passed to ast_cli()

- Simplify printing out the warranty and license


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@54147 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2007-02-13 05:57:52 +00:00
parent 8f8df3e5a9
commit 4300a7a6cd
3 changed files with 44 additions and 50 deletions

View File

@@ -31,7 +31,7 @@ extern "C" {
#include "asterisk/linkedlists.h" #include "asterisk/linkedlists.h"
void ast_cli(int fd, char *fmt, ...) void ast_cli(int fd, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3))); __attribute__ ((format (printf, 2, 3)));
#define RESULT_SUCCESS 0 #define RESULT_SUCCESS 0

View File

@@ -1428,66 +1428,60 @@ static int handle_bang(int fd, int argc, char *argv[])
{ {
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
static const char *warranty_lines[] = { static const char warranty_lines[] = {
"\n", "\n"
" NO WARRANTY\n", " NO WARRANTY\n"
"\n", "\n"
"BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n", "BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n"
"FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\n", "FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\n"
"OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\n", "OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\n"
"PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\n", "PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\n"
"OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n", "OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n"
"MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\n", "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\n"
"TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\n", "TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\n"
"PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\n", "PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\n"
"REPAIR OR CORRECTION.\n", "REPAIR OR CORRECTION.\n"
"\n", "\n"
"IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n", "IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n"
"WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\n", "WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\n"
"REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\n", "REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\n"
"INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\n", "INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\n"
"OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\n", "OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\n"
"TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\n", "TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\n"
"YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\n", "YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\n"
"PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\n", "PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\n"
"POSSIBILITY OF SUCH DAMAGES.\n", "POSSIBILITY OF SUCH DAMAGES.\n"
}; };
static int show_warranty(int fd, int argc, char *argv[]) static int show_warranty(int fd, int argc, char *argv[])
{ {
int x; ast_cli(fd, warranty_lines);
for (x = 0; x < sizeof(warranty_lines) / sizeof(warranty_lines[0]); x++)
ast_cli(fd, (char *) warranty_lines[x]);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
static const char *license_lines[] = { static const char license_lines[] = {
"\n", "\n"
"This program is free software; you can redistribute it and/or modify\n", "This program is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License version 2 as\n", "it under the terms of the GNU General Public License version 2 as\n"
"published by the Free Software Foundation.\n", "published by the Free Software Foundation.\n"
"\n", "\n"
"This program also contains components licensed under other licenses.\n", "This program also contains components licensed under other licenses.\n"
"They include:\n", "They include:\n"
"\n", "\n"
"This program is distributed in the hope that it will be useful,\n", "This program is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n", "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n", "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n", "GNU General Public License for more details.\n"
"\n", "\n"
"You should have received a copy of the GNU General Public License\n", "You should have received a copy of the GNU General Public License\n"
"along with this program; if not, write to the Free Software\n", "along with this program; if not, write to the Free Software\n"
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n", "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"
}; };
static int show_license(int fd, int argc, char *argv[]) static int show_license(int fd, int argc, char *argv[])
{ {
int x; ast_cli(fd, license_lines);
for (x = 0; x < sizeof(license_lines) / sizeof(license_lines[0]); x++)
ast_cli(fd, (char *) license_lines[x]);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }

View File

@@ -54,7 +54,7 @@ AST_THREADSTORAGE(ast_cli_buf);
/*! \brief Initial buffer size for resulting strings in ast_cli() */ /*! \brief Initial buffer size for resulting strings in ast_cli() */
#define AST_CLI_INITLEN 256 #define AST_CLI_INITLEN 256
void ast_cli(int fd, char *fmt, ...) void ast_cli(int fd, const char *fmt, ...)
{ {
int res; int res;
struct ast_str *buf; struct ast_str *buf;