mer feb 12 14:56:57 CET 2003
authorMatteo Brancaleoni <mbrancaleoni@espia.it>
Wed, 12 Feb 2003 13:59:15 +0000 (13:59 +0000)
committerMatteo Brancaleoni <mbrancaleoni@espia.it>
Wed, 12 Feb 2003 13:59:15 +0000 (13:59 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@612 65c4cc65-6c06-0410-ace0-fbb531ad65f3

62 files changed:
.cvsignore [new file with mode: 0755]
CHANGES
apps/Makefile
apps/app_agi.c
apps/app_macro.c [new file with mode: 0755]
apps/app_substring.c
astman/.cvsignore [new file with mode: 0755]
channel.c
channels/.cvsignore [new file with mode: 0755]
channels/Makefile
channels/chan_iax.c
channels/chan_mgcp.c
channels/chan_sip.c
channels/chan_zap.c
channels/ixjuser.h
cli.c
codecs/.cvsignore [new file with mode: 0755]
codecs/lpc10/analys.c
codecs/lpc10/bsynz.c
codecs/lpc10/chanwr.c
codecs/lpc10/dcbias.c
codecs/lpc10/decode.c
codecs/lpc10/deemp.c
codecs/lpc10/difmag.c
codecs/lpc10/dyptrk.c
codecs/lpc10/encode.c
codecs/lpc10/energy.c
codecs/lpc10/f2c.h
codecs/lpc10/f2clib.c
codecs/lpc10/ham84.c
codecs/lpc10/hp100.c
codecs/lpc10/invert.c
codecs/lpc10/irc2pc.c
codecs/lpc10/ivfilt.c
codecs/lpc10/lpc10.h
codecs/lpc10/lpcdec.c
codecs/lpc10/lpcenc.c
codecs/lpc10/lpcini.c
codecs/lpc10/lpfilt.c
codecs/lpc10/median.c
codecs/lpc10/mload.c
codecs/lpc10/onset.c
codecs/lpc10/pitsyn.c
codecs/lpc10/placea.c
codecs/lpc10/placev.c
codecs/lpc10/preemp.c
codecs/lpc10/prepro.c
codecs/lpc10/random.c
codecs/lpc10/rcchk.c
codecs/lpc10/synths.c
codecs/lpc10/tbdm.c
codecs/lpc10/voicin.c
codecs/lpc10/vparms.c
configs/extensions.conf.sample
editline/.cvsignore [new file with mode: 0755]
editline/np/.cvsignore [new file with mode: 0755]
include/asterisk/pbx.h
include/asterisk/rtp.h
pbx.c
pbx/.cvsignore [new file with mode: 0755]
pbx/pbx_config.c
rtp.c

diff --git a/.cvsignore b/.cvsignore
new file mode 100755 (executable)
index 0000000..7dca5fe
--- /dev/null
@@ -0,0 +1,4 @@
+asterisk
+build.h
+ast_expr.c
+.version
diff --git a/CHANGES b/CHANGES
index 2088156..55cd0d7 100755 (executable)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+ -- Create special variable "EXTEN-n" where it is extension stripped by n MSD
+ -- Fix uninitialized frame pointer in channel.c
+ -- Add global variables support under [globals] of extensions.conf
+ -- Add macro support (show application Macro)
+ -- Allow [123-5] etc in extensions
+ -- Allow format of App(arg1,arg2,...) instead of just App,arg1|arg2 in dialplan
+ -- Add message waiting indicator to SIP
+ -- Fix double free bug in channel.c
 Asterisk 0.3.0
  -- Add fastfoward, rewind, seek, and truncate functions to streams
  -- Support registration
index 1f08653..95f7275 100755 (executable)
@@ -17,7 +17,7 @@ APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_intercom.
      app_agi.so app_qcall.so app_adsiprog.so app_getcpeid.so app_milliwatt.so \
      app_zapateller.so app_datetime.so app_setcallerid.so app_festival.so \
      app_queue.so app_senddtmf.so app_parkandannounce.so app_striplsd.so \
-     app_setcidname.so app_lookupcidname.so app_substring.so
+     app_setcidname.so app_lookupcidname.so app_substring.so app_macro.so
 
 #APPS+=app_sql_postgres.so
 #APPS+=app_sql_odbc.so
index add410a..91ca974 100755 (executable)
@@ -72,8 +72,6 @@ STANDARD_LOCAL_USER;
 
 LOCAL_USER_DECL;
 
-extern char *pbx_builtin_getvar_helper(struct ast_channel *chan, char *name);
-extern void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value);
 
 #define TONE_BLOCK_SIZE 200
 
diff --git a/apps/app_macro.c b/apps/app_macro.c
new file mode 100755 (executable)
index 0000000..bb8b43d
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Macro Implementation
+ * 
+ * Copyright (C) 2003, Digium
+ *
+ * Mark Spencer <markster@digium.com>
+ *
+ * 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 <asterisk/options.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <pthread.h>
+
+#define MAX_ARGS 80
+
+static char *tdesc = "Extension Macros";
+
+static char *descrip =
+"  Macro(macroname|arg1|arg2...): Executes a macro using the context\n"
+"'macro-<macroname>', jumping to the 's' extension of that context and\n"
+"executing each step, then returning when the steps end.  The calling\n"
+"extension, context, and priority are stored in ${MACRO_EXTEN}, \n"
+"${MACRO_CONTEXT} and ${MACRO_PRIORITY} respectively.  Arguments become\n"
+"${ARG1}, ${ARG2}, etc in the macro context.  Macro returns -1 if\n"
+"any step in the macro returns -1, and 0 otherwise.  If you Goto out\n"
+"of the Macro context, the Macro will terminate and control will be return\n"
+"at the location of the Goto.  Otherwise if ${MACRO_OFFSET} is set at\n"
+"termination, Macro will attempt to continue at priority\n"
+"MACRO_OFFSET + N + 1 if such a step exists, and N + 1 otherwise.\n";
+
+static char *app = "Macro";
+
+static char *synopsis = "Macro Implementation";
+
+STANDARD_LOCAL_USER;
+
+LOCAL_USER_DECL;
+
+static int macro_exec(struct ast_channel *chan, void *data)
+{
+  char tmp[256] = "";
+  char *cur, *rest;
+  char *macro;
+  char fullmacro[80];
+  char varname[80];
+  char *oldargs[MAX_ARGS + 1] = { NULL, };
+  int argc, x;
+  int res;
+  char oldexten[256]="";
+  int oldpriority;
+  char pc[80];
+  char oldcontext[256] = "";
+  char *offsets;
+  int offset;
+  
+  char *save_macro_exten;
+  char *save_macro_context;
+  char *save_macro_priority;
+  char *save_macro_offset;
+  
+  if (!data || !strlen(data)) {
+    ast_log(LOG_WARNING, "Invalid Macro incantation\n");
+    return 0;
+  }
+  strncpy(tmp, data, sizeof(tmp) - 1);
+  rest = tmp;
+  macro = strsep(&rest, "|");
+  if (!macro || !strlen(macro)) {
+       ast_log(LOG_WARNING, "Invalid macro name specified\n");
+       return 0;
+  }
+  snprintf(fullmacro, sizeof(fullmacro), "macro-%s", macro);
+  if (!ast_exists_extension(chan, fullmacro, "s", 1, chan->callerid)) {
+       if (!ast_context_find(fullmacro)) 
+               ast_log(LOG_WARNING, "No such context '%s' for macro '%s'\n", fullmacro, macro);
+       else
+               ast_log(LOG_WARNING, "Context '%s' for macro '%s' lacks 's' extension, priority 1\n", fullmacro, macro);
+       return 0;
+  }
+  /* Save old info */
+  oldpriority = chan->priority;
+  strncpy(oldexten, chan->exten, sizeof(oldexten) - 1);
+  strncpy(oldcontext, chan->context, sizeof(oldcontext) - 1);
+  argc = 1;
+  /* Save old macro variables */
+  save_macro_exten = pbx_builtin_getvar_helper(chan, "MACRO_EXTEN");
+  if (save_macro_exten) save_macro_exten = strdup(save_macro_exten);
+  pbx_builtin_setvar_helper(chan, "MACRO_EXTEN", oldexten);
+
+  save_macro_context = pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT");
+  if (save_macro_context) save_macro_context = strdup(save_macro_context);
+  pbx_builtin_setvar_helper(chan, "MACRO_CONTEXT", oldcontext);
+
+  save_macro_priority = pbx_builtin_getvar_helper(chan, "MACRO_PRIORITY");
+  if (save_macro_priority) save_macro_priority = strdup(save_macro_priority);
+  snprintf(pc, sizeof(pc), "%d", oldpriority);
+  pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", pc);
+  
+  save_macro_offset = pbx_builtin_getvar_helper(chan, "MACRO_OFFSET");
+  if (save_macro_offset) save_macro_offset = strdup(save_macro_offset);
+  pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", NULL);
+
+  /* Setup environment for new run */
+  strcpy(chan->exten, "s");
+  strncpy(chan->context, fullmacro, sizeof(chan->context));
+  chan->priority = 1;
+
+  while((cur = strsep(&rest, "|")) && (argc < MAX_ARGS)) {
+       /* Save copy of old arguments if we're overwriting some, otherwise
+          let them pass through to the other macro */
+       oldargs[argc] = pbx_builtin_getvar_helper(chan, varname);
+       if (oldargs[argc])
+               oldargs[argc] = strdup(oldargs[argc]);
+       snprintf(varname, sizeof(varname), "ARG%d", argc);
+       pbx_builtin_setvar_helper(chan, varname, cur);
+       argc++;
+  }
+  while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid)) {
+       if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid))) {
+               /* Something bad happened, or a hangup has been requested. */
+               if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F'))) {
+                       /* Just return result as to the previous application as if it had been dialed */
+                       ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
+                       break;
+               }
+               switch(res) {
+               case AST_PBX_KEEPALIVE:
+                       if (option_debug)
+                               ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited KEEPALIVE in macro %s on '%s'\n", chan->context, chan->exten, chan->priority, macro, chan->name);
+                       else if (option_verbose > 1)
+                               ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited KEEPALIVE in macro '%s' on '%s'\n", chan->context, chan->exten, chan->priority, macro, chan->name);
+                       goto out;
+                       break;
+               default:
+                       if (option_debug)
+                               ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
+                       else if (option_verbose > 1)
+                               ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro);
+                       goto out;
+               }
+       }
+       if (strcasecmp(chan->context, fullmacro)) {
+               if (option_verbose > 1)
+                       ast_verbose(VERBOSE_PREFIX_2 "Channel '%s' jumping out of macro '%s'\n", chan->name, macro);
+               break;
+       }
+       if (chan->_softhangup) {
+               ast_log(LOG_DEBUG, "Extension %s, priority %d returned normally even though call was hung up\n",
+                       chan->exten, chan->priority);
+               goto out;
+       }
+       chan->priority++;
+  }
+out:
+  for (x=1;x<argc;x++) {
+       /* Restore old arguments and delete ours */
+       snprintf(varname, sizeof(varname), "ARG%d", x);
+       if (oldargs[x]) {
+               pbx_builtin_setvar_helper(chan, varname, oldargs[x]);
+               free(oldargs[x]);
+       } else {
+               pbx_builtin_setvar_helper(chan, varname, NULL);
+       }
+  }
+
+  /* Restore macro variables */
+  pbx_builtin_setvar_helper(chan, "MACRO_EXTEN", save_macro_exten);
+  if (save_macro_exten) free(save_macro_exten);
+  pbx_builtin_setvar_helper(chan, "MACRO_CONTEXT", save_macro_context);
+  if (save_macro_context) free(save_macro_context);
+  pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", save_macro_priority);
+  if (save_macro_priority) free(save_macro_priority);
+
+  if (!strcasecmp(chan->context, fullmacro)) {
+       /* If we're leaving the macro normally, restore original information */
+       chan->priority = oldpriority;
+       strncpy(chan->exten, oldexten, sizeof(chan->exten) - 1);
+       strncpy(chan->context, oldcontext, sizeof(chan->context) - 1);
+       if ((offsets = pbx_builtin_getvar_helper(chan, "MACRO_OFFSET"))) {
+               /* Handle macro offset if it's set by checking the availability of step n + offset + 1, otherwise continue
+                  normally if there is any problem */
+               if (sscanf(offsets, "%d", &offset) == 1) {
+                       if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + offset + 1, chan->callerid)) {
+                               chan->priority += offset;
+                       }
+               }
+       }
+  }
+
+  pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", save_macro_offset);
+  if (save_macro_offset) free(save_macro_offset);
+  return res;
+}
+
+int unload_module(void)
+{
+       STANDARD_HANGUP_LOCALUSERS;
+       return ast_unregister_application(app);
+}
+
+int load_module(void)
+{
+       return ast_register_application(app, macro_exec, synopsis, descrip);
+}
+
+char *description(void)
+{
+       return tdesc;
+}
+
+int usecount(void)
+{
+       int res;
+       STANDARD_USECOUNT(res);
+       return res;
+}
+
+char *key()
+{
+       return ASTERISK_GPL_KEY;
+}
index a1edf64..97f0fea 100755 (executable)
@@ -27,8 +27,6 @@
 
 static char *tdesc = "Save substring digits in a given variable";
 
