- Added touchtone support.

- Added new tcl command "vbox_breaklist" to clear/set the touchtone
  breaklist.
- Removed the audio fragment size setting again. I don't know why this
  crash my machine. The fragment size setting can be enabled in audio.h
  with a define.
This commit is contained in:
michael 1998-08-31 15:30:37 +00:00
parent dd4b8cfca4
commit 4e9a4a104d
10 changed files with 280 additions and 23 deletions

View File

@ -1,5 +1,5 @@
##
## $Id: Makefile.am,v 1.4 1998/08/30 17:32:05 michael Exp $
## $Id: Makefile.am,v 1.5 1998/08/31 15:30:37 michael Exp $
##
## system admin executables to install ####################################
@ -39,7 +39,8 @@ vboxgetty_SOURCES = log.c log.h \
voice.c voice.h \
control.c control.h \
lock.c lock.h \
audio.c audio.h
audio.c audio.h \
breaklist.c breaklist.h
## other directories to process ###########################################

View File

@ -1,9 +1,17 @@
/*
** $Id: audio.c,v 1.2 1998/08/31 10:43:00 michael Exp $
** $Id: audio.c,v 1.3 1998/08/31 15:30:38 michael Exp $
**
** Copyright 1996-1998 Michael 'Ghandi' Herold <michael@abadonna.mayn.de>
**
** $Log: audio.c,v $
** Revision 1.3 1998/08/31 15:30:38 michael
** - Added touchtone support.
** - Added new tcl command "vbox_breaklist" to clear/set the touchtone
** breaklist.
** - Removed the audio fragment size setting again. I don't know why this
** crash my machine. The fragment size setting can be enabled in audio.h
** with a define.
**
** Revision 1.2 1998/08/31 10:43:00 michael
** - Changed "char" to "unsigned char".
**
@ -49,14 +57,16 @@ int audio_open_dev(unsigned char *name)
return(audio_close_dev(desc));
}
#ifdef VBOXAUDIO_SET_FRAGEMENTSIZE
/* Fragmentgröße und Anzahl der Fragmente einstellen. Die */
/* höheren 16 Bit sind die Anzahl der Fragmente, die nied- */
/* eren die Fragmentgröße. Hier 5 Fragmente und 32 Byte */
/* Fragmentgröße (Bit 4). Es darf nur *ein* Bit für die */
/* eren die Fragmentgröße. Hier 5 Fragmente und 64 Byte */
/* Fragmentgröße (Bit 5). Es darf nur *ein* Bit für die */
/* Größe verwendet werden, sonst schmiert der Rechner eis- */
/* kalt ab! */
mask = 0x00050004;
mask = 0x00050005;
if (ioctl(desc, SNDCTL_DSP_SETFRAGMENT, &mask) == -1)
{
@ -65,6 +75,10 @@ int audio_open_dev(unsigned char *name)
return(audio_close_dev(desc));
}
#else
log(LOG_D, "Setting audio fragment size disabled at compile time!\n");
#endif
/* OSS ab 3.6 gibt muLaw nur zurück, wenn die Audiohardware */
/* das Format unterstützt. Ansonsten wird muLaw durch eine */
/* Lookup-Table emuliert. Es wird hier nur geprüft ob U8 */
@ -143,6 +157,10 @@ int audio_open_dev(unsigned char *name)
return(audio_close_dev(desc));
}
log(LOG_D, "Audio fragment size is %d; voice buffer size is %d.\n", mask, VBOXVOICE_BUFSIZE);
#ifdef VBOXAUDIO_SET_FRAGEMENTSIZE
if (mask != VBOXVOICE_BUFSIZE)
{
log(LOG_E, "Audio fragment size is not %d (audio disabled).\n", VBOXVOICE_BUFSIZE);
@ -150,6 +168,8 @@ int audio_open_dev(unsigned char *name)
return(audio_close_dev(desc));
}
#endif
return(desc);
}

View File

@ -1,5 +1,5 @@
/*
** $Id: audio.h,v 1.2 1998/08/31 10:43:01 michael Exp $
** $Id: audio.h,v 1.3 1998/08/31 15:30:39 michael Exp $
**
** Copyright 1996-1998 Michael 'Ghandi' Herold <michael@abadonna.mayn.de>
*/
@ -7,6 +7,15 @@
#ifndef _VBOX_AUDIO_H
#define _VBOX_AUDIO_H 1
/** Defines **************************************************************/
/* Define the next line if you want to set the audio buffer size */
/* to the same as the voice buffer size (this will reduce the */
/* echo effect). But note, this can crash your machine (kernel */
/* bug)! */
#undef VBOXAUDIO_SET_FRAGEMENTSIZE
/** Prototypes ***********************************************************/
extern int audio_open_dev(unsigned char *);

