Sat Aug 6 00:39:29 2011

Asterisk developer's documentation


func_language.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 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 Language related dialplan functions
00020  * 
00021  */
00022 
00023 #include "asterisk.h"
00024 
00025 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 61681 $")
00026 
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <string.h>
00030 #include <sys/types.h>
00031 
00032 #include "asterisk/module.h"
00033 #include "asterisk/channel.h"
00034 #include "asterisk/pbx.h"
00035 #include "asterisk/logger.h"
00036 #include "asterisk/utils.h"
00037 #include "asterisk/app.h"
00038 #include "asterisk/stringfields.h"
00039 
00040 static int depwarning = 0;
00041 
00042 static int language_read(struct ast_channel *chan, char *cmd, char *data,
00043           char *buf, size_t len)
00044 {
00045    if (!depwarning) {
00046       depwarning = 1;
00047       ast_log(LOG_WARNING,
00048             "LANGUAGE() is deprecated; use CHANNEL(language) instead.\n");
00049    }
00050 
00051    ast_copy_string(buf, chan ? chan->language : "", len);
00052 
00053    return 0;
00054 }
00055 
00056 static int language_write(struct ast_channel *chan, char *cmd, char *data,
00057            const char *value)
00058 {
00059    if (!depwarning) {
00060       depwarning = 1;
00061       ast_log(LOG_WARNING,
00062             "LANGUAGE() is deprecated; use CHANNEL(language) instead.\n");
00063    }
00064 
00065    if (chan && value)
00066       ast_string_field_set(chan, language, value);
00067 
00068    return 0;
00069 }
00070 
00071 static struct ast_custom_function language_function = {
00072    .name = "LANGUAGE",
00073    .synopsis = "Gets or sets the channel's language.",
00074    .syntax = "LANGUAGE()",
00075    .desc = "Deprecated. Use CHANNEL(language) instead.\n",
00076    .read = language_read,
00077    .write = language_write,
00078 };
00079 
00080 static int unload_module(void)
00081 {
00082    return ast_custom_function_unregister(&language_function);
00083 }
00084 
00085 static int load_module(void)
00086 {
00087    return ast_custom_function_register(&language_function);
00088 }
00089 
00090 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Channel language dialplan function");

Generated on Sat Aug 6 00:39:29 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7