-extern void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value);
-
 static char *descrip =
 "  StripLSD(variable=string_of_digits|count1|count2): Assigns the substring\n"
 "of string_of_digits to a given variable. Parameter count1 may be positive\n"
diff --git a/astman/.cvsignore b/astman/.cvsignore
new file mode 100755 (executable)
index 0000000..a030529
--- /dev/null
@@ -0,0 +1 @@
+astman
index b7c4ff3..83659c0 100755 (executable)
--- a/channel.c
+++ b/channel.c
@@ -376,6 +376,7 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int lock)
 int ast_queue_hangup(struct ast_channel *chan, int lock)
 {
        struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
+       chan->_softhangup |= AST_SOFTHANGUP_DEV;
        return ast_queue_frame(chan, &f, lock);
 }
 
@@ -1145,7 +1146,7 @@ static int do_senddigit(struct ast_channel *chan, char digit)
 int ast_write(struct ast_channel *chan, struct ast_frame *fr)
 {
        int res = -1;
-       struct ast_frame *f;
+       struct ast_frame *f = NULL;
        /* Stop if we're a zombie or need a soft hangup */
        if (chan->zombie || ast_check_hangup(chan)) 
                return -1;
@@ -1180,7 +1181,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
        default:
                if (chan->pvt->write) {
                        if (chan->pvt->writetrans) {
-                               f = ast_translate(chan->pvt->writetrans, fr, 1);
+                               f = ast_translate(chan->pvt->writetrans, fr, 0);
                        } else
                                f = fr;
                        if (f)  
@@ -1189,6 +1190,8 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                                res = 0;
                }
        }
+       if (f && (f != fr))
+               ast_frfree(f);
        chan->blocking = 0;
        /* Consider a write failure to force a soft hangup */
        if (res < 0)
diff --git a/channels/.cvsignore b/channels/.cvsignore
new file mode 100755 (executable)
index 0000000..ee5ff43
--- /dev/null
@@ -0,0 +1,3 @@
+busy.h
+gentone
+ringtone.h
index 7669373..dc7eaf4 100755 (executable)
@@ -32,7 +32,7 @@ CFLAGS+=$(shell [ -f alsa-monitor.h ] && echo " -DALSA_MONITOR")
 ZAPPRI=$(shell [ -f /usr/lib/libpri.so.1 ] && echo "-lpri")
 ZAPR2=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo "-lmfcr2")
 CHANZAP=$(shell if [ -f .oldzap ]; then echo "chan_zap_old.c"; else echo "chan_zap.c"; fi)
-ZAPLIB=$(shell if ! [ -f .newzap ]; then echo "-lzap"; fi)
+ZAPLIB=$(shell if [ -f .oldzap ]; then echo "-lzap"; fi)
 
 ALSA_SRC=chan_alsa.c
 ALSA_SRC+=$(shell [ -f alsa-monitor.h ] && echo "alsa-monitor.h")
index 71ca1e7..ce896c7 100755 (executable)
@@ -4712,12 +4712,13 @@ static int cache_get_callno(char *data)
        for (x=0;x<AST_IAX_MAX_CALLS; x++) {
                /* Look for an *exact match* call.  Once a call is negotiated, it can only
                   look up entries for a single context */
-               ast_pthread_mutex_lock(&iaxsl[x]);
-               if (iaxs[x] && !strcasecmp(data, iaxs[x]->dproot)) {
+               if (!pthread_mutex_trylock(&iaxsl[x])) {
+                       if (iaxs[x] && !strcasecmp(data, iaxs[x]->dproot)) {
+                               ast_pthread_mutex_unlock(&iaxsl[x]);
+                               return x;
+                       }
                        ast_pthread_mutex_unlock(&iaxsl[x]);
-                       return x;
                }
-               ast_pthread_mutex_unlock(&iaxsl[x]);
        }
        /* No match found, we need to create a new one */
        strncpy(st, data, sizeof(st)-1);
index 79e9620..88a0d2c 100755 (executable)
@@ -380,11 +380,34 @@ static int mgcp_answer(struct ast_channel *ast)
        return res;
 }
 
+static struct ast_frame *mgcp_rtp_read(struct mgcp_endpoint *p)
+{
+       /* Retrieve audio/etc from channel.  Assumes p->lock is already held. */
+       struct ast_frame *f;
+       f = ast_rtp_read(p->rtp);
+       if (p->owner) {
+               /* We already hold the channel lock */
+               if (f->frametype == AST_FRAME_VOICE) {
+                       if (f->subclass != p->owner->nativeformats) {
+                               ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+                               p->owner->nativeformats = f->subclass;
+                               ast_set_read_format(p->owner, p->owner->readformat);
+                               ast_set_write_format(p->owner, p->owner->writeformat);
+                       }
+               }
+       }
+       return f;
+}
+
+
 static struct ast_frame  *mgcp_read(struct ast_channel *ast)
 {
-       static struct ast_frame f = { AST_FRAME_NULL, };
-       ast_log(LOG_DEBUG, "I should never get called but am on %s!\n", ast->name);
-       return &f;
+       struct ast_frame *fr;
+       struct mgcp_endpoint *p = ast->pvt->pvt;
+       ast_pthread_mutex_lock(&p->lock);
+       fr = mgcp_rtp_read(p);
+       ast_pthread_mutex_unlock(&p->lock);
+       return fr;
 }
 
 static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame)
@@ -473,6 +496,8 @@ static struct ast_channel *mgcp_new(struct mgcp_endpoint *i, int state)
                        tmp->nativeformats = capability;
                fmt = ast_best_codec(tmp->nativeformats);
                snprintf(tmp->name, sizeof(tmp->name), "MGCP/%s@%s", i->name, i->parent->name);
+               if (i->rtp)
+                       tmp->fds[0] = ast_rtp_fd(i->rtp);
                tmp->type = type;
                ast_setstate(tmp, state);
                if (state == AST_STATE_RING)
@@ -556,6 +581,7 @@ static char *get_header(struct mgcp_request *req, char *name)
        return __get_header(req, name, &start);
 }
 
+#if 0
 static int rtpready(struct ast_rtp *rtp, struct ast_frame *f, void *data)
 {
        /* Just deliver the audio directly */
@@ -582,6 +608,7 @@ static int rtpready(struct ast_rtp *rtp, struct ast_frame *f, void *data)
        ast_pthread_mutex_unlock(&p->lock);
        return 0;
 }
