work in progress

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10892 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale committed 2008-12-20 05:24:51 +00:00
1 parent 40760653a3
commit 6ac7c18bb9
6 files changed
+819 -46

No files matched your search

+37 -1
View File
@@ -34,6 +34,9 @@
#ifndef _ESL_H_
#define _ESL_H_
#define esl_copy_string(_x, _y, _z) strncpy(_x, _y, _z - 1)
#define esl_set_string(_x, _y) esl_copy_string(_x, _y, sizeof(_x))
typedef struct esl_event_header esl_event_header_t;
typedef struct esl_event esl_event_t;
@@ -204,6 +207,8 @@ typedef struct {
char header_buf[4196];
char last_reply[1024];
esl_event_t *last_event;
esl_event_t *last_ievent;
esl_event_t *info_event;
int debug;
int connected;
} esl_handle_t;
@@ -213,12 +218,44 @@ typedef enum {
ESL_FALSE = 0
} esl_bool_t;
#ifndef __FUNCTION__
#define __FUNCTION__ (const char *)__func__
#endif
#define ESL_PRE __FILE__, __FUNCTION__, __LINE__
#define ESL_LOG_LEVEL_DEBUG 7
#define ESL_LOG_LEVEL_INFO 6
#define ESL_LOG_LEVEL_NOTICE 5
#define ESL_LOG_LEVEL_WARNING 4
#define ESL_LOG_LEVEL_ERROR 3
#define ESL_LOG_LEVEL_CRIT 2
#define ESL_LOG_LEVEL_ALERT 1
#define ESL_LOG_LEVEL_EMERG 0
#define ESL_LOG_DEBUG ESL_PRE, ESL_LOG_LEVEL_DEBUG
#define ESL_LOG_INFO ESL_PRE, ESL_LOG_LEVEL_INFO
#define ESL_LOG_NOTICE ESL_PRE, ESL_LOG_LEVEL_NOTICE
#define ESL_LOG_WARNING ESL_PRE, ESL_LOG_LEVEL_WARNING
#define ESL_LOG_ERROR ESL_PRE, ESL_LOG_LEVEL_ERROR
#define ESL_LOG_CRIT ESL_PRE, ESL_LOG_LEVEL_CRIT
#define ESL_LOG_ALERT ESL_PRE, ESL_LOG_LEVEL_ALERT
#define ESL_LOG_EMERG ESL_PRE, ESL_LOG_LEVEL_EMERG
typedef void (*esl_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...);
extern esl_logger_t esl_log;
void esl_global_set_logger(esl_logger_t logger);
void esl_global_set_default_logger(int level);
#include "esl_event.h"
#include "esl_threadmutex.h"
#include "esl_config.h"
size_t esl_url_encode(const char *url, char *buf, size_t len);
char *esl_url_decode(char *s);
int esl_toupper(int c);
int esl_tolower(int c);
esl_status_t esl_connect(esl_handle_t *handle, const char *host, esl_port_t port, const char *password);
esl_status_t esl_disconnect(esl_handle_t *handle);
@@ -226,7 +263,6 @@ esl_status_t esl_send(esl_handle_t *handle, const char *cmd);
esl_status_t esl_recv(esl_handle_t *handle);
esl_status_t esl_send_recv(esl_handle_t *handle, const char *cmd);
#endif
+138
View File
@@ -0,0 +1,138 @@
/*
* Copyright (c) 2007, Anthony Minessale II
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @defgroup config Config File Parser
* @ingroup config
* This module implements a basic interface and file format parser
*
* <pre>
*
* EXAMPLE
*
* [category1]
* var1 => val1
* var2 => val2
* \# lines that begin with \# are comments
* \#var3 => val3
* </pre>
* @{
*/
#ifndef ESL_CONFIG_H
#define ESL_CONFIG_H
#include "esl.h"
#define ESL_URL_SEPARATOR "://"
#ifdef WIN32
#define ESL_PATH_SEPARATOR "\\"
#ifndef ESL_CONFIG_DIR
#define ESL_CONFIG_DIR "c:\\openesl"
#endif
#define esl_is_file_path(file) (*(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR))
#else
#define ESL_PATH_SEPARATOR "/"
#ifndef ESL_CONFIG_DIR
#define ESL_CONFIG_DIR "/etc/openesl"
#endif
#define esl_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))
#endif
typedef struct esl_config esl_config_t;
/*! \brief A simple file handle representing an open configuration file **/
struct esl_config {
/*! FILE stream buffer to the opened file */
FILE *file;
/*! path to the file */
char path[512];
/*! current category */
char category[256];
/*! current section */
char section[256];
/*! buffer of current line being read */
char buf[1024];
/*! current line number in file */
int lineno;
/*! current category number in file */
int catno;
/*! current section number in file */
int sectno;
int lockto;
};
/*!
\brief Open a configuration file
\param cfg (esl_config_t *) config handle to use
\param file_path path to the file
\return 1 (true) on success 0 (false) on failure
*/
int esl_config_open_file(esl_config_t * cfg, const char *file_path);
/*!
\brief Close a previously opened configuration file
\param cfg (esl_config_t *) config handle to use
*/
void esl_config_close_file(esl_config_t * cfg);
/*!
\brief Retrieve next name/value pair from configuration file
\param cfg (esl_config_t *) config handle to use
\param var pointer to aim at the new variable name
\param val pointer to aim at the new value
*/
int esl_config_next_pair(esl_config_t * cfg, char **var, char **val);
/*!
\brief Retrieve the CAS bits from a configuration string value
\param strvalue pointer to the configuration string value (expected to be in format whatever:xxxx)
\param outbits pointer to aim at the CAS bits
*/
int esl_config_get_cas_bits(char *strvalue, unsigned char *outbits);
/** @} */
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
*/