Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:47:54 2009

## 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 - 2005, 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 <stdlib.h>
    00024 #include <string.h>
    00025 #include <sys/types.h>
    00026
    00027 #include "asterisk.h"
    00028
    00029 /* ASTERISK_FILE_VERSION(__FILE__, "$Revision: 61680 $") */
    00030
    00031 #include "asterisk/channel.h"
    00032 #include "asterisk/pbx.h"
    00033 #include "asterisk/logger.h"
    00034 #include "asterisk/utils.h"
    00035 #include "asterisk/app.h"
    00036
    00037 static char *builtin_function_language_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
    00038 {
    00039    ast_copy_string(buf, chan ? chan->language : "", len);
    00040
    00041    return buf;
    00042 }
    00043
    00044 static void builtin_function_language_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
    00045 {
    00046    if (chan && value)
    00047       ast_copy_string(chan->language, value, sizeof(chan->language));
    00048 }
    00049
    00050 #ifndef BUILTIN_FUNC
    00051 static
    00052 #endif
    00053 struct ast_custom_function language_function = {
    00054    .name = "LANGUAGE",
    00055    .synopsis = "Gets or sets the channel's language.",
    00056    .syntax = "LANGUAGE()",
    00057    .desc = "Gets or sets the channel language.  This information is used for the\n"
    00058    "syntax in generation of numbers, and to choose a natural language file\n"
    00059    "when available.  For example, if language is set to 'fr' and the file\n"
    00060    "'demo-congrats' is requested to be played, if the file\n"
    00061    "'fr/demo-congrats' exists, then it will play that file, and if not\n"
    00062    "will play the normal 'demo-congrats'.  For some language codes,\n"
    00063    "changing the language also changes the syntax of some Asterisk\n"
    00064    "functions, like SayNumber.\n",
    00065    .read = builtin_function_language_read,
    00066    .write = builtin_function_language_write,
    00067 };
    00068
    00069 /*
    00070 Local Variables:
    00071 mode: C
    00072 c-file-style: "linux"
    00073 indent-tabs-mode: nil
    00074 End:
    00075 */