Thu Oct 11 06:42:07 2012

Asterisk developer's documentation


func_moh.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  * Russell Bryant <russelb@clemson.edu> 
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief Functions for reading or setting the MusicOnHold class
00022  *
00023  * \author Russell Bryant <russelb@clemson.edu> 
00024  */
00025 
00026 #include "asterisk.h"
00027 
00028 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 61681 $")
00029 
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 
00033 #include "asterisk/module.h"
00034 #include "asterisk/channel.h"
00035 #include "asterisk/pbx.h"
00036 #include "asterisk/utils.h"
00037 #include "asterisk/stringfields.h"
00038 
00039 static int depwarning = 0;
00040 
00041 static int moh_read(struct ast_channel *chan, char *cmd, char *data,
00042           char *buf, size_t len)
00043 {
00044    if (!depwarning) {
00045       depwarning = 1;
00046       ast_log(LOG_WARNING, "MUSICCLASS() is deprecated; use CHANNEL(musicclass) instead.\n");
00047    }
00048 
00049    ast_copy_string(buf, chan ? chan->musicclass : "", len);
00050 
00051    return 0;
00052 }
00053 
00054 static int moh_write(struct ast_channel *chan, char *cmd, char *data,
00055            const char *value)
00056 {
00057    if (!depwarning) {
00058       depwarning = 1;
00059       ast_log(LOG_WARNING, "MUSICCLASS() is deprecated; use CHANNEL(musicclass) instead.\n");
00060    }
00061 
00062    if (chan)
00063       ast_string_field_set(chan, musicclass, value);
00064 
00065    return 0;
00066 }
00067 
00068 static struct ast_custom_function moh_function = {
00069    .name = "MUSICCLASS",
00070    .synopsis = "Read or Set the MusicOnHold class",
00071    .syntax = "MUSICCLASS()",
00072    .desc = "Deprecated. Use CHANNEL(musicclass) instead.\n",
00073    .read = moh_read,
00074    .write = moh_write,
00075 };
00076 
00077 static int unload_module(void)
00078 {
00079    return ast_custom_function_unregister(&moh_function);
00080 }
00081 
00082 static int load_module(void)
00083 {
00084    return ast_custom_function_register(&moh_function);
00085 }
00086 
00087 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Music-on-hold dialplan function");

Generated on Thu Oct 11 06:42:07 2012 for Asterisk - the Open Source PBX by  doxygen 1.5.6