View File

@ -1,4 +1,4 @@
# $Id: answercall.tcl,v 1.1 1998/08/30 17:32:16 michael Exp $
# $Id: answercall.tcl,v 1.2 1998/08/31 15:30:54 michael Exp $
#----------------------------------------------------------------------#
# This script is called after the call is answered. Here you can do #
@ -23,7 +23,9 @@
# you want touchtone support, create a new answer script in the #
# users spool directory and add the touchtone functions! #
#vbox_breaklist c
vbox_breaklist c
vbox_breaklist a "5"
vbox_breaklist a "*123#"
# Start voice recording and stop audio playback. If you want a #
# permanent audio playback, you can start it here. If not, use #
@ -43,6 +45,8 @@ if {("$result" != "HANGUP") && ("$result" != "SUSPEND")} {
# Now the message will be recorded. The script will stop if the #
# remote caller hangup or if the call should be suspended. #
vbox_breaklist r "5"
set result [vbox_voice w $vbxv_savetime]
}

View File

@ -1,9 +1,17 @@
/*
** $Id: modem.c,v 1.4 1998/08/31 10:43:07 michael Exp $
** $Id: modem.c,v 1.5 1998/08/31 15:30:39 michael Exp $
**
** Copyright 1996-1998 Michael 'Ghandi' Herold <michael@abadonna.mayn.de>
**
** $Log: modem.c,v $
** Revision 1.5 1998/08/31 15:30:39 michael
** - Added touchtone support.
** - Added new tcl command "vbox_breaklist" to clear/set the touchtone
** breaklist.
** - Removed the audio fragment size setting again. I don't know why this
** crash my machine. The fragment size setting can be enabled in audio.h
** with a define.
**
** Revision 1.4 1998/08/31 10:43:07 michael
** - Changed "char" to "unsigned char".
**
@ -445,7 +453,7 @@ static void modem_timeout_function(int s)
alarm(0);
signal(SIGALRM, SIG_IGN);
log_line(LOG_D, "*** Timeout function called (%d) ***\n", s);
log_line(LOG_D, "*** Timeout [%d] ***\n", s);
timeoutstatus = 1;
}

View File

@ -1,9 +1,17 @@
/*
** $Id: tclscript.c,v 1.8 1998/08/31 10:43:12 michael Exp $
** $Id: tclscript.c,v 1.9 1998/08/31 15:30:41 michael Exp $
**
** Copyright 1996-1998 Michael 'Ghandi' Herold <michael@abadonna.mayn.de>
**
** $Log: tclscript.c,v $
** Revision 1.9 1998/08/31 15:30:41 michael
** - Added touchtone support.
** - Added new tcl command "vbox_breaklist" to clear/set the touchtone
** breaklist.
** - Removed the audio fragment size setting again. I don't know why this
** crash my machine. The fragment size setting can be enabled in audio.h
** with a define.
**
** Revision 1.8 1998/08/31 10:43:12 michael
** - Changed "char" to "unsigned char".
**
@ -68,6 +76,8 @@
#include "modem.h"
#include "tclscript.h"
#include "stringutils.h"
#include "breaklist.h"
static Tcl_Interp *interpreter = NULL;
@ -79,6 +89,7 @@ int vbox_block(VBOX_TCLFUNC_PROTO);
int vbox_log(VBOX_TCLFUNC_PROTO);
int vbox_modem_command(VBOX_TCLFUNC_PROTO);
int vbox_voice(VBOX_TCLFUNC_PROTO);
int vbox_breaklist(VBOX_TCLFUNC_PROTO);
static struct vbox_tcl_function vbox_tcl_functions[] =
@ -87,6 +98,7 @@ static struct vbox_tcl_function vbox_tcl_functions[] =
{ "vbox_log", vbox_log },
{ "vbox_modem_command", vbox_modem_command },
{ "vbox_voice" , vbox_voice },
{ "vbox_breaklist", vbox_breaklist },
{ NULL, NULL }
};
@ -463,3 +475,104 @@ int vbox_voice(VBOX_TCLFUNC)
return(TCL_OK);
}
int vbox_breaklist(VBOX_TCLFUNC)
{
unsigned char *cmd;
unsigned char *arg;
int rc;
int i;
char *rs;
if (objc == 2)
{
if ((cmd = Tcl_GetStringFromObj(objv[1], NULL)))
{
switch (*cmd)
{
case 'c':
case 'C':
breaklist_clear();
break;
case 'd':
breaklist_dump();
break;
default:
log(LOG_W, "Usage: vbox_breaklist <clear|dump>", cmd);
break;
}
Tcl_SetResult(intp, "OK", NULL);
}
return(TCL_OK);
}
if (objc >= 3)
{
cmd = Tcl_GetStringFromObj(objv[1], NULL);
arg = Tcl_GetStringFromObj(objv[2], NULL);
if ((cmd) && (arg))
{
switch (*cmd)
{
case 'A':
case 'a':
{
rs = breaklist_add(arg);
Tcl_SetResult(intp, (rs ? "OK" : "ERROR"), NULL);
}
break;
case 'R':
case 'r':
{
rc = breaklist_del(arg);
Tcl_SetResult(intp, (rc == 0 ? "OK" : "ERROR"), NULL);
}
break;
default:
{
log(LOG_W, "Usage: vbox_breaklist <add|remove> <sequence>\n");
Tcl_SetResult(intp, "ERROR", NULL);
}
break;
}
}
}
return(TCL_OK);
}

View File

@ -1,9 +1,17 @@
/*
** $Id: userrc.c,v 1.2 1998/08/31 10:43:14 michael Exp $
** $Id: userrc.c,v 1.3 1998/08/31 15:30:42 michael Exp $
**
** Copyright 1996-1998 Michael 'Ghandi' Herold <michael@abadonna.mayn.de>
**
** $Log: userrc.c,v $
** Revision 1.3 1998/08/31 15:30:42 michael
** - Added touchtone support.
** - Added new tcl command "vbox_breaklist" to clear/set the touchtone
** breaklist.
** - Removed the audio fragment size setting again. I don't know why this
** crash my machine. The fragment size setting can be enabled in audio.h
** with a define.
**
** Revision 1.2 1998/08/31 10:43:14 michael
** - Changed "char" to "unsigned char".
**
@ -172,7 +180,7 @@ int userrc_parse(struct vboxuser *vboxuser, unsigned char *home, unsigned char *
}
vboxuser->space = xstrtol(space, 0);
vboxuser->umask = (mode_t)strtol(mask, &stop, 8);
vboxuser->umask = (mode_t)strtol(mask, (char **)&stop, 8);
if (*stop != '\0')
{

View File

@ -1,9 +1,17 @@
/*
** $Id: vboxgetty.c,v 1.7 1998/08/31 10:43:16 michael Exp $
** $Id: vboxgetty.c,v 1.8 1998/08/31 15:30:43 michael Exp $
**
** Copyright 1996-1998 Michael 'Ghandi' Herold <michael@abadonna.mayn.de>
**
** $Log: vboxgetty.c,v $
** Revision 1.8 1998/08/31 15:30:43 michael
** - Added touchtone support.
** - Added new tcl command "vbox_breaklist" to clear/set the touchtone
** breaklist.
** - Removed the audio fragment size setting again. I don't know why this
** crash my machine. The fragment size setting can be enabled in audio.h
** with a define.
**
** Revision 1.7 1998/08/31 10:43:16 michael
** - Changed "char" to "unsigned char".
**
@ -71,6 +79,7 @@
#include "vboxgetty.h"
#include "control.h"
#include "lock.h"
#include "breaklist.h"
/** Variables ************************************************************/
@ -131,6 +140,8 @@ void main(int argc, char **argv)
int modemstate;
int modeminits;
breaklist_init();
progbasename = argv[0];
if ((stop = rindex(argv[0], '/'))) progbasename = ++stop;
@ -419,9 +430,8 @@ void quit_program(int rc)
}
scr_remove_interpreter();
rc_free(rc_getty_c);
breaklist_clear();
log_close();
exit(rc);

