With respect to bug 7862, the syntax and description are misleading to users. the...
[asterisk/asterisk.git] / funcs / func_language.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 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 Language related dialplan functions
20  * 
21  */
22
23 #include "asterisk.h"
24
25 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <sys/types.h>
31
32 #include "asterisk/module.h"
33 #include "asterisk/channel.h"
34 #include "asterisk/pbx.h"
35 #include "asterisk/logger.h"
36 #include "asterisk/utils.h"
37 #include "asterisk/app.h"
38 #include "asterisk/stringfields.h"
39
40 static int depwarning = 0;
41
42 static int language_read(struct ast_channel *chan, char *cmd, char *data,
43                          char *buf, size_t len)
44 {
45         if (!depwarning) {
46                 depwarning = 1;
47                 ast_log(LOG_WARNING,
48                                 "LANGUAGE() is deprecated; use CHANNEL(language) instead.\n");
49         }
50
51         ast_copy_string(buf, chan->language, len);
52
53         return 0;
54 }
55
56 static int language_write(struct ast_channel *chan, char *cmd, char *data,
57                           const char *value)
58 {
59         if (!depwarning) {
60                 depwarning = 1;
61                 ast_log(LOG_WARNING,
62                                 "LANGUAGE() is deprecated; use CHANNEL(language) instead.\n");
63         }
64
65         if (value)
66                 ast_string_field_set(chan, language, value);
67
68         return 0;
69 }
70
71 static struct ast_custom_function language_function = {
72         .name = "LANGUAGE",
73         .synopsis = "Gets or sets the channel's language.",
74         .syntax = "LANGUAGE()",
75         .desc = "Deprecated. Use CHANNEL(language) instead.\n",
76         .read = language_read,
77         .write = language_write,
78 };
79
80 static int unload_module(void)
81 {
82         return ast_custom_function_unregister(&language_function);
83 }
84
85 static int load_module(void)
86 {
87         return ast_custom_function_register(&language_function);
88 }
89
90 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Channel language dialplan function");