Skip to content
Snippets Groups Projects
extconf.c 171 KiB
Newer Older
 * Asterisk -- An open source telephony toolkit.
 *
 * Copyright (C) 2006, Digium, Inc.
 *
 * Steve Murphy <murf@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.
 */


Andrew Latham's avatar
Andrew Latham committed
/*!
Matt Jordan's avatar
Matt Jordan committed
 * \file
 * A condensation of the pbx_config stuff, to read into exensions.conf, and provide an interface to the data there,
 * for operations outside of asterisk. A huge, awful hack.
 *
 */
Andrew Latham's avatar
Andrew Latham committed
/*!
 * \li \ref extconf.c uses the configuration file \ref extconfig.conf and \ref extensions.conf and \ref asterisk.conf
 * \addtogroup configuration_file Configuration Files
 */

/*!
 * \page extconfig.conf extconfig.conf
 * \verbinclude extconfig.conf.sample
 */

/*!
 * \page extensions.conf extensions.conf
 * \verbinclude extensions.conf.sample
 */

/*** MODULEINFO
	<support_level>extended</support_level>
 ***/

#define ASTMM_LIBC ASTMM_REDIRECT
Steve Murphy's avatar
Steve Murphy committed
#undef DEBUG_THREADS
#include "asterisk/compat.h"
#include "asterisk/paths.h"	/* we use AST_CONFIG_DIR */

#include <errno.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <stdarg.h>
#include <string.h>
#include <locale.h>
#include <ctype.h>
#if !defined(SOLARIS) && !defined(__CYGWIN__)
#include <err.h>
#endif
#include <regex.h>
#include <limits.h>
#include <pthread.h>
#include <netdb.h>
#include <sys/param.h>
#include <signal.h>
static void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...) __attribute__((format(printf, 5, 6)));
void ast_verbose(const char *fmt, ...) __attribute__((format(printf, 1, 2)));

#define ASINCLUDE_GLOB 1
#ifdef AST_INCLUDE_GLOB
# include <glob.h>
#endif

#define AST_API_MODULE  1 /* gimme the inline defs! */
struct ast_channel
{
	char x; /* basically empty! */
};



#include "asterisk/inline_api.h"
#include "asterisk/endian.h"
#include "asterisk/ast_expr.h"
#include "asterisk/extconf.h"
Steve Murphy's avatar
Steve Murphy committed

#define EVENTLOG "event_log"
#define	QUEUELOG	"queue_log"

#define DEBUG_M(a) { \
	a; \
}

#define VERBOSE_PREFIX_1 " "
#define VERBOSE_PREFIX_2 "  == "
#define VERBOSE_PREFIX_3 "    -- "
#define VERBOSE_PREFIX_4 "       > "


void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...)
	__attribute__((format(printf, 5, 6)));

/* IN CONFLICT: void ast_verbose(const char *fmt, ...)
   __attribute__((format(printf, 1, 2))); */

int ast_register_verbose(void (*verboser)(const char *string));
int ast_unregister_verbose(void (*verboser)(const char *string));

void ast_console_puts(const char *string);

#define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__

#ifdef LOG_DEBUG
#undef LOG_DEBUG
#endif
#define __LOG_DEBUG    0
#define LOG_DEBUG      __LOG_DEBUG, _A_

#ifdef LOG_EVENT
#undef LOG_EVENT
#endif
#define __LOG_EVENT    1
#define LOG_EVENT      __LOG_EVENT, _A_

#ifdef LOG_NOTICE
#undef LOG_NOTICE
#endif
#define __LOG_NOTICE   2
#define LOG_NOTICE     __LOG_NOTICE, _A_

#ifdef LOG_WARNING
#undef LOG_WARNING
#endif
#define __LOG_WARNING  3
#define LOG_WARNING    __LOG_WARNING, _A_

#ifdef LOG_ERROR
#undef LOG_ERROR
#endif
#define __LOG_ERROR    4
#define LOG_ERROR      __LOG_ERROR, _A_

#ifdef LOG_VERBOSE
#undef LOG_VERBOSE
#endif
#define __LOG_VERBOSE  5
#define LOG_VERBOSE    __LOG_VERBOSE, _A_

#ifdef LOG_DTMF
#undef LOG_DTMF
#endif
#define __LOG_DTMF  6
#define LOG_DTMF    __LOG_DTMF, _A_

Steve Murphy's avatar
Steve Murphy committed
/* lock.h */
#define _ASTERISK_LOCK_H /* A small indication that this is horribly wrong. */
Steve Murphy's avatar
Steve Murphy committed
#ifndef	HAVE_MTX_PROFILE
#define	__MTX_PROF(a)	return pthread_mutex_lock((a))
#else
Steve Murphy's avatar
Steve Murphy committed
#define	__MTX_PROF(a)	do {			\
	int i;					\
	/* profile only non-blocking events */	\
	ast_mark(mtx_prof, 1);			\
	i = pthread_mutex_trylock((a));		\
	ast_mark(mtx_prof, 0);			\
	if (!i)					\
		return i;			\
	else					\
		return pthread_mutex_lock((a)); \
	} while (0)
#endif	/* HAVE_MTX_PROFILE */
Steve Murphy's avatar
Steve Murphy committed
#define AST_PTHREADT_NULL (pthread_t) -1
#define AST_PTHREADT_STOP (pthread_t) -2
Steve Murphy's avatar
Steve Murphy committed
#if defined(SOLARIS) || defined(BSD)
#define AST_MUTEX_INIT_W_CONSTRUCTORS
#endif /* SOLARIS || BSD */
Steve Murphy's avatar
Steve Murphy committed
/* Asterisk REQUIRES recursive (not error checking) mutexes
Loading
Loading full blame...