View File

@ -1,9 +1,17 @@
/*
** $Id: voice.c,v 1.8 1998/08/31 10:43:21 michael Exp $
** $Id: voice.c,v 1.9 1998/08/31 15:30:45 michael Exp $
**
** Copyright 1996-1998 Michael 'Ghandi' Herold <michael@abadonna.mayn.de>
**
** $Log: voice.c,v $
** Revision 1.9 1998/08/31 15:30:45 michael
** - Added touchtone support.
** - Added new tcl command "vbox_breaklist" to clear/set the touchtone
** breaklist.
** - Removed the audio fragment size setting again. I don't know why this
** crash my machine. The fragment size setting can be enabled in audio.h
** with a define.
**
** Revision 1.8 1998/08/31 10:43:21 michael
** - Changed "char" to "unsigned char".
**
@ -87,6 +95,7 @@
#include "tclscript.h"
#include "control.h"
#include "audio.h"
#include "breaklist.h"
/** Variables ************************************************************/
@ -110,7 +119,7 @@ static void voice_stop_vtxrtx(void);
static void voice_create_vboxcall(void);
static void voice_remove_vboxcall(void);
static void voice_mkdir(unsigned char *);
static int voice_check_touchtone(int);
static int voice_check_touchtone(int);
/*************************************************************************
** voice_init(): Beantwortet den Anruf und startet das Tcl-Skript. **
@ -270,6 +279,8 @@ int voice_wait(int timeout)
int result;
char *stop;
total_byte_i = 0;
total_byte_o = 0;
last_was_dle = 0;
voicestat = VBOXVOICE_STAT_OK;
@ -283,7 +294,7 @@ int voice_wait(int timeout)
modem_byte_o = 0;
result = 0;
while ((modem_byte_o < VBOXVOICE_BUFSIZE) && (voicestat == VBOXVOICE_STAT_OK))
while ((modem_byte_o < (VBOXVOICE_BUFSIZE - 2)) && (voicestat == VBOXVOICE_STAT_OK))
{
if ((result = vboxmodem_raw_read(&vboxmodem, modem_line_i, 1)) == 1)
{
@ -293,6 +304,10 @@ int voice_wait(int timeout)
{
switch (*modem_line_i)
{
case DLE:
modem_line_o[modem_byte_o++] = DLE;
break;
case ETX:
voicestat |= VBOXVOICE_STAT_HANGUP;
break;
@ -459,7 +474,7 @@ int voice_play(unsigned char *name)
modem_set_timeout(5);
while ((modem_byte_o < VBOXVOICE_BUFSIZE) && (voicestat == VBOXVOICE_STAT_OK))
while ((modem_byte_o < (VBOXVOICE_BUFSIZE - 2)) && (voicestat == VBOXVOICE_STAT_OK))
{
if ((i = read(desc, modem_line_i, 1)) != 1)
{
@ -477,6 +492,10 @@ int voice_play(unsigned char *name)
{
switch (*modem_line_i)
{
case DLE:
modem_line_o[modem_byte_o++] = DLE;
break;
case ETX:
voicestat |= VBOXVOICE_STAT_HANGUP;
break;
@ -834,6 +853,10 @@ static void voice_mkdir(unsigned char *name)
static int voice_check_touchtone(int c)
{
unsigned char tone[2];
unsigned char *stop;
int i;
switch (c)
{
case '0':
@ -852,6 +875,67 @@ static int voice_check_touchtone(int c)
case 'D':
case '#':
case '*':
{
if (c != '*')
{
tone[0] = c;
tone[1] = 0;
if (*voice_touchtone_sequence == '*')
{
/* Wenn das erste Zeichen in der Sequenz ein '*' */
/* ist (Sequenzstart) wird der neue Touchtone am */
/* Ende angehängt - es sei denn die Sequenz ent- */
/* hält ein '#' (Sequenzende). */
if (!(stop = rindex(voice_touchtone_sequence, '#')))
{
if (strlen(voice_touchtone_sequence) >= VBOXVOICE_SEQUENCE)
{
/* Die Sequenz ist bereits voll; der neue */
/* Touchtone wird nicht angehängt! */
log(LOG_E, "Internal touchtone sequence is full (touchtone ignored).\n");
}
else strcat(voice_touchtone_sequence, tone);
}
else strcpy(voice_touchtone_sequence, tone);
}
else
{
/* Erstes Zeichen in der Sequenz ist kein '*', der */
/* Touchtone ersetzt die alte Sequenz. */
strcpy(voice_touchtone_sequence, tone);
}
}
else strcpy(voice_touchtone_sequence, "*");
log(LOG_I, "Touchtone \"%c\" entered (%s).\n", c, voice_touchtone_sequence);
/* Prüfen ob die eingegebene Sequenz in der Breakliste */
/* vorkommt. */
for (i = 0; i < VBOXBREAK_MAX_ENTRIES; i++)
{
if (breaklist[i])
{
if (strcmp(breaklist[i], voice_touchtone_sequence) == 0) return(0);
}
}
}
break;
case 'q': /* Quiet */
case 's': /* Silence */
case 'c': /* Fax calling tone */
case 'b': /* Busy tone */
break;
default:
log_line(LOG_W, "Illegal \"<DLE>\" shielded code \"");
log_char(LOG_W, c);
log_text(LOG_W, "\" (ignored)...\n");
break;
}

View File

@ -1,5 +1,5 @@
/*
** $Id: voice.h,v 1.6 1998/08/31 10:43:22 michael Exp $
** $Id: voice.h,v 1.7 1998/08/31 15:30:47 michael Exp $
**
** Copyright 1996-1998 Michael 'Ghandi' Herold <michael@abadonna.mayn.de>
*/
@ -27,7 +27,7 @@
/** Defines **************************************************************/
#define VBOXVOICE_BUFSIZE 32 /* Voice/Audio Buffer Größe */
#define VBOXVOICE_BUFSIZE 64 /* Voice/Audio Buffer Größe */
#define VBOXVOICE_SAMPLERATE 8000 /* Samplerate (nur zum Check) */
#define VBOXVOICE_SEQUENCE 64 /* Touchtone Buffer Größe */