+#endif
 
 static struct mgcp_endpoint *find_endpoint(char *name, int msgid, struct sockaddr_in *sin)
 {
@@ -1081,9 +1108,13 @@ static void start_rtp(struct mgcp_endpoint *p)
 {
                ast_pthread_mutex_lock(&p->lock);
                /* Allocate the RTP now */
-               p->rtp = ast_rtp_new(sched, io);
+               p->rtp = ast_rtp_new(NULL, NULL);
+               if (p->rtp && p->owner)
+                       p->owner->fds[0] = ast_rtp_fd(p->rtp);
+#if 0
                ast_rtp_set_callback(p->rtp, rtpready);
                ast_rtp_set_data(p->rtp, p);
+#endif         
                /* Make a call*ID */
                snprintf(p->callid, sizeof(p->callid), "%08x%s", rand(), p->txident);
                /* Transmit the connection create */
index e9ec11f..9818b27 100755 (executable)
@@ -154,7 +154,6 @@ static struct sip_pvt {
        char callerid[256];                                     /* Caller*ID */
        char via[256];
        char accountcode[256];                          /* Account code */
-       char mailbox[AST_MAX_EXTENSION];                /* Associated mailbox */
        int amaflags;                                           /* AMA Flags */
        struct sip_request initreq;                     /* Initial request */
        
@@ -183,7 +182,6 @@ struct sip_user {
        char callerid[80];
        char methods[80];
        char accountcode[80];
-       char mailbox[AST_MAX_EXTENSION];
        int hascallerid;
        int amaflags;
        int insecure;
@@ -199,6 +197,8 @@ struct sip_peer {
        char methods[80];
        char username[80];
        char mailbox[AST_MAX_EXTENSION];
+       int lastmsgssent;
+       time_t  lastmsgcheck;
        int dynamic;
        int expire;
        int expirey;
@@ -274,7 +274,6 @@ static int transmit_invite(struct sip_pvt *p, char *msg, int sendsdp, char *auth
 static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp);
 static int transmit_message_with_text(struct sip_pvt *p, char *text);
 static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req);
-static int sip_send_mwi(struct sip_pvt *p);
 
 static int __sip_xmit(struct sip_pvt *p, char *data, int len)
 {
@@ -358,7 +357,6 @@ static int create_addr(struct sip_pvt *r, char *peer)
                        r->canreinvite = p->canreinvite;
                        r->maxtime = p->maxms;
                        strncpy(r->context, p->context,sizeof(r->context)-1);
-                       strncpy(r->mailbox, p->mailbox,sizeof(r->mailbox)-1);
                        if ((p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) &&
                                (!p->maxms || ((p->lastms > 0)  && (p->lastms <= p->maxms)))) {
                                if (p->addr.sin_addr.s_addr) {
@@ -638,13 +636,6 @@ static int sip_answer(struct ast_channel *ast)
        return res;
 }
 
-static struct ast_frame  *sip_read(struct ast_channel *ast)
-{
-       static struct ast_frame f = { AST_FRAME_NULL, };
-       ast_log(LOG_DEBUG, "I should never get called but am on %s!\n", ast->name);
-       return &f;
-}
-
 static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
 {
        struct sip_pvt *p = ast->pvt->pvt;
@@ -818,6 +809,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state)
                fmt = ast_best_codec(tmp->nativeformats);
                snprintf(tmp->name, sizeof(tmp->name), "SIP/%s:%d", inet_ntoa(i->sa.sin_addr), ntohs(i->sa.sin_port));
                tmp->type = type;
+               tmp->fds[0] = ast_rtp_fd(i->rtp);
                ast_setstate(tmp, state);
                if (state == AST_STATE_RING)
                        tmp->rings = 1;
@@ -922,31 +914,33 @@ static char *get_header(struct sip_request *req, char *name)
        return __get_header(req, name, &start);
 }
 
-static int rtpready(struct ast_rtp *rtp, struct ast_frame *f, void *data)
+static struct ast_frame *sip_rtp_read(struct sip_pvt *p)
 {
-       /* Just deliver the audio directly */
-       struct sip_pvt *p = data;
-       ast_pthread_mutex_lock(&p->lock);
+       /* Retrieve audio/etc from channel.  Assumes p->lock is already held. */
+       struct ast_frame *f;
+       f = ast_rtp_read(p->rtp);
        if (p->owner) {
-               /* Generally, you lock in the order channel lock, followed by private
-                  lock.  Since here we are doing the reverse, there is the possibility
-                  of deadlock.  As a result, in the case of a deadlock, we simply fail out
-                  here. */
-               if (!pthread_mutex_trylock(&p->owner->lock)) {
-                       if (f->frametype == AST_FRAME_VOICE) {
-                               if (f->subclass != p->owner->nativeformats) {
-                                       ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
-                                       p->owner->nativeformats = f->subclass;
-                                       ast_set_read_format(p->owner, p->owner->readformat);
-                                       ast_set_write_format(p->owner, p->owner->writeformat);
-                               }
+               /* We already hold the channel lock */
+               if (f->frametype == AST_FRAME_VOICE) {
+                       if (f->subclass != p->owner->nativeformats) {
+                               ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+                               p->owner->nativeformats = f->subclass;
+                               ast_set_read_format(p->owner, p->owner->readformat);
+                               ast_set_write_format(p->owner, p->owner->writeformat);
                        }
-                       ast_queue_frame(p->owner, f, 0);
-                       pthread_mutex_unlock(&p->owner->lock);
                }
        }
+       return f;
+}
+
+static struct ast_frame *sip_read(struct ast_channel *ast)
+{
+       struct ast_frame *fr;
+       struct sip_pvt *p = ast->pvt->pvt;
+       ast_pthread_mutex_lock(&p->lock);
+       fr = sip_rtp_read(p);
        ast_pthread_mutex_unlock(&p->lock);
-       return 0;
+       return fr;
 }
 
 static void build_callid(char *callid, int len, struct in_addr ourip)
@@ -974,7 +968,7 @@ static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin)
        /* Keep track of stuff */
        memset(p, 0, sizeof(struct sip_pvt));
        p->initid = -1;
-       p->rtp = ast_rtp_new(sched, io);
+       p->rtp = ast_rtp_new(NULL, NULL);
        p->branch = rand();     
        p->tag = rand();
        /* Start with 101 instead of 1 */
@@ -986,8 +980,10 @@ static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin)
        }
        ast_rtp_settos(p->rtp, tos);
        ast_pthread_mutex_init(&p->lock);
+#if 0
        ast_rtp_set_data(p->rtp, p);
        ast_rtp_set_callback(p->rtp, rtpready);
+#endif 
        if (sin) {
                memcpy(&p->sa, sin, sizeof(p->sa));
                memcpy(&p->ourip, myaddrfor(&p->sa.sin_addr), sizeof(p->ourip));
@@ -1238,8 +1234,8 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
                ast_log(LOG_WARNING, "No compatible codecs!\n");
                return -1;
        }
-       if (p->owner && (p->owner->nativeformats != p->capability)) {
-               ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %d\n", p->capability);
+       if (p->owner && !(p->owner->nativeformats & p->capability)) {
+               ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %d and not %d\n", p->capability, p->owner->nativeformats);
                p->owner->nativeformats = p->capability;
                ast_set_read_format(p->owner, p->owner->readformat);
                ast_set_write_format(p->owner, p->owner->writeformat);
@@ -1630,9 +1626,8 @@ static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp)
        return send_response(p, &resp);
 }
 
-static int transmit_invite(struct sip_pvt *p, char *cmd, int sdp, char *auth, char *vxml_url)
+static void initreqprep(struct sip_request *req, struct sip_pvt *p, char *cmd, char *vxml_url)
 {
-       struct sip_request req;
        char invite[256];
        char from[256];
        char to[256];
@@ -1670,12 +1665,12 @@ static int transmit_invite(struct sip_pvt *p, char *cmd, int sdp, char *auth, ch
        {
                snprintf(to, sizeof(to), "<%s>", invite );
        }
-       memset(&req, 0, sizeof(req));
-       init_req(&req, cmd, invite);
+       memset(req, 0, sizeof(struct sip_request));
+       init_req(req, cmd, invite);
        snprintf(tmp, sizeof(tmp), "%d %s", ++p->ocseq, cmd);
 
-       add_header(&req, "Via", p->via);
-       add_header(&req, "From", from);
+       add_header(req, "Via", p->via);
+       add_header(req, "From", from);
        {
                char contact2[256] ="", *c, contact[256];
                /* XXX This isn't exactly right and it's implemented
@@ -1683,12 +1678,18 @@ static int transmit_invite(struct sip_pvt *p, char *cmd, int sdp, char *auth, ch
                strncpy(contact2, from, sizeof(contact2)-1);
                c = ditch_braces(contact2);
                snprintf(contact, sizeof(contact), "<%s>", c);
-               add_header(&req, "Contact", contact);
+               add_header(req, "Contact", contact);
        }
-       add_header(&req, "To", to);
-       add_header(&req, "Call-ID", p->callid);
-       add_header(&req, "CSeq", tmp);
-       add_header(&req, "User-Agent", "Asterisk PBX");
+       add_header(req, "To", to);
+       add_header(req, "Call-ID", p->callid);
+       add_header(req, "CSeq", tmp);
+       add_header(req, "User-Agent", "Asterisk PBX");
+}
+
+static int transmit_invite(struct sip_pvt *p, char *cmd, int sdp, char *auth, char *vxml_url)
+{
+       struct sip_request req;
+       initreqprep(&req, p, cmd, vxml_url);
        if (auth)
                add_header(&req, "Proxy-Authorization", auth);
        if (sdp) {
@@ -1706,6 +1707,30 @@ static int transmit_invite(struct sip_pvt *p, char *cmd, int sdp, char *auth, ch
        return send_request(p, &req);
 }
 
+static int transmit_notify(struct sip_pvt *p, int hasmsgs)
+{
+       struct sip_request req;
+       char tmp[256];
+       char clen[20];
+       initreqprep(&req, p, "NOTIFY", NULL);
+       add_header(&req, "Event", "message-summary");
+       add_header(&req, "Content-Type", "text/plain");
+
+       snprintf(tmp, sizeof(tmp), "Message-Waiting: %s\n", hasmsgs ? "yes" : "no");
+       snprintf(clen, sizeof(clen), "%d", strlen(tmp));
+       add_header(&req, "Content-Length", clen);
+       add_line(&req, tmp);
+
+       if (!p->initreq.headers) {
+               /* Use this as the basis */
+               copy_request(&p->initreq, &req);
+               parse(&p->initreq);
+       }
+
+       p->lastinvite = p->ocseq;
+       return send_request(p, &req);
+}
+
 static int transmit_register(struct sip_registry *r, char *cmd, char *auth);
 
 static int sip_reregister(void *data) 
@@ -1801,10 +1826,9 @@ static int transmit_register(struct sip_registry *r, char *cmd, char *auth)
        add_header(&req, "User-Agent", "Asterisk PBX");
        if (auth) 
                add_header(&req, "Authorization", auth);
-#define EXPIRE_TIMEOUT "Thu, 01 Dec 2003 16:00:00 GMT"
 
-
-       add_header(&req, "expires", EXPIRE_TIMEOUT);
+       snprintf(tmp, sizeof(tmp), "%d", DEFAULT_EXPIREY);
+       add_header(&req, "Expires", tmp);
        add_header(&req, "Event", "registration");
        copy_request(&p->initreq, &req);
        r->regstate=auth?REG_STATE_AUTHSENT:REG_STATE_REGSENT;
@@ -1904,8 +1928,6 @@ static int parse_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_req
                strncpy(p->username, c, sizeof(p->username) - 1);
        else
                strcpy(p->username, "");
-       if (p->mailbox)
-               strncpy(pvt->mailbox, p->mailbox,sizeof(pvt->mailbox)-1);
        if (p->expire > -1)
                ast_sched_del(sched, p->expire);
        if ((expirey < 1) || (expirey > MAX_EXPIREY))
@@ -2050,7 +2072,9 @@ static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct si
                                if (parse_contact(p, peer, req)) {
                                        ast_log(LOG_WARNING, "Failed to parse contact info\n");
                                } else {
+                                       /* Say OK and ask subsystem to retransmit msg counter */
                                        transmit_response(p, "200 OK", req);
+                                       peer->lastmsgssent = -1;
                                        res = 0;
                                }
                        } 
@@ -2230,7 +2254,6 @@ static int check_user(struct sip_pvt *p, struct sip_request *req, char *cmd, cha
                if (!strcasecmp(user->name, of)) {
                        if (!(res = check_auth(p, req, p->randdata, sizeof(p->randdata), user->name, user->secret, cmd, uri))) {
                                strncpy(p->context, user->context, sizeof(p->context) - 1);
-                               strncpy(p->mailbox, user->mailbox, sizeof(p->mailbox) - 1);
                                if (strlen(user->callerid) && strlen(p->callerid)) 
                                        strncpy(p->callerid, user->callerid, sizeof(p->callerid) - 1);
                                strncpy(p->accountcode, user->accountcode, sizeof(p->accountcode)  -1);
@@ -2705,8 +2728,8 @@ retrylock:
                                if (r->expire != -1)
                                        ast_sched_del(sched, r->expire);
                                expires=atoi(get_header(req, "expires"));
-                               if (!expires) expires=20;
-                               r->expire=ast_sched_add(sched, (expires-2)*1000, sip_reregister, r); 
+                               if (!expires) expires=DEFAULT_EXPIREY;
+                                       r->expire=ast_sched_add(sched, (expires-2)*1000, sip_reregister, r); 
 
                        }
                        break;
@@ -2855,7 +2878,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
        char *cmd;
        char *cseq;
        char *e;
-       struct ast_channel *c;
+       struct ast_channel *c=NULL;
        int seqno;
        int len;
        int ignore=0;
@@ -3006,24 +3029,24 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                                ast_log(LOG_NOTICE, "Unable to create/find channel\n");
                                transmit_response(p, "503 Unavailable", req);
                                sip_destroy(p);
+                       }
                }
-               }
-               } else if (!strcasecmp(cmd, "REFER")) {
-                       struct ast_channel *transfer_to;
-                       ast_log(LOG_DEBUG, "We found a REFER!\n");
-                       if (!strlen(p->context))
-                               strncpy(p->context, context, sizeof(p->context) - 1);
-                           res = get_refer_info(p, req);
-                           if (res < 0)
-                                   transmit_response_with_allow(p, "404 Not Found", req);
-                           else if (res > 0)
-                                  transmit_response_with_allow(p, "484 Address Incomplete", req);
-                           else
-                                  transmit_response(p, "202 Accepted", req);
-                           ast_log(LOG_DEBUG,"202 Accepted\n");
-                           transfer_to = c->bridge;
-                               if (transfer_to)
-                                  ast_async_goto(transfer_to,"", p->refer_to,1, 1);
+       } else if (!strcasecmp(cmd, "REFER")) {
+               struct ast_channel *transfer_to;
+               ast_log(LOG_DEBUG, "We found a REFER!\n");
+               if (!strlen(p->context))
+                       strncpy(p->context, context, sizeof(p->context) - 1);
+               res = get_refer_info(p, req);
+               if (res < 0)
+                       transmit_response_with_allow(p, "404 Not Found", req);
+               else if (res > 0)
+                       transmit_response_with_allow(p, "484 Address Incomplete", req);
+               else
+                       transmit_response(p, "202 Accepted", req);
+               ast_log(LOG_DEBUG,"202 Accepted\n");
+               transfer_to = c->bridge;
+               if (transfer_to)
+                       ast_async_goto(transfer_to,"", p->refer_to,1, 1);
                        
        } else if (!strcasecmp(cmd, "CANCEL") || !strcasecmp(cmd, "BYE")) {
                copy_request(&p->initreq, req);
@@ -3055,9 +3078,9 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                transmit_response(p, "100 Trying", req);
                if ((res = register_verify(p, sin, req, e)) < 0) 
                        ast_log(LOG_NOTICE, "Registration from '%s' failed for '%s'\n", get_header(req, "To"), inet_ntoa(sin->sin_addr));
-               sip_send_mwi(p);
-               if (res < 1)
+               if (res < 1) {
                        sip_destroy(p);
+               }
        } else if (!strcasecmp(cmd, "ACK")) {
                /* Uhm, I haven't figured out the point of the ACK yet.  Are we
                   supposed to retransmit responses until we get an ack? 
@@ -3117,11 +3140,55 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
        return 1;
 }
 
+static int sip_send_mwi_to_peer(struct sip_peer *peer)
+{
+       /* Called with peerl lock, but releases it */
+       struct sip_pvt *p;
+       int hasmsgs;
+       char name[256] = "";
+       /* Check for messages */
+       hasmsgs = ast_app_has_voicemail(peer->mailbox);
+       
+       time(&peer->lastmsgcheck);
+       
+       /* Return now if it's the same thing we told them last time */
+       if (hasmsgs == peer->lastmsgssent) {
+               ast_pthread_mutex_unlock(&peerl.lock);
+               return 0;
+       }
+       
+       p = sip_alloc(NULL, NULL);
+       if (!p) {
+               ast_log(LOG_WARNING, "Unable to build sip pvt data for MWI\n");
+               ast_pthread_mutex_unlock(&peerl.lock);
+               return -1;
+       }
+       strncpy(name, peer->name, sizeof(name) - 1);
+       peer->lastmsgssent = hasmsgs;
+       ast_pthread_mutex_unlock(&peerl.lock);
+       if (create_addr(p, peer->name)) {
+               /* Maybe they're not registered, etc. */
+               sip_destroy(p);
+               return 0;
+       }
+       /* Recalculate our side, and recalculate Call ID */
+       memcpy(&p->ourip, myaddrfor(&p->sa.sin_addr), sizeof(p->ourip));
+       snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=%08x", inet_ntoa(p->ourip), ourport, p->branch);
+       build_callid(p->callid, sizeof(p->callid), p->ourip);
+       /* Send MWI */
+       transmit_notify(p, hasmsgs);
+       /* Destroy channel */
+       sip_destroy(p);
+       return 0;
+}
+
 static void *do_monitor(void *data)
 {
        int res;
        struct sip_pkt *p;
        struct sip_pvt *sip;
+       struct sip_peer *peer;
+       time_t t;
        /* Add an I/O event to our UDP socket */
        if (sipsock > -1) 
                ast_io_add(io, sipsock, sipsock_read, AST_IO_IN, NULL);
@@ -3165,6 +3232,19 @@ restartsearch:
                ast_pthread_mutex_lock(&monlock);
                if (res >= 0) 
                        ast_sched_runq(sched);
+               ast_pthread_mutex_lock(&peerl.lock);
+               peer = peerl.peers;
+               time(&t);
+               while(peer) {
+                       if (strlen(peer->mailbox) && (t - peer->lastmsgcheck > 10)) {
+                               sip_send_mwi_to_peer(peer);
+                               break;
+                       }
+                       peer = peer->next;
+               }
+               /* Remember, sip_send_mwi_to_peer releases the lock if we've called it */
+               if (!peer)
+                       ast_pthread_mutex_unlock(&peerl.lock);
                ast_pthread_mutex_unlock(&monlock);
        }
        /* Never reached */
@@ -3260,60 +3340,6 @@ static int sip_poke_peer(struct sip_peer *peer)
 }
 
 
-static int sip_send_mwi(struct sip_pvt *p)
-{
-       struct sip_request req;
-       int res;
-
-       if(strlen(p->mailbox)) {
-               ast_log(LOG_NOTICE, "mwi: check mailbox: %s\n", p->mailbox);
-               res = ast_app_has_voicemail(p->mailbox);
-               if(res) {
-                       ast_log(LOG_NOTICE, "mwi: mailbox has messages\n");
-                       reqprep(&req, p, "NOTIFY", 1);
-                       add_header(&req, "Event", "message-summary");
-                       add_header(&req, "Content-Type", "text/plain");
-                       add_line(&req, "Message-Waiting: yes\n");
-                       send_request(p, &req);
-
-               } else {
-
-                       ast_log(LOG_NOTICE, "mwi: mailbox does not contain messages\n");
-                        reqprep(&req, p, "NOTIFY", 1);
-                       add_header(&req, "Event", "message-summary");
-                        add_header(&req, "Content-Type", "text/plain");
-                       add_line(&req, "Message-Waiting: no\n");
-                       send_request(p, &req);
-               }
-
-       }
-       return 0;
-
-}
-
-static int sip_send_mwi_to_peer(struct sip_peer *peer)
-{
-       struct sip_pvt *p;
-       p = sip_alloc(NULL, NULL);
-       if (!p) {
-               ast_log(LOG_WARNING, "Unable to build sip pvt data for MWI\n");
-               return -1;
-       }
-       if (create_addr(p, peer->name)) {
-               sip_destroy(p);
-               return -1;
-       }
-       /* Recalculate our side, and recalculate Call ID */
-       memcpy(&p->ourip, myaddrfor(&p->sa.sin_addr), sizeof(p->ourip));
-       snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=%08x", inet_ntoa(p->ourip), ourport, p->branch);
-       build_callid(p->callid, sizeof(p->callid), p->ourip);
-       /* Send MWI */
-       sip_send_mwi(p);
-       /* Destroy channel */
-       sip_destroy(p);
-       return 0;
-}
-
 static struct ast_channel *sip_request(char *type, int format, void *data)
 {
        int oldformat;
@@ -3326,7 +3352,7 @@ static struct ast_channel *sip_request(char *type, int format, void *data)
        oldformat = format;
        format &= capability;
        if (!format) {
-               ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format);
+               ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format %d while capability is %d\n", oldformat, capability);
                return NULL;
        }
        p = sip_alloc(NULL, NULL);
@@ -3397,8 +3423,6 @@ static struct sip_user *build_user(char *name, struct ast_variable *v)
                                user->hascallerid=1;
                        } else if (!strcasecmp(v->name, "accountcode")) {
                                strncpy(user->accountcode, v->value, sizeof(user->accountcode)-1);
-                       } else if (!strcasecmp(v->name, "mailbox")) {
-                                strncpy(user->mailbox, v->value, sizeof(user->mailbox)-1);
                        } else if (!strcasecmp(v->name, "amaflags")) {
                                format = ast_cdr_amaflags2int(v->value);
                                if (format < 0) {
@@ -3451,6 +3475,7 @@ static struct sip_peer *build_peer(char *name, struct ast_variable *v)
                memset(peer, 0, sizeof(struct sip_peer));
                peer->expire = -1;
                peer->pokeexpire = -1;
+               peer->lastmsgssent = -1;
        }
        if (peer) {
                if (!found) {
@@ -3515,7 +3540,7 @@ static struct sip_peer *build_peer(char *name, struct ast_variable *v)
                        } else if (!strcasecmp(v->name, "username")) {
                                strncpy(peer->username, v->value, sizeof(peer->username)-1);
                        } else if (!strcasecmp(v->name, "mailbox")) {
-                                strncpy(peer->mailbox, v->value, sizeof(peer->mailbox)-1);
+                               strncpy(peer->mailbox, v->value, sizeof(peer->mailbox)-1);
                        } else if (!strcasecmp(v->name, "allow")) {
                                format = ast_getformatbyname(v->value);
                                if (format < 1) 
index 342038e..5244bbe 100755 (executable)
@@ -3320,6 +3320,8 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
                /* Assume calls are not idle calls unless we're told differently */
                i->isidlecall = 0;
 #endif
+               /* Assure there is no confmute on this channel */
+               zt_confmute(i, 0);
                if (startpbx) {
                        if (ast_pbx_start(tmp)) {
                                ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
@@ -5260,6 +5262,7 @@ static void *pri_dchannel(void *vpri)
                                                        pri->pvt[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
                                }
                                break;
+                       case PRI_EVENT_INFO_RECEIVED:
                        case PRI_EVENT_RING:
                                chan = e->ring.channel;
                                if ((chan < 1) || (chan > pri->channels)) {
@@ -5281,20 +5284,22 @@ static void *pri_dchannel(void *vpri)
                                if (!chan && (e->ring.flexible))
                                        chan = pri_find_empty_chan(pri);
                                if (chan) {
-                                       /* Get caller ID */
-                                       if (pri->pvt[chan]->use_callerid) {
-                                               if (strlen(e->ring.callingname)) {
-                                                       snprintf(pri->pvt[chan]->callerid, sizeof(pri->pvt[chan]->callerid), "\"%s\" <%s>", e->ring.callingname, e->ring.callingnum);
+                                       if (e->e==PRI_EVENT_RING) {
+                                               /* Get caller ID */
+                                               if (pri->pvt[chan]->use_callerid) {
+                                                       if (strlen(e->ring.callingname)) {
+                                                               snprintf(pri->pvt[chan]->callerid, sizeof(pri->pvt[chan]->callerid), "\"%s\" <%s>", e->ring.callingname, e->ring.callingnum);
+                                                       } else
+                                                               strncpy(pri->pvt[chan]->callerid, e->ring.callingnum, sizeof(pri->pvt[chan]->callerid)-1);
                                                } else
-                                                       strncpy(pri->pvt[chan]->callerid, e->ring.callingnum, sizeof(pri->pvt[chan]->callerid)-1);
-                                       } else
-                                               strcpy(pri->pvt[chan]->callerid, "");
+                                                       strcpy(pri->pvt[chan]->callerid, "");
+                                               strncpy(pri->pvt[chan]->rdnis, e->ring.redirectingnum, sizeof(pri->pvt[chan]->rdnis));
+                                       }
                                        /* Get called number */
                                        if (strlen(e->ring.callednum)) {
                                                strncpy(pri->pvt[chan]->exten, e->ring.callednum, sizeof(pri->pvt[chan]->exten)-1);
                                        } else
                                                strcpy(pri->pvt[chan]->exten, "s");
-                                       strncpy(pri->pvt[chan]->rdnis, e->ring.redirectingnum, sizeof(pri->pvt[chan]->rdnis));
                                        /* Make sure extension exists */
                                        if (ast_exists_extension(NULL, pri->pvt[chan]->context, pri->pvt[chan]->exten, 1, pri->pvt[chan]->callerid)) {
                                                /* Setup law */
@@ -5324,10 +5329,15 @@ static void *pri_dchannel(void *vpri)
                                                        pri->pvt[chan]->call = 0;
                                                }
                                        } else {
-                                               if (option_verbose > 2) 
-                                                       ast_verbose(VERBOSE_PREFIX_3 "Extension '%s' in context '%s' from '%s' does not exist.  Rejecting call on channel %d, span %d\n", 
-                                                               pri->pvt[chan]->exten, pri->pvt[chan]->context, pri->pvt[chan]->callerid, chan, pri->span);
-                                               pri_release(pri->pri, e->ring.call, PRI_CAUSE_UNALLOCATED);
+                                               if (ast_matchmore_extension(NULL, pri->pvt[chan]->context, pri->pvt[chan]->exten, 1, pri->pvt[chan]->callerid))
+                                               {
+                                                       if (e->e==PRI_EVENT_RING) pri_need_more_info(pri->pri, e->ring.call, chan, 1);
+                                               } else {
+                                                       if (option_verbose > 2)
+                                                               ast_verbose(VERBOSE_PREFIX_3 "Extension '%s' in context '%s' from '%s' does not exist.  Rejecting call on channel %d, span %d\n",
+                                                       pri->pvt[chan]->exten, pri->pvt[chan]->context, pri->pvt[chan]->callerid, chan, pri->span);
+                                                       pri_release(pri->pri, e->ring.call, PRI_CAUSE_UNALLOCATED);
+                                               }
                                        }
                                } else 
                                        pri_release(pri->pri, e->ring.call, PRI_CAUSE_REQUESTED_CHAN_UNAVAIL);
index 2de8abd..ac98a6c 100755 (executable)
@@ -1,8 +1,11 @@
 /******************************************************************************
 $Id$
 $Log$
-Revision 1.15  1999/12/01 05:25:58  markster
-Version 0.3.0 from FTP
+Revision 1.16  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.1  1999/12/01 05:25:58  markster
 Start on the Internet Phone Jack channel
diff --git a/cli.c b/cli.c
index 14cf395..d7ebcc7 100755 (executable)
--- a/cli.c
+++ b/cli.c
@@ -198,6 +198,7 @@ static int handle_chanlist(int fd, int argc, char *argv[])
 #define FORMAT_STRING  "%15s  (%-10s %-12s %-4d) %7s %-12s  %-15s\n"
 #define FORMAT_STRING2 "%15s  (%-10s %-12s %-4s) %7s %-12s  %-15s\n"
        struct ast_channel *c=NULL;
+       int numchans = 0;
        if (argc != 2)
                return RESULT_SHOWUSAGE;
        c = ast_channel_walk(NULL);
@@ -205,8 +206,10 @@ static int handle_chanlist(int fd, int argc, char *argv[])
        while(c) {
                ast_cli(fd, FORMAT_STRING, c->name, c->context, c->exten, c->priority, ast_state2str(c->_state),
                c->appl ? c->appl : "(None)", c->data ? ( strlen(c->data) ? c->data : "(Empty)" ): "(None)");
+               numchans++;
                c = ast_channel_walk(c);
        }
+       ast_cli(fd, "%d active channel(s)\n", numchans);
        return RESULT_SUCCESS;
 }
 
diff --git a/codecs/.cvsignore b/codecs/.cvsignore
new file mode 100755 (executable)
index 0000000..428ba00
--- /dev/null
@@ -0,0 +1,2 @@
+g723.1
+g723.1b
index c90f2c1..c9d078a 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -79,9 +82,12 @@ static integer c__1 = 1;
 /*     ANALYS Version 55 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -246,9 +252,12 @@ static integer c__1 = 1;
     real phi[100]      /* was [10][10] */, psi[10];
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -277,9 +286,12 @@ static integer c__1 = 1;
 /* Frame size, Prediction order, Pitch period */
 /*       Arguments to ANALYS */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index c0dedea..6c15ebb 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -48,9 +51,12 @@ extern struct {
 /*     BSYNZ Version 54 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -144,9 +150,12 @@ extern struct {
     real lpi0, hpi0;
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -175,9 +184,12 @@ extern struct {
 /* Frame size, Prediction order, Pitch period */
 /*       Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index ebd5631..5b60082 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -35,9 +38,12 @@ extern int chanrd_(integer *order, integer *ipitv, integer *irms, integer *irc,
 /*     CHANL Version 49 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 5aa29e4..b34480a 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern int dcbias_(integer *len, real *speech, real *sigout);
 /*     DCBIAS Version 50 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 51319da..3e7b574 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -53,9 +56,12 @@ static integer c__2 = 2;
 /*     DECODE Version 54 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -188,9 +194,12 @@ static integer c__2 = 2;
     integer ishift, errcnt, lsb;
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -219,9 +228,12 @@ static integer c__2 = 2;
 /* Frame size, Prediction order, Pitch period */
 /*       Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 52e2088..a79d84a 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -37,9 +40,12 @@ extern int deemp_(real *x, integer *n, struct lpc10_decoder_state *st);
 /*     DEEMP Version 48 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 918b68c..734ad96 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern int difmag_(real *speech, integer *lpita, integer *tau, integer *ltau, in
 /*     DIFMAG Version 49 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:14  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:14  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 227c978..7a5c136 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -47,9 +50,12 @@ extern struct {
 /*     DYPTRK Version 52 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -136,9 +142,12 @@ extern struct {
 
 /*       Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index e173317..81093ac 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -43,9 +46,12 @@ static integer c__2 = 2;
 /*     ENCODE Version 54 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -128,9 +134,12 @@ static integer c__2 = 2;
     integer idel, nbit, i__, j, i2, i3, mrk;
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -151,9 +160,12 @@ static integer c__2 = 2;
 /* Frame size, Prediction order, Pitch period */
 /*       Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index d5b9700..f159dd5 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern int energy_(integer *len, real *speech, real *rms);
 /*     ENERGY Version 50 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 594d370..7f4bcf2 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
index 0e7e8dc..e72c307 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
index a9665d6..c4848b1 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern int ham84_(integer *input, integer *output, integer *errcnt);
 /*     HAM84 Version 45G */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index b223d43..7dae73b 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -39,9 +42,12 @@ extern int inithp100_(void);
 /*      HP100 Version 55 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 203c7ac..5604591 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern int invert_(integer *order, real *phi, real *psi, real *rc);
 /*     INVERT Version 45G */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -91,9 +97,12 @@ extern int invert_(integer *order, real *phi, real *psi, real *rc);
 
 /*       Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 6f0b2d1..a178442 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern int irc2pc_(real *rc, real *pc, integer *order, real *gprime, real *g2pas
 /*     IRC2PC Version 48 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -82,9 +88,12 @@ extern int irc2pc_(real *rc, real *pc, integer *order, real *gprime, real *g2pas
 
 /*     Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 2f55901..98184e4 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern int ivfilt_(real *lpbuf, real *ivbuf, integer *len, integer *nsamp, real
 /*     IVFILT Version 48 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 5804fc5..ef7d4ee 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 00:20:06  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.1  2000/01/05 00:20:06  markster
 Add broken lpc10 code...  It's not too far from working I don't think...
index ea68c61..9929d1f 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -58,9 +61,12 @@ static integer c__10 = 10;
 /* ***************************************************************** */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -113,9 +119,12 @@ static integer c__10 = 10;
     real rms;
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -147,9 +156,12 @@ static integer c__10 = 10;
 /* Frame size, Prediction order, Pitch period */
 /*       Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 680da5b..a3222af 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -50,9 +53,12 @@ static integer c__10 = 10;
 /* ***************************************************************** */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -109,9 +115,12 @@ static integer c__10 = 10;
 
 /*       Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index bd6b01a..90d61b9 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -45,9 +48,12 @@ struct {
 /* ***************************************************************** */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -71,9 +77,12 @@ struct {
 {
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -97,9 +106,12 @@ struct {
 /*   LPC Configuration parameters: */
 /* Frame size, Prediction order, Pitch period */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 3f599f5..9dff6b5 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern int lpfilt_(real *inbuf, real *lpbuf, integer *len, integer *nsamp);
 /*     LPFILT Version 55 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index fcd3d7d..376c46c 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern integer median_(integer *d1, integer *d2, integer *d3);
 /*     MEDIAN Version 45G */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 63bcf5c..0789cfa 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern int mload_(integer *order, integer *awins, integer *awinf, real *speech,
 /*     MLOAD Version 48 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 8a115f1..1e9c1d0 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -41,9 +44,12 @@ static real c_b2 = 1.f;
 /*     ONSET Version 49 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -143,9 +149,12 @@ static real c_b2 = 1.f;
 
 /*       Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 52e41cc..b5bffde 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -37,9 +40,12 @@ extern int pitsyn_(integer *order, integer *voice, integer *pitch, real *rms, re
 /*     PITSYN Version 53 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -143,9 +149,12 @@ extern int pitsyn_(integer *order, integer *voice, integer *pitch, real *rms, re
 
 /*       Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 3db692c..7e705e7 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2001/04/12 21:27:53  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.3  2001/04/12 21:27:53  markh
 app_record now supports wildcards of sort so your output file is not overwritten every time it's run.  File.h got a documentation update on the ast_fileexists to include the return call.  Watch out for the placea.c placev.c code, it's updates have not been tested yet.  Just a few parenthesis to make it compile nicer on newer gcc versions with all the -W flags set.
@@ -32,9 +35,12 @@ extern int placea_(integer *ipitch, integer *voibuf, integer *obound, integer *a
 /*     PLACEA Version 48 */
 
 /* $Log$
- * Revision 1.13  2001/04/12 21:27:53  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.3  2001/04/12 21:27:53  markh
 /* app_record now supports wildcards of sort so your output file is not overwritten every time it's run.  File.h got a documentation update on the ast_fileexists to include the return call.  Watch out for the placea.c placev.c code, it's updates have not been tested yet.  Just a few parenthesis to make it compile nicer on newer gcc versions with all the -W flags set.
 /*
index 93dbd6d..eae5fcd 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2001/04/12 21:27:53  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.3  2001/04/12 21:27:53  markh
 app_record now supports wildcards of sort so your output file is not overwritten every time it's run.  File.h got a documentation update on the ast_fileexists to include the return call.  Watch out for the placea.c placev.c code, it's updates have not been tested yet.  Just a few parenthesis to make it compile nicer on newer gcc versions with all the -W flags set.
@@ -32,9 +35,12 @@ extern int placev_(integer *osbuf, integer *osptr, integer *oslen, integer *obou
 /*     PLACEV Version 48 */
 
 /* $Log$
- * Revision 1.13  2001/04/12 21:27:53  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.3  2001/04/12 21:27:53  markh
 /* app_record now supports wildcards of sort so your output file is not overwritten every time it's run.  File.h got a documentation update on the ast_fileexists to include the return call.  Watch out for the placea.c placev.c code, it's updates have not been tested yet.  Just a few parenthesis to make it compile nicer on newer gcc versions with all the -W flags set.
 /*
index f6dec77..05fb9fb 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern int preemp_(real *inbuf, real *pebuf, integer *nsamp, real *coef, real *z
 /*     PREEMP Version 55 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 53c14ba..e21b4ca 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -44,9 +47,12 @@ static integer c__1 = 1;
 /*     PREPRO Version 48 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 4bee0e8..ec3ef45 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -37,9 +40,12 @@ extern integer random_(struct lpc10_decoder_state *st);
 /*     RANDOM Version 49 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 17d3c19..a2fe867 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -29,9 +32,12 @@ extern int rcchk_(integer *order, real *rc1f, real *rc2f);
 /*     RCCHK Version 45G */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 4f8efac..33becea 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:39  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:39  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -58,9 +61,12 @@ static real c_b2 = .7f;
 /*     SYNTHS Version 54 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -178,9 +184,12 @@ static real c_b2 = .7f;
     real rci[160]      /* was [10][16] */;
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -209,9 +218,12 @@ static real c_b2 = .7f;
 /* Frame size, Prediction order, Pitch period */
 /*       Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:39  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:39  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index d3b49c9..c04c9dd 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:40  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:40  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -30,9 +33,12 @@ extern int tbdm_(real *speech, integer *lpita, integer *tau, integer *ltau, real
 /*     TBDM Version 49 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:40  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:40  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 2c92aad..ae7eb15 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:40  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:40  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -48,9 +51,12 @@ extern struct {
 /*     VOICIN Version 52 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:40  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:40  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
@@ -290,9 +296,12 @@ s*/
 /*     Global Variables: */
 /*       Arguments */
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:40  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:40  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index 3bd2d58..5973b9a 100755 (executable)
@@ -1,8 +1,11 @@
 /*
 
 $Log$
-Revision 1.13  2000/01/05 08:20:40  markster
-Version 0.3.0 from FTP
+Revision 1.14  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
+
+Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+mer feb 12 14:56:57 CET 2003
 
 Revision 1.2  2000/01/05 08:20:40  markster
 Some OSS fixes and a few lpc changes to make it actually work
@@ -33,9 +36,12 @@ static real c_b2 = 1.f;
 /*     VPARMS Version 50 */
 
 /* $Log$
- * Revision 1.13  2000/01/05 08:20:40  markster
- * Version 0.3.0 from FTP
+ * Revision 1.14  2003/02/12 13:59:15  matteo
+ * mer feb 12 14:56:57 CET 2003
  *
+/* Revision 1.1.1.1  2003/02/12 13:59:15  matteo
+/* mer feb 12 14:56:57 CET 2003
+/*
 /* Revision 1.2  2000/01/05 08:20:40  markster
 /* Some OSS fixes and a few lpc changes to make it actually work
 /*
index b408feb..325cf2e 100755 (executable)
@@ -2,8 +2,7 @@
 ; Static extension configuration files, used by
 ; the pbx_config module.
 ;
-; The "General" category is for certain variables.  All other categories
-; are interpreted as extension contexts
+; The "General" category is for certain variables.  
 ;
 [general]
 ;
 ; XXX Not yet implemented XXX
 ;
 static=yes
-
 ;
-; if stati=yes and writeprotect=no, you can save dialplan by
+; if static=yes and writeprotect=no, you can save dialplan by
 ; CLI command 'save dialplan' too
 ;
 writeprotect=no
 
-; Remote things always ring all phones first.
-;[remote]
-;exten => s,1,Dial,AdtranVoFR/4200&AdtranVoFR/4151&AdtranVoFR/4300|15
-;exten => s,2,Goto,default|s|2
-;include => default
+;
+; The "Globals" category contains global variables that can be referenced
+; in the dialplan with ${VARIABLE}
+;
+[globals]
+CONSOLE=Console/dsp                            ; Console interface for demo
+;CONSOLE=Zap/1
+;CONSOLE=Phone/phone0
+IAXINFO=guest                                  ; IAXtel username/password
+;IAXINFO=myuser:mypass
+TRUNK=Zap/g2                                   ; Trunk interface
+;TRUNK=IAX/user:pass@provider
+
+;
+; Any category other than "General" and "Globals" represent 
+; extension contexts, which are collections of extensions.  
+;
+; Extension names may be numbers, letters, or combinations
+; thereof. If an extension name is prefixed by a '_'
+; character, it is interpreted as a pattern rather than a
+; literal.  In patterns, some characters have special meanings:
+;
+;   X - any digit from 0-9
+;   N - any digit from 2-9
+;   [1235-9] - any digit in the brackets (in this example, 1,2,3,5,6,7,8,9)
+;   . - wildcard, matches anything remaining (e.g. _9011. matches anything starting with 9011 including 9011)
+;
+; For example the extenion _NXXXXXX would match normal 7 digit dialings, while
+; _1NXXNXXXXXX would represent an area code plus phone number
+; preceeded by a one.
+;
+; Contexts contain several lines, one for each step of each
+; extension, which can take one of two forms as listed below,
+; with the first form being preferred.  One may include another
+; context in the current one as well, optionally with a
+; date and time.  Included contexts are included in the order
+; they are listed.
+;
+;[context]
+;exten => someexten,priority,application(arg1,arg2,...)
+;exten => someexten,priority,application,arg1|arg2...
 ;
 ; Timing list for includes is 
 ;
 ;   <time range>|<days of week>|<days of month>|<months>
 ;
 ;include => daytime|9:00-17:00|mon-fri|*|*
+;
+; ignorepat can be used to instruct drivers to not cancel dialtone upon
+; receipt of a particular pattern.  The most commonly used example is
+; of course '9' like this:
+;
+;ignorepat => 9
+;
+; so that dialtone remains even after dialing a 9.
+;
 
 ;
 ; Here are the entries you need to participate in the IAXTEL
@@ -39,35 +82,73 @@ writeprotect=no
 ; there are exceptions.  For more information, and to sign
 ; up, please go to www.gnophone.com or www.iaxtel.com
 ;
-[iaxtel]
-exten => _91NXXNXXXXXX,1,StripMSD,1
-exten => _1NXXNXXXXXX,2,Dial,IAX/iaxtel.com/BYEXTENSION@iaxtel
+[iaxtel700]
+exten => _91700NXXXXXX,1,Dial(IAX/${IAXINFO}@iaxtel.com/${EXTEN-1}@iaxtel)
 
-[provider]
+[iaxprovider]
 ;switch => IAX/user:[key]@myserver/mycontext
 
-; Local stuff
-[local]
-; Special extension for local phone numbers, long distance, etc, going
-; out via the Frame Relay interface.  Patterns are prefixed with "_", which
-; is ignored.
+[trunkint]
 ;
-; ignorepat can be used to instruct drivers to not cancel dialtone upon
-; receipt of a particular pattern.  The most commonly used example is
-; of course '9' like this:
+; International long distance through trunk
 ;
-; ignorepat => 9
+exten => 9011.,1,Dial(${TRUNK}/${EXTEN-1})
+exten => 9011.,2,Congestion
+
+[trunkld]
 ;
-; so that dialtone remains even after dialing a 9.
+; Long distance context accessed through trunk
+;
+exten => _91NXXNXXXXXX,1,Dial(${TRUNK}/${EXTEN-1})
+exten => _91NXXNXXXXXX,2,Congestion
+
+[trunklocal]
+;
+; Local seven-digit dialing accessed through trunk interface
+;
+exten => _9NXXXXXX,1,Dial(${TRUNK}/${EXTEN-1})
+exten => _9NXXXXXX,2,Congestion
+
+[trunktollfree]
+;
+; Long distance context accessed through trunk interface
+;
+exten => _91800NXXXXXX,1,Dial(${TRUNK}/${EXTEN-1})
+exten => _91800NXXXXXX,2,Congestion
+exten => _91888NXXXXXX,1,Dial(${TRUNK}/${EXTEN-1})
+exten => _91888NXXXXXX,2,Congestion
+exten => _91877NXXXXXX,1,Dial(${TRUNK}/${EXTEN-1})
+exten => _91877NXXXXXX,2,Congestion
+exten => _91866NXXXXXX,1,Dial(${TRUNK}/${EXTEN-1})
+exten => _91866NXXXXXX,2,Congestion
+
+[international]
+;
+; Master context for international long distance
+;
+ignorepat => 9
+include => longdistance
+include => trunkint
+
+[longdistance]
+;
+; Master context for long distance
+;
+ignorepat => 9
+include => local
+include => trunkld
+
+[local]
+;
+; Master context for local, toll-free, and iaxtel calls only
 ;
 ignorepat => 9
-;exten => _9NXXXXXX,1,Dial,IAX/user:[key]@myserver/BYEXTENSION
-;exten => _91NXXNXXXXXX,1,Dial,IAX/user:[key]@myserver/BYEXTENSION
-;exten => _9911,1,Dial,IAX/user:[key]@myserver/BYEXTENSION
-include => parkedcalls
 include => default
+include => parkedcalls
+include => trunklocal
+include => iaxtel700
+include => trunktollfree
 include => provider
-include => iaxtel
 ;
 ; You can use an alternative switch type as well, to resolve
 ; extensions that are not known here, for example with remote 
@@ -75,6 +156,18 @@ include => iaxtel
 ; 
 ; switch => IAX/user:password@bigserver/local
 
+[macro-stdexten];
+;
+; Standard extension macro:
+;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
+;   ${ARG2} - Device(s) to ring
+;
+exten => s,1,Dial(${ARG2},20)                                  ; Ring the interface, 20 seconds maximum
+exten => s,2,Voicemail(u${ARG1})                               ; If unavailable, send to voicemail w/ unavail announce
+exten => s,3,Goto(default,s,1)                                 ; If they press #, return to start
+exten => s,102,Voicemail(b${ARG1})                             ; If busy, send to voicemail w/ busy announce
+exten => s,103,Goto(default,s,1)                               ; If they press #, return to start
+
 
 [demo]
 ;
@@ -84,71 +177,85 @@ exten => s,1,Wait,1                        ; Wait a second, just for fun
 exten => s,2,Answer                    ; Answer the line
 exten => s,3,DigitTimeout,5            ; Set Digit Timeout to 5 seconds
 exten => s,4,ResponseTimeout,10                ; Set Response Timeout to 10 seconds
-exten => s,5,BackGround,demo-congrats  ; Play a congratulatory message
-exten => s,6,BackGround,demo-instruct  ; Play some instructions
+exten => s,5,BackGround(demo-congrats) ; Play a congratulatory message
+exten => s,6,BackGround(demo-instruct) ; Play some instructions
 
-exten => 2,1,BackGround,demo-moreinfo  ; Give some more information.
-exten => 2,2,Goto,s|6
+exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
+exten => 2,2,Goto(s,6)
 
-exten => 3,1,SetLanguage,fr            ; Set language to french
-exten => 3,2,Goto,s|5                  ; Start with the congratulations
+exten => 3,1,SetLanguage(fr)           ; Set language to french
+exten => 3,2,Goto(s,5)                 ; Start with the congratulations
 
+exten => 1000,1,Goto(default,s,1)
 ;
 ; We also create an example user, 1234, who is on the console and has
 ; voicemail, etc.
 ;
-exten => 1234,1,Playback,transfer|skip         ; "Please hold while..." 
+exten => 1234,1,Playback(transfer,skip)                ; "Please hold while..." 
                                        ; (but skip if channel is not up)
-exten => 1234,2,Dial,Console/dsp|10    ; Ring the console, 10 secs max
-exten => 1234,3,Voicemail,u1234                ; Send to voicemail...
-exten => 1234,5,Goto,s|6                       ; Start over
-exten => 1234,103,Voicemail,b1234      ; (2 + 101) "I'm on the phone"
-exten => 1234,104,Goto,5                       ; Go to voicemail, etc.
+exten => 1234,2,Macro(stdexten,1234,${CONSOLE})
 
-exten => 1235,1,Goto,1234|3            ; Right to voicemail
+exten => 1235,1,Voicemail(u1234)               ; Right to voicemail
 
-exten => 1236,1,Dial,Console/dsp               ; Ring forever
-exten => 1236,2,Goto,1234|103          ; Unless busy
+exten => 1236,1,Dial(Console/dsp)              ; Ring forever
+exten => 1236,2,Voicemail(u1234)               ; Unless busy
 
 ;
 ; # for when they're done with the demo
 ;
-exten => #,1,Playback,demo-thanks              ; "Thanks for trying the demo"
+exten => #,1,Playback(demo-thanks)             ; "Thanks for trying the demo"
 exten => #,2,Hangup                    ; Hang them up.
 
 ;
 ; A timeout and "invalid extension rule"
 ;
-exten => t,1,Goto,#|1                  ; If they take too long, give up
-exten => i,1,Playback,invalid          ; "That's not valid, try again"
+exten => t,1,Goto(#,1)                 ; If they take too long, give up
+exten => i,1,Playback(invalid)         ; "That's not valid, try again"
 
 ;
 ; Create an extension, 500, for dialing the
 ; Asterisk demo.
 ;
-exten => 500,1,Playback,demo-abouttotry        ; Let them know what's going on
-exten => 500,2,Dial,IAX/asterisk@demo  ; Call the Asterisk demo
-exten => 500,3,Playback,demo-nogo              ; Couldn't connect to the demo site
-exten => 500,4,Goto,s|6                        ; Return to the start over message.
+exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
+exten => 500,2,Dial(IAX/guest@misery.digium.com/s@default)     ; Call the Asterisk demo
+exten => 500,3,Playback(demo-nogo)     ; Couldn't connect to the demo site
+exten => 500,4,Goto(s,6)               ; Return to the start over message.
 
 ;
 ; Create an extension, 600, for evaulating echo latency.
 ;
-exten => 600,1,Playback,demo-echotest  ; Let them know what's going on
+exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
 exten => 600,2,Echo                    ; Do the echo test
-exten => 600,3,Playback,demo-echodone  ; Let them know it's over
-exten => 600,4,Goto,s|6                        ; Start over
+exten => 600,3,Playback(demo-echodone) ; Let them know it's over
+exten => 600,4,Goto(s,6)               ; Start over
 
 ;
 ; Give voicemail at extension 8500
 ;
 exten => 8500,1,VoicemailMain
-exten => 8500,2,Goto,s|6
+exten => 8500,2,Goto(s,6)
 ;
 ; Here's what a phone entry would look like (IXJ for example)
 ;
-;exten => 1265,1,Dial,Phone/phone0|15
-;exten => 1265,2,Goto,s|5
+;exten => 1265,1,Dial(Phone/phone0,15)
+;exten => 1265,2,Goto(s,5)
+
+;[mainmenu]
+;
+; Example "main menu" context with submenu
+;
+;exten => s,1,Answer
+;exten => s,2,Background(thanks)               ; "Thanks for calling press 1 for sales, 2 for support, ..."
+;exten => 1,1,Goto(submenu,s,1)
+;exten => 2,1,Hangup
+;include => default
+;
+;[submenu]
+;exten => s,1,Ringing                                  ; Make them comfortable with 2 seconds of ringback
+;exten => s,2,Wait,2
+;exten => s,3,Background(submenuopts)  ; "Thanks for calling the sales department.  Press 1 for steve, 2 for..."
+;exten => 1,1,Goto(default,steve,1)
+;exten => 2,1,Goto(default,mark,2)
 
 [default]
 ;
@@ -157,95 +264,29 @@ exten => 8500,2,Goto,s|6
 ;
 include => demo
 
-; This is a more complicated sample extension configuration, similar to
-; what we used to use at LSS.
-
-;[default]
-;exten => s,1,Wait,0
-;exten => s,2,Answer
-;exten => s,3,DigitTimeout,5
-;exten => s,4,ResponseTimeout,10
-;exten => s,5,BackGround,welcome
-;exten => *,1,Directory,default
-;exten => *,2,Goto,s|4
-;exten => #,1,Playback,goodbye
-;exten => #,2,Hangup
-;exten => 100,1,Goto,other|s|1
-;exten => 200,1,Intercom
-;exten => 400,1,MP3Player,song8.mp3
-;exten => 401,1,MP3Player,sample.mp3
-;exten => 402,1,MP3Player,sunscreen.mp3
-;exten => 403,1,MP3Player,http://trode.vergenet.net:8000
-;exten => 404,1,MP3Player,http://216.32.166.94:14900
-;exten => 405,1,Playback,sample
-;
-; Here's the template for a typical extension, carefully broken apart
-; for analysis.  The others are pretty much the same, but not as well
-; documented.
-;
-; Step 1:  Play back a "Please hold while I try that extension" message
-;exten => 4300,1,Playback,transfer
-; Step 2:  Dial the numbers where Ben is likely to be.  Try for no more
-;          than 15 seconds.
-;exten => 4300,2,Dial,AdtranVoFR/4300|15
-; Step 3:  Send them to voicemail, preceeded by their unavailable message.
-;exten => 4300,3,Voicemail,u4300
-; Step 4:  If they return from voicemail, go back to the top
-;exten => 4300,4,Goto,s|4
-; Step 103: If the Dialing is busy, it will try here first.  We'll play a
-;           special "I'm busy" message and send them to voicemail
-;exten => 4300,103,Voicemail,b4300
-; Step 104: And then continue from whereever the other would
-;exten => 4300,104,Goto,4
-; Exten. 4301: Provide a short-circuit so we can transfer striaght to 
-;              voicemail.
-;exten => 4301,1,Goto,4300|3
-; Exten. 4302: Provide a way to ring a given phone indefinitely
-;exten => 4302,1,Dial,AdtranVoFR/4300
-
-;exten => 4200,1,Playback,transfer
-;exten => 4200,2,Dial,AdtranVoFR/4200|15
-;exten => 4200,3,Playback,vm/4200/unavail
-;exten => 4200,4,Voicemail,4200
-;exten => 4200,5,Goto,s|4
-;exten => 4200,103,Playback,vm/4200/busy
-;exten => 4200,104,Goto,4
-;exten => 4201,1,Goto,4200|3
-;exten => 4202,1,Dial,AdtranVoFR/4200
-
-;exten => 4110,1,Playback,transfer
-;exten => 4110,2,Dial,AdtranVoFR/4110|15
-;exten => 4110,2,Wait,5
-;exten => 4110,3,Playback,vm/4110/unavail
-;exten => 4110,4,Voicemail,4110
-;exten => 4110,5,Goto,s|4
-;exten => 4110,103,Playback,vm/4110/busy
-;exten => 4110,104,Goto,4
-;exten => 4111,1,Goto,4110|3
-;exten => 4112,1,Dial,AdtranVoFR/4110
-;exten => 4113,1,Voicemail,s4110
 
-;exten => 8500,1,VoicemailMain
-;exten => 8500,2,Goto,s|4
-;exten => 762,1,Playback,somepeople
-;exten => 762,2,Wait,4
-;exten => 762,3,Goto,s|4
-
-; Timeout stuff...  We could send to an operator, or just ditch them.
-;exten => t,1,Goto,#|1
-;exten => i,1,BackGround,invalid
-include => parkedcalls
+; Real extensions would go here.  Generally you want real extensions to be 4 or 5
+; digits long (although there is no such requirement) and start with a single
+; digit that is fairly large (like 6 or 7) so that you have plenty of room to
+; overlap extensions and menu options without conflict.  You can alias them with
+; names, too and use global variables
 
-;[other]
-;exten => s,1,Playback,digits/9
-;exten => s,2,Playback,digits/8
-;exten => s,3,Playback,digits/7
-;exten => s,4,Goto,100|1
-;exten => 100,1,Playback,digits/6
-;exten => 100,2,Playback,digits/5
-;exten => 100,3,Goto,default|s|4
-
-;[outboundpri]
-;exten => _91NXXNXXXXXX,1,StripMSD,1
-;exten => _1NXXNXXXXXX,2,Dial,Zap/g2/BYEXTENSION
-;ignorepat => 9
+
+;exten => 6275,Macro(stdexten,6275,${MARK})                    ; assuming ${MARK} is something like Zap/2
+;exten => mark,1,Goto(6275|1)                                          ; alias mark to 6275
+;exten => 6236,Macro(stdexten,6236,${WIL})                     ; Ditto for wil
+;exten => wil,1,Goto(6236|1)
+;
+; Some other handy things are an extension for checking voicemail via
+; voicemailmain
+;
+;exten => 8500,1,VoicemailMain
+;exten => 8500,2,Hangup
+;
+; Or a conference room (you'll need to edit meetme.conf to enable this room)
+;
+;exten => 8600,1,Meetme,1234
+;
+; For more information on applications, just type "show applications" at your
+; friendly Asterisk CLI prompt.
+;
diff --git a/editline/.cvsignore b/editline/.cvsignore
new file mode 100755 (executable)
index 0000000..995bc1a
--- /dev/null
@@ -0,0 +1,22 @@
+np/vis.o_a
+np/unvis.o_a
+np/strlcpy.o_a
+np/strlcat.o_a
+np/fgetln.o_a
+vi.h
+tokenizer.o_a
+readline.o_a
+history.o_a
+help.h
+help.c
+fcns.h
+fcns.c
+emacs.h
+editline.o_a
+editline.c
+config.status
+config.log
+config.h
+common.h
+config.cache
+Makefile
diff --git a/editline/np/.cvsignore b/editline/np/.cvsignore
new file mode 100755 (executable)
index 0000000..67d3a1d
--- /dev/null
@@ -0,0 +1,5 @@
+vis.o_a
+unvis.o_a
+strlcpy.o_a
+strlcat.o_a
+fgetln.o_a
index 8e18bbc..f6034b6 100755 (executable)
@@ -435,6 +435,10 @@ struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con,
        struct ast_ignorepat *ip);
 struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw);
 
+extern char *pbx_builtin_getvar_helper(struct ast_channel *chan, char *name);
+extern void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value);
+extern void pbx_builtin_clear_globals(void);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif
index 8b21767..8137eb3 100755 (executable)
@@ -44,6 +44,10 @@ void ast_rtp_set_data(struct ast_rtp *rtp, void *data);
 
 int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *f);
 
+struct ast_frame *ast_rtp_read(struct ast_rtp *rtp);
+
+int ast_rtp_fd(struct ast_rtp *rtp);
+
 int ast_rtp_senddigit(struct ast_rtp *rtp, char digit);
 
 int ast_rtp_settos(struct ast_rtp *rtp, int tos);
diff --git a/pbx.c b/pbx.c
index cd6389f..59cb83b 100755 (executable)
--- a/pbx.c
+++ b/pbx.c
@@ -145,10 +145,12 @@ static int pbx_builtin_ringing(struct ast_channel *, void *);
 static int pbx_builtin_congestion(struct ast_channel *, void *);
 static int pbx_builtin_busy(struct ast_channel *, void *);
 static int pbx_builtin_setvar(struct ast_channel *, void *);
+static int pbx_builtin_noop(struct ast_channel *, void *);
 static int pbx_builtin_gotoif(struct ast_channel *, void *);
 void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value);
 char *pbx_builtin_getvar_helper(struct ast_channel *chan, char *name);
 
+static struct varshead globals = AST_LIST_HEAD_INITIALIZER(varshead);
 
 static struct pbx_builtin {
        char name[AST_MAX_APP];
@@ -261,6 +263,10 @@ static struct pbx_builtin {
 "Set variable to value",
 "  Setvar(#n=value): Sets variable n to value" },
 
+       { "NoOp", pbx_builtin_noop,
+"No operation",
+"  NoOp(): No-operation; Does nothing." },
+
        { "GotoIf", pbx_builtin_gotoif,
 "Conditional goto",
 "  GotoIf(Condition?label1:label2): Go to label 1 if condition is\n"
@@ -417,47 +423,83 @@ static void pbx_destroy(struct ast_pbx *p)
        free(p);
 }
 
+#define EXTENSION_MATCH_CORE(data,pattern,match) {\
+       /* All patterns begin with _ */\
+       if (pattern[0] != '_') \
+               return 0;\
+       /* Start optimistic */\
+       match=1;\
+       pattern++;\
+       while(match && *data && *pattern && (*pattern != '/')) {\
+               switch(toupper(*pattern)) {\
+               case '[': \
+               {\
+                       int i,border=0;\
+                       char *where;\
+                       match=0;\
+                       pattern++;\
+                       where=strchr(pattern,']');\
+                       if (where)\
+                               border=(int)(where-pattern);\
+                       if (!where || border > strlen(pattern)) {\
+                               ast_log(LOG_WARNING, "Wrong usage of [] in the extension\n");\
+                               return match;\
+                       }\
+                       for (i=0; i<border; i++) {\
+                               int res=0;\
+                               if (i+2<border)\
+                                       if (pattern[i+1]=='-') {\
+                                               if (*data >= pattern[i] && *data <= pattern[i+2]) {\
+                                                       res=1;\
+                                               } else {\
+                                                       i+=2;\
+                                                       continue;\
+                                               }\
+                                       }\
+                               if (res==1 || *data==pattern[i]) {\
+                                       match = 1;\
+                                       break;\
+                               }\
+                       }\
+                       pattern+=border;\
+                       break;\
+               }\
+               case 'N':\
+                       if ((*data < '2') || (*data > '9'))\
+                               match=0;\
+                       break;\
+               case 'X':\
+                       if ((*data < '0') || (*data > '9'))\
+                               match = 0;\
+                       break;\
+               case 'Z':\
+                       if ((*data < '1') || (*data > '9'))\
+                               match = 0;\
+                       break;\
+               case '.':\
+                       /* Must match */\
+                       return 1;\
+               case ' ':\
+               case '-':\
+                       /* Ignore these characters */\
+                       data--;\
+                       break;\
+               default:\
+                       if (*data != *pattern)\
+                               match =0;\
+               }\
+               data++;\
+               pattern++;\
+       }\
+}
+
 int ast_extension_match(char *pattern, char *data)
 {
        int match;
        /* If they're the same return */
        if (!strcasecmp(pattern, data))
                return 1;
-       /* All patterns begin with _ */
-       if (pattern[0] != '_') 
-               return 0;
-       /* Start optimistic */
-       match=1;
-       pattern++;
-       while(match && *data && *pattern && (*pattern != '/')) {
-               switch(toupper(*pattern)) {
-               case 'N':
-                       if ((*data < '2') || (*data > '9'))
-                               match=0;
-                       break;
-               case 'X':
-                       if ((*data < '0') || (*data > '9'))
-                               match = 0;
-                       break;
-               case 'Z':
-                       if ((*data < '1') || (*data > '9'))
-                               match = 0;
-                       break;
-               case '.':
-                       /* Must match */
-                       return 1;
-               case ' ':
-               case '-':
-                       /* Ignore these characters */
-                       data--;
-                       break;
-               default:
-                       if (*data != *pattern)
-                               match =0;
-               }
-               data++;
-               pattern++;
-       }
+       EXTENSION_MATCH_CORE(data,pattern,match);
        /* Must be at the end of both */
        if (*data || (*pattern && (*pattern != '/')))
                match = 0;
@@ -476,41 +518,7 @@ static int extension_close(char *pattern, char *data, int needmore)
                (!needmore || (strlen(pattern) > strlen(data)))) {
                return 1;
        }
-       /* All patterns begin with _ */
-       if (pattern[0] != '_') 
-               return 0;
-       /* Start optimistic */
-       match=1;
-       pattern++;
-       while(match && *data && *pattern && (*pattern != '/')) {
-               switch(toupper(*pattern)) {
-               case 'N':
-                       if ((*data < '2') || (*data > '9'))
-                               match=0;
-                       break;
-               case 'X':
-                       if ((*data < '0') || (*data > '9'))
-                               match = 0;
-                       break;
-               case 'Z':
-                       if ((*data < '1') || (*data > '9'))
-                               match = 0;
-                       break;
-               case '.':
-                       /* Must match instantly */
-                       return 1;
-               case ' ':
-               case '-':
-                       /* Ignore these characters */
-                       data--;
-                       break;
-               default:
-                       if (*data != *pattern)
-                               match =0;
-               }
-               data++;
-               pattern++;
-       }
+       EXTENSION_MATCH_CORE(data,pattern,match);
        /* If there's more or we don't care about more, return non-zero, otlherwise it's a miss */
        if (!needmore || *pattern) {
                return match;
@@ -665,7 +673,7 @@ static void *pbx_substitute_variables(struct ast_channel *c, struct ast_exten *e
        char *cp1,*cp3,*cp4,*cp5;
        void *cp2;
        char c1,c2;
-       int m,mve,origlen,quoted,dolsign,docopy;
+       int m,mve,origlen,quoted,dolsign,docopy,offset;
        struct ast_var_t *variables;
        struct varshead *headp;
        char pri[80];
@@ -767,6 +775,13 @@ static void *pbx_substitute_variables(struct ast_channel *c, struct ast_exten *e
                                        } else if (!strcmp(cp3, "EXTEN")) {
                                                cp4 = c->exten;
                                                break;
+                                       } else if (!strncmp(cp3, "EXTEN-", strlen("EXTEN-")) && 
+                                               (sscanf(cp3 + strlen("EXTEN-"), "%d", &offset) == 1)) {
+                                               if (offset < 0)
+                                                       offset=0;
+                                               if (offset > strlen(c->exten))
+                                                       offset = strlen(c->exten);
+                                               cp4 = c->exten + offset;
                                        } else if (!strcmp(cp3, "RDNIS")) {
                                                cp4 = c->rdnis;
                                                if (!cp4)
@@ -782,12 +797,22 @@ static void *pbx_substitute_variables(struct ast_channel *c, struct ast_exten *e
                                        } else {
                                        AST_LIST_TRAVERSE(headp,variables,entries) {
 //                                             ast_log(LOG_WARNING,"Comparing variable '%s' with '%s'\n",cp3,ast_var_name(variables));
-                                               if (strncasecmp(ast_var_name(variables),cp3,m)==0) {
-                                                       cp4=ast_var_value(variables);
-                                                       break;
+                                                       if (strncasecmp(ast_var_name(variables),cp3,m)==0) {
+                                                               cp4=ast_var_value(variables);
+                                                               break;
+                                                       }
+                                               }
+                                               if (!cp4) {
+                                                       /* Try globals */
+                                               AST_LIST_TRAVERSE(&globals,variables,entries) {
+       //                                              ast_log(LOG_WARNING,"Comparing variable '%s' with '%s'\n",cp3,ast_var_name(variables));
+                                                               if (strncasecmp(ast_var_name(variables),cp3,m)==0) {
+                                                                       cp4=ast_var_value(variables);
+                                                                       break;
+                                                               }
+                                                       }
                                                }
                                        }
-                               }
                                free(cp3);
                                break;
                        default :
@@ -811,12 +836,13 @@ static void *pbx_substitute_variables(struct ast_channel *c, struct ast_exten *e
                                if (cp4!=NULL) {
                                        cp2=realloc(cp2,origlen+strlen(cp4)+1);
                                        strncat((char *)cp2,cp4,strlen(cp4));
+                                       origlen += strlen(cp4);
                                } else {
                                        ast_log(LOG_WARNING,"mve!=0 and cp4=NULL, something gone astray\n");
                                }
                        }
                }
-                       
+                     cp4 = NULL;
        } while (*cp1++!='\0');
        
        /* Second stage, expression evaluation */
@@ -2764,6 +2790,7 @@ int ast_async_goto(struct ast_channel *chan, char *context, char *exten, int pri
                struct ast_frame *f;
                tmpchan = ast_channel_alloc(0);
                if (tmpchan) {
+                       ast_setstate(tmpchan, chan->_state);
                        snprintf(tmpchan->name, sizeof(tmpchan->name), "AsyncGoto/%s", chan->name);
                        /* Make formats okay */
                        tmpchan->readformat = chan->readformat;
@@ -2826,7 +2853,8 @@ static void ext_strncpy(char *dst, char *src, int len)
        while(*src && (count < len - 1)) {
                switch(*src) {
                case ' ':
-               case '-':
+//otherwise exten => [a-b],1,... doesn't work
+//             case '-':
                        /* Ignore */
                        break;
                default:
@@ -3485,21 +3513,35 @@ char *pbx_builtin_getvar_helper(struct ast_channel *chan, char *name) {
        struct ast_var_t *variables;
        struct varshead *headp;
 
-       headp = &chan->varshead;
+    if (chan)
+        headp=&chan->varshead;
+       else
+               headp=&globals;
 
-       if (name)
+       if (name) {
                AST_LIST_TRAVERSE(headp,variables,entries) {
                        if (!strcmp(name, ast_var_name(variables)))
                                return ast_var_value(variables);
                }
+               if (headp != &globals) {
+                       /* Check global variables if we haven't already */
+                       headp = &globals;
+                       AST_LIST_TRAVERSE(headp,variables,entries) {
+                               if (!strcmp(name, ast_var_name(variables)))
+                                       return ast_var_value(variables);
+                       }
+               }
+       }
        return NULL;
 }
 
 void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value) {
        struct ast_var_t *newvariable;
         struct varshead *headp;
-        
+    if (chan)
         headp=&chan->varshead;
+       else
+               headp=&globals;
                 
        AST_LIST_TRAVERSE (headp,newvariable,entries) {
                if (strncasecmp(ast_var_name(newvariable),name,strlen(name))==0) {
@@ -3510,10 +3552,12 @@ void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value
                }
        } 
        
-       newvariable=ast_var_assign(name,value); 
-       AST_LIST_INSERT_HEAD(headp,newvariable,entries);
-       
-        return;
+       if (value) {
+               if ((option_verbose > 1) && (headp == &globals))
+                       ast_verbose(VERBOSE_PREFIX_3 "Setting global variable '%s' to '%s'\n",name, value);
+               newvariable=ast_var_assign(name,value); 
+               AST_LIST_INSERT_HEAD(headp,newvariable,entries);
+       }
 }
 
 static int pbx_builtin_setvar(struct ast_channel *chan, void *data)
@@ -3536,6 +3580,22 @@ static int pbx_builtin_setvar(struct ast_channel *chan, void *data)
         return(0);
 }
 
+static int pbx_builtin_noop(struct ast_channel *chan, void *data)
+{
+       return 0;
+}
+
+
+void pbx_builtin_clear_globals(void)
+{
+       struct ast_var_t *vardata;
+       while (!AST_LIST_EMPTY(&globals)) {
+               vardata = AST_LIST_FIRST(&globals);
+               AST_LIST_REMOVE_HEAD(&globals, entries);
+               ast_var_delete(vardata);
+       }
+}
+
 static int pbx_checkcondition(char *condition) {
        char *s;
        int ret;
@@ -3552,7 +3612,6 @@ static int pbx_checkcondition(char *condition) {
        return(ret);
 }
 
-
 static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
 {
        char *condition,*branch1,*branch2,*branch;
diff --git a/pbx/.cvsignore b/pbx/.cvsignore
new file mode 100755 (executable)
index 0000000..053dfa8
--- /dev/null
@@ -0,0 +1 @@
+pbx_kdeconsole.moc
index b37a98f..56de6ed 100755 (executable)
@@ -1059,6 +1059,7 @@ static int handle_context_add_extension(int fd, int argc, char *argv[])
        char *whole_exten;
        char *exten, *prior;
        char *cidmatch, *app, *app_data;
+       char *start, *end;
 
        /* check for arguments at first */
        if (argc != 5 && argc != 6) return RESULT_SHOWUSAGE;
@@ -1075,7 +1076,14 @@ static int handle_context_add_extension(int fd, int argc, char *argv[])
        }
        prior       = strsep(&whole_exten,",");
        app         = strsep(&whole_exten,",");
-       app_data    = whole_exten;
+       if ((start = strchr(app, '(')) && (end = strrchr(app, ')'))) {
+               *start = *end = '\0';
+               app_data = start + 1;
+               for (start = app_data; *start; start++)
+                       if (*start == ',')
+                               *start = '|';
+       } else
+               app_data    = whole_exten;
 
        if (!exten || !prior || !app || !app_data) return RESULT_SHOWUSAGE;
 
@@ -1466,6 +1474,7 @@ static int pbx_load_module(void)
        struct ast_variable *v;
        char *cxt, *ext, *pri, *appl, *data, *tc, *cidmatch;
        struct ast_context *con;
+       char *start, *end;
 
        cfg = ast_load(config);
        if (cfg) {
@@ -1474,10 +1483,15 @@ static int pbx_load_module(void)
                        "static"));
                write_protect_config = ast_true(ast_variable_retrieve(cfg, "general",
                        "writeprotect"));
+               v = ast_variable_browse(cfg, "globals");
+               while(v) {
+                       pbx_builtin_setvar_helper(NULL, v->name, v->value);
+                       v = v->next;
+               }
                cxt = ast_category_browse(cfg, NULL);
                while(cxt) {
                        /* All categories but "general" are considered contexts */
-                       if (!strcasecmp(cxt, "general")) {
+                       if (!strcasecmp(cxt, "general") || !strcasecmp(cxt, "globals")) {
                                cxt = ast_category_browse(cfg, cxt);
                                continue;
                        }
@@ -1495,10 +1509,18 @@ static int pbx_load_module(void)
                                                        pri = strsep(&stringp, ",");
                                                        if (!pri)
                                                                pri="";
-                                                       appl = strsep(&stringp, ",");
+                                                       appl = stringp;
+                                                       if (!(start = strchr(appl, '(')))
+                                                               appl = strsep(&stringp, ",");
                                                        if (!appl)
                                                                appl="";
-                                                       if (stringp!=NULL && *stringp=='"') {
+                                                       if (start && (end = strrchr(appl, ')'))) {
+                                                               *start = *end = '\0';
+                                                               data = start + 1;
+                                                               for (start = data; *start; start++)
+                                                                       if (*start == ',')
+                                                                               *start = '|';
+                                                       } else if (stringp!=NULL && *stringp=='"') {
                                                                stringp++;
                                                                data = strsep(&stringp, "\"");
                                                                stringp++;
@@ -1566,6 +1588,7 @@ int load_module(void)
 int reload(void)
 {
        ast_context_destroy(NULL, registrar);
+       pbx_builtin_clear_globals();
        pbx_load_module();
        return 0;
 }
diff --git a/rtp.c b/rtp.c
index 2a015b6..21bee69 100755 (executable)
--- a/rtp.c
+++ b/rtp.c
@@ -61,6 +61,10 @@ struct ast_rtp {
        ast_rtp_callback callback;
 };
 
+int ast_rtp_fd(struct ast_rtp *rtp)
+{
+       return rtp->s;
+}
 
 static int g723_len(unsigned char buf)
 {
@@ -106,7 +110,7 @@ void ast_rtp_set_callback(struct ast_rtp *rtp, ast_rtp_callback callback)
        rtp->callback = callback;
 }
 
-static void send_dtmf(struct ast_rtp *rtp)
+static struct ast_frame *send_dtmf(struct ast_rtp *rtp)
 {
        printf("Sending dtmf: %d (%c)\n", rtp->resp, rtp->resp);
        rtp->f.frametype = AST_FRAME_DTMF;
@@ -116,15 +120,15 @@ static void send_dtmf(struct ast_rtp *rtp)
        rtp->f.mallocd = 0;
        rtp->f.src = "RTP";
        rtp->resp = 0;
-       if (rtp->callback)
-               rtp->callback(rtp, &rtp->f, rtp->data);
+       return &rtp->f;
        
 }
 
-static void process_rfc2833(struct ast_rtp *rtp, unsigned char *data, int len)
+static struct ast_frame *process_rfc2833(struct ast_rtp *rtp, unsigned char *data, int len)
 {
        unsigned int event;
        char resp = 0;
+       struct ast_frame *f = NULL;
        event = ntohl(*((unsigned int *)(data)));
        event >>= 24;
 #if 0
@@ -140,16 +144,17 @@ static void process_rfc2833(struct ast_rtp *rtp, unsigned char *data, int len)
                resp = 'A' + (event - 12);
        }
        if (rtp->resp && (rtp->resp != resp)) {
-               send_dtmf(rtp);
+               f = send_dtmf(rtp);
        }
        rtp->resp = resp;
        rtp->dtmfcount = dtmftimeout;
+       return f;
 }
 
-static void process_type121(struct ast_rtp *rtp, unsigned char *data, int len)
+static struct ast_frame *process_type121(struct ast_rtp *rtp, unsigned char *data, int len)
 {
        char resp = 0;
-       
+       struct ast_frame *f = NULL;
        unsigned char b0,b1,b2,b3,b4,b5,b6,b7;
        
        b0=*(data+0);b1=*(data+1);b2=*(data+2);b3=*(data+3);
@@ -169,7 +174,7 @@ static void process_type121(struct ast_rtp *rtp, unsigned char *data, int len)
                                resp='A'+(b3-12);
                        }
                        rtp->resp=resp;
-                       send_dtmf(rtp);
+                       f = send_dtmf(rtp);
                }
        }
        if (b2==3) {
@@ -178,11 +183,23 @@ static void process_type121(struct ast_rtp *rtp, unsigned char *data, int len)
        if (b2==0) {
 //             printf("Stop(0) %d\n",b3);
        }
+       return f;
 }
 
 static int rtpread(int *id, int fd, short events, void *cbdata)
 {
        struct ast_rtp *rtp = cbdata;
+       struct ast_frame *f;
+       f = ast_rtp_read(rtp);
+       if (f) {
+               if (rtp->callback)
+                       rtp->callback(rtp, f, rtp->data);
+       }
+       return 1;
+}
+
+struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
+{
        int res;
        struct sockaddr_in sin;
        int len;
@@ -191,6 +208,7 @@ static int rtpread(int *id, int fd, short events, void *cbdata)
        int hdrlen = 12;
        unsigned int timestamp;
        unsigned int *rtpheader;
+       static struct ast_frame *f, null_frame = { AST_FRAME_NULL, };
        
        len = sizeof(sin);
        
@@ -202,11 +220,11 @@ static int rtpread(int *id, int fd, short events, void *cbdata)
                ast_log(LOG_WARNING, "RTP Read error: %s\n", strerror(errno));
                if (errno == EBADF)
                        CRASH;
-               return 1;
+               return &null_frame;
        }
        if (res < hdrlen) {
                ast_log(LOG_WARNING, "RTP Read too short\n");
-               return 1;
+               return &null_frame;
        }
        /* Get fields */
        seqno = ntohl(rtpheader[0]);
@@ -219,19 +237,23 @@ static int rtpread(int *id, int fd, short events, void *cbdata)
        rtp->f.frametype = AST_FRAME_VOICE;
        rtp->f.subclass = rtp2ast(payloadtype);
        if (rtp->f.subclass < 0) {
+               f = NULL;
                if (payloadtype == 101) {
                        /* It's special -- rfc2833 process it */
-                       process_rfc2833(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
+                       f = process_rfc2833(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
                } else if (payloadtype == 121) {
                        /* CISCO proprietary DTMF bridge */
-                       process_type121(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
+                       f = process_type121(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
                } else if (payloadtype == 100) {
                        /* CISCO's notso proprietary DTMF bridge */
-                       process_rfc2833(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
+                       f = process_rfc2833(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
                } else {
                        ast_log(LOG_NOTICE, "Unknown RTP codec %d received\n", payloadtype);
                }
-               return 1;
+               if (f)
+                       return f;
+               else
+                       return &null_frame;
        }
 
        if (!rtp->lastrxts)
@@ -253,10 +275,8 @@ static int rtpread(int *id, int fd, short events, void *cbdata)
 
        /* Send any pending DTMF */
        if (rtp->resp && !rtp->dtmfcount) {
-               send_dtmf(rtp);
-               /* Setup the voice frame again */
-               rtp->f.frametype = AST_FRAME_VOICE;
-               rtp->f.subclass = rtp2ast(payloadtype);
+               printf("Sending pending DTMF\n");
+               return send_dtmf(rtp);
        }
        rtp->f.mallocd = 0;
        rtp->f.datalen = res - hdrlen;
@@ -287,9 +307,7 @@ static int rtpread(int *id, int fd, short events, void *cbdata)
                break;
        }
        rtp->f.src = "RTP";
-       if (rtp->callback)
-               rtp->callback(rtp, &rtp->f, rtp->data);
-       return 1;
+       return &rtp->f;
 }
 
 static struct {
@@ -370,9 +388,12 @@ struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io)
                        return NULL;
                }
        }
-       rtp->io = io;
-       rtp->sched = sched;
-       rtp->ioid = ast_io_add(rtp->io, rtp->s, rtpread, AST_IO_IN, rtp);
+       if (io && sched) {
+               /* Operate this one in a callback mode */
+               rtp->sched = sched;
+               rtp->io = io;
+               rtp->ioid = ast_io_add(rtp->io, rtp->s, rtpread, AST_IO_IN, rtp);
+       }
        return rtp;
 }