Please see CHANGES for a detailed description
This commit is contained in:
parent
3beb5afbfa
commit
f6906b91b3
20
vbox/CHANGES
20
vbox/CHANGES
|
@ -1,8 +1,26 @@
|
|||
# $Id: CHANGES,v 1.7 1997/03/07 08:15:35 michael Exp $
|
||||
# $Id: CHANGES,v 1.8 1997/03/08 19:56:41 michael Exp $
|
||||
#
|
||||
# To describe the news & fixes better (my english is not the best :-) the
|
||||
# changelog is only available in german.
|
||||
|
||||
08-Mär-97
|
||||
=========
|
||||
|
||||
o [Neu] Neues Programm vboxbeep: überwacht ein oder mehrere Spoolverzeich-
|
||||
nisse und gibt einen Signalton aus, wenn sich in einem davon neue
|
||||
Nachrichten befinden.
|
||||
|
||||
|
||||
07-Mär-97
|
||||
=========
|
||||
|
||||
o [Neu] Funktionen vbox_get_nr_new_messages() & vbox_get_nr_all_messages()
|
||||
in Tcl implementiert.
|
||||
|
||||
o [Fix] Funktion parse_cmp() hat die Kompression zwar ganz toll ausgewert-
|
||||
et, aber nicht gesetzt.
|
||||
|
||||
|
||||
03-Mär-97
|
||||
=========
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# $Id: Makefile.in,v 1.7 1997/03/07 08:15:36 michael Exp $
|
||||
# $Id: Makefile.in,v 1.8 1997/03/08 19:56:42 michael Exp $
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
# Things you can change to personalize the Makefile for your own site. #
|
||||
|
@ -69,6 +69,7 @@ LOGFILE = @VBOX_LOGDIR@/vboxgetty-%s.log
|
|||
# the "configure" script [/var/run]: #
|
||||
#----------------------------------------------------------------------------#
|
||||
|
||||
PIDFDIR = @VBOX_PIDDIR@
|
||||
PIDFILE = @VBOX_PIDDIR@/vboxgetty-%s.pid
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
|
@ -106,6 +107,12 @@ INSTALL_BIN = @INSTALL@ -m 755 -o root -g root -s
|
|||
|
||||
INSTALL_SHBIN = @INSTALL@ -m 755 -o root -g root
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
# Program to install binaries to the bin directory and set the suid bit: #
|
||||
#----------------------------------------------------------------------------#
|
||||
|
||||
INSTALL_UBIN = @INSTALL@ -m 4755 -o root -g root -s
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
# Program to install configurations to sysconf directory: #
|
||||
#----------------------------------------------------------------------------#
|
||||
|
@ -214,6 +221,9 @@ endif
|
|||
@$(ECHO) "Installing '$(bindir)/vboxctrl'..."
|
||||
@$(INSTALL_BIN) $(TOPDIR)/src/vboxctrl $(bindir)
|
||||
|
||||
@$(ECHO) "Installing '$(bindir)/vboxbeep'..."
|
||||
@$(INSTALL_UBIN) $(TOPDIR)/src/vboxbeep $(bindir)
|
||||
|
||||
@$(ECHO) "Installing '$(bindir)/vboxmail'..."
|
||||
@$(INSTALL_SHBIN) $(TOPDIR)/utils/vboxmail $(bindir)
|
||||
|
||||
|
@ -254,6 +264,7 @@ createconfig: ignore
|
|||
@$(ECHO) "#define VERDATE \"$(VERDATE)\"" >>$(RUNTIMEFILE)
|
||||
@$(ECHO) "#define SPOOLDIR \"$(SPOOLDIR)\"" >>$(RUNTIMEFILE)
|
||||
@$(ECHO) "#define LOGFILE \"$(LOGFILE)\"" >>$(RUNTIMEFILE)
|
||||
@$(ECHO) "#define PIDFDIR \"$(PIDFDIR)\"" >>$(RUNTIMEFILE)
|
||||
@$(ECHO) "#define PIDFILE \"$(PIDFILE)\"" >>$(RUNTIMEFILE)
|
||||
@$(ECHO) "#define LOCKFILE \"$(LOCKFILE)\"" >>$(RUNTIMEFILE)
|
||||
@$(ECHO) "#define BINDIR \"$(bindir)\"" >>$(RUNTIMEFILE)
|
||||
|
@ -287,6 +298,7 @@ clean: ignore
|
|||
@$(RM) -f $(TOPDIR)/src/vbox
|
||||
@$(RM) -f $(TOPDIR)/src/vboxconvert
|
||||
@$(RM) -f $(TOPDIR)/src/vboxctrl
|
||||
@$(RM) -f $(TOPDIR)/src/vboxbeep
|
||||
@$(RM) -f $(TOPDIR)/doc/*.html
|
||||
@$(RM) -f $(TOPDIR)/doc/*.sgml
|
||||
@$(RM) -f $(TOPDIR)/doc/*.txt
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
|
||||
o Funktion zum zählen der neuen Nachrichten (Tcl).
|
||||
|
||||
o Environment Variable VBOXSPOOL als Voreinstellungen für das Spoolverzeich-
|
||||
nis benutzen. vbox und vboxctrl werten diese dann aus.
|
||||
|
||||
o Programm vboxctrl mit dem die Kontrolldateien für vboxgetty gesteuert
|
||||
werden können.
|
||||
|
|
|
@ -1498,8 +1498,6 @@ fi
|
|||
# ...and create the files from *.in...
|
||||
#--------------------------------------------------------------------------
|
||||
|
||||
bindir=xxx
|
||||
|
||||
trap '' 1 2 15
|
||||
cat > confcache <<\EOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
|
|
|
@ -227,6 +227,4 @@ AC_SUBST(ISDN_GLOBAL_CONFIG)
|
|||
# ...and create the files from *.in...
|
||||
#--------------------------------------------------------------------------
|
||||
|
||||
bindir=xxx
|
||||
|
||||
AC_OUTPUT(Makefile src/Makefile)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# $Id: Makefile.in,v 1.4 1997/02/26 20:33:49 michael Exp $
|
||||
# $Id: Makefile.in,v 1.5 1997/03/08 19:56:49 michael Exp $
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
# The information below is modified by the configure script when Makefile is #
|
||||
|
@ -66,9 +66,13 @@ libvbox.o: $(HEADERS) libvbox.c
|
|||
vboxctrl.o: $(HEADERS) vboxctrl.c
|
||||
$(CC) $(CFLAGS) -c vboxctrl.c
|
||||
|
||||
vboxbeep.o: $(HEADERS) vboxbeep.c
|
||||
$(CC) $(CFLAGS) -c vboxbeep.c
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
|
||||
all: vboxlib vboxgetty vboxconvert vboxctrl vbox
|
||||
all: vboxlib vboxgetty vboxconvert vboxctrl vboxbeep vbox
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
# Compiling vboxlib #
|
||||
|
@ -128,6 +132,15 @@ VBOXCTRLOBJS = vboxctrl.o
|
|||
vboxctrl: $(VBOXCTRLOBJS)
|
||||
$(CC) $(VBOXCTRLOBJS) -L. -lvbox -o vboxctrl
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
# Compiling vboxleds #
|
||||
#----------------------------------------------------------------------------#
|
||||
|
||||
VBOXBEEPOBJS = vboxbeep.o
|
||||
|
||||
vboxbeep: $(VBOXBEEPOBJS)
|
||||
$(CC) $(VBOXBEEPOBJS) -L. -lvbox -o vboxbeep
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
# Misc #
|
||||
#----------------------------------------------------------------------------#
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: libvbox.c,v 1.4 1997/02/26 20:33:51 michael Exp $
|
||||
** $Id: libvbox.c,v 1.5 1997/03/08 19:56:50 michael Exp $
|
||||
**
|
||||
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
|
||||
*/
|
||||
|
@ -12,7 +12,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
#include "libvbox.h"
|
||||
|
||||
/** Variables ************************************************************/
|
||||
|
@ -22,6 +23,75 @@ char *compressions[] =
|
|||
"?", "?", "ADPCM-2", "ADPCM-3", "ADPCM-4", "ALAW", "ULAW"
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
** get_message_ptime(): Returns the vbox message length in seconds. **
|
||||
** The length is calculated from the size & the **
|
||||
** compression mode. **
|
||||
*************************************************************************
|
||||
** compression Compression mode of the sample. **
|
||||
** size Size of the sample. **
|
||||
** <return> Sample length in seconds. **
|
||||
*************************************************************************/
|
||||
|
||||
int get_message_ptime(int compression, int size)
|
||||
{
|
||||
if ((compression >= 2) && (compression <= 4))
|
||||
{
|
||||
size = ((size * 8) / compression);
|
||||
}
|
||||
|
||||
return((size / KERNEL_SAMPLE_FREQ));
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
** get_nr_messages(): Returns number of files in directory <path>. If **
|
||||
** <countnew> is set only files with modification **
|
||||
** time greater 0 are counted. Theres no check if **
|
||||
** the files is a vbox message! **
|
||||
*************************************************************************
|
||||
** path Directory with files to count. **
|
||||
** countnew 0 to count all or 1 to count only new files. **
|
||||
** <return> Number of files found. **
|
||||
*************************************************************************/
|
||||
|
||||
int get_nr_messages(char *path, int countnew)
|
||||
{
|
||||
struct dirent *entry;
|
||||
struct stat status;
|
||||
|
||||
char temp[PATH_MAX + 1];
|
||||
DIR *dir;
|
||||
int messages;
|
||||
|
||||
messages = 0;
|
||||
|
||||
if ((dir = opendir(path)))
|
||||
{
|
||||
while ((entry = readdir(dir)))
|
||||
{
|
||||
if (countnew)
|
||||
{
|
||||
if (strcmp(entry->d_name, "." ) == 0) continue;
|
||||
if (strcmp(entry->d_name, "..") == 0) continue;
|
||||
|
||||
xstrncpy(temp, path , PATH_MAX);
|
||||
xstrncat(temp, "/" , PATH_MAX);
|
||||
xstrncat(temp, entry->d_name, PATH_MAX);
|
||||
|
||||
if (stat(temp, &status) == 0)
|
||||
{
|
||||
if (status.st_mtime > 0) messages++;
|
||||
}
|
||||
}
|
||||
else messages++;
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
return(messages);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
** ctrl_create(): Creates a vbox control file. The file is created **
|
||||
** with the permissions -rw-rw-rw-. **
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: libvbox.h,v 1.3 1997/02/26 13:10:39 michael Exp $
|
||||
** $Id: libvbox.h,v 1.4 1997/03/08 19:56:51 michael Exp $
|
||||
**
|
||||
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
|
||||
*/
|
||||
|
@ -17,6 +17,8 @@
|
|||
#define CTRL_MODE_REMOVE (0)
|
||||
#define CTRL_MODE_CREATE (1)
|
||||
|
||||
#define KERNEL_SAMPLE_FREQ (8000)
|
||||
|
||||
#define VAH_MAGIC "VBOX" /* Magic id */
|
||||
#define VAH_MAX_MAGIC (4)
|
||||
#define VAH_MAX_NAME (32)
|
||||
|
@ -70,4 +72,7 @@ extern long xstrtol(char *, long);
|
|||
extern int header_put(int, vaheader_t *);
|
||||
extern int header_get(int, vaheader_t *);
|
||||
|
||||
extern int get_nr_messages(char *, int);
|
||||
extern int get_message_ptime(int, int);
|
||||
|
||||
#endif /* _VBOX_LIBVBOX_H */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: modem.c,v 1.6 1997/02/28 14:12:53 michael Exp $
|
||||
** $Id: modem.c,v 1.7 1997/03/08 19:56:53 michael Exp $
|
||||
**
|
||||
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
|
||||
*/
|
||||
|
@ -845,13 +845,7 @@ int modem_count_rings(int needrings)
|
|||
int haverings;
|
||||
int havesregs;
|
||||
int havesetup;
|
||||
|
||||
if (needrings <= 0)
|
||||
{
|
||||
log(L_INFO, "Call will not be answered - no rings are set...\n");
|
||||
|
||||
returnerror();
|
||||
}
|
||||
int n;
|
||||
|
||||
voice_init_section();
|
||||
|
||||
|
@ -901,7 +895,6 @@ int modem_count_rings(int needrings)
|
|||
returnok();
|
||||
}
|
||||
|
||||
|
||||
if (!setup.voice.doanswer)
|
||||
{
|
||||
log(L_INFO, "Call will not be answered - disabled in \"vboxrc\"...\n");
|
||||
|
@ -917,7 +910,6 @@ int modem_count_rings(int needrings)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if ((strncmp(line, "CALLER NUMBER: ", 15) == 0) && (!havesetup))
|
||||
{
|
||||
if ((sreg = modem_get_s_register(20)))
|
||||
|
@ -948,7 +940,14 @@ int modem_count_rings(int needrings)
|
|||
|
||||
if ((setup.voice.ringsonnew >= 0) && (setup.voice.ringsonnew != needrings))
|
||||
{
|
||||
log(L_INFO, "*** TOLLCHECK NOT SUPPORTED ***\n");
|
||||
log(L_DEBUG, "Checking for new messages in \"%s\"...\n", setup.voice.checknewpath);
|
||||
|
||||
if ((n = get_nr_messages(setup.voice.checknewpath, TRUE)) > 0)
|
||||
{
|
||||
log(L_DEBUG, "Found %d new messages; new number of rings are %d...\n", n, setup.voice.ringsonnew);
|
||||
|
||||
needrings = setup.voice.ringsonnew;
|
||||
}
|
||||
}
|
||||
|
||||
havesetup = TRUE;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: rcgetty.c,v 1.3 1997/02/26 13:10:46 michael Exp $
|
||||
** $Id: rcgetty.c,v 1.4 1997/03/08 19:56:54 michael Exp $
|
||||
**
|
||||
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
|
||||
*/
|
||||
|
@ -230,6 +230,8 @@ static char *parse_cmp(char *cmd, char *arg, void *ptr, int min, int max)
|
|||
|
||||
if (cmp == 5) return("alaw not longer supported");
|
||||
|
||||
(*(int *)ptr) = cmp;
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: script.c,v 1.4 1997/02/26 20:33:54 michael Exp $
|
||||
** $Id: script.c,v 1.5 1997/03/08 19:56:55 michael Exp $
|
||||
**
|
||||
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
|
||||
*/
|
||||
|
@ -25,6 +25,8 @@ int vbox_put_message(ClientData, Tcl_Interp *, int, char *[]);
|
|||
int vbox_get_message(ClientData, Tcl_Interp *, int, char *[]);
|
||||
int vbox_wait(ClientData, Tcl_Interp *, int, char *[]);
|
||||
int vbox_pause(ClientData, Tcl_Interp *, int, char *[]);
|
||||
int vbox_get_nr_new_messages(ClientData, Tcl_Interp *, int, char *[]);
|
||||
int vbox_get_nr_all_messages(ClientData, Tcl_Interp *, int, char *[]);
|
||||
|
||||
/** Defines **************************************************************/
|
||||
|
||||
|
@ -62,21 +64,23 @@ int script_run(char *script)
|
|||
needcreated = 0;
|
||||
havecreated = 0;
|
||||
|
||||
TCLCREATECMD("vbox_breaklist" , vbox_breaklist , NULL, NULL);
|
||||
TCLCREATECMD("vbox_put_message" , vbox_put_message , NULL, NULL);
|
||||
TCLCREATECMD("vbox_play_message" , vbox_put_message , NULL, NULL);
|
||||
TCLCREATECMD("vbox_get_message" , vbox_get_message , NULL, NULL);
|
||||
TCLCREATECMD("vbox_record_message" , vbox_get_message , NULL, NULL);
|
||||
TCLCREATECMD("vbox_init_touchtones" , vbox_init_touchtones , NULL, NULL);
|
||||
TCLCREATECMD("vbox_wait" , vbox_wait , NULL, NULL);
|
||||
TCLCREATECMD("vbox_pause" , vbox_pause , NULL, NULL);
|
||||
TCLCREATECMD("vbox_breaklist" , vbox_breaklist , NULL, NULL);
|
||||
TCLCREATECMD("vbox_put_message" , vbox_put_message , NULL, NULL);
|
||||
TCLCREATECMD("vbox_play_message" , vbox_put_message , NULL, NULL);
|
||||
TCLCREATECMD("vbox_get_message" , vbox_get_message , NULL, NULL);
|
||||
TCLCREATECMD("vbox_record_message" , vbox_get_message , NULL, NULL);
|
||||
TCLCREATECMD("vbox_init_touchtones" , vbox_init_touchtones , NULL, NULL);
|
||||
TCLCREATECMD("vbox_wait" , vbox_wait , NULL, NULL);
|
||||
TCLCREATECMD("vbox_pause" , vbox_pause , NULL, NULL);
|
||||
TCLCREATECMD("vbox_get_nr_new_messages", vbox_get_nr_new_messages , NULL, NULL);
|
||||
TCLCREATECMD("vbox_get_nr_all_messages", vbox_get_nr_all_messages , NULL, NULL);
|
||||
|
||||
if (havecreated == needcreated)
|
||||
{
|
||||
needcreated = 0;
|
||||
havecreated = 0;
|
||||
|
||||
sprintf(savename, "%16.16lu-%6.6lu", (unsigned long)time(NULL), (unsigned long)getpid());
|
||||
sprintf(savename, "%14.14lu-%8.8lu", (unsigned long)time(NULL), (unsigned long)getpid());
|
||||
sprintf(savetime, "%d", setup.voice.recordtime);
|
||||
|
||||
TCLCREATEVAR("vbox_var_bindir" , BINDIR);
|
||||
|
@ -388,3 +392,55 @@ int vbox_init_touchtones(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
|
|||
|
||||
return(TCL_OK);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
int vbox_get_nr_new_messages(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
|
||||
{
|
||||
int n;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
log(L_ERROR, "[vbox_get_nr_new_messages] usage: vbox_get_nr_new_messages <path>\n");
|
||||
|
||||
printstring(ip->result, "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
log(L_JUNK, "[vbox_get_nr_new_messages] counting new messages in \"%s\"...\n", argv[1]);
|
||||
|
||||
n = get_nr_messages(argv[1], TRUE);
|
||||
|
||||
printstring(ip->result, "%d", n);
|
||||
}
|
||||
|
||||
return(TCL_OK);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
int vbox_get_nr_all_messages(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
|
||||
{
|
||||
int n;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
log(L_ERROR, "[vbox_get_nr_all_messages] usage: vbox_get_nr_all_messages <path>\n");
|
||||
|
||||
printstring(ip->result, "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
log(L_JUNK, "[vbox_get_nr_all_messages] counting new messages in \"%s\"...\n", argv[1]);
|
||||
|
||||
n = get_nr_messages(argv[1], FALSE);
|
||||
|
||||
printstring(ip->result, "%d", n);
|
||||
}
|
||||
|
||||
return(TCL_OK);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,469 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kd.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <paths.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "libvbox.h"
|
||||
#include "runtime.h"
|
||||
|
||||
#define MAX_MESSAGE_BOXES 10
|
||||
|
||||
|
||||
struct messagebox
|
||||
{
|
||||
char *name;
|
||||
time_t time;
|
||||
};
|
||||
|
||||
static struct messagebox messageboxes[MAX_MESSAGE_BOXES];
|
||||
|
||||
static char sound_available_hours[24];
|
||||
|
||||
static char *vbasename = NULL;
|
||||
static char *pidname = NULL;
|
||||
static int killmode = 0;
|
||||
static time_t starttime = 0;
|
||||
|
||||
static struct option arguments[] =
|
||||
{
|
||||
{ "version" , no_argument , NULL, 'v' },
|
||||
{ "help" , no_argument , NULL, 'h' },
|
||||
{ "kill" , no_argument , NULL, 'k' },
|
||||
{ "sound" , required_argument , NULL, 's' },
|
||||
{ NULL , 0 , NULL, 0 }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static void lets_hear_the_sound(void);
|
||||
static int add_dir_to_messagebox(int, char *);
|
||||
static void free_all_messageboxes(void);
|
||||
static time_t get_newest_message_time(char *);
|
||||
static void beep(int);
|
||||
static int get_pid_from_file(void);
|
||||
static void remove_pid_file(void);
|
||||
static void create_pid_file(void);
|
||||
static void leave_program(int);
|
||||
static void set_new_starttime(int);
|
||||
static void free_resources(void);
|
||||
static void init_signals();
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int b;
|
||||
int opts;
|
||||
|
||||
if (!(vbasename = rindex(argv[0], '/')))
|
||||
{
|
||||
vbasename = argv[0];
|
||||
}
|
||||
else vbasename++;
|
||||
|
||||
for (i = 0; i < MAX_MESSAGE_BOXES; i++)
|
||||
{
|
||||
messageboxes[i].name = NULL;
|
||||
messageboxes[i].time = 0;
|
||||
}
|
||||
|
||||
if (!(pidname = malloc(strlen(PIDFDIR) + strlen("/vboxbeep.pid") + 1)))
|
||||
{
|
||||
fprintf(stderr, "%s: not enough memory to create pid name.\n", vbasename);
|
||||
|
||||
exit(5);
|
||||
}
|
||||
|
||||
printstring(pidname, "%s/vboxbeep.pid", PIDFDIR);
|
||||
|
||||
killmode = 0;
|
||||
starttime = 0;
|
||||
|
||||
b=0;
|
||||
if (add_dir_to_messagebox(b, "/var/spool/vbox/michael/incoming")) b++;
|
||||
if (add_dir_to_messagebox(b, "/var/spool/vbox/nicole/incoming" )) b++;
|
||||
|
||||
b = 0;
|
||||
|
||||
while ((opts = getopt_long(argc, argv, "vhk", arguments, (int *)0)) != EOF)
|
||||
{
|
||||
switch (opts)
|
||||
{
|
||||
case 'k':
|
||||
killmode = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
init_signals();
|
||||
|
||||
i = get_pid_from_file();
|
||||
|
||||
if (i)
|
||||
{
|
||||
if (killmode == 0)
|
||||
{
|
||||
fprintf(stderr, "%s: sending signal to stop beep's to process %d...\n", vbasename, i);
|
||||
|
||||
if (kill(i, SIGUSR1) != 0)
|
||||
{
|
||||
fprintf(stderr, "%s: error sending signal (%s).\n", vbasename, strerror(errno));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getuid() == 0)
|
||||
{
|
||||
fprintf(stderr, "%s: sending terminate signal to process %d...\n", vbasename, i);
|
||||
|
||||
if (kill(i, SIGTERM) != 0)
|
||||
{
|
||||
fprintf(stderr, "%s: error sending signal (%s).\n", vbasename, strerror(errno));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: you must be *root* to kill a running %s.\n", vbasename, vbasename);
|
||||
}
|
||||
}
|
||||
|
||||
free_resources();
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (killmode == 1)
|
||||
{
|
||||
fprintf(stderr, "%s: can't find running %s process.\n", vbasename, vbasename);
|
||||
|
||||
free_resources();
|
||||
|
||||
exit(5);
|
||||
}
|
||||
|
||||
if (getuid() != 0)
|
||||
{
|
||||
fprintf(stderr, "%s: you must be *root* to start %s.\n", vbasename, vbasename);
|
||||
|
||||
free_resources();
|
||||
|
||||
exit(5);
|
||||
}
|
||||
|
||||
create_pid_file();
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
for (i = 0; i < MAX_MESSAGE_BOXES; i++)
|
||||
{
|
||||
if (messageboxes[i].name)
|
||||
{
|
||||
messageboxes[i].time = get_newest_message_time(messageboxes[i].name);
|
||||
|
||||
if (messageboxes[i].time > starttime)
|
||||
{
|
||||
lets_hear_the_sound();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xpause(5000);
|
||||
}
|
||||
|
||||
leave_program(0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static void init_signals(void)
|
||||
{
|
||||
signal(SIGTERM , leave_program);
|
||||
signal(SIGHUP , leave_program);
|
||||
signal(SIGUSR1 , set_new_starttime);
|
||||
signal(SIGQUIT , SIG_IGN);
|
||||
signal(SIGINT , SIG_IGN);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static void free_resources(void)
|
||||
{
|
||||
if (pidname) free(pidname);
|
||||
|
||||
pidname = NULL;
|
||||
|
||||
free_all_messageboxes();
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static void leave_program(int sig)
|
||||
{
|
||||
remove_pid_file();
|
||||
free_resources();
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static void set_new_starttime(int sig)
|
||||
{
|
||||
init_signals();
|
||||
|
||||
starttime = time(NULL);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static void lets_hear_the_sound(void)
|
||||
{
|
||||
struct tm *timel;
|
||||
|
||||
time_t timec;
|
||||
int vt;
|
||||
int i;
|
||||
int k;
|
||||
|
||||
timec = time(NULL);
|
||||
|
||||
if (!(timel = localtime(&timec)))
|
||||
{
|
||||
fprintf(stderr, "%s: can't get current local time.\n", vbasename);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((vt = open("/dev/console", O_RDWR)) == -1)
|
||||
{
|
||||
fprintf(stderr, "%s: can't open \"/dev/console\" (%s).\n", vbasename, strerror(errno));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
beep(vt);
|
||||
beep(vt);
|
||||
beep(vt);
|
||||
|
||||
close(vt);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static void beep(int vt)
|
||||
{
|
||||
ioctl(vt, KIOCSOUND, 3200);
|
||||
|
||||
xpause(100);
|
||||
|
||||
ioctl(vt, KIOCSOUND, 0);
|
||||
|
||||
xpause(25);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static int add_dir_to_messagebox(int nr, char *box)
|
||||
{
|
||||
char *name;
|
||||
|
||||
if (nr < MAX_MESSAGE_BOXES)
|
||||
{
|
||||
if ((name = strdup(box)))
|
||||
{
|
||||
messageboxes[nr].name = name;
|
||||
messageboxes[nr].time = time(NULL);
|
||||
|
||||
returnok();
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s: can't add \"%s\" to checklist.\n", vbasename, box);
|
||||
|
||||
returnerror();
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static void free_all_messageboxes(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_MESSAGE_BOXES; i++)
|
||||
{
|
||||
if (messageboxes[i].name) free(messageboxes[i].name);
|
||||
|
||||
messageboxes[i].name = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static time_t get_newest_message_time(char *box)
|
||||
{
|
||||
struct dirent *entry;
|
||||
struct stat status;
|
||||
|
||||
DIR *dir = NULL;
|
||||
time_t newest = 0;
|
||||
|
||||
if (chdir(box) == 0)
|
||||
{
|
||||
if ((dir = opendir(".")))
|
||||
{
|
||||
while ((entry = readdir(dir)))
|
||||
{
|
||||
if (strcmp(entry->d_name, "." ) == 0) continue;
|
||||
if (strcmp(entry->d_name, "..") == 0) continue;
|
||||
|
||||
if (stat(entry->d_name, &status) == 0)
|
||||
{
|
||||
if (status.st_mtime > newest) newest = status.st_mtime;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
else fprintf(stderr, "%s: can't open \"%s\" (%s).\n", vbasename, box, strerror(errno));
|
||||
}
|
||||
else fprintf(stderr, "%s: can't change to \"%s\" (%s).\n", vbasename, box, strerror(errno));
|
||||
|
||||
return(newest);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static void create_pid_file(void)
|
||||
{
|
||||
FILE *pid;
|
||||
|
||||
if (!(pid = fopen(pidname, "w")))
|
||||
{
|
||||
fprintf(stderr, "%s: could not create pid file \"%s\" (%s).\n", vbasename, pidname, strerror(errno));
|
||||
|
||||
leave_program(0);
|
||||
}
|
||||
|
||||
fprintf(pid, "%d\n", getpid());
|
||||
|
||||
fclose(pid);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static void remove_pid_file(void)
|
||||
{
|
||||
if (unlink(pidname) != 0)
|
||||
{
|
||||
fprintf(stderr, "%s: can't remove pid file \"%s\" (%s).\n", vbasename, pidname, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static int get_pid_from_file(void)
|
||||
{
|
||||
char temp[32];
|
||||
FILE *pid;
|
||||
|
||||
if ((pid = fopen(pidname, "r")))
|
||||
{
|
||||
fgets(temp, 32, pid);
|
||||
fclose(pid);
|
||||
|
||||
return(atoi(temp));
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
static void parse_numbers(char *string, int min, int max, char field[])
|
||||
{
|
||||
char *number;
|
||||
char *beg;
|
||||
char *end;
|
||||
int begnr;
|
||||
int endnr;
|
||||
int i;
|
||||
|
||||
number = strtok(string, ",;:");
|
||||
|
||||
while (number)
|
||||
{
|
||||
beg = number;
|
||||
|
||||
if ((end = index(number, '-')))
|
||||
{
|
||||
*end++ = '\0';
|
||||
}
|
||||
else end = beg;
|
||||
|
||||
begnr = atoi(beg);
|
||||
endnr = atoi(end);
|
||||
|
||||
if ((begnr >= min) && (begnr <= max) && (endnr >= min) && (endnr <= max))
|
||||
{
|
||||
if (endnr >= begnr)
|
||||
{
|
||||
for (i = begnr; i <= endnr; i++)
|
||||
{
|
||||
fprintf(stderr, "Set: %d\n", i);
|
||||
|
||||
field[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
number = strtok(NULL, ",;:");
|
||||
}
|
||||
|
||||
free(string);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: vboxconvert.c,v 1.4 1997/02/27 15:43:52 michael Exp $
|
||||
** $Id: vboxconvert.c,v 1.5 1997/03/08 19:56:56 michael Exp $
|
||||
**
|
||||
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
|
||||
**
|
||||
|
@ -1078,6 +1078,8 @@ static unsigned char byte_linear_to_ulaw(int sample)
|
|||
|
||||
static int test_sample_is_vbox(char *name, int quiet)
|
||||
{
|
||||
struct stat status;
|
||||
|
||||
vaheader_t header;
|
||||
time_t timestamp;
|
||||
long int compression;
|
||||
|
@ -1093,18 +1095,22 @@ static int test_sample_is_vbox(char *name, int quiet)
|
|||
|
||||
if ((compression < 2) || (compression > 6)) compression = 0;
|
||||
|
||||
timestamp = ntohl(header.time);
|
||||
|
||||
if (!quiet)
|
||||
if (fstat(fd, &status) == 0)
|
||||
{
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "Creation time...........: %s", ctime(×tamp));
|
||||
fprintf(stdout, "Compression.............: %s\n", compressions[compression]);
|
||||
fprintf(stdout, "Speaker name............: %s\n", header.name);
|
||||
fprintf(stdout, "Speaker caller number...: %s\n", header.callerid);
|
||||
fprintf(stdout, "Speaker phone number....: %s\n", header.phone);
|
||||
fprintf(stdout, "Speaker location........: %s\n", header.location);
|
||||
fprintf(stdout, "\n");
|
||||
timestamp = ntohl(header.time);
|
||||
|
||||
if (!quiet)
|
||||
{
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "Creation time...........: %s", ctime(×tamp));
|
||||
fprintf(stdout, "Compression.............: %s\n", compressions[compression]);
|
||||
fprintf(stdout, "Length..................: %d seconds\n", get_message_ptime(compression, (status.st_size - sizeof(vaheader_t))));
|
||||
fprintf(stdout, "Speaker name............: %s\n", header.name);
|
||||
fprintf(stdout, "Speaker caller number...: %s\n", header.callerid);
|
||||
fprintf(stdout, "Speaker phone number....: %s\n", header.phone);
|
||||
fprintf(stdout, "Speaker location........: %s\n", header.location);
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -312,13 +312,8 @@ int voice_put_message(char *message)
|
|||
|
||||
if (timeend >= timebeg)
|
||||
{
|
||||
if ((compression >= 2) && (compression <= 4))
|
||||
{
|
||||
bytetotal = ((bytetotal * 8) / compression);
|
||||
}
|
||||
|
||||
secstotal = (timeend - timebeg);
|
||||
bytetotal = (bytetotal / 8000 );
|
||||
bytetotal = get_message_ptime(compression, bytetotal);
|
||||
|
||||
log(L_JUNK, "Function play %d secs (kernel needs %d secs)...\n", secstotal, bytetotal);
|
||||
|
||||
|
|
Loading…
Reference in New Issue