mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-08 10:58:15 +00:00
Version 0.1.2 from FTP
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@152 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
# the GNU General Public License
|
||||
#
|
||||
|
||||
APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_intercom.so app_mp3.so
|
||||
APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_intercom.so app_mp3.so app_system.so app_echo.so
|
||||
|
||||
CFLAGS+=
|
||||
|
||||
|
||||
80
apps/app_echo.c
Executable file
80
apps/app_echo.c
Executable file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Asterisk -- A telephony toolkit for Linux.
|
||||
*
|
||||
* Echo application -- play back what you hear to evaluate latency
|
||||
*
|
||||
* Copyright (C) 1999, Mark Spencer
|
||||
*
|
||||
* Mark Spencer <markster@linux-support.net>
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
*/
|
||||
|
||||
#include <asterisk/file.h>
|
||||
#include <asterisk/logger.h>
|
||||
#include <asterisk/channel.h>
|
||||
#include <asterisk/pbx.h>
|
||||
#include <asterisk/module.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
static char *tdesc = "Simple Echo Application";
|
||||
|
||||
static char *app = "Echo";
|
||||
|
||||
STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
static int skel_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
int res=-1;
|
||||
struct localuser *u;
|
||||
struct ast_frame *f;
|
||||
LOCAL_USER_ADD(u);
|
||||
/* Do our thing here */
|
||||
while((f = ast_read(chan))) {
|
||||
if (f->frametype == AST_FRAME_VOICE) {
|
||||
if (ast_write(chan, f))
|
||||
break;
|
||||
} else if (f->frametype == AST_FRAME_DTMF) {
|
||||
if (f->subclass == '#') {
|
||||
res = 0;
|
||||
break;
|
||||
} else
|
||||
if (ast_write(chan, f))
|
||||
break;
|
||||
}
|
||||
}
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return res;
|
||||
}
|
||||
|
||||
int unload_module(void)
|
||||
{
|
||||
STANDARD_HANGUP_LOCALUSERS;
|
||||
return ast_unregister_application(app);
|
||||
}
|
||||
|
||||
int load_module(void)
|
||||
{
|
||||
return ast_register_application(app, skel_exec);
|
||||
}
|
||||
|
||||
char *description(void)
|
||||
{
|
||||
return tdesc;
|
||||
}
|
||||
|
||||
int usecount(void)
|
||||
{
|
||||
int res;
|
||||
STANDARD_USECOUNT(res);
|
||||
return res;
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <asterisk/logger.h>
|
||||
#include <asterisk/channel.h>
|
||||
#include <asterisk/pbx.h>
|
||||
#include <asterisk/module.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
@@ -22,63 +23,32 @@
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
static pthread_mutex_t skellock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static int usecnt=0;
|
||||
|
||||
static char *tdesc = "Trivial skeleton Application";
|
||||
|
||||
static char *app = "skel";
|
||||
|
||||
struct skeluser {
|
||||
struct ast_channel *chan;
|
||||
struct skeluser *next;
|
||||
} *users = NULL;
|
||||
STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
static int skel_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
int res=0;
|
||||
struct skeluser *u, *ul=NULL;
|
||||
struct localuser *u;
|
||||
if (!data) {
|
||||
ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
|
||||
return -1;
|
||||
}
|
||||
if (!(u=malloc(sizeof(struct skeluser)))) {
|
||||
ast_log(LOG_WARNING, "Out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
pthread_mutex_lock(&skellock);
|
||||
u->chan = chan;
|
||||
u->next = users;
|
||||
users = u;
|
||||
usecnt++;
|
||||
pthread_mutex_unlock(&skellock);
|
||||
LOCAL_USER_ADD(u);
|
||||
/* Do our thing here */
|
||||
pthread_mutex_lock(&skellock);
|
||||
u = users;
|
||||
while(u) {
|
||||
if (ul)
|
||||
ul->next = u->next;
|
||||
else
|
||||
users = u->next;
|
||||
u = u->next;
|
||||
}
|
||||
usecnt--;
|
||||
pthread_mutex_unlock(&skellock);
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return res;
|
||||
}
|
||||
|
||||
int unload_module(void)
|
||||
{
|
||||
struct skeluser *u;
|
||||
pthread_mutex_lock(&skellock);
|
||||
u = users;
|
||||
while(u) {
|
||||
/* Hang up anybody who is using us */
|
||||
ast_softhangup(u->chan);
|
||||
u = u->next;
|
||||
}
|
||||
pthread_mutex_unlock(&skellock);
|
||||
STANDARD_HANGUP_LOCALUSERS;
|
||||
return ast_unregister_application(app);
|
||||
}
|
||||
|
||||
@@ -95,8 +65,6 @@ char *description(void)
|
||||
int usecount(void)
|
||||
{
|
||||
int res;
|
||||
pthread_mutex_lock(&skellock);
|
||||
res = usecnt;
|
||||
pthread_mutex_unlock(&skellock);
|
||||
STANDARD_USECOUNT(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
82
apps/app_system.c
Executable file
82
apps/app_system.c
Executable file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Asterisk -- A telephony toolkit for Linux.
|
||||
*
|
||||
* Execute arbitrary system commands
|
||||
*
|
||||
* Copyright (C) 1999, Mark Spencer
|
||||
*
|
||||
* Mark Spencer <markster@linux-support.net>
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License
|
||||
*/
|
||||
|
||||
#include <asterisk/file.h>
|
||||
#include <asterisk/logger.h>
|
||||
#include <asterisk/channel.h>
|
||||
#include <asterisk/pbx.h>
|
||||
#include <asterisk/module.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
static char *tdesc = "Generic System() application";
|
||||
|
||||
static char *app = "System";
|
||||
|
||||
STANDARD_LOCAL_USER;
|
||||
|
||||
LOCAL_USER_DECL;
|
||||
|
||||
static int skel_exec(struct ast_channel *chan, void *data)
|
||||
{
|
||||
int res=0;
|
||||
struct localuser *u;
|
||||
if (!data) {
|
||||
ast_log(LOG_WARNING, "System requires an argument(command)\n");
|
||||
return -1;
|
||||
}
|
||||
LOCAL_USER_ADD(u);
|
||||
/* Do our thing here */
|
||||
res = system((char *)data);
|
||||
if (res < 0) {
|
||||
ast_log(LOG_WARNING, "Unable to execute '%s'\n", data);
|
||||
res = -1;
|
||||
} else if (res == 127) {
|
||||
ast_log(LOG_WARNING, "Unable to execute '%s'\n", data);
|
||||
res = -1;
|
||||
} else {
|
||||
if (res && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101))
|
||||
chan->priority+=100;
|
||||
res = 0;
|
||||
}
|
||||
LOCAL_USER_REMOVE(u);
|
||||
return res;
|
||||
}
|
||||
|
||||
int unload_module(void)
|
||||
{
|
||||
STANDARD_HANGUP_LOCALUSERS;
|
||||
return ast_unregister_application(app);
|
||||
}
|
||||
|
||||
int load_module(void)
|
||||
{
|
||||
return ast_register_application(app, skel_exec);
|
||||
}
|
||||
|
||||
char *description(void)
|
||||
{
|
||||
return tdesc;
|
||||
}
|
||||
|
||||
int usecount(void)
|
||||
{
|
||||
int res;
|
||||
STANDARD_USECOUNT(res);
|
||||
return res;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent)
|
||||
struct ast_config *cfg;
|
||||
char *copy, *name, *passwd, *email, *dir, *fmt, *fmts, *fn=NULL;
|
||||
char comment[256];
|
||||
struct ast_filestream *writer, *others[MAX_OTHER_FORMATS];
|
||||
struct ast_filestream *writer=NULL, *others[MAX_OTHER_FORMATS];
|
||||
char *sfmt[MAX_OTHER_FORMATS];
|
||||
int res = -1, fmtcnt=0, x;
|
||||
int msgnum;
|
||||
@@ -182,8 +182,12 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent)
|
||||
snprintf(comment, sizeof(comment), "Voicemail from %s to %s (%s) on %s\n",
|
||||
(chan->callerid ? chan->callerid : "Unknown"),
|
||||
name, ext, chan->name);
|
||||
if (ast_fileexists(fn, NULL) > 0) {
|
||||
msgnum++;
|
||||
continue;
|
||||
}
|
||||
writer = ast_writefile(fn, fmt, comment, O_EXCL, 1 /* check for other formats */, 0700);
|
||||
if (!writer && (errno != EEXIST))
|
||||
if (!writer)
|
||||
break;
|
||||
msgnum++;
|
||||
} while(!writer && (msgnum < MAXMSG));
|
||||
@@ -221,9 +225,14 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent)
|
||||
if (f->frametype == AST_FRAME_VOICE) {
|
||||
/* Write the primary format */
|
||||
res = ast_writestream(writer, f);
|
||||
if (res) {
|
||||
ast_log(LOG_WARNING, "Error writing primary frame\n");
|
||||
break;
|
||||
}
|
||||
/* And each of the others */
|
||||
for (x=0;x<fmtcnt;x++)
|
||||
for (x=0;x<fmtcnt;x++) {
|
||||
res |= ast_writestream(others[x], f);
|
||||
}
|
||||
ast_frfree(f);
|
||||
/* Exit on any error */
|
||||
if (res) {
|
||||
@@ -314,20 +323,30 @@ static int vm_execmain(struct ast_channel *chan, void *data)
|
||||
ast_log(LOG_WARNING, "No voicemail configuration\n");
|
||||
goto out;
|
||||
}
|
||||
if (ast_streamfile(chan, "vm-login"))
|
||||
if (ast_streamfile(chan, "vm-login")) {
|
||||
ast_log(LOG_WARNING, "Couldn't stream login file\n");
|
||||
goto out;
|
||||
}
|
||||
do {
|
||||
/* Prompt for, and read in the username */
|
||||
if (ast_readstring(chan, username, sizeof(username), 2000, 5000, "#"))
|
||||
if (ast_readstring(chan, username, sizeof(username), 2000, 5000, "#")) {
|
||||
ast_log(LOG_WARNING, "Couldn't read username\n");
|
||||
goto out;
|
||||
}
|
||||
if (!strlen(username)) {
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Username not entered\n");
|
||||
res = 0;
|
||||
goto out;
|
||||
}
|
||||
if (ast_streamfile(chan, "vm-password"))
|
||||
if (ast_streamfile(chan, "vm-password")) {
|
||||
ast_log(LOG_WARNING, "Unable to stream password file\n");
|
||||
goto out;
|
||||
if (ast_readstring(chan, password, sizeof(password), 2000, 5000, "#"))
|
||||
}
|
||||
if (ast_readstring(chan, password, sizeof(password), 2000, 5000, "#")) {
|
||||
ast_log(LOG_WARNING, "Unable to read password\n");
|
||||
goto out;
|
||||
}
|
||||
copy = ast_variable_retrieve(cfg, NULL, username);
|
||||
if (copy) {
|
||||
copy = strdup(copy);
|
||||
|
||||
Reference in New Issue
Block a user