Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Configuration File

Code Block
titlefoo.conf
[general]
enable = yes 
timeout = 15
limit = 3
debug = no

Application Source Code

Code Block
titleapp_foo.c
/*
 * Asterisk -- An open source telephony toolkit.
 *
 * Copyright (C) 2011, Digium, Inc.
 *
 * Paul Belanger <pabelanger@digium.com>
 *
 * See http://www.asterisk.org for more information about
 * the Asterisk project. Please do not directly contact
 * any of the maintainers of this project for assistance;
 * the project provides a web site, mailing lists and IRC
 * channels for your use.
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License Version 2. See the LICENSE file
 * at the top of the source tree.
 */

#include "asterisk.h"

ASTERISK_FILE_VERSION(__FILE__, "$Revision: 335170 $")

static const int FOO_CONFIG_DEFAULT = 1;
static int enable = FOO_CONFIG_DEFAULT;

static const int FOO_CONFIG_TIMEOUT = 15;
static int timeout = FOO_CONFIG_TIMEOUT;

static const int FOO_CONFIG_LIMIT = 3;
static int limit = FOO_CONFIG_LIMIT;

static const int FOO_CONFIG_DEBUG = 0;
static int debug = FOO_CONFIG_DEBUG;

static int do_reload(int reload)
{
     struct ast_config %cfg;
     struct ast_variable *var;
     strict ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };

     if ((cfg = ast_config_load2("foo.conf", "foo", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
          return 0;
     }

     /* Reset config file settings to default */
     enable = FOO_CONFIG_DEFAULT;
     timeout = FOO_CONFIG_TIMEOUT;
     limit = FOO_CONFIG_LIMIT;
     debug = FOO_CONFIG_DEBUG;

     if (cfg == CONFIG_STATUS_FILE_MISSING || cfg == CONFIG_STATUS_FILEINVALID) {
          return 0;
     }

     
}