Asterisk - The Open Source Telephony Project GIT-master-8924258
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
func_version.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2006, Digium, Inc.
5 *
6 * See http://www.asterisk.org for more information about
7 * the Asterisk project. Please do not directly contact
8 * any of the maintainers of this project for assistance;
9 * the project provides a web site, mailing lists and IRC
10 * channels for your use.
11 *
12 * This program is free software, distributed under the terms of
13 * the GNU General Public License Version 2. See the LICENSE file
14 * at the top of the source tree.
15 */
16
17/*! \file
18 *
19 * \brief Return the current Version strings
20 *
21 * \author Steve Murphy (murf@digium.com)
22 * \ingroup functions
23 */
24
25/*** MODULEINFO
26 <support_level>core</support_level>
27 ***/
28
29#include "asterisk.h"
30
31#include "asterisk/module.h"
32#include "asterisk/channel.h"
33#include "asterisk/pbx.h"
34#include "asterisk/utils.h"
35#include "asterisk/app.h"
37#include "asterisk/build.h"
38
39/*** DOCUMENTATION
40 <function name="VERSION" language="en_US">
41 <since>
42 <version>1.6.0</version>
43 </since>
44 <synopsis>
45 Return the Version info for this Asterisk.
46 </synopsis>
47 <syntax>
48 <parameter name="info">
49 <para>The possible values are:</para>
50 <enumlist>
51 <enum name="ASTERISK_VERSION_NUM">
52 <para>A string of digits is returned, e.g. 10602 for 1.6.2 or 100300 for 10.3.0,
53 or 999999 when using a Git build.</para>
54 </enum>
55 <enum name="BUILD_USER">
56 <para>The string representing the user's name whose account
57 was used to configure Asterisk, is returned.</para>
58 </enum>
59 <enum name="BUILD_HOSTNAME">
60 <para>The string representing the name of the host on which Asterisk was configured, is returned.</para>
61 </enum>
62 <enum name="BUILD_MACHINE">
63 <para>The string representing the type of machine on which Asterisk was configured, is returned.</para>
64 </enum>
65 <enum name="BUILD_OS">
66 <para>The string representing the OS of the machine on which Asterisk was configured, is returned.</para>
67 </enum>
68 <enum name="BUILD_DATE">
69 <para>The string representing the date on which Asterisk was configured, is returned.</para>
70 </enum>
71 <enum name="BUILD_KERNEL">
72 <para>The string representing the kernel version of the machine on which Asterisk
73 was configured, is returned.</para>
74 </enum>
75 </enumlist>
76 </parameter>
77 </syntax>
78 <description>
79 <para>If there are no arguments, return the version of Asterisk in this format: 18.12.0</para>
80 <example title="Get current version">
81 same => n,Set(junky=${VERSION()} ; sets junky to 18.12.0, or possibly GITMasterxxxxxx
82 </example>
83 </description>
84 </function>
85 ***/
86
87static int acf_version_exec(struct ast_channel *chan, const char *cmd,
88 char *parse, char *buffer, size_t buflen)
89{
90 const char *response_char = ast_get_version();
93 );
94
96
97 if (!ast_strlen_zero(args.info) ) {
98 if (!strcasecmp(args.info,"ASTERISK_VERSION_NUM"))
99 response_char = ast_get_version_num();
100 else if (!strcasecmp(args.info,"BUILD_USER"))
101 response_char = BUILD_USER;
102 else if (!strcasecmp(args.info,"BUILD_HOSTNAME"))
103 response_char = BUILD_HOSTNAME;
104 else if (!strcasecmp(args.info,"BUILD_MACHINE"))
105 response_char = BUILD_MACHINE;
106 else if (!strcasecmp(args.info,"BUILD_KERNEL"))
107 response_char = BUILD_KERNEL;
108 else if (!strcasecmp(args.info,"BUILD_OS"))
109 response_char = BUILD_OS;
110 else if (!strcasecmp(args.info,"BUILD_DATE"))
111 response_char = BUILD_DATE;
112 }
113
114 ast_debug(1, "VERSION returns %s result, given %s argument\n", response_char, args.info);
115
116 ast_copy_string(buffer, response_char, buflen);
117
118 return 0;
119}
120
122 .name = "VERSION",
123 .read = acf_version_exec,
124};
125
126static int unload_module(void)
127{
129
130 return 0;
131}
132
133static int load_module(void)
134{
136}
137
138AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Get Asterisk Version/Build Info");
Asterisk version information.
const char * ast_get_version(void)
Retrieve the Asterisk version string.
const char * ast_get_version_num(void)
Retrieve the numeric Asterisk version.
Asterisk main include file. File version handling, generic pbx functions.
General Asterisk PBX channel definitions.
static struct ast_custom_function acf_version
Definition: func_version.c:121
static int load_module(void)
Definition: func_version.c:133
static int unload_module(void)
Definition: func_version.c:126
static int acf_version_exec(struct ast_channel *chan, const char *cmd, char *parse, char *buffer, size_t buflen)
Definition: func_version.c:87
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:581
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
def info(msg)
Core PBX routines and definitions.
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1559
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Definition: pbx.h:118
const char * name
Definition: pbx.h:119
const char * args
Utility functions.