Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:47:54 2009

## 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 - 2005, 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  */
    00024
    00025 #include <stdlib.h>
    00026
    00027 #include "asterisk.h"
    00028
    00029 #include "asterisk/channel.h"
    00030 #include "asterisk/pbx.h"
    00031 #include "asterisk/utils.h"
    00032
    00033 static char *function_moh_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
    00034 {
    00035    ast_copy_string(buf, chan ? chan->musicclass : "", len);
    00036
    00037    return buf;
    00038 }
    00039
    00040 static void function_moh_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
    00041 {
    00042    if (chan)
    00043       ast_copy_string(chan->musicclass, value, sizeof(chan->musicclass));
    00044 }
    00045
    00046 #ifndef BUILTIN_FUNC
    00047 static
    00048 #endif
    00049 struct ast_custom_function moh_function = {
    00050    .name = "MUSICCLASS",
    00051    .synopsis = "Read or Set the MusicOnHold class",
    00052    .syntax = "MUSICCLASS()",
    00053    .desc = "This function will read or set the music on hold class for a channel.\n",
    00054    .read = function_moh_read,
    00055    .write = function_moh_write,
    00056 };
    00057