mirror of https://github.com/asterisk/asterisk
I have removed the STATIC_BUILD option immediately as it has not been maintained in many years and is non-functional. ASTERISK-27965 Change-Id: I64783d017b86dba9ee3c7bcfb97e59889a3f76d716.0
parent
a9cef123d9
commit
134e2f0ddc
@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Asterisk -- An open source telephony toolkit.
|
||||
*
|
||||
* Copyright (C) 1999 - 2005, Digium, Inc.
|
||||
*
|
||||
* Mark Spencer <markster@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.
|
||||
*/
|
||||
|
||||
/*! \file
|
||||
*
|
||||
* \brief App to set callerid presentation
|
||||
*
|
||||
* \author Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* \ingroup applications
|
||||
*/
|
||||
|
||||
/*** MODULEINFO
|
||||
<defaultenabled>no</defaultenabled>
|
||||
<support_level>deprecated</support_level>
|
||||
<replacement>func_callerid</replacement>
|
||||
***/
|
||||
|
||||
#include "asterisk.h"
|
||||
|
||||
#include "asterisk/lock.h"
|
||||
#include "asterisk/file.h"
|
||||
#include "asterisk/channel.h"
|
||||
#include "asterisk/pbx.h"
|
||||
#include "asterisk/module.h"
|
||||
#include "asterisk/translate.h"
|
||||
#include "asterisk/image.h"
|
||||
#include "asterisk/callerid.h"
|
||||
|
||||
/*** DOCUMENTATION
|
||||
<application name="SetCallerPres" language="en_US">
|
||||
<synopsis>
|
||||
Set CallerID Presentation.
|
||||
</synopsis>
|
||||
<syntax>
|
||||
<parameter name="presentation" required="true">
|
||||
<enumlist>
|
||||
<enum name="allowed_not_screened">
|
||||
<para>Presentation Allowed, Not Screened.</para>
|
||||
</enum>
|
||||
<enum name="allowed_passed_screen">
|
||||
<para>Presentation Allowed, Passed Screen.</para>
|
||||
</enum>
|
||||
<enum name="allowed_failed_screen">
|
||||
<para>Presentation Allowed, Failed Screen.</para>
|
||||
</enum>
|
||||
<enum name="allowed">
|
||||
<para>Presentation Allowed, Network Number.</para>
|
||||
</enum>
|
||||
<enum name="prohib_not_screened">
|
||||
<para>Presentation Prohibited, Not Screened.</para>
|
||||
</enum>
|
||||
<enum name="prohib_passed_screen">
|
||||
<para>Presentation Prohibited, Passed Screen.</para>
|
||||
</enum>
|
||||
<enum name="prohib_failed_screen">
|
||||
<para>Presentation Prohibited, Failed Screen.</para>
|
||||
</enum>
|
||||
<enum name="prohib">
|
||||
<para>Presentation Prohibited, Network Number.</para>
|
||||
</enum>
|
||||
<enum name="unavailable">
|
||||
<para>Number Unavailable.</para>
|
||||
</enum>
|
||||
</enumlist>
|
||||
</parameter>
|
||||
</syntax>
|
||||
<description>
|
||||
<para>Set Caller*ID presentation on a call.</para>
|
||||
</description>
|
||||
</application>
|
||||
***/
|
||||
|
||||
static char *app2 = "SetCallerPres";
|
||||
|
||||
static int setcallerid_pres_exec(struct ast_channel *chan, const char *data)
|
||||
{
|
||||
int pres = -1;
|
||||
static int deprecated = 0;
|
||||
|
||||
if (!deprecated) {
|
||||
deprecated = 1;
|
||||
ast_log(LOG_WARNING, "SetCallerPres is deprecated. Please use Set(CALLERPRES()=%s) instead.\n", (char *)data);
|
||||
}
|
||||
|
||||
/* For interface consistency, permit the argument to be specified as a number */
|
||||
if (sscanf(data, "%30d", &pres) != 1 || pres < 0 || pres > 255 || (pres & 0x9c)) {
|
||||
pres = ast_parse_caller_presentation(data);
|
||||
}
|
||||
|
||||
if (pres < 0) {
|
||||
ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
|
||||
(char *) data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set the combined caller id presentation. */
|
||||
ast_channel_caller(chan)->id.name.presentation = pres;
|
||||
ast_channel_caller(chan)->id.number.presentation = pres;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int unload_module(void)
|
||||
{
|
||||
return ast_unregister_application(app2);
|
||||
}
|
||||
|
||||
static int load_module(void)
|
||||
{
|
||||
return ast_register_application_xml(app2, setcallerid_pres_exec);
|
||||
}
|
||||
|
||||
AST_MODULE_INFO_STANDARD_DEPRECATED(ASTERISK_GPL_KEY, "Set CallerID Presentation Application");
|
@ -1,252 +0,0 @@
|
||||
/*
|
||||
* Asterisk -- An open source telephony toolkit.
|
||||
*
|
||||
* Copyright (C) 2004 - 2005, Holger Schurig
|
||||
*
|
||||
*
|
||||
* Ideas taken from other cdr_*.c files
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \brief Store CDR records in a SQLite database.
|
||||
*
|
||||
* \author Holger Schurig <hs4233@mail.mn-solutions.de>
|
||||
* SQLite http://www.sqlite.org/
|
||||
*
|
||||
* See also
|
||||
* \arg \ref Config_cdr
|
||||
* \arg http://www.sqlite.org/
|
||||
*
|
||||
* Creates the database and table on-the-fly
|
||||
* \ingroup cdr_drivers
|
||||
*
|
||||
* \note This module has been marked deprecated in favor for cdr_sqlite3_custom
|
||||
*/
|
||||
|
||||
/*** MODULEINFO
|
||||
<depend>sqlite</depend>
|
||||
<defaultenabled>no</defaultenabled>
|
||||
<support_level>deprecated</support_level>
|
||||
<replacement>sqlite3_custom</replacement>
|
||||
***/
|
||||
|
||||
#include "asterisk.h"
|
||||
|
||||
#include <sqlite.h>
|
||||
|
||||
#include "asterisk/channel.h"
|
||||
#include "asterisk/module.h"
|
||||
#include "asterisk/utils.h"
|
||||
#include "asterisk/paths.h"
|
||||
|
||||
#define LOG_UNIQUEID 0
|
||||
#define LOG_USERFIELD 0
|
||||
#define LOG_HRTIME 0
|
||||
|
||||
/* When you change the DATE_FORMAT, be sure to change the CHAR(19) below to something else */
|
||||
#define DATE_FORMAT "%Y-%m-%d %T"
|
||||
|
||||
static const char name[] = "sqlite";
|
||||
static sqlite* db = NULL;
|
||||
|
||||
AST_MUTEX_DEFINE_STATIC(sqlite_lock);
|
||||
|
||||
/*! \brief SQL table format */
|
||||
static const char sql_create_table[] = "CREATE TABLE cdr ("
|
||||
" AcctId INTEGER PRIMARY KEY,"
|
||||
" clid VARCHAR(80),"
|
||||
" src VARCHAR(80),"
|
||||
" dst VARCHAR(80),"
|
||||
" dcontext VARCHAR(80),"
|
||||
" channel VARCHAR(80),"
|
||||
" dstchannel VARCHAR(80),"
|
||||
" lastapp VARCHAR(80),"
|
||||
" lastdata VARCHAR(80),"
|
||||
" start CHAR(19),"
|
||||
" answer CHAR(19),"
|
||||
" end CHAR(19),"
|
||||
#if LOG_HRTIME
|
||||
" duration FLOAT,"
|
||||
" billsec FLOAT,"
|
||||
#else
|
||||
" duration INTEGER,"
|
||||
" billsec INTEGER,"
|
||||
#endif
|
||||
" disposition INTEGER,"
|
||||
" amaflags INTEGER,"
|
||||
" accountcode VARCHAR(20)"
|
||||
#if LOG_UNIQUEID
|
||||
" ,uniqueid VARCHAR(32)"
|
||||
#endif
|
||||
#if LOG_USERFIELD
|
||||
" ,userfield VARCHAR(255)"
|
||||
#endif
|
||||
");";
|
||||
|
||||
static void format_date(char *buffer, size_t length, struct timeval *when)
|
||||
{
|
||||
struct ast_tm tm;
|
||||
|
||||
ast_localtime(when, &tm, NULL);
|
||||
ast_strftime(buffer, length, DATE_FORMAT, &tm);
|
||||
}
|
||||
|
||||
static int sqlite_log(struct ast_cdr *cdr)
|
||||
{
|
||||
int res = 0;
|
||||
char *zErr = 0;
|
||||
char startstr[80], answerstr[80], endstr[80];
|
||||
int count;
|
||||
#if LOG_HRTIME
|
||||
double hrbillsec = 0.0;
|
||||
double hrduration;
|
||||
#endif
|
||||
|
||||
ast_mutex_lock(&sqlite_lock);
|
||||
|
||||
format_date(startstr, sizeof(startstr), &cdr->start);
|
||||
format_date(answerstr, sizeof(answerstr), &cdr->answer);
|
||||
format_date(endstr, sizeof(endstr), &cdr->end);
|
||||
|
||||
#if LOG_HRTIME
|
||||
if (!ast_tvzero(cdr->answer)) {
|
||||
hrbillsec = (double) ast_tvdiff_us(cdr->end, cdr->answer) / 1000000.0;
|
||||
}
|
||||
hrduration = (double) ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0;
|
||||
#endif
|
||||
|
||||
for(count=0; count<5; count++) {
|
||||
res = sqlite_exec_printf(db,
|
||||
"INSERT INTO cdr ("
|
||||
"clid,src,dst,dcontext,"
|
||||
"channel,dstchannel,lastapp,lastdata, "
|
||||
"start,answer,end,"
|
||||
"duration,billsec,disposition,amaflags, "
|
||||
"accountcode"
|
||||
# if LOG_UNIQUEID
|
||||
",uniqueid"
|
||||
# endif
|
||||
# if LOG_USERFIELD
|
||||
",userfield"
|
||||
# endif
|
||||
") VALUES ("
|
||||
"'%q', '%q', '%q', '%q', "
|
||||
"'%q', '%q', '%q', '%q', "
|
||||
"'%q', '%q', '%q', "
|
||||
#if LOG_HRTIME
|
||||
"%f, %f, %d, %d, "
|
||||
#else
|
||||
"%d, %d, %d, %d, "
|
||||
#endif
|
||||
"'%q'"
|
||||
# if LOG_UNIQUEID
|
||||
",'%q'"
|
||||
# endif
|
||||
# if LOG_USERFIELD
|
||||
",'%q'"
|
||||
# endif
|
||||
")", NULL, NULL, &zErr,
|
||||
cdr->clid, cdr->src, cdr->dst, cdr->dcontext,
|
||||
cdr->channel, cdr->dstchannel, cdr->lastapp, cdr->lastdata,
|
||||
startstr, answerstr, endstr,
|
||||
#if LOG_HRTIME
|
||||
hrduration, hrbillsec, cdr->disposition, cdr->amaflags,
|
||||
#else
|
||||
cdr->duration, cdr->billsec, cdr->disposition, cdr->amaflags,
|
||||
#endif
|
||||
cdr->accountcode
|
||||
# if LOG_UNIQUEID
|
||||
,cdr->uniqueid
|
||||
# endif
|
||||
# if LOG_USERFIELD
|
||||
,cdr->userfield
|
||||
# endif
|
||||
);
|
||||
if (res != SQLITE_BUSY && res != SQLITE_LOCKED)
|
||||
break;
|
||||
usleep(200);
|
||||
}
|
||||
|
||||
if (zErr) {
|
||||
ast_log(LOG_ERROR, "cdr_sqlite: %s\n", zErr);
|
||||
ast_free(zErr);
|
||||
}
|
||||
|
||||
ast_mutex_unlock(&sqlite_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int unload_module(void)
|
||||
{
|
||||
if (ast_cdr_unregister(name)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (db) {
|
||||
sqlite_close(db);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int load_module(void)
|
||||
{
|
||||
char *zErr;
|
||||
char fn[PATH_MAX];
|
||||
int res;
|
||||
|
||||
ast_log(LOG_NOTICE, "This module has been marked deprecated in favor of "
|
||||
"using cdr_sqlite3_custom.\n");
|
||||
|
||||
/* is the database there? */
|
||||
snprintf(fn, sizeof(fn), "%s/cdr.db", ast_config_AST_LOG_DIR);
|
||||
db = sqlite_open(fn, AST_FILE_MODE, &zErr);
|
||||
if (!db) {
|
||||
ast_log(LOG_ERROR, "cdr_sqlite: %s\n", zErr);
|
||||
ast_free(zErr);
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
}
|
||||
|
||||
/* is the table there? */
|
||||
res = sqlite_exec(db, "SELECT COUNT(AcctId) FROM cdr;", NULL, NULL, NULL);
|
||||
if (res) {
|
||||
res = sqlite_exec(db, sql_create_table, NULL, NULL, &zErr);
|
||||
if (res) {
|
||||
ast_log(LOG_ERROR, "cdr_sqlite: Unable to create table 'cdr': %s\n", zErr);
|
||||
ast_free(zErr);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* TODO: here we should probably create an index */
|
||||
}
|
||||
|
||||
res = ast_cdr_register(name, ast_module_info->description, sqlite_log);
|
||||
if (res) {
|
||||
ast_log(LOG_ERROR, "Unable to register SQLite CDR handling\n");
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
}
|
||||
return AST_MODULE_LOAD_SUCCESS;
|
||||
|
||||
err:
|
||||
if (db)
|
||||
sqlite_close(db);
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
}
|
||||
|
||||
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SQLite CDR Backend",
|
||||
.support_level = AST_MODULE_SUPPORT_DEPRECATED,
|
||||
.load = load_module,
|
||||
.unload = unload_module,
|
||||
.load_pri = AST_MODPRI_CDR_DRIVER,
|
||||
.requires = "cdr",
|
||||
);
|
@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Asterisk -- An open source telephony toolkit.
|
||||
*
|
||||
* Copyright (C) 1999 - 2005, Digium, Inc.
|
||||
*
|
||||
* Mark Spencer <markster@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.
|
||||
*/
|
||||
|
||||
/*! \file
|
||||
*
|
||||
* \brief JPEG File format support.
|
||||
*
|
||||
* \arg File name extension: jpeg, jpg
|
||||
* \ingroup formats
|
||||
*/
|
||||
|
||||
/*** MODULEINFO
|
||||
<support_level>extended</support_level>
|
||||
***/
|
||||
|
||||
#include "asterisk.h"
|
||||
|
||||
#include "asterisk/mod_format.h"
|
||||
#include "asterisk/module.h"
|
||||
#include "asterisk/image.h"
|
||||
#include "asterisk/endian.h"
|
||||
#include "asterisk/format_cache.h"
|
||||
|
||||
static struct ast_frame *jpeg_read_image(int fd, int len)
|
||||
{
|
||||
struct ast_frame fr;
|
||||
int res;
|
||||
char buf[65536];
|
||||
if (len > sizeof(buf) || len < 0) {
|
||||
ast_log(LOG_WARNING, "JPEG image too large to read\n");
|
||||
return NULL;
|
||||
}
|
||||
res = read(fd, buf, len);
|
||||
if (res < len) {
|
||||
ast_log(LOG_WARNING, "Only read %d of %d bytes: %s\n", res, len, strerror(errno));
|
||||
}
|
||||
memset(&fr, 0, sizeof(fr));
|
||||
fr.frametype = AST_FRAME_IMAGE;
|
||||
fr.subclass.format = ast_format_jpeg;
|
||||
fr.data.ptr = buf;
|
||||
fr.src = "JPEG Read";
|
||||
fr.datalen = len;
|
||||
return ast_frisolate(&fr);
|
||||
}
|
||||
|
||||
static int jpeg_identify(int fd)
|
||||
{
|
||||
char buf[10];
|
||||
int res;
|
||||
res = read(fd, buf, sizeof(buf));
|
||||
if (res < sizeof(buf))
|
||||
return 0;
|
||||
if (memcmp(buf + 6, "JFIF", 4))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int jpeg_write_image(int fd, struct ast_frame *fr)
|
||||
{
|
||||
int res=0;
|
||||
if (fr->datalen) {
|
||||
res = write(fd, fr->data.ptr, fr->datalen);
|
||||
if (res != fr->datalen) {
|
||||
ast_log(LOG_WARNING, "Only wrote %d of %d bytes: %s\n", res, fr->datalen, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static struct ast_imager jpeg_format = {
|
||||
.name = "jpg",
|
||||
.desc = "JPEG (Joint Picture Experts Group)",
|
||||
.exts = "jpg|jpeg",
|
||||
.read_image = jpeg_read_image,
|
||||
.identify = jpeg_identify,
|
||||
.write_image = jpeg_write_image,
|
||||
};
|
||||
|
||||
static int load_module(void)
|
||||
{
|
||||
jpeg_format.format = ast_format_jpeg;
|
||||
if (ast_image_register(&jpeg_format))
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
return AST_MODULE_LOAD_SUCCESS;
|
||||
}
|
||||
|
||||
static int unload_module(void)
|
||||
{
|
||||
ast_image_unregister(&jpeg_format);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "jpeg (joint picture experts group) image format",
|
||||
.support_level = AST_MODULE_SUPPORT_EXTENDED,
|
||||
.load = load_module,
|
||||
.unload = unload_module,
|
||||
.load_pri = AST_MODPRI_APP_DEPEND
|
||||
);
|
Loading…
Reference in new issue