Fri Jul 24 00:40:56 2009

Asterisk developer's documentation


func_version.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2006, Digium, Inc.
00005  *
00006  * See http://www.asterisk.org for more information about
00007  * the Asterisk project. Please do not directly contact
00008  * any of the maintainers of this project for assistance;
00009  * the project provides a web site, mailing lists and IRC
00010  * channels for your use.
00011  *
00012  * This program is free software, distributed under the terms of
00013  * the GNU General Public License Version 2. See the LICENSE file
00014  * at the top of the source tree.
00015  */
00016 
00017 /*! \file
00018  *
00019  * \brief Return the current Version strings
00020  * 
00021  * \author Steve Murphy (murf@digium.com)
00022  * \ingroup functions
00023  */
00024 
00025 #include "asterisk.h"
00026 
00027 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 105595 $")
00028 
00029 #include "asterisk/module.h"
00030 #include "asterisk/channel.h"
00031 #include "asterisk/pbx.h"
00032 #include "asterisk/utils.h"
00033 #include "asterisk/app.h"
00034 #include "asterisk/ast_version.h"
00035 #include "asterisk/build.h"
00036 
00037 static int acf_version_exec(struct ast_channel *chan, const char *cmd,
00038           char *parse, char *buffer, size_t buflen)
00039 {
00040    const char *response_char = ast_get_version();
00041    AST_DECLARE_APP_ARGS(args,
00042       AST_APP_ARG(info);
00043    );
00044 
00045    AST_STANDARD_APP_ARGS(args, parse);
00046 
00047    if (!ast_strlen_zero(args.info) ) {
00048       if (!strcasecmp(args.info,"ASTERISK_VERSION_NUM"))
00049          response_char = ast_get_version_num();
00050       else if (!strcasecmp(args.info,"BUILD_USER"))
00051          response_char = BUILD_USER;
00052       else if (!strcasecmp(args.info,"BUILD_HOSTNAME"))
00053          response_char = BUILD_HOSTNAME;
00054       else if (!strcasecmp(args.info,"BUILD_MACHINE"))
00055          response_char = BUILD_MACHINE;
00056       else if (!strcasecmp(args.info,"BUILD_KERNEL"))
00057          response_char = BUILD_KERNEL;
00058       else if (!strcasecmp(args.info,"BUILD_OS"))
00059          response_char = BUILD_OS;
00060       else if (!strcasecmp(args.info,"BUILD_DATE"))
00061          response_char = BUILD_DATE;
00062    }
00063 
00064    ast_debug(1, "VERSION returns %s result, given %s argument\n", response_char, args.info);
00065 
00066    ast_copy_string(buffer, response_char, buflen);
00067 
00068    return 0;
00069 }
00070 
00071 static struct ast_custom_function acf_version = {
00072    .name = "VERSION",
00073    .synopsis = "Return the Version info for this Asterisk",
00074    .syntax = "VERSION([info])",
00075    .desc =
00076       "If there are no arguments, return the version of Asterisk in this format: SVN-branch-1.4-r44830M\n"
00077       "If the argument is 'ASTERISK_VERSION_NUM', a string of digits is returned (right now fixed at 999999).\n"
00078       "If the argument is 'BUILD_USER', the string representing the user's name whose account was used to configure Asterisk, is returned.\n"
00079       "If the argument is 'BUILD_HOSTNAME', the string representing the name of the host on which Asterisk was configured, is returned.\n"
00080       "If the argument is 'BUILD_MACHINE', the string representing the type of machine on which Asterisk was configured, is returned.\n"
00081       "If the argument is 'BUILD_OS', the string representing the OS of the machine on which Asterisk was configured, is returned.\n"
00082       "If the argument is 'BUILD_DATE', the string representing the date on which Asterisk was configured, is returned.\n"
00083       "If the argument is 'BUILD_KERNEL', the string representing the kernel version of the machine on which Asterisk was configured, is returned .\n"
00084       "  Example:  Set(junky=${VERSION()}; \n"
00085       "  Sets junky to the string 'SVN-branch-1.6-r74830M', or possibly, 'SVN-trunk-r45126M'.\n",
00086    .read = acf_version_exec,
00087 };
00088 
00089 static int unload_module(void)
00090 {
00091    ast_custom_function_unregister(&acf_version);
00092 
00093    return 0;
00094 }
00095 
00096 static int load_module(void)
00097 {
00098    return ast_custom_function_register(&acf_version);
00099 }
00100 
00101 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Get Asterisk Version/Build Info");

Generated on Fri Jul 24 00:40:57 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7