Please see CHANGES for a detailed description

This commit is contained in:
Michael 'Ghandi' Herold 1997-03-18 12:39:26 +00:00
parent eca3fb12c8
commit ea5204c477
31 changed files with 5298 additions and 2160 deletions

28
vbox/.compile Executable file
View File

@ -0,0 +1,28 @@
#! /bin/sh
##
## Script to compile with the new glibc or with my old libc5.
# If the argument '-5' is specified we will use the old libc.so.5 to
# compile the package, otherwise the current libc.so.6.
if [ "$1" = "-5" ]
then
export CFLAGS="-Wall -O2 -nostdinc -I/usr/i486-linuxlibc5/include -I/usr/lib/gcc-lib/i486-linuxlibc5/2.7.2.1/include -b i486-linuxlibc5 -L/usr/i486-linuxlibc5/lib"
export LDFLAGS="-b i486-linuxlibc5"
fi
# My personal options for the new Filesystem Hierarchy Standard (FHS).
./configure --prefix=/opt/vbox \
--exec-prefix=/opt/vbox \
--sysconfdir=/etc/opt/vbox \
--with-spooldir=/var/spool/vbox \
--with-logdir=/var/log/vbox \
--with-piddir=/var/run \
--with-lockdir=/var/lock \

View File

@ -3,6 +3,58 @@
# To describe the news & fixes better (my english is not the best :-) the
# changelog is only available in german.
15-Mär-97
=========
o [Neu] Option '--with-localedir' ins Konfigurationsskripts einge-
baut. Damit kann festgelegt werden, in welches Verzeichnis die
Kataloge kopiert werden sollen (die verschiedenen libc's haben
verschiedene Pfade aus denen sie lesen).
o [Neu] Option '--disable-nls' ins Konfigurationsskripts eingebaut um
den 'native language support' auszuschalten (es würde auch
reichen die Kataloge nicht zu kopieren :-)
o [Neu] Programm 'vboxbeep' beendet und lokalisiert.
o [Neu] Konfigurationsskripts und Makefiles angepasst. Es sollte immer
mit der Option -O2 (oder höher) compiliert werden, da der
Compiler sonst bei den Includes von *linux* meckert!
14-Mär-97
=========
o [Neu] Signalhändler in 'vboxtoau' und 'autovbox' eingebaut, damit
die temporären Dateien bei einem Abbruch ordentlich gelöscht
werden.
o [Neu] Programm 'vboxconvert' lokalisiert.
13-Mär-97
=========
o [Neu] Programm 'vboxctrl' lokalisiert.
o [Neu] Unterstützung für gnu's gettext Paket eingebaut. Entweder wird
die glibc ab Version 2 (libc.so.6) oder ein installiertes
gettext Paket benötigt. Das Konfigurationsskript sucht sich
selbst die beste Möglichkeit aus.
o [Neu] Funktion lock_type_lock() belegt Speicher für den Namen jetzt
selbst.
o [Neu] Funktion log_init() belegt Speicher für den Namen jetzt selbst.
12-Mär-97
=========
o [Neu] Konfigurationsskripts und Makefiles komplett überarbeitet.
Angefangen Unterstützung für Katalogdateien zu implementieren
(gnu's gettext).
08-Mär-97
=========

View File

@ -2,181 +2,153 @@
# $Id$
#----------------------------------------------------------------------------#
# Things you can change to personalize the Makefile for your own site. #
# Please do not change any path values here (the values are stored in some #
# other files too) - instead use "configure" to change! #
# Things you can change to personalize the Makefile for your own site. Some #
# values (eg the directory pathes) are used in some other files too, so do #
# not change the values by hand - use the options to the configure-script #
# insteed. Options you can change without configure are marked with [*]. #
# #
# Changes to Makefile will get lost if you re-run the configuration script! #
#----------------------------------------------------------------------------#
#----------------------------------------------------------------------------#
# Default directory tree in which to install the vbox specific files. The #
# value specified here *MUST* be overridden at configure-time with the #
# "--prefix" and "--exec-prefix" options to the "configure" script #
# [/usr/local/vbox]: #
#----------------------------------------------------------------------------#
prefix = @prefix@
exec_prefix = @exec_prefix@
#----------------------------------------------------------------------------#
# Directory in which normal binaries should be installed. The value #
# specified here *MUST* be overridden at configure-time with the "--bindir" #
# option to the "configure" script [/usr/local/vbox/bin]: #
#----------------------------------------------------------------------------#
bindir = @bindir@
#----------------------------------------------------------------------------#
# Directory in which system binaries (only started by system or root) should #
# be installed. The value specified here *MUST* be overridden at configure- #
# time with the "--sbindir" option to the "configure" script #
# [/usr/local/vbox/sbin]: #
#----------------------------------------------------------------------------#
sbindir = @sbindir@
#----------------------------------------------------------------------------#
# Directory in which configurations should be installed. The value specified #
# here *MUST* be overridden at configure-time with the "--sysconfdir" option #
# to the "configure" script [/usr/local/vbox/etc]: #
#----------------------------------------------------------------------------#
sysconfdir = @sysconfdir@
#----------------------------------------------------------------------------#
# Directory in which the user messages are stored. The value specified here #
# *MUST* be overridden at configure-time with the "--with-spooldir" option #
# to the "configure" script [/var/spool/vbox]: #
#----------------------------------------------------------------------------#
SPOOLDIR = @VBOX_SPOOLDIR@
#----------------------------------------------------------------------------#
# Name of the logfile each vboxgetty writes to. The placeholder '%s' is #
# replaced at runtime by the name of the used tty device. The directory #
# *MUST* be overridden at configure-time with the "--with-logdir" option to #
# the "configure" script [/var/log/vbox]: #
#----------------------------------------------------------------------------#
LOGFDIR = @VBOX_LOGDIR@
LOGFILE = @VBOX_LOGDIR@/vboxgetty-%s.log
#----------------------------------------------------------------------------#
# Name of the file each vboxgetty save his PID. The placeholder '%s' is #
# replaced at runtime by the name of the used tty device. The directory #
# *MUST* be overridden at configure-time with the "--with-piddir" option to #
# the "configure" script [/var/run]: #
#----------------------------------------------------------------------------#
PIDFDIR = @VBOX_PIDDIR@
PIDFILE = @VBOX_PIDDIR@/vboxgetty-%s.pid
#----------------------------------------------------------------------------#
# Name of the file each vboxgetty lock the used tty. The placeholder '%s' is #
# replaced at runtime by the name of the used tty device. The directory #
# *MUST* be overridden at configure-time with the "--with-lockdir" option to #
# the "configure" script [/var/run]: #
#----------------------------------------------------------------------------#
LOCKFILE = @VBOX_LOCKDIR@/LCK..%s
#----------------------------------------------------------------------------#
# Directory in which vbox looks for the global isdn configuration. The value #
# specified here *MUST* be overridden at configure-time with the #
# "--with-i4lconfdir" option to the "configure" script [$I4LCONFDIR]: #
#----------------------------------------------------------------------------#
ISDN_GLOB_CONF = @ISDN_GLOBAL_CONFIG@
#----------------------------------------------------------------------------#
# Program to install binaries to the sbin directory: #
# [*] Program to install binaries to the sbin directory (eg vboxgetty): #
#----------------------------------------------------------------------------#
INSTALL_SBIN = @INSTALL@ -m 750 -o root -g root -s
#----------------------------------------------------------------------------#
# Program to install binaries to the bin directory: #
# [*] Program to install binaries to the bin directory (eg vboxconvert): #
#----------------------------------------------------------------------------#
INSTALL_BIN = @INSTALL@ -m 755 -o root -g root -s
#----------------------------------------------------------------------------#
# Program to install bash scripts to the bin directory: #
# [*] Program to install bash scripts to the bin directory (eg vboxplay): #
#----------------------------------------------------------------------------#
INSTALL_SHBIN = @INSTALL@ -m 755 -o root -g root
#----------------------------------------------------------------------------#
# Program to install binaries to the bin directory and set the suid bit: #
# [*] Program to install binaries to the bin directory and set the suid bit #
# (eg vboxbeep): #
#----------------------------------------------------------------------------#
INSTALL_UBIN = @INSTALL@ -m 4755 -o root -g root -s
#----------------------------------------------------------------------------#
# Program to install configurations to sysconf directory: #
# [*] Program to install configurations to sysconf directory #
# (eg vboxgetty.conf): #
#----------------------------------------------------------------------------#
INSTALL_SYSCONF = @INSTALL@ -m 644 -o root -g root
#----------------------------------------------------------------------------#
# Program to create missing directories: #
# [*] Program to install locales to the locale directory: #
#----------------------------------------------------------------------------#
INSTALL_LOCALE = @INSTALL@ -m 644 -o root -g root
#----------------------------------------------------------------------------#
# [*] Program to create missing directories: #
#----------------------------------------------------------------------------#
INSTALL_DIRS = @INSTALL@ -d
#----------------------------------------------------------------------------#
# Path and names for some needed programs: #
# [*] Message catalogs to create. The catalogs must be seperated with space #
# (eg: de en fr): #
# #
# Available catalogs are: de #
#----------------------------------------------------------------------------#
MAKE = @VBOX_MAKE@
ECHO = @VBOX_ECHO@
MV = @VBOX_MV@
RM = @VBOX_RM@
SED = @VBOX_SED@
LN = @LN_S@
MAILCMD = @VBOX_MAIL@
AR = @VBOX_AR@
RANLIB = @VBOX_RANLIB@
CATALOGS = @CATALOGS_TO_INSTALL@
#----------------------------------------------------------------------------#
# The information below is modified by the configure script when Makefile is #
# generated from Makefile.in. You shouldn't normally modify any of this #
# stuff by hand. #
# [*] Compiler to use and flags for the compiler & linker: #
#----------------------------------------------------------------------------#
CC = @CC@
CFLAGS = @CFLAGS@
TOPDIR = @srcdir@
SRCDIR = $(TOPDIR)/src
RUNTIMEFILE = $(SRCDIR)/runtime.h
VERSION = @VBOX_VERSION@
VERDATE = @VBOX_VERDATE@
GOT_LIB_NCURSES = @VBOX_LIB_NCURSES@
LDFLAGS = @LDFLAGS@
#----------------------------------------------------------------------------#
# [*] Some needed programs: #
#----------------------------------------------------------------------------#
LN = @LN_S@
ECHO = @VBOX_ECHO@
MV = @VBOX_MV@
RM = @VBOX_RM@
SED = @VBOX_SED@
MAILCMD = @VBOX_MAIL@
AR = @VBOX_AR@
RANLIB = @VBOX_RANLIB@
@SET_MAKE@
#----------------------------------------------------------------------------#
# The information below is modified by the configure script when Makefile is #
# generated from Makefile.in. Some of this values are stored in other files #
# too, so don't change it by hand! #
#----------------------------------------------------------------------------#
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
sysconfdir = @sysconfdir@
LOGFILEDIR = @VBOX_LOGDIR@
PIDFILEDIR = @VBOX_PIDDIR@
LCKFILEDIR = @VBOX_LCKDIR@
SPOOLDIR = @VBOX_SPOOLDIR@
LOCALEDIR = @VBOX_LOCALE_DIR@
#----------------------------------------------------------------------------#
# The information below should be usable as is. The configure script won't #
# modify it and you shouldn't need to modify it either. #
#----------------------------------------------------------------------------#
.EXPORT_ALL_VARIABLES:
TOPDIR = @srcdir@
VPATH = @srcdir@
HAVE_NCURSES = @HAVE_NCURSES_LIBS@
HAVE_TCL = @HAVE_TCL_LIBS@
HAVE_INTL = @HAVE_INTL_LIBS@
GETTYRC = $(sysconfdir)/vboxgetty.conf
VBINDIR = $(bindir)
PACKAGE = @PACKAGE@
VERSION = @VERSION@
VERDATE = @VERDATE@
#----------------------------------------------------------------------------#
# Export variables needed by the other utilities... #
#----------------------------------------------------------------------------#
export CC
export CFLAGS
export LDFLAGS
export AR
export RANLIB
export SED
export GETTYRC
export VBINDIR
export TOPDIR
export CATALOGS
export PACKAGE
#----------------------------------------------------------------------------#
# All action we must do... #
#----------------------------------------------------------------------------#
all: vbox sedconvert
#
# For isdn4k-utils package compatibility
#
config:
@./configure
#----------------------------------------------------------------------------#
# vbox #
#----------------------------------------------------------------------------#
vbox: createconfig
@$(ECHO) ""
@$(ECHO) "Compiling vbox & utilities..."
@$(ECHO) ""
vbox: ignore
@$(MAKE) -C $(TOPDIR)/src all
#----------------------------------------------------------------------------#
@ -184,9 +156,6 @@ vbox: createconfig
#----------------------------------------------------------------------------#
sedconvert: ignore
@$(ECHO) ""
@$(ECHO) "Creating scripts & documentations..."
@$(ECHO) ""
@$(TOPDIR)/utils/mksed <$(TOPDIR)/utils/vboxmail.in >$(TOPDIR)/utils/vboxmail
@$(TOPDIR)/utils/mksed <$(TOPDIR)/utils/vboxplay.in >$(TOPDIR)/utils/vboxplay
@ -196,21 +165,12 @@ sedconvert: ignore
install: install-dirs
@$(ECHO) ""
@$(ECHO) "Installing programs & configurations..."
@$(ECHO) ""
@$(ECHO) "Installing '$(sbindir)/vboxgetty'..."
@$(INSTALL_SBIN) $(TOPDIR)/src/vboxgetty $(sbindir)/vboxgetty
@$(ECHO) "Installing '$(sysconfdir)/vboxgetty.conf.example'..."
@$(INSTALL_SYSCONF) $(TOPDIR)/examples/vboxgetty.conf.example $(sysconfdir)
ifeq ($(GOT_LIB_NCURSES),y)
@$(ECHO) "Installing '$(bindir)/vbox'..."
@$(INSTALL_BIN) $(TOPDIR)/src/vbox $(bindir)
endif
@$(ECHO) "Installing '$(bindir)/vboxconvert'..."
@$(INSTALL_BIN) $(TOPDIR)/src/vboxconvert $(bindir)
@cd $(bindir); \
@ -230,20 +190,31 @@ endif
@$(ECHO) "Installing '$(bindir)/vboxplay'..."
@$(INSTALL_SHBIN) $(TOPDIR)/utils/vboxplay $(bindir)
ifeq ($(ACTION_ON_VBOX),y)
@$(ECHO) "Installing '$(bindir)/vbox'..."
@$(INSTALL_BIN) $(TOPDIR)/src/vbox $(bindir)
endif
@set -e; for i in $(CATALOGS); do \
$(ECHO) "Installing '$(LOCALEDIR)/$$i/LC_MESSAGES/$(PACKAGE).mo'..."; \
$(INSTALL_LOCALE) $(TOPDIR)/messages/$$i.mo $(LOCALEDIR)/$$i/LC_MESSAGES/$(PACKAGE).mo; \
done
#----------------------------------------------------------------------------#
# install directories... #
# Uninstall... #
#----------------------------------------------------------------------------#
uninstall: ignore
#----------------------------------------------------------------------------#
# Install directories... #
#----------------------------------------------------------------------------#
MAKETHISDIRS = $(prefix) $(exec_prefix) $(sbindir) $(bindir) \
$(sysconfdir) $(SPOOLDIR) $(LOGFDIR)
$(sysconfdir) $(SPOOLDIR) $(LOGFILEDIR) $(PIDFILEDIR) \
$(LCKFILEDIR)
install-dirs: ignore
@$(ECHO) ""
@$(ECHO) "Creating directories..."
@$(ECHO) ""
@set -e; for i in $(MAKETHISDIRS); do \
$(ECHO) -n "Checking '$$i'... "; \
if [ -d $$i ]; then \
@ -253,55 +224,55 @@ install-dirs: ignore
$(INSTALL_DIRS) $$i; \
fi; \
done
@set -e; for i in $(CATALOGS); do \
$(ECHO) -n "Checking '$(LOCALEDIR)/$$i/LC_MESSAGES'... "; \
if [ -d $(LOCALEDIR)/$$i/LC_MESSAGES ]; then \
$(ECHO) "it's here."; \
else \
$(ECHO) "creating..."; \
$(INSTALL_DIRS) $(LOCALEDIR)/$$i/LC_MESSAGES; \
fi; \
done
#----------------------------------------------------------------------------#
# create runtime configuration... #
# Create po und mo messages (only for development)... #
#----------------------------------------------------------------------------#
createconfig: ignore
@$(ECHO) "/* Generated at runtime */" >$(RUNTIMEFILE)
@$(ECHO) "#define VERSION \"$(VERSION)\"" >>$(RUNTIMEFILE)
@$(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)
@$(ECHO) "#define GETTYRC \"$(sysconfdir)/vboxgetty.conf\"" >>$(RUNTIMEFILE)
@$(ECHO) "#define I4LCONFDIR \"$(ISDN_GLOB_CONF)\"" >>$(RUNTIMEFILE)
messages: ignore
@$(TOPDIR)/utils/mkpos
#----------------------------------------------------------------------------#
# misc #
# Create release version... #
#----------------------------------------------------------------------------#
release: distclean messages
#----------------------------------------------------------------------------#
# Cleaning... #
#----------------------------------------------------------------------------#
distclean: clean
@$(RM) -f $(TOPDIR)/Makefile
@$(RM) -f $(TOPDIR)/src/Makefile
@$(RM) -f $(TOPDIR)/doc/Makefile
@$(RM) -f $(TOPDIR)/utils/vboxmail
@$(RM) -f $(TOPDIR)/utils/vboxplay
@$(RM) -f config.cache config.log config.status
@$(RM) -f .config
@$(RM) -f $(TOPDIR)/Makefile $(TOPDIR)/src/Makefile \
$(TOPDIR)/src/config.h $(TOPDIR)/utils/vboxmail \
$(TOPDIR)/utils/vboxplay $(TOPDIR)/.config \
$(TOPDIR)/config.cache $(TOPDIR)/config.log \
$(TOPDIR)/config.status
clean: ignore
@$(ECHO) ""
@$(ECHO) "Cleaning source tree..."
@$(ECHO) ""
@$(RM) -f $(TOPDIR)/*~
@$(RM) -f $(TOPDIR)/src/*~
@$(RM) -f $(TOPDIR)/doc/*~
@$(RM) -f $(TOPDIR)/examples/*~
@$(RM) -f $(TOPDIR)/utils/*~
@$(RM) -f $(TOPDIR)/src/*.[oas]
@$(RM) -f $(TOPDIR)/src/vboxgetty
@$(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
@$(RM) -f $(RUNTIMEFILE)
@$(RM) -f $(TOPDIR)/*~ $(TOPDIR)/src/*~ $(TOPDIR)/doc/*~ \
$(TOPDIR)/examples/*~ $(TOPDIR)/utils/*~ \
$(TOPDIR)/messages/*~ $(TOPDIR)/messages/backup-* \
$(TOPDIR)/src/*.[oas] $(TOPDIR)/src/vboxgetty \
$(TOPDIR)/src/vbox $(TOPDIR)/src/vboxconvert \
$(TOPDIR)/src/vboxctrl $(TOPDIR)/src/vboxbeep \
$(TOPDIR)/doc/*.html $(TOPDIR)/doc/*.sgml \
$(TOPDIR)/doc/*.txt
#----------------------------------------------------------------------------#
# For isdn4k-utils package compatibility... #
#----------------------------------------------------------------------------#
config: ignore
@./configure
ignore:

View File

@ -1,3 +1,18 @@
o Environment Variable VBOXSPOOL als Voreinstellungen für das Spoolverzeich-
nis benutzen. vbox und vboxctrl werten diese dann aus.
Erzeugen der locales:
localedef -i de_DE -f "ISO_8859-1,1987" de
Erzeugt z.B.:
$ ls -lF /usr/share/locale/de/
-rw-r--r-- 1 root root 29970 Mar 14 12:50 LC_COLLATE
-rw-r--r-- 1 root root 10432 Mar 14 12:50 LC_CTYPE
-rw-r--r-- 1 root root 94 Mar 14 12:50 LC_MONETARY
-rw-r--r-- 1 root root 26 Mar 14 12:50 LC_NUMERIC
-rw-r--r-- 1 root root 492 Mar 14 12:50 LC_TIME

212
vbox/aclocal.m4 vendored Normal file
View File

@ -0,0 +1,212 @@
dnl #------------------------------------------------------------------------#
dnl # Test if all needed libraries for vboxgetty are installed. We will end #
dnl # the configure script if one is missing! #
dnl #------------------------------------------------------------------------#
AC_DEFUN(GND_PACKAGE_TCL,
[
HAVE_TCL_LIBS="n"
LINK_TCL_LIBS=""
gnd_use_tcl_lib=""
AC_ARG_WITH(tcllib,
[ --with-tcllib=LIB use tcl library LIB to link [tcl]],
gnd_use_tcl_lib="${withval}"
)
if (test "${gnd_use_tcl_lib}" = "")
then
gnd_1st_tcl_lib_test="tcl8.0"
gnd_2nd_tcl_lib_test="tcl7.6"
gnd_3rd_tcl_lib_test="tcl"
else
gnd_1st_tcl_lib_test="${gnd_use_tcl_lib}"
gnd_2nd_tcl_lib_test="tcl8.0"
gnd_3rd_tcl_lib_test="tcl7.6"
fi
AC_CHECK_LIB(m,
cos,
AC_CHECK_LIB(dl,
dlerror,
AC_CHECK_LIB(${gnd_1st_tcl_lib_test},
Tcl_CreateInterp,
LINK_TCL_LIBS="-l${gnd_1st_tcl_lib_test} -lm -ldl",
AC_CHECK_LIB(${gnd_2nd_tcl_lib_test},
Tcl_CreateInterp,
LINK_TCL_LIBS="-l${gnd_2nd_tcl_lib_test} -lm -ldl",
AC_CHECK_LIB(${gnd_3rd_tcl_lib_test},
Tcl_CreateInterp,
LINK_TCL_LIBS="-l${gnd_3rd_tcl_lib_test} -lm -ldl",
,
-lm -ldl
),
-lm -ldl
),
-lm -ldl
),
),
)
AC_CHECK_HEADER(tcl.h, , LINK_TCL_LIBS="")
if (test "${LINK_TCL_LIBS}" = "")
then
AC_MSG_WARN(tcl package or needed components not found! Some of the)
AC_MSG_WARN(utilities (eg vboxgetty) will not be build...)
HAVE_TCL_LIBS="n"
else
HAVE_TCL_LIBS="y"
fi
AC_SUBST(LINK_TCL_LIBS)
AC_SUBST(HAVE_TCL_LIBS)
]
)
dnl #------------------------------------------------------------------------#
dnl # Checks if the ncurses package is installed: #
dnl #------------------------------------------------------------------------#
AC_DEFUN(GND_PACKAGE_NCURSES,
[
HAVE_NCURSES_LIBS="n"
LINK_NCURSES_LIBS=""
AC_CHECK_HEADER(ncurses.h,
AC_CHECK_HEADER(panel.h,
AC_CHECK_LIB(ncurses, initscr,
AC_CHECK_LIB(panel, update_panels,
HAVE_NCURSES_LIBS="y",
HAVE_NCURSES_LIBS="n",
-lncurses
)
)
)
)
if (test "${HAVE_NCURSES_LIBS}" = "y")
then
LINK_NCURSES_LIBS="-lncurses -lpanel"
else
AC_MSG_WARN(ncurses package not found or not complete! Some of the)
AC_MSG_WARN(utilities (eg vbox) will not be build...)
fi
AC_SUBST(HAVE_NCURSES_LIBS)
AC_SUBST(LINK_NCURSES_LIBS)
]
)
dnl #------------------------------------------------------------------------#
dnl # Checks if we have gettext installed or buildin: #
dnl #------------------------------------------------------------------------#
AC_DEFUN(GND_PACKAGE_GETTEXT,
[
HAVE_INTL_LIBS="n"
LINK_INTL_LIBS=""
CATALOGS_TO_INSTALL=""
AC_MSG_CHECKING([whether native language support is requested])
AC_ARG_ENABLE(nls,
[ --disable-nls do not use native language support],
nls_cv_use_nls="${enableval}",
nls_cv_use_nls="yes"
)
AC_MSG_RESULT("${nls_cv_use_nls}")
AC_CHECK_HEADERS(locale.h)
if (test "${nls_cv_use_nls}" = "yes")
then
nls_cv_use_nls="no"
AC_CHECK_HEADERS(libintl.h)
if (test "${ac_cv_header_locale_h}" = "yes")
then
AC_MSG_CHECKING([whether locale.h defines LC_MESSAGES])
AC_TRY_LINK([#include <locale.h>],
[return LC_MESSAGES],
gnd_cv_val_LC_MESSAGES="yes",
gnd_cv_val_LC_MESSAGES="no"
)
AC_MSG_RESULT("${gnd_cv_val_LC_MESSAGES}")
if (test "${gnd_cv_val_LC_MESSAGES}" = "yes")
then
AC_DEFINE(HAVE_LC_MESSAGES)
fi
if (test "${ac_cv_header_libintl_h}" = "yes")
then
AC_CHECK_FUNCS(gettext dcgettext)
if (test "${ac_cv_func_gettext}" = "yes")
then
nls_cv_use_nls="yes"
HAVE_INTL_LIBS="buildin"
fi
if (test "${nls_cv_use_nls}" = "no")
then
AC_CHECK_LIB(intl, gettext, AC_DEFINE(HAVE_GETTEXT))
AC_CHECK_LIB(intl, dcgettext, AC_DEFINE(HAVE_DCGETTEXT))
if (test "${ac_cv_lib_intl_gettext}" = "yes")
then
HAVE_INTL_LIBS="y"
LINK_INTL_LIBS="-lintl"
nls_cv_use_nls="yes"
fi
fi
fi
fi
fi
if (test "${nls_cv_use_nls}" = "yes")
then
AC_DEFINE(ENABLE_NLS)
AC_MSG_CHECKING(for catalogs to be installed)
NEW_LINGUAS=""
for lang in ${LINGUAS=$ALL_LINGUAS}
do
case "${ALL_LINGUAS}" in
*$lang*) CATALOGS_TO_INSTALL="${lang} ${CATALOGS_TO_INSTALL}";;
esac
done
AC_MSG_RESULT(${CATALOGS_TO_INSTALL})
fi
AC_SUBST(HAVE_INTL_LIBS)
AC_SUBST(LINK_INTL_LIBS)
AC_SUBST(CATALOGS_TO_INSTALL)
]
)

1867
vbox/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -3,25 +3,39 @@ dnl generate the file "configure", which is run during vbox installation
dnl to configure the system for the local environment.
AC_INIT(src/vboxgetty.h)
AC_CONFIG_HEADER(src/config.h)
#--------------------------------------------------------------------------
# Version of the vbox package. Theres no need to change this ;-)
#--------------------------------------------------------------------------
dnl #------------------------------------------------------------------------#
dnl # Set of available languages: #
dnl #------------------------------------------------------------------------#
VBOX_VERSION="2.0.0"
VBOX_VERDATE="4. Januar 1997"
ALL_LINGUAS="de"
#--------------------------------------------------------------------------
# Some defaults...
#--------------------------------------------------------------------------
dnl #------------------------------------------------------------------------#
dnl # Some defaults: #
dnl #------------------------------------------------------------------------#
AC_PREFIX_DEFAULT(/usr/local/vbox)
CFLAGS="-i486 -O2 -Wall"
dnl #------------------------------------------------------------------------#
dnl # Version of the vbox package. Theres no need to change this ;-) #
dnl #------------------------------------------------------------------------#
#--------------------------------------------------------------------------
# Search for some programs needed by the makefiles.
#--------------------------------------------------------------------------
PACKAGE="vbox"
VERSION="2.0.0"
VERDATE="12-Mar-97"
AC_DEFINE_UNQUOTED(PACKAGE, "${PACKAGE}")
AC_DEFINE_UNQUOTED(VERSION, "${VERSION}")
AC_DEFINE_UNQUOTED(VERDATE, "${VERDATE}")
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_SUBST(VERDATE)
dnl #------------------------------------------------------------------------#
dnl # Checks for programs: #
dnl #------------------------------------------------------------------------#
AC_PROG_CC
AC_PROG_INSTALL
@ -29,7 +43,6 @@ AC_PROG_MAKE_SET
AC_PROG_LN_S
AC_PATH_PROG(VBOX_ECHO, echo, "echo")
AC_PATH_PROG(VBOX_MAKE, make, "make")
AC_PATH_PROG(VBOX_RM, rm, "rm")
AC_PATH_PROG(VBOX_MV, mv, "mv")
AC_PATH_PROG(VBOX_SED, sed, "sed")
@ -37,25 +50,60 @@ AC_PATH_PROG(VBOX_MAIL, mail, "mail")
AC_PATH_PROG(VBOX_AR, ar, "ar")
AC_PATH_PROG(VBOX_RANLIB, ranlib, "ranlib")
AC_SUBST(VBOX_ECHO)
AC_SUBST(VBOX_RM)
AC_SUBST(VBOX_MV)
AC_SUBST(VBOX_SED)
AC_SUBST(VBOX_MAIL)
AC_SUBST(VBOX_AR)
AC_SUBST(VBOX_RANLIB)
#--------------------------------------------------------------------------
# Get the top-level install tree for the package.
#--------------------------------------------------------------------------
dnl #------------------------------------------------------------------------#
dnl # Checks for header files: #
dnl #------------------------------------------------------------------------#
AC_HEADER_TIME
AC_CHECK_HEADERS(sys/time.h)
dnl #------------------------------------------------------------------------#
dnl # Checks for typedefs, structures, and compiler characteristics: #
dnl #------------------------------------------------------------------------#
AC_C_CONST
AC_C_INLINE
dnl #------------------------------------------------------------------------#
dnl # Checks for needed external packages: #
dnl #------------------------------------------------------------------------#
GND_PACKAGE_GETTEXT
GND_PACKAGE_NCURSES
GND_PACKAGE_TCL
dnl #------------------------------------------------------------------------#
dnl # Checks for the configure options (--prefix, --with-*, etc.): #
dnl #------------------------------------------------------------------------#
dnl #==========#
dnl # --prefix #
dnl #==========#
AC_MSG_CHECKING(for prefix)
if test "$prefix" = "NONE"
if (test "${prefix}" = "NONE")
then
VBOX_PREFIX="$ac_default_prefix"
VBOX_PREFIX="${ac_default_prefix}"
else
VBOX_PREFIX="$prefix"
VBOX_PREFIX="${prefix}"
fi
AC_MSG_RESULT($VBOX_PREFIX)
AC_MSG_RESULT(${VBOX_PREFIX})
#--------------------------------------------------------------------------
# Test where vbox stores the message tree.
#--------------------------------------------------------------------------
AC_SUBST(VBOX_PREFIX)
dnl #=================#
dnl # --with-spooldir #
dnl #=================#
AC_MSG_CHECKING(where the messages are stored)
@ -68,9 +116,12 @@ AC_ARG_WITH(spooldir,
AC_MSG_RESULT(${VBOX_SPOOLDIR})
#--------------------------------------------------------------------------
# Test where vbox writes the logs.
#--------------------------------------------------------------------------
AC_DEFINE_UNQUOTED(SPOOLDIR, "${VBOX_SPOOLDIR}")
AC_SUBST(VBOX_SPOOLDIR)
dnl #===============#
dnl # --with-logdir #
dnl #===============#
AC_MSG_CHECKING(where the logs are stored)
@ -81,11 +132,14 @@ AC_ARG_WITH(logdir,
VBOX_LOGDIR=${withval}
)
AC_MSG_RESULT($VBOX_LOGDIR)
AC_MSG_RESULT(${VBOX_LOGDIR})
#--------------------------------------------------------------------------
# Test where vbox stores the process ids.
#--------------------------------------------------------------------------
AC_DEFINE_UNQUOTED(LOGFILEDIR, "${VBOX_LOGDIR}")
AC_SUBST(VBOX_LOGDIR)
dnl #===============#
dnl # --with-piddir #
dnl #===============#
AC_MSG_CHECKING(where the pids are stored)
@ -96,47 +150,40 @@ AC_ARG_WITH(piddir,
VBOX_PIDDIR=${withval}
)
AC_MSG_RESULT($VBOX_PIDDIR)
AC_MSG_RESULT(${VBOX_PIDDIR})
#--------------------------------------------------------------------------
# Test where vbox made the locks.
#--------------------------------------------------------------------------
AC_DEFINE_UNQUOTED(PIDFILEDIR, "${VBOX_PIDDIR}")
AC_SUBST(VBOX_PIDDIR)
dnl #================#
dnl # --with-lockdir #
dnl #================#
AC_MSG_CHECKING(where the locks are made)
VBOX_LOCKDIR="/var/lock"
VBOX_LCKDIR="/var/lock"
AC_ARG_WITH(lockdir,
[ --with-lockdir=DIR locks are made in DIR [/var/lock]],
VBOX_LOCKDIR=${withval}
VBOX_LCKDIR=${withval}
)
AC_MSG_RESULT($VBOX_LOCKDIR)
AC_MSG_RESULT(${VBOX_LCKDIR})
#--------------------------------------------------------------------------
# Test where vbox made the locks.
#--------------------------------------------------------------------------
AC_DEFINE_UNQUOTED(LCKFILEDIR, "${VBOX_LCKDIR}")
AC_SUBST(VBOX_LCKDIR)
VBOX_TCL=""
AC_ARG_WITH(tcllib,
[ --with-tcllib=LIB use tcl library LIB [tcl]],
VBOX_TCL=${withval}
)
#--------------------------------------------------------------------------
# Test where the global isdn configuration is stored...
#--------------------------------------------------------------------------
dnl #===================#
dnl # --with-i4lconfdir #
dnl #===================#
AC_MSG_CHECKING(where the isdn configuration is stored)
if test "$I4LCONFDIR" = ""
if (test "$I4LCONFDIR" = "")
then
ISDN_GLOBAL_CONFIG="/etc/isdn"
ISDN_GLOBAL_CONFIG="/etc/isdn"
else
ISDN_GLOBAL_CONFIG="$I4LCONFDIR"
ISDN_GLOBAL_CONFIG="${I4LCONFDIR}"
fi
AC_ARG_WITH(confdir,
@ -144,87 +191,41 @@ AC_ARG_WITH(confdir,
ISDN_GLOBAL_CONFIG=${withval}
)
AC_MSG_RESULT($ISDN_GLOBAL_CONFIG)
AC_MSG_RESULT(${ISDN_GLOBAL_CONFIG})
#--------------------------------------------------------------------------
# Test if the complete ncurses package is installed. This means the lib's
# ncurses and panel must exist. If not some tools from the package will not
# compile!
#--------------------------------------------------------------------------
AC_DEFINE_UNQUOTED(I4LCONFDIR, "${ISDN_GLOBAL_CONFIG}")
VBOX_LIB_NCURSES="n"
dnl #==================#
dnl # --with-localedir #
dnl #==================#
AC_CHECK_LIB(ncurses, initscr,
AC_CHECK_LIB(panel, update_panels,
VBOX_LIB_NCURSES="y",
[AC_MSG_WARN(vbox needs ncurses (1.9.9g or higher) to compile!)],
-lncurses
),
[AC_MSG_WARN(vbox needs ncurses (1.9.9g or higher) to compile!)]
AC_MSG_CHECKING(where the message catalogs are stored)
VBOX_LOCALE_DIR="/usr/share/locale"
AC_ARG_WITH(modir,
[ --with-localedir=DIR directory to install catalogs [/usr/share/locale] ],
VBOX_LOCALE_DIR=${withval}
)
#--------------------------------------------------------------------------
# Test if all needed libraries for vboxgetty are installed. We will end the
# configure script if one is missing!
#--------------------------------------------------------------------------
AC_MSG_RESULT(${VBOX_LOCALE_DIR})
if test "${VBOX_TCL}" = ""
AC_SUBST(VBOX_LOCALE_DIR)
dnl #------------------------------------------------------------------------#
dnl # Creates output files: #
dnl #------------------------------------------------------------------------#
if (test "${ac_cv_prog_CC}" = "gcc")
then
TST1_TCL_LIB="tcl8.0"
TST2_TCL_LIB="tcl7.6"
TST3_TCL_LIB="tcl"
else
TST1_TCL_LIB="${VBOX_TCL}"
TST2_TCL_LIB="tcl8.0"
TST3_TCL_LIB="tcl7.6"
if (test "${CFLAGS}" = "")
then
CFLAGS="-Wall -O2"
fi
fi
AC_CHECK_LIB(m, cos,
AC_CHECK_LIB(dl, dlerror,
AC_CHECK_LIB(${TST1_TCL_LIB}, Tcl_CreateInterp,
VBOX_GETTY_LIBS="-l${TST1_TCL_LIB} -lm -ldl",
AC_CHECK_LIB(${TST2_TCL_LIB}, Tcl_CreateInterp,
VBOX_GETTY_LIBS="-l${TST2_TCL_LIB} -lm -ldl",
AC_CHECK_LIB(${TST3_TCL_LIB}, Tcl_CreateInterp,
VBOX_GETTY_LIBS="-l${TST3_TCL_LIB} -lm -ldl",
[AC_MSG_ERROR(vboxgetty needs the tcl package (7.6 or higher) to compile! Use --with-tcllib to specify your tcl library!)],
-lm -ldl
),
-lm -ldl
),
-lm -ldl
),
[AC_MSG_ERROR(vboxgetty needs the dynamic link library to compile!)]
),
[AC_MSG_ERROR(vboxgetty needs the math library to compile!)]
)
#--------------------------------------------------------------------------
# Subst the variables...
#--------------------------------------------------------------------------
AC_SUBST(VBOX_PREFIX)
AC_SUBST(VBOX_VERSION)
AC_SUBST(VBOX_VERDATE)
AC_SUBST(VBOX_SPOOLDIR)
AC_SUBST(VBOX_LOGDIR)
AC_SUBST(VBOX_PIDDIR)
AC_SUBST(VBOX_LOCKDIR)
AC_SUBST(VBOX_GETTY_LIBS)
AC_SUBST(VBOX_LIBS)
AC_SUBST(VBOX_ECHO)
AC_SUBST(VBOX_MAKE)
AC_SUBST(VBOX_RM)
AC_SUBST(VBOX_MV)
AC_SUBST(VBOX_SED)
AC_SUBST(VBOX_MAIL)
AC_SUBST(VBOX_AR)
AC_SUBST(VBOX_RANLIB)
AC_SUBST(VBOX_LIB_NCURSES)
AC_SUBST(ISDN_GLOBAL_CONFIG)
#--------------------------------------------------------------------------
# ...and create the files from *.in...
#--------------------------------------------------------------------------
AC_OUTPUT(Makefile src/Makefile)

BIN
vbox/messages/de.mo Normal file

Binary file not shown.

1440
vbox/messages/de.po Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,12 @@
# stuff by hand. #
#----------------------------------------------------------------------------#
GOT_LIB_NCURSES = @VBOX_LIB_NCURSES@
HAVE_NCURSES = @HAVE_NCURSES_LIBS@
LIBS_NCURSES = @LINK_NCURSES_LIBS@
HAVE_TCL = @HAVE_TCL_LIBS@
LIBS_TCL = @LINK_TCL_LIBS@
HAVE_INTL = @HAVE_INTL_LIBS@
LIBS_INTL = @LINK_INTL_LIBS@
#----------------------------------------------------------------------------#
# Headers #
@ -34,7 +39,7 @@ lists.o: $(HEADERS) lists.c
$(CC) $(CFLAGS) -c lists.c
script.o: $(HEADERS) script.c
$(CC) $(CFLAGS) -c script.c
$(CC) $(CFLAGS) -DBINDIR='"$(VBINDIR)"' -c script.c
voice.o: $(HEADERS) voice.c
$(CC) $(CFLAGS) -c voice.c
@ -55,7 +60,7 @@ rcvbox.o: $(HEADERS) rcvbox.c
$(CC) $(CFLAGS) -c rcvbox.c
vboxgetty.o: $(HEADERS) vboxgetty.c
$(CC) $(CFLAGS) -c vboxgetty.c
$(CC) $(CFLAGS) -DGETTYRC='"$(GETTYRC)"' -c vboxgetty.c
vboxconvert.o: $(HEADERS) vboxconvert.c
$(CC) $(CFLAGS) -c vboxconvert.c
@ -69,7 +74,6 @@ vboxctrl.o: $(HEADERS) vboxctrl.c
vboxbeep.o: $(HEADERS) vboxbeep.c
$(CC) $(CFLAGS) -c vboxbeep.c
#----------------------------------------------------------------------------#
all: vboxlib vboxgetty vboxconvert vboxctrl vboxbeep vbox
@ -81,20 +85,18 @@ all: vboxlib vboxgetty vboxconvert vboxctrl vboxbeep vbox
VBOXLIBOBJS = libvbox.o
vboxlib: $(VBOXLIBOBJS)
@$(AR) rc libvbox.a $(VBOXLIBOBJS)
-@$(RANLIB) libvbox.a
$(AR) cru libvbox.a $(VBOXLIBOBJS)
-$(RANLIB) libvbox.a
#----------------------------------------------------------------------------#
# Compiling vboxgetty #
#----------------------------------------------------------------------------#
VBOXGETTYLIBS = @VBOX_GETTY_LIBS@
VBOXGETTYOBJS = vboxgetty.o init.o log.o perms.o lock.o streamio.o modem.o \
script.o voice.o lists.o rcvbox.o rcgetty.o \
vboxgetty: $(VBOXGETTYOBJS)
$(CC) $(VBOXGETTYOBJS) $(VBOXGETTYLIBS) -L. -lvbox -o vboxgetty
$(CC) $(CFLAGS) $(VBOXGETTYOBJS) -o vboxgetty -L. $(LIBS_TCL) $(LIBS_INTL) -lvbox
#----------------------------------------------------------------------------#
# Compiling vbox #
@ -118,10 +120,10 @@ vbox:
# Compiling vboxconvert #
#----------------------------------------------------------------------------#
CONVOBJS = vboxconvert.o
VBOXCONVOBJS = vboxconvert.o
vboxconvert: $(CONVOBJS)
$(CC) $(CONVOBJS) -L. -lvbox -o vboxconvert
vboxconvert: $(VBOXCONVOBJS)
$(CC) $(CFLAGS) $(VBOXCONVOBJS) -o vboxconvert -L. $(LIBS_INTL) -lvbox
#----------------------------------------------------------------------------#
# Compiling vboxctrl #
@ -130,7 +132,7 @@ vboxconvert: $(CONVOBJS)
VBOXCTRLOBJS = vboxctrl.o
vboxctrl: $(VBOXCTRLOBJS)
$(CC) $(VBOXCTRLOBJS) -L. -lvbox -o vboxctrl
$(CC) $(CFLAGS) $(VBOXCTRLOBJS) -o vboxctrl -L. $(LIBS_INTL) -lvbox
#----------------------------------------------------------------------------#
# Compiling vboxleds #
@ -139,7 +141,7 @@ vboxctrl: $(VBOXCTRLOBJS)
VBOXBEEPOBJS = vboxbeep.o
vboxbeep: $(VBOXBEEPOBJS)
$(CC) $(VBOXBEEPOBJS) -L. -lvbox -o vboxbeep
$(CC) $(CFLAGS) $(VBOXBEEPOBJS) -o vboxbeep -L. $(LIBS_INTL) -lvbox
#----------------------------------------------------------------------------#
# Misc #
@ -147,3 +149,41 @@ vboxbeep: $(VBOXBEEPOBJS)
clean:
@rm -f *~

123
vbox/src/config.h.in Normal file
View File

@ -0,0 +1,123 @@
#ifndef _VBOX_CONFIG_H
#define _VBOX_CONFIG_H 1
/*
* Define to include both, <time.h> *and* <sys/time.h>:
*/
#undef TIME_WITH_SYS_TIME
/*
* Define if you have the <sys/time.h> header file:
*/
#undef HAVE_SYS_TIME_H
/*
* Define if you have the <libintl.h> header file:
*/
#undef HAVE_LIBINTL_H
/*
* Define if you have the <locale.h> header file:
*/
#undef HAVE_LOCALE_H
/*
* Define if your <locale.h> file contains LC_MESSAGES:
*/
#undef HAVE_LC_MESSAGES
/*
* Define if you have the gettext() function:
*/
#undef HAVE_GETTEXT
/*
* Define if you have the dcgettext() function:
*/
#undef HAVE_DCGETTEXT
/*
* Define if you want native language support (this needs the library libintl,
* external or build into lib C).
*/
#undef ENABLE_NLS
/*
* Define as __inline if that's what the C compiler calls it:
*/
/*
* Define to empty if the keyword does not work:
*/
#undef const
/*
* Do not change any of the options below by hand - use the configure script
* insteed! The directory pathes are stored in other files too!
*/
#undef SPOOLDIR
#undef LOGFILEDIR
#undef PIDFILEDIR
#undef LCKFILEDIR
#undef I4LCONFDIR
/*
* No need to change anything below this line!
*/
#undef VERSION
#undef VERDATE
#undef PACKAGE
/*
* If we can't include <locale.h> or <libintl.h> or the function gettext()
* doesn't exist, we disable native language support!
*/
#if !HAVE_LOCALE_H || !HAVE_LIBINTL_H || !HAVE_GETTEXT
# undef ENABLE_NLS
#endif
#if ENABLE_NLS
# include <locale.h>
# include <libintl.h>
#else
# if HAVE_LOCALE_H
# include <locale.h>
# endif
# if !HAVE_GETTEXT
# define gettext(s) (s)
# endif
#endif
#endif /* _VBOX_CONFIG_H */

View File

@ -4,6 +4,8 @@
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
*/
#include "config.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@ -12,7 +14,6 @@
#include <string.h>
#include <pwd.h>
#include "runtime.h"
#include "init.h"
#include "rcgetty.h"
#include "log.h"
@ -27,11 +28,11 @@
/** Variables ************************************************************/
setup_t setup; /* Global setup structure */
setup_t setup; /* Global setup structure */
/*************************************************************************
** init_program(): Initialize the globals settings. **
*************************************************************************/
/*************************************************************************/
/** init_program(): Initialize the globals settings. **/
/*************************************************************************/
int init_program(char *device, char *gettyrc)
{
@ -44,40 +45,50 @@ int init_program(char *device, char *gettyrc)
setup.spool[0] = '\0';
setup.freespace = 0;
/* Initialize the log and start the session. The name of the log */
/* is stored into the global setup. */
/*
* Initialize the log and start the session. The name of the log
* is stored into the global setup.
*/
if (!log_init()) returnerror();
log(L_JUNK, "------------------------------------------------------------\n");
log(L_INFO, "Running vbox version %s...\n", VERSION);
log(L_INFO, gettext("-----------------------[Begin session]----------------------\n"));
log(L_INFO, gettext("Running vbox version %s...\n"), VERSION);
/* Check the version of the tcl interpreter. On bad version only */
/* a warning is displayed. */
/*
* Check the version of the tcl interpreter. On bad version only
* a warning is displayed.
*/
script_check_interpreter();
/* Parse vboxgetty.conf. This function will init the most fields */
/* in the global structure. */
/*
* Parse vboxgetty.conf. This function will init the most fields
* in the global structure.
*/
if (!getty_get_settings(gettyrc)) returnerror();
/* If the UID or GID is 0 (no user is set) return with error and */
/* exit. */
/*
* If the UID or GID is 0 (no user is set) return with error and
* exit.
*/
if ((setup.users.uid == 0) || (setup.users.gid == 0))
{
log(L_FATAL, "you *must* set a user/group (not root)!\n");
log(L_FATAL, gettext("You *must* set a user/group (not root)!\n"));
returnerror();
}
/* Get the user settings from /etc/passwd. The name and the */
/* home directory are stored into the global structure. */
/*
* Get the user settings from /etc/passwd. The name and the home
* directory are stored into the global structure.
*/
if (!(passwd = getpwuid(setup.users.uid)))
{
log(L_FATAL, "Can't get passwd entry for userid %d.\n", setup.users.uid);
log(L_FATAL, gettext("Can't get passwd entry for userid %d.\n"), setup.users.uid);
returnerror();
}
@ -104,44 +115,45 @@ int init_program(char *device, char *gettyrc)
xstrncat(setup.spool, setup.users.name, SETUP_MAX_SPOOLNAME);
}
log(L_INFO, "User %s's messagebox is '%s'...\n", setup.users.name, setup.spool);
log(L_INFO, "User %s's vboxrc is '%s'...\n", setup.users.name, setup.vboxrcname);
log(L_INFO, "User %s's vboxctrl is '%s'...\n", setup.users.name, setup.vboxctrl);
log(L_INFO, gettext("User %s's messagebox is \"%s\"...\n"), setup.users.name, setup.spool);
log(L_INFO, gettext("User %s's vboxrc is \"%s\"...\n"), setup.users.name, setup.vboxrcname);
/* Create the spool directory and set the permissions to the */
/* current user (with umask). */
/* Create the spool directory and set the permissions to the */
/* current user (with umask). */
if ((mkdir(setup.spool, S_IRWXU) == -1) && (errno != EEXIST))
{
log(L_FATAL, "Can't create \"%s\" (%s).\n", setup.spool, strerror(errno));
log(L_FATAL, gettext("Can't create \"%s\" (%s).\n"), setup.spool, strerror(errno));
returnerror();
}
if (!permissions_set(setup.spool, setup.users.uid, setup.users.gid, S_IRWXU|S_IRWXG|S_IRWXO, setup.users.umask)) returnerror();
/* Now we check if 'vboxctrl-stop' exists. If true, loop and */
/* watch if the files is deleted. */
/*
* Now we check if 'vboxctrl-stop' exists. If true, loop and watch
* if the files is deleted.
*/
if (ctrl_ishere(setup.spool, CTRL_NAME_STOP))
{
log(L_INFO, "Control file '%s' exists - waiting...\n", CTRL_NAME_STOP);
log(L_INFO, gettext("Control file \"%s\" exists - waiting...\n"), CTRL_NAME_STOP);
while (ctrl_ishere(setup.spool, CTRL_NAME_STOP))
{
xpause(5000);
log(L_JUNK, gettext("Control file \"%s\" exists - waiting...\n"), CTRL_NAME_STOP);
log(L_JUNK, "Control file '%s' exists - waiting...\n", CTRL_NAME_STOP);
xpause(5000);
}
log(L_INFO, "Control file deleted - back in business...\n");
log(L_INFO, gettext("Control file deleted - back in business...\n"));
}
if (ctrl_ishere(setup.spool, CTRL_NAME_ANSWERNOW))
{
if (!ctrl_remove(setup.spool, CTRL_NAME_ANSWERNOW))
{
log(L_WARN, "Can't remove control file '%s'!\n", CTRL_NAME_ANSWERNOW);
log(L_WARN, gettext("Can't remove control file \"%s\"!\n"), CTRL_NAME_ANSWERNOW);
}
}
@ -149,61 +161,74 @@ int init_program(char *device, char *gettyrc)
{
if (!ctrl_remove(setup.spool, CTRL_NAME_REJECT))
{
log(L_WARN, "Can't remove control file '%s'!\n", CTRL_NAME_REJECT);
log(L_WARN, gettext("Can't remove control file \"%s\"!\n"), CTRL_NAME_REJECT);
}
}
/* Open the modem device - this *must* done under the rights of */
/* the root user! */
/*
* Open the modem device - this *must* done under the rights of
* the root user!
*/
if (!modem_open_port()) returnerror();
/* Lock the modem port and create the pid file. After this the */
/* filepermissions will set to the user, so he can delete this */
/* files if the getty quit. */
/*
* Lock the modem port and create the pid file. After this the
* filepermissions will set to the user, so he can delete this
* files if the getty quit.
*/
if (!lock_type_lock(LCK_PID )) returnerror();
if (!lock_type_lock(LCK_MODEM)) returnerror();
/* Drop root privilegs to the current user and set the correct */
/* umask. */
/*
* Drop root privilegs to the current user and set the correct
* umask.
*/
if (!permissions_drop(setup.users.uid, setup.users.gid, setup.users.name, setup.users.home)) returnerror();
umask(setup.users.umask);
/* Load vbox's runtime configuration into memory and initialize */
/* the voice defaults. */
/*
* Load vbox's runtime configuration into memory and initialize
* the voice defaults.
*/
if (!(setup.vboxrc = streamio_open(setup.vboxrcname)))
{
log(L_FATAL, "Can't open \"%s\".\n", setup.vboxrcname);
log(L_FATAL, gettext("Can't open \"%s\".\n"), setup.vboxrcname);
returnerror();
}
voice_init_section();
/* Now the complete global setup structure is filled and can be */
/* used. */
/*
* Now the complete global setup structure is filled and can be
* used.
*/
returnok();
}
/*************************************************************************
** exit_program(): Exit program. **
*************************************************************************/
/*************************************************************************/
/** exit_program(): Exit program. **/
/*************************************************************************/
void exit_program(int s)
{
block_all_signals();
log(L_INFO, "Exit program on signal %d...\n", s);
log(L_INFO, gettext("Exit program on signal %d...\n"), s);
modem_close_port();
streamio_close(setup.vboxrc);
lock_type_unlock(LCK_PID);
lock_type_unlock(LCK_MODEM);
log(L_INFO, gettext("------------------------[End session]-----------------------\n"));
log_exit();
exit(0);

View File

@ -46,7 +46,7 @@ typedef struct
char vboxrcname[SETUP_MAX_VBOXRC + 1];
char vboxctrl[SETUP_MAX_VBOXCTRL + 1];
char spool[SETUP_MAX_SPOOLNAME + 1];
char logname[SETUP_MAX_LOGNAME + 1];
char *logname;
int freespace;
} setup_t;

View File

@ -18,41 +18,39 @@
/** Variables ************************************************************/
char *compressions[] =
{
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. **
*************************************************************************/
/*************************************************************************/
/** 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))
{
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. **
*************************************************************************/
/*************************************************************************/
/** 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)
{
@ -65,12 +63,9 @@ int get_nr_messages(char *path, int countnew)
messages = 0;
if ((dir = opendir(path)))
{
while ((entry = readdir(dir)))
{
if (countnew)
{
if ((dir = opendir(path))) {
while ((entry = readdir(dir))) {
if (countnew) {
if (strcmp(entry->d_name, "." ) == 0) continue;
if (strcmp(entry->d_name, "..") == 0) continue;
@ -78,12 +73,10 @@ int get_nr_messages(char *path, int countnew)
xstrncat(temp, "/" , PATH_MAX);
xstrncat(temp, entry->d_name, PATH_MAX);
if (stat(temp, &status) == 0)
{
if (stat(temp, &status) == 0) {
if (status.st_mtime > 0) messages++;
}
}
else messages++;
} else messages++;
}
closedir(dir);
@ -92,14 +85,14 @@ int get_nr_messages(char *path, int countnew)
return(messages);
}
/*************************************************************************
** ctrl_create(): Creates a vbox control file. The file is created **
** with the permissions -rw-rw-rw-. **
*************************************************************************
** path Path to the spool directory of the current user. **
** file Name of the control file to create. **
** <return> 0 on error; 1 on success. **
*************************************************************************/
/*************************************************************************/
/** ctrl_create(): Creates a vbox control file. The file is created **/
/** with the permissions -rw-rw-rw-. **/
/*************************************************************************/
/** path Path to the spool directory of the current user. **/
/** file Name of the control file to create. **/
/** <return> 0 on error; 1 on success. **/
/*************************************************************************/
int ctrl_create(char *path, char *file)
{
@ -110,25 +103,23 @@ int ctrl_create(char *path, char *file)
xstrncat(location, "/" , PATH_MAX);
xstrncat(location, file, PATH_MAX);
if ((fd = open(location, O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != -1)
{
if ((fd = open(location, O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != -1) {
chmod(location, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
chmod(location, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
close(fd);
returnok();
}
returnerror();
}
/*************************************************************************
** ctrl_remove(): Removes a vbox control file. **
*************************************************************************
** path Path to the spool directory of the current user. **
** file Name of the control file to remove. **
** <return> 0 on error; 1 on success. **
*************************************************************************/
/*************************************************************************/
/** ctrl_remove(): Removes a vbox control file. **/
/*************************************************************************/
/** path Path to the spool directory of the current user. **/
/** file Name of the control file to remove. **/
/** <return> 0 on error; 1 on success. **/
/*************************************************************************/
int ctrl_remove(char *path, char *file)
{
@ -141,8 +132,7 @@ int ctrl_remove(char *path, char *file)
loop = 5;
while (loop > 0)
{
while (loop > 0) {
unlink(location);
unlink(location);
@ -156,13 +146,13 @@ int ctrl_remove(char *path, char *file)
returnerror();
}
/*************************************************************************
** ctrl_ishere(): Checks if a control file exists. **
*************************************************************************
** path Path to the spool directory of the current user. **
** file Name of the control file to check. **
** <return> 0 don't exists; 1 exists. **
*************************************************************************/
/*************************************************************************/
/** ctrl_ishere(): Checks if a control file exists. **/
/*************************************************************************/
/** path Path to the spool directory of the current user. **/
/** file Name of the control file to check. **/
/** <return> 0 don't exists; 1 exists. **/
/*************************************************************************/
int ctrl_ishere(char *path, char *file)
{
@ -177,13 +167,13 @@ int ctrl_ishere(char *path, char *file)
returnerror();
}
/*************************************************************************
** xstrncpy(): Copys one string to another. **
*************************************************************************
** dest Pointer to the destination. **
** source Pointer to the source. **
** max Max length of destination. **
*************************************************************************/
/*************************************************************************/
/** xstrncpy(): Copys one string to another. **/
/*************************************************************************/
/** dest Pointer to the destination. **/
/** source Pointer to the source. **/
/** max Max length of destination. **/
/*************************************************************************/
void xstrncpy(char *dest, char *source, int max)
{
@ -192,40 +182,41 @@ void xstrncpy(char *dest, char *source, int max)
dest[max] = '\0';
}
/*************************************************************************
** xstrncat(): Cats one string to another. **
*************************************************************************
** dest Pointer to the destination. **
** source Pointer to the source. **
** max Max length of destination. **
*************************************************************************/
/*************************************************************************/
/** xstrncat(): Cats one string to another. **/
/*************************************************************************/
/** dest Pointer to the destination. **/
/** source Pointer to the source. **/
/** max Max length of destination. **/
/*************************************************************************/
void xstrncat(char *dest, char *source, int max)
{
if ((max - strlen(dest)) > 0) strncat(dest, source, max - strlen(dest));
if ((max - strlen(dest)) > 0)
strncat(dest, source, max - strlen(dest));
dest[max] = '\0';
}
/*************************************************************************
** xpause(): Waits some miliseconds. **
*************************************************************************
** ms Miliseconds to wait. **
*************************************************************************/
/*************************************************************************/
/** xpause(): Waits some miliseconds. **/
/*************************************************************************/
/** ms Miliseconds to wait. **/
/*************************************************************************/
void xpause(unsigned long ms)
{
usleep(ms * 1000);
}
/*************************************************************************
** xstrtol(): Converts a string to a long number, using a default on **
** error. **
*************************************************************************
** str String to convert to long. **
** use Default value if string can't converted. **
** <return> Converted string value on success; default on error. **
*************************************************************************/
/*************************************************************************/
/** xstrtol(): Converts a string to a long number, using a default on **/
/** error. **/
/*************************************************************************/
/** str String to convert to long. **/
/** use Default value if string can't converted. **/
/** <return> Converted string value on success; default on error. **/
/*************************************************************************/
long xstrtol(char *str, long use)
{
@ -239,44 +230,39 @@ long xstrtol(char *str, long use)
return(line);
}
/*************************************************************************
** header_put(): Writes the vbox audio header. **
*************************************************************************
** fd File descriptor used to write. **
** header Pointer to a filled vbox audio header. **
** <return> 0 on error; 1 on success. **
*************************************************************************/
/*************************************************************************/
/** header_put(): Writes the vbox audio header. **/
/*************************************************************************/
/** fd File descriptor used to write. **/
/** header Pointer to a filled vbox audio header. **/
/** <return> 0 on error; 1 on success. **/
/*************************************************************************/
int header_put(int fd, vaheader_t *header)
{
if (write(fd, header, sizeof(vaheader_t)) != sizeof(vaheader_t))
{
if (write(fd, header, sizeof(vaheader_t)) != sizeof(vaheader_t)) {
returnerror();
}
returnok();
}
/*************************************************************************
** header_get(): Reads a vbox audio header. **
*************************************************************************
** fd File descriptor used to read. **
** header Pointer to a vbox audio header. **
** <return> 0 on error; 1 on success. **
*************************************************************************/
/*************************************************************************/
/** header_get(): Reads a vbox audio header. **/
/*************************************************************************/
/** fd File descriptor used to read. **/
/** header Pointer to a vbox audio header. **/
/** <return> 0 on error; 1 on success. **/
/*************************************************************************/
int header_get(int fd, vaheader_t *header)
{
vaheader_t dummy;
if (read(fd, &dummy, VAH_MAX_MAGIC) == VAH_MAX_MAGIC)
{
if (strncmp(dummy.magic, VAH_MAGIC, VAH_MAX_MAGIC) == 0)
{
if (lseek(fd, 0, SEEK_SET) == 0)
{
if (read(fd, header, sizeof(vaheader_t)) == sizeof(vaheader_t))
{
if (read(fd, &dummy, VAH_MAX_MAGIC) == VAH_MAX_MAGIC) {
if (strncmp(dummy.magic, VAH_MAGIC, VAH_MAX_MAGIC) == 0) {
if (lseek(fd, 0, SEEK_SET) == 0) {
if (read(fd, header, sizeof(vaheader_t)) == sizeof(vaheader_t)) {
returnok();
}
}

View File

@ -4,14 +4,16 @@
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include "runtime.h"
#include "lock.h"
#include "log.h"
#include "init.h"
@ -25,32 +27,45 @@ static int gettyfd = -1;
static struct locks locks[] =
{
{ LCK_MODEM, &modemfd, LOCKFILE, "modem port" },
{ LCK_PID , &gettyfd, PIDFILE , "vbox" },
{ 0 , NULL , NULL , NULL }
{ LCK_MODEM, &modemfd, LCKFILEDIR "/LCK..%s" , "?" },
{ LCK_PID , &gettyfd, PIDFILEDIR "/vboxgetty-%s.pid" , "?" },
{ 0 , NULL , NULL , NULL }
};
/** Prototypes ***********************************************************/
static int lock_locking(int, int);
static int lock_unlocking(int, int);
static int lock_locking(int, int);
static int lock_unlocking(int, int);
static void lock_init_locknames(void);
/*************************************************************************
** lock_type_lock(): Create vbox lock. **
*************************************************************************/
/**************************************************************************/
/** lock_init_locknames(): Sets locknames. **/
/**************************************************************************/
static void lock_init_locknames(void)
{
locks[0].desc = gettext("modem port");
locks[1].desc = gettext("vboxgetty");
}
/*************************************************************************/
/** lock_type_lock(): Create vbox lock. **/
/*************************************************************************/
int lock_type_lock(int type)
{
char name[LOCK_MAX_LOCKNAME + 1];
char temp[14];
char *name;
char temp[32];
char *device;
int i;
int size;
lock_init_locknames();
if (!(device = rindex(setup.modem.device, '/')))
{
device = setup.modem.device;
}
else device++;
else
device++;
i = 0;
@ -58,9 +73,9 @@ int lock_type_lock(int type)
{
if (locks[i].file == NULL)
{
log(L_WARN, "Lock setup for type %d not found.\n", type);
log(L_WARN, gettext("Lock setup for type %d not found.\n"), type);
returnok();
returnerror();
}
if (locks[i].type == type) break;
@ -68,11 +83,13 @@ int lock_type_lock(int type)
i++;
}
if ((strlen(locks[i].file) + strlen(device)) < LOCK_MAX_LOCKNAME)
size = (strlen(locks[i].file) + strlen(device) + 2);
if ((name = (char *)malloc(size)))
{
sprintf(name, locks[i].file, device);
printstring(name, locks[i].file, device);
log(L_DEBUG, "Locking %s '%s'...\n", locks[i].desc, name);
log(L_DEBUG, gettext("Locking %s (%s)...\n"), locks[i].desc, name);
if (*(locks[i].fd) == -1)
{
@ -80,48 +97,54 @@ int lock_type_lock(int type)
{
if (lock_locking(*(locks[i].fd), 5))
{
sprintf(temp, "%10d\n", getpid());
printstring(temp, "%d\n", getpid());
write(*(locks[i].fd), temp, strlen(temp));
/* Set permissions but make the locks readable to */
/* all (overrides umask). */
/*
* Set permissions but make the locks readable to
* all (overrides umask).
*/
permissions_set(name, setup.users.uid, setup.users.gid, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH, (setup.users.umask & ~(S_IRUSR|S_IRGRP|S_IROTH)));
free(name);
returnok();
}
else log(L_FATAL, "Can't lock '%s'.\n", name);
else log(L_FATAL, gettext("Can't lock \"%s\".\n"), name);
}
else log(L_FATAL, "Can't create '%s'.\n", name);
else log(L_FATAL, gettext("Can't create \"%s\".\n"), name);
}
else
{
log(L_WARN, "Use existing lock for '%s' (%d).\n", name, *(locks[i].fd));
log(L_WARN, gettext("Use existing lock for \"%s\" (%d).\n"), name, *(locks[i].fd));
free(name);
returnok();
}
}
else log(L_FATAL, "Lockname too long. Set 'LOCK_MAX_LOCKNAME' in 'lock.h' to a higher value.\n");
else log(L_FATAL, gettext("Not enough memory to allocate lockname.\n"));
returnerror();
}
/*************************************************************************
** lock_type_unlock(): Deletes vbox lock. **
*************************************************************************/
/*************************************************************************/
/** lock_type_unlock(): Deletes vbox lock. **/
/*************************************************************************/
int lock_type_unlock(int type)
{
char name[LOCK_MAX_LOCKNAME + 1];
char *name;
char *device;
int i;
int size;
lock_init_locknames();
if (!(device = rindex(setup.modem.device, '/')))
{
device = setup.modem.device;
}
else device++;
else
device++;
i = 0;
@ -129,9 +152,9 @@ int lock_type_unlock(int type)
{
if (locks[i].file == NULL)
{
log(L_WARN, "Lock setup for type %d not found.\n", type);
log(L_WARN, gettext("Lock setup for type %d not found.\n"), type);
returnok();
returnerror();
}
if (locks[i].type == type) break;
@ -139,11 +162,13 @@ int lock_type_unlock(int type)
i++;
}
if ((strlen(locks[i].file) + strlen(device)) < LOCK_MAX_LOCKNAME)
size = (strlen(locks[i].file) + strlen(device) + 2);
if ((name = (char *)malloc(size)))
{
sprintf(name, locks[i].file, device);
printstring(name, locks[i].file, device);
log(L_DEBUG, "Unlocking %s '%s'...\n", locks[i].desc, name);
log(L_DEBUG, gettext("Unlocking %s (%s)...\n"), locks[i].desc, name);
if (*(locks[i].fd) != -1)
{
@ -154,17 +179,23 @@ int lock_type_unlock(int type)
*(locks[i].fd) = -1;
}
unlink(name);
unlink(name);
if (unlink(name) != 0)
{
log(L_WARN, gettext("Can't remove lock \"%s\".\n"), name);
}
free(name);
returnok();
}
else log(L_FATAL, "Lockname too long. Set 'LOCK_MAX_LOCKNAME' in 'lock.h' to a higher value.\n");
else log(L_FATAL, gettext("Not enough memory to allocate lockname.\n"));
returnerror();
}
/*************************************************************************
** lock_locking(): Locks a file descriptor with delay. **
*************************************************************************/
/*************************************************************************/
/** lock_locking(): Locks a file descriptor with delay. **/
/*************************************************************************/
static int lock_locking(int fd, int trys)
{
@ -180,9 +211,9 @@ static int lock_locking(int fd, int trys)
returnerror();
}
/*************************************************************************
** lock_unlocking(): Unlocks a file descriptor with delay. **
*************************************************************************/
/*************************************************************************/
/** lock_unlocking(): Unlocks a file descriptor with delay. **/
/*************************************************************************/
static int lock_unlocking(int fd, int trys)
{
@ -197,4 +228,3 @@ static int lock_unlocking(int fd, int trys)
returnerror();
}

View File

@ -4,14 +4,25 @@
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
*/
#include "config.h"
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <locale.h>
#include "runtime.h"
#include "log.h"
#include "vboxgetty.h"
#include "libvbox.h"
@ -23,72 +34,74 @@ static long logdbg = L_DEFAULT;
/** Structures ***********************************************************/
static struct logsequence logsequence[] =
{
static struct logsequence logsequence[] = {
{ ETX , "<ETX>" }, { NL , "<NL>" }, { CR , "<CR>" },
{ DLE , "<DLE>" }, { XON , "<XON>" }, { XOFF, "<XOFF>" },
{ DC4 , "<DC4>" }, { CAN , "<CAN>" }, { 0 , NULL }
};
/*************************************************************************
** log_init(): Initialize the log functions. **
*************************************************************************/
/**************************************************************************/
/** log_init(): Initialize the log functions. **/
/**************************************************************************/
int log_init(void)
{
char *device;
char *device;
size_t size;
if (!(device = rindex(setup.modem.device, '/')))
{
device = setup.modem.device;
}
else device++;
else
device++;
setlocale(LC_CTYPE, "");
size = (strlen(LOGFILEDIR) + strlen("vboxgetty-.log") + strlen(device) + 2);
if ((strlen(device) + strlen(LOGFILE)) < SETUP_MAX_LOGNAME)
{
sprintf(setup.logname, LOGFILE, device);
if ((logsio = fopen(setup.logname, "a")))
{
if ((setup.logname = (char *)malloc(size))) {
printstring(setup.logname, "%s/vboxgetty-%s.log", LOGFILEDIR, device);
if ((logsio = fopen(setup.logname, "a"))) {
log_debuglevel(L_DEFAULT);
returnok();
} else {
log(L_STDERR, "%s: Can't open log '%s'.\n", vbasename, setup.logname);
}
else log(L_STDERR, "%s: Can't open log '%s'.\n", vbasename, setup.logname);
} else {
log(L_STDERR, "%s: Not enough memory to allocate logname.\n", vbasename);
}
else log(L_STDERR, "%s: Logname too long. Please set 'SETUP_MAX_LOGNAME' in 'setup.h' to a higher value!\n", vbasename);
returnerror();
}
/*************************************************************************
** log_exit(): Exits the log functions. **
*************************************************************************/
/**************************************************************************/
/** log_exit(): Exits the log functions. **/
/**************************************************************************/
void log_exit(void)
{
log(L_JUNK, "Closing log...\n");
if (logsio) {
fclose(logsio);
logsio = NULL;
}
if (logsio) fclose(logsio);
logsio = NULL;
if (setup.logname) {
free(setup.logname);
setup.logname = NULL;
}
}
/*************************************************************************
** log_debuglevel(): Sets the log debug level. **
*************************************************************************/
/*************************************************************************/
/** log_debuglevel(): Sets the log debug level. **/
/*************************************************************************/
void log_debuglevel(long level)
{
logdbg = level;
}
/*************************************************************************
** log_line(): Writes a line to the log including the current date & **
** time and the log level. **
*************************************************************************/
/*************************************************************************/
/** log_line(): Writes a line to the log including the current date & **/
/** time and the log level. **/
/*************************************************************************/
void log_line(long level, char *fmt, ...)
{
@ -98,44 +111,51 @@ void log_line(long level, char *fmt, ...)
char logsign;
char timeline[20];
if ((logdbg & level) || (level == L_FATAL) || (level == L_STDERR))
{
if ((logdbg & level) || (level == L_FATAL) || (level == L_STDERR)) {
if (!logsio) level = L_STDERR;
if (level == L_STDERR)
{
if (level == L_STDERR) {
va_start(arg, fmt);
vfprintf(stderr, fmt, arg);
va_end(arg);
}
else
{
else {
timec = time(NULL);
if ((timel = localtime(&timec)))
{
if (strftime(timeline, 20, "%d-%b %H:%M:%S", timel) != 15)
{
if ((timel = localtime(&timec))) {
if (strftime(timeline, 20, "%d-%b %H:%M:%S", timel) != 15) {
strcpy(timeline, "??-??? ??:??:??");
}
}
switch (level)
{
case L_FATAL: logsign = 'F';
break;
case L_ERROR: logsign = 'E';
break;
case L_WARN: logsign = 'W';
break;
case L_INFO: logsign = 'I';
break;
case L_DEBUG: logsign = 'D';
break;
case L_JUNK: logsign = 'J';
break;
default: logsign = '?';
break;
switch (level) {
case L_FATAL:
logsign = 'F';
break;
case L_ERROR:
logsign = 'E';
break;
case L_WARN:
logsign = 'W';
break;
case L_INFO:
logsign = 'I';
break;
case L_DEBUG:
logsign = 'D';
break;
case L_JUNK:
logsign = 'J';
break;
default:
logsign = '?';
break;
}
fprintf(logsio, "%s <%c> ", timeline, logsign);
@ -149,55 +169,48 @@ void log_line(long level, char *fmt, ...)
}
}
/*************************************************************************
** log_char(): Writes a char to the log. **
*************************************************************************/
/*************************************************************************/
/** log_char(): Writes a char to the log. **/
/*************************************************************************/
void log_char(long level, char c)
{
int i;
if ((logdbg & level) || (level == L_FATAL) || (level == L_STDERR))
{
if (!isprint(c))
{
if ((logdbg & level) || (level == L_FATAL) || (level == L_STDERR)) {
if (!isprint(c)) {
i = 0;
while (logsequence[i].text)
{
if (logsequence[i].code == c)
{
while (logsequence[i].text) {
if (logsequence[i].code == c) {
log_text(level, "%s", logsequence[i].text);
return;
}
i++;
}
log_text(level, "[0x%02X]", (unsigned char)c);
} else {
log_text(level, "%c", c);
}
else log_text(level, "%c", c);
}
}
/*************************************************************************
** log_text(): Writes a line to the log. **
*************************************************************************/
/*************************************************************************/
/** log_text(): Writes a line to the log. **/
/*************************************************************************/
void log_text(long level, char *fmt, ...)
{
FILE *useio;
va_list arg;
if ((logdbg & level) || (level == L_FATAL) || (level == L_STDERR))
{
if ((!logsio) || (level == L_STDERR))
{
if ((logdbg & level) || (level == L_FATAL) || (level == L_STDERR)) {
if ((!logsio) || (level == L_STDERR)) {
useio = stderr;
level = L_STDERR;
} else {
useio = logsio;
}
else useio = logsio;
va_start(arg, fmt);
vfprintf(useio, fmt, arg);
@ -207,16 +220,17 @@ void log_text(long level, char *fmt, ...)
}
}
/*************************************************************************
** log_code(): Writes a line with log_char() to the log. **
*************************************************************************/
/*************************************************************************/
/** log_code(): Writes a line with log_char() to the log. **/
/*************************************************************************/
void log_code(long level, char *sequence)
{
int i;
if ((logdbg & level) || (level == L_FATAL) || (level == L_STDERR))
{
for (i = 0; i < strlen(sequence); i++) log_char(level, sequence[i]);
if ((logdbg & level) || (level == L_FATAL) || (level == L_STDERR)) {
for (i = 0; i < strlen(sequence); i++) {
log_char(level, sequence[i]);
}
}
}

View File

@ -4,8 +4,19 @@
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
*/
#include <sys/types.h>
#include <sys/stat.h>
#include "config.h"
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include <termio.h>
#include <unistd.h>
#include <stdio.h>
@ -13,7 +24,8 @@
#include <string.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "modem.h"
#include "log.h"
@ -58,50 +70,50 @@ static void modem_set_flowcontrol(TIO *);
static int modem_get_echo(char *);
static int modem_get_rawsequence(char *, int);
/*************************************************************************
** modem_open_port(): Opens the modem port. **
*************************************************************************/
/*************************************************************************/
/** modem_open_port(): Opens the modem port. **/
/*************************************************************************/
int modem_open_port(void)
{
log(L_DEBUG, "Opening modem port '%s'...\n", setup.modem.device);
log(L_DEBUG, gettext("Opening modem port \"%s\"...\n"), setup.modem.device);
if (setup.modem.fd == -1)
{
if ((setup.modem.fd = open(setup.modem.device, O_RDWR|O_NDELAY)) == -1)
{
log(L_FATAL, "Can't open modem port \"%s\".\n", setup.modem.device);
log(L_FATAL, gettext("Can't open modem port \"%s\".\n"), setup.modem.device);
returnerror();
}
if (fcntl(setup.modem.fd, F_SETFL, O_RDWR) == -1)
{
log(L_FATAL, "Can't call fcntl() to setup modem port.\n");
log(L_FATAL, gettext("Can't call fcntl() to setup modem port.\n"));
returnerror();
}
}
else log(L_WARN, "Found open modem port (%d).\n", setup.modem.fd);
else log(L_WARN, gettext("Found open modem port (%d).\n"), setup.modem.fd);
returnok();
}
/*************************************************************************
** modem_set_speed(): Sets the modemport speed to 57600. **
*************************************************************************/
/*************************************************************************/
/** modem_set_speed(): Sets the modemport speed to 57600. **/
/*************************************************************************/
static void modem_set_speed(TIO *modemtio)
{
log(L_JUNK, "Setting modem speed to 57600...\n");
log(L_JUNK, gettext("Setting modem speed to 57600...\n"));
cfsetospeed(modemtio, B57600);
cfsetispeed(modemtio, B57600);
}
/*************************************************************************
** modem_set_termio(): Sets the modem terminal IO. **
*************************************************************************/
/*************************************************************************/
/** modem_set_termio(): Sets the modem terminal IO. **/
/*************************************************************************/
int modem_set_termio(TIO *modemtio)
{
@ -110,9 +122,9 @@ int modem_set_termio(TIO *modemtio)
returnerror();
}
/*************************************************************************
** modem_get_termio(): Gets the modem terminal IO. **
*************************************************************************/
/*************************************************************************/
/** modem_get_termio(): Gets the modem terminal IO. **/
/*************************************************************************/
int modem_get_termio(TIO *modemtio)
{
@ -121,31 +133,31 @@ int modem_get_termio(TIO *modemtio)
returnerror();
}
/*************************************************************************
** modem_set_flowcontrol(): Sets modem flowcontrol to hardware hand- **
** shake. **
*************************************************************************/
/*************************************************************************/
/** modem_set_flowcontrol(): Sets modem flowcontrol to hardware hand- **/
/** shake. **/
/*************************************************************************/
static void modem_set_flowcontrol(TIO *modemtio)
{
log(L_JUNK, "Setting modem flow control (HARD)...\n");
log(L_JUNK, gettext("Setting modem flow control (HARD)...\n"));
modemtio->c_cflag &= ~(CRTSCTS);
modemtio->c_iflag &= ~(IXON|IXOFF|IXANY);
modemtio->c_cflag |= (CRTSCTS);
}
/*************************************************************************
** modem_hangup(): Toggles the data terminal ready line to hangup the **
** modem. **
*************************************************************************/
/*************************************************************************/
/** modem_hangup(): Toggles the data terminal ready line to hangup the **/
/** modem. **/
/*************************************************************************/
int modem_hangup(void)
{
TIO porttio;
TIO savetio;
log(L_DEBUG, "Hangup modem (drop dtr %d ms)...\n", setup.modem.toggle_dtr_time);
log(L_DEBUG, gettext("Hangup modem (drop dtr %d ms)...\n"), setup.modem.toggle_dtr_time);
modem_flush(1);
@ -162,9 +174,9 @@ int modem_hangup(void)
return(modem_set_termio(&savetio));
}
/*************************************************************************
** modem_set_sane_mode(): Sets modem terminal IO to sane mode. **
*************************************************************************/
/*************************************************************************/
/** modem_set_sane_mode(): Sets modem terminal IO to sane mode. **/
/*************************************************************************/
static void modem_set_sane_mode(TIO *modemtio, int local)
{
@ -175,9 +187,9 @@ static void modem_set_sane_mode(TIO *modemtio, int local)
modemtio->c_lflag = (ECHOK|ECHOE|ECHO|ISIG|ICANON);
}
/*************************************************************************
** modem_set_raw_mode(): Sets modem terminal IO to raw mode. **
*************************************************************************/
/*************************************************************************/
/** modem_set_raw_mode(): Sets modem terminal IO to raw mode. **/
/*************************************************************************/
static void modem_set_raw_mode(TIO *modemtio)
{
@ -188,23 +200,23 @@ static void modem_set_raw_mode(TIO *modemtio)
modemtio->c_cc[VTIME] = 0;
}
/*************************************************************************
** modem_initialize(): Initialize the modem. **
*************************************************************************/
/*************************************************************************/
/** modem_initialize(): Initialize the modem. **/
/*************************************************************************/
int modem_initialize(void)
{
TIO porttio;
log(L_INFO, "Initializing modem port (voice mode; %d ms)...\n", setup.modem.initpause);
log(L_INFO, gettext("Initializing modem port (voice mode; %d ms)...\n"), setup.modem.initpause);
xpause(setup.modem.initpause);
if (!modem_hangup()) log(L_WARN, "Can't hangup modem!\n");
if (!modem_hangup()) log(L_WARN, gettext("Can't hangup modem!\n"));
if (!modem_get_termio(&porttio))
{
log(L_ERROR, "Can't get modem terminal IO settings (not initialized).\n");
log(L_ERROR, gettext("Can't get modem terminal IO settings (not initialized).\n"));
returnerror();
}
@ -216,7 +228,7 @@ int modem_initialize(void)
if (!modem_set_termio(&porttio))
{
log(L_ERROR, "Can't set modem terminal IO settings (not initialized).\n");
log(L_ERROR, gettext("Can't set modem terminal IO settings (not initialized).\n"));
returnerror();
}
@ -229,34 +241,34 @@ int modem_initialize(void)
returnok();
}
/*************************************************************************
** modem_close_port(): Close modem port. **
*************************************************************************/
/*************************************************************************/
/** modem_close_port(): Close modem port. **/
/*************************************************************************/
void modem_close_port(void)
{
if (!modem_hangup()) log(L_WARN, "Can't hangup modem!\n");
if (!modem_hangup()) log(L_WARN, gettext("Can't hangup modem!\n"));
log(L_DEBUG, "Closing modem port (%d)...\n", setup.modem.fd);
log(L_DEBUG, gettext("Closing modem port (%d)...\n"), setup.modem.fd);
close(setup.modem.fd);
setup.modem.fd = -1;
}
/*************************************************************************
** modem_get_last_result(): Returns the last modem result. **
*************************************************************************/
/*************************************************************************/
/** modem_get_last_result(): Returns the last modem result. **/
/*************************************************************************/
char *modem_get_last_result(void)
{
return(modem_store_result);
}
/*************************************************************************
** modem_command(): Sends a command to the modem and waits for one or **
** more results. **
*************************************************************************/
/*************************************************************************/
/** modem_command(): Sends a command to the modem and waits for one or **/
/** more results. **/
/*************************************************************************/
int modem_command(char *command, char *result)
{
@ -273,15 +285,15 @@ int modem_command(char *command, char *result)
{
modem_flush(0);
log_line(L_DEBUG, "Sending \"");
log_line(L_DEBUG, gettext("Sending \""));
log_code(L_DEBUG, command);
log_text(L_DEBUG, "\"...\n");
log_text(L_DEBUG, gettext("\"...\n"));
if (strcmp(command, commandsuffix) != 0)
{
if ((!modem_write(command)) || (!modem_write(commandsuffix)))
{
log(L_ERROR, "Can't send modem command.\n");
log(L_ERROR, gettext("Can't send modem command.\n"));
modem_flush(1);
@ -290,7 +302,7 @@ int modem_command(char *command, char *result)
if (!modem_get_echo(command))
{
log(L_ERROR, "Can't read modem command echo.\n");
log(L_ERROR, gettext("Can't read modem command echo.\n"));
modem_flush(1);
@ -301,7 +313,7 @@ int modem_command(char *command, char *result)
{
if (!modem_write(command))
{
log(L_ERROR, "Can't send modem command.\n");
log(L_ERROR, gettext("Can't send modem command.\n"));
modem_flush(1);
@ -316,7 +328,7 @@ int modem_command(char *command, char *result)
{
if ((command) && (*command))
{
log(L_ERROR, "Can't read modem command result.\n");
log(L_ERROR, gettext("Can't read modem command result.\n"));
}
modem_flush(1);
@ -330,9 +342,9 @@ int modem_command(char *command, char *result)
if ((back = modem_check_result(line, result)) < 1)
{
log_line(L_ERROR, "Modem returns unneeded command \"");
log_line(L_ERROR, gettext("Modem returns unneeded command \""));
log_code(L_ERROR, line);
log_text(L_ERROR, "\".\n");
log_text(L_ERROR, gettext("\".\n"));
modem_flush(1);
@ -344,9 +356,9 @@ int modem_command(char *command, char *result)
returnok();
}
/*************************************************************************
** modem_get_s_register(): Returns a s-register value. **
*************************************************************************/
/*************************************************************************/
/** modem_get_s_register(): Returns a s-register value. **/
/*************************************************************************/
char *modem_get_s_register(int r)
{
@ -359,7 +371,7 @@ char *modem_get_s_register(int r)
if (modem_command(command, "?") == 1)
{
log(L_DEBUG, "Got s-register value '%s'.\n", modem_get_last_result());
log(L_DEBUG, gettext("Got s-register value \"%s\".\n"), modem_get_last_result());
modem_raw_read(temp, 4);
@ -370,9 +382,9 @@ char *modem_get_s_register(int r)
return("ERROR");
}
/*************************************************************************
** modem_check_result(): Checks for a string in the modem result. **
*************************************************************************/
/*************************************************************************/
/** modem_check_result(): Checks for a string in the modem result. **/
/*************************************************************************/
static int modem_check_result(char *have, char *need)
{
@ -381,9 +393,9 @@ static int modem_check_result(char *have, char *need)
char *more;
int nr;
log_line(L_DEBUG, "Waiting for \"");
log_line(L_DEBUG, gettext("Waiting for \""));
log_code(L_DEBUG, need);
log_text(L_DEBUG, "\"... ");
log_text(L_DEBUG, gettext("\"... "));
xstrncpy(line, need, MODEM_BUFFER_LEN);
@ -399,11 +411,11 @@ static int modem_check_result(char *have, char *need)
{
if (more)
{
log_text(L_DEBUG, "Got \"");
log_text(L_DEBUG, gettext("Got \""));
log_code(L_DEBUG, word);
log_text(L_DEBUG, "\" (%d).\n", nr);
log_text(L_DEBUG, gettext("\" (%d).\n"), nr);
}
else log_text(L_DEBUG, "Got it.\n");
else log_text(L_DEBUG, gettext("Got it.\n"));
return(nr);
}
@ -411,14 +423,14 @@ static int modem_check_result(char *have, char *need)
word = strtok(NULL, "|");
}
log_text(L_DEBUG, "Oops!\n");
log_text(L_DEBUG, gettext("Oops!\n"));
return(0);
}
/*************************************************************************
** modem_write(): Sends a null terminated string to the modem. **
*************************************************************************/
/*************************************************************************/
/** modem_write(): Sends a null terminated string to the modem. **/
/*************************************************************************/
static int modem_write(char *s)
{
@ -427,38 +439,38 @@ static int modem_write(char *s)
returnerror();
}
/*************************************************************************
** modem_raw_write(): Sends a string to the modem. **
*************************************************************************/
/*************************************************************************/
/** modem_raw_write(): Sends a string to the modem. **/
/*************************************************************************/
size_t modem_raw_write(char *string, int len)
{
return(write(setup.modem.fd, string, len));
}
/*************************************************************************
** modem_get_echo(): Reads modem echo. **
*************************************************************************/
/*************************************************************************/
/** modem_get_echo(): Reads modem echo. **/
/*************************************************************************/
static int modem_get_echo(char *echo)
{
return(modem_get_rawsequence(echo, TRUE));
}
/*************************************************************************
** modem_get_sequence(): Reads a specified sequence from the modem. **
*************************************************************************/
/*************************************************************************/
/** modem_get_sequence(): Reads a specified sequence from the modem. **/
/*************************************************************************/
int modem_get_sequence(char *seq)
{
return(modem_get_rawsequence(seq, FALSE));
}
/*************************************************************************
** modem_get_rawsequence(): Reads a raw sequence from modem. This is **
** ab subroutine for modem_get_sequence() & **
** modem_get_echo(). **
*************************************************************************/
/*************************************************************************/
/** modem_get_rawsequence(): Reads a raw sequence from modem. This is **/
/** a subroutine for modem_get_sequence() & **/
/** modem_get_echo(). **/
/*************************************************************************/
static int modem_get_rawsequence(char *line, int echo)
{
@ -468,7 +480,7 @@ static int modem_get_rawsequence(char *line, int echo)
timeout = (echo ? setup.modem.timeout_echo : setup.modem.timeout_cmd);
log(L_JUNK, "Reading modem %s (%d secs timeout)...\n", (echo ? "echo" : "sequence"), timeout);
log(L_JUNK, gettext("Reading modem %s (%d secs timeout)...\n"), (echo ? gettext("echo") : gettext("sequence")), timeout);
modem_set_timeout(timeout);
@ -477,12 +489,14 @@ static int modem_get_rawsequence(char *line, int echo)
if ((modem_raw_read(&c, 1) != 1) || (modem_get_timeout()))
{
modem_set_timeout(0);
returnerror();
}
if (line[i] != c)
{
modem_set_timeout(0);
returnerror();
}
}
@ -492,6 +506,7 @@ static int modem_get_rawsequence(char *line, int echo)
if ((modem_raw_read(&c, 1) != 1) || (modem_get_timeout()))
{
modem_set_timeout(0);
returnerror();
}
}
@ -506,9 +521,9 @@ static int modem_get_rawsequence(char *line, int echo)
returnok();
}
/*************************************************************************
** modem_read(): Reads a terminated string from the modem. **
*************************************************************************/
/*************************************************************************/
/** modem_read(): Reads a terminated string from the modem. **/
/*************************************************************************/
static int modem_read(char *line, int readtimeout)
{
@ -518,7 +533,7 @@ static int modem_read(char *line, int readtimeout)
int havetxt = FALSE;
int timeout;
log(L_JUNK, "Reading modem input (%d secs timeout)...\n", readtimeout);
log(L_JUNK, gettext("Reading modem input (%d secs timeout)...\n"), readtimeout);
modem_set_timeout(readtimeout);
@ -547,7 +562,7 @@ static int modem_read(char *line, int readtimeout)
if ((r != 1) || (timeout) || (linelen >= (MODEM_BUFFER_LEN - 1)) )
{
log(L_JUNK, "Can't read from modem [%d]%s.\n", r, (timeout ? " (timeout)" : ""));
log(L_JUNK, gettext("Can't read from modem [%d]%s.\n"), r, (timeout ? gettext(" (timeout)") : ""));
returnerror();
}
@ -555,9 +570,9 @@ static int modem_read(char *line, int readtimeout)
returnok();
}
/*************************************************************************
** modem_raw_read(): Reads a raw string from modem. **
*************************************************************************/
/*************************************************************************/
/** modem_raw_read(): Reads a raw string from modem. **/
/*************************************************************************/
int modem_raw_read(char *line, int len)
{
@ -567,12 +582,12 @@ int modem_raw_read(char *line, int len)
int i;
#ifdef DBG_NEW_MODEM_READER
log(L_JUNK, "[READ] Function request %d byte(s) (now pos %d; len %d).\n", len, modem_input_pos, modem_input_len);
log(L_JUNK, gettext("[READ] Function request %d byte(s) (now pos %d; len %d).\n"), len, modem_input_pos, modem_input_len);
#endif
if (len > MODEM_INPUT_LEN)
{
log(L_FATAL, "Internal modem buffer overflow (size %d; request %d)!\n", MODEM_INPUT_LEN, len);
log(L_FATAL, gettext("Internal modem buffer overflow (size %d; request %d)!\n"), MODEM_INPUT_LEN, len);
return(-1);
}
@ -585,7 +600,7 @@ int modem_raw_read(char *line, int len)
modem_input_pos += len;
#ifdef DBG_NEW_MODEM_READER
log(L_JUNK, "[READ] Return all %d bytes (now pos %d; len %d).\n", len, modem_input_pos, modem_input_len);
log(L_JUNK, gettext("[READ] Return all %d bytes (now pos %d; len %d).\n"), len, modem_input_pos, modem_input_len);
#endif
return(len);
@ -596,11 +611,11 @@ int modem_raw_read(char *line, int len)
memcpy(line, &modem_input[modem_input_pos], modem_input_len);
#ifdef DBG_NEW_MODEM_READER
log(L_JUNK, "[READ] Store %d of %d bytes (now pos 0; len 0).\n", modem_input_len, len);
log(L_JUNK, gettext("[READ] Store %d of %d bytes (now pos 0; len 0).\n"), modem_input_len, len);
#endif
}
#ifdef DBG_NEW_MODEM_READER
else log(L_JUNK, "[READ] Store nothing (pos 0; len 0).\n");
else log(L_JUNK, gettext("[READ] Store nothing (pos 0; len 0).\n"));
#endif
len -= modem_input_len;
@ -615,22 +630,22 @@ int modem_raw_read(char *line, int len)
modem_input_len = 0;
#ifdef DBG_NEW_MODEM_READER
log(L_JUNK, "[READ] Return only %d bytes (now pos %d; len %d).\n", use, modem_input_pos, modem_input_len);
log(L_JUNK, gettext("[READ] Return only %d bytes (now pos %d; len %d).\n"), use, modem_input_pos, modem_input_len);
#endif
return(use);
}
#ifdef DBG_NEW_MODEM_READER
log(L_JUNK, "[READ] Read %d bytes (now pos %d; len %d).\n", modem_input_len, modem_input_pos, modem_input_len);
log(L_JUNK, gettext("[READ] Read %d bytes (now pos %d; len %d).\n"), modem_input_len, modem_input_pos, modem_input_len);
#endif
for (i = 0; i < modem_input_len; i++)
{
#ifdef DBG_NEW_MODEM_READER
log_line(L_JUNK, "[READ] ");
log_line(L_JUNK, gettext("[READ] "));
log_char(L_JUNK, modem_input[i]);
log_text(L_JUNK, "\n");
log_text(L_JUNK, gettext("\n"));
#endif
modem_check_nocarrier(modem_input[i]);
@ -644,7 +659,7 @@ int modem_raw_read(char *line, int len)
modem_input_pos += len;
#ifdef DBG_NEW_MODEM_READER
log(L_JUNK, "[READ] Return %d bytes (now pos %d; len %d.\n", use + len, modem_input_pos, modem_input_len);
log(L_JUNK, gettext("[READ] Return %d bytes (now pos %d; len %d.\n"), use + len, modem_input_pos, modem_input_len);
#endif
return(use + len);
@ -659,9 +674,9 @@ int modem_raw_read(char *line, int len)
for (i = 0; i < r; i++)
{
#ifdef DBG_OLD_MODEM_READER
log_line(L_JUNK, "[OLDREAD] ");
log_line(L_JUNK, gettext("[OLDREAD] "));
log_char(L_JUNK, line[i]);
log_text(L_JUNK, "\n");
log_text(L_JUNK, gettext("\n"));
#endif
modem_check_nocarrier(line[i]);
@ -673,23 +688,23 @@ int modem_raw_read(char *line, int len)
#endif
}
/*************************************************************************
** modem_timeout_function(): **
*************************************************************************/
/*************************************************************************/
/** modem_timeout_function(): **/
/*************************************************************************/
static void modem_timeout_function(int s)
{
alarm(0);
signal(SIGALRM, SIG_IGN);
log(L_JUNK, "Timeout function called.\n");
log(L_JUNK, gettext("Timeout function called.\n"));
timeoutstatus = TRUE;
}
/*************************************************************************
** modem_set_timeout(): Sets the timeout for the modem functions. **
*************************************************************************/
/*************************************************************************/
/** modem_set_timeout(): Sets the timeout for the modem functions. **/
/*************************************************************************/
void modem_set_timeout(int timeout)
{
@ -707,18 +722,18 @@ void modem_set_timeout(int timeout)
}
}
/*************************************************************************
** modem_get_timeout(): Returns the timeout status. **
*************************************************************************/
/*************************************************************************/
/** modem_get_timeout(): Returns the timeout status. **/
/*************************************************************************/
int modem_get_timeout(void)
{
return(timeoutstatus);
}
/*************************************************************************
** modem_check_nocarrier(): Watchs the modem input for NO CARRIER. **
*************************************************************************/
/*************************************************************************/
/** modem_check_nocarrier(): Watchs the modem input for NO CARRIER. **/
/*************************************************************************/
static void modem_check_nocarrier(char c)
{
@ -728,7 +743,7 @@ static void modem_check_nocarrier(char c)
if (nocarrierpos >= strlen(nocarriertxt))
{
log(L_JUNK, "*** NO CARRIER ***\n");
log(L_JUNK, gettext("*** NO CARRIER ***\n"));
nocarrier = TRUE;
nocarrierpos = 0;
@ -742,9 +757,9 @@ static void modem_check_nocarrier(char c)
}
}
/*************************************************************************
** modem_flush(): Flushs modem input/output. **
*************************************************************************/
/*************************************************************************/
/** modem_flush(): Flushs modem input/output. **/
/*************************************************************************/
void modem_flush(int timeout)
{
@ -753,7 +768,7 @@ void modem_flush(int timeout)
long gotjunk = 0;
char onebyte = 0;
log(L_DEBUG, "Flushing modem%s...\n", (timeout ? " (timeout)" : ""));
log(L_DEBUG, gettext("Flushing modem%s...\n"), (timeout ? gettext(" (timeout)") : ""));
if (modem_get_termio(&porttio))
{
@ -769,15 +784,15 @@ void modem_flush(int timeout)
{
if (gotjunk++ < 20)
{
log_line(L_JUNK, "Junk: ");
log_line(L_JUNK, gettext("Junk: "));
log_char(L_JUNK, onebyte);
log_text(L_JUNK, "\n");
log_text(L_JUNK, gettext("\n"));
}
}
if (gotjunk > 20)
{
log(L_DEBUG, "Flush has junked %d bytes...\n", gotjunk);
log(L_DEBUG, gettext("Flush has junked %d bytes...\n"), gotjunk);
}
modem_set_termio(&savetio);
@ -788,9 +803,9 @@ void modem_flush(int timeout)
tcflush(setup.modem.fd, TCIOFLUSH);
}
/*************************************************************************
** modem_wait(): Waits for modem activity. **
*************************************************************************/
/*************************************************************************/
/** modem_wait(): Waits for modem activity. **/
/*************************************************************************/
int modem_wait(void)
{
@ -800,7 +815,7 @@ int modem_wait(void)
fd_set fd;
int back;
log(L_INFO, "Waiting...\n");
log(L_INFO, gettext("Waiting...\n"));
FD_ZERO(&fd);
FD_SET(setup.modem.fd, &fd);
@ -820,21 +835,21 @@ int modem_wait(void)
{
if (back < 0)
{
log(L_ERROR, "Select returns with error (%d)...\n", back);
log(L_ERROR, gettext("Select returns with error (%d)...\n"), back);
}
else log(L_JUNK, "Select returns with timeout...\n");
else log(L_JUNK, gettext("Select returns with timeout...\n"));
returnerror();
}
log(L_INFO, "Wakeup!\n");
log(L_INFO, gettext("Wakeup!\n"));
returnok();
}
/*************************************************************************
** modem_count_rings():
*************************************************************************/
/*************************************************************************/
/** modem_count_rings(): Counts incoming rings. **/
/*************************************************************************/
/* FIXME */
@ -857,7 +872,7 @@ int modem_count_rings(int needrings)
{
if (ctrl_ishere(setup.spool, CTRL_NAME_STOP))
{
log(L_INFO, "Control file '%s' exists - killing me now...\n", CTRL_NAME_STOP);
log(L_INFO, gettext("Control file \"%s\" exists - killing me now...\n"), CTRL_NAME_STOP);
kill(getpid(), SIGTERM);
}
@ -866,11 +881,11 @@ int modem_count_rings(int needrings)
{
if (ctrl_ishere(setup.spool, CTRL_NAME_REJECT))
{
log(L_INFO, "Control file '%s' exists - rejecting call...\n", CTRL_NAME_REJECT);
log(L_INFO, gettext("Control file \"%s\" exists - rejecting call...\n"), CTRL_NAME_REJECT);
if (!ctrl_remove(setup.spool, CTRL_NAME_REJECT))
{
log(L_WARN, "Can't remove control file '%s'!\n", CTRL_NAME_REJECT);
log(L_WARN, gettext("Can't remove control file \"%s\"!\n"), CTRL_NAME_REJECT);
}
returnerror();
@ -878,11 +893,11 @@ int modem_count_rings(int needrings)
if (ctrl_ishere(setup.spool, CTRL_NAME_ANSWERNOW))
{
log(L_INFO, "Control file '%s' exists - answering now...\n", CTRL_NAME_ANSWERNOW);
log(L_INFO, gettext("Control file \"%s\" exists - answering now...\n"), CTRL_NAME_ANSWERNOW);
if (!ctrl_remove(setup.spool, CTRL_NAME_ANSWERNOW))
{
log(L_WARN, "Can't remove control file '%s'!\n", CTRL_NAME_ANSWERNOW);
log(L_WARN, gettext("Can't remove control file \"%s\"!\n"), CTRL_NAME_ANSWERNOW);
}
returnok();
@ -890,21 +905,21 @@ int modem_count_rings(int needrings)
if (ctrl_ishere(setup.spool, CTRL_NAME_ANSWERALL))
{
log(L_INFO, "Control file '%s' exists - answering now...\n", CTRL_NAME_ANSWERALL);
log(L_INFO, gettext("Control file \"%s\" exists - answering now...\n"), CTRL_NAME_ANSWERALL);
returnok();
}
if (!setup.voice.doanswer)
{
log(L_INFO, "Call will not be answered - disabled in \"vboxrc\"...\n");
log(L_INFO, gettext("Call will not be answered - disabled in \"vboxrc\"...\n"));
returnerror();
}
if (needrings <= 0)
{
log(L_INFO, "Call will not be answered - no rings are set...\n");
log(L_INFO, gettext("Call will not be answered - no rings are set...\n"));
returnerror();
}
@ -916,35 +931,35 @@ int modem_count_rings(int needrings)
{
if (strcmp(sreg, "1") != 0)
{
log(L_INFO, "Incoming call is not voice - hanging up...\n");
log(L_INFO, gettext("Incoming call is not voice - hanging up...\n"));
returnerror();
}
}
else log(L_WARN, "Can't get incoming call type - I think it's voice...\n");
else log(L_WARN, gettext("Can't get incoming call type - I think it's voice...\n"));
voice_init_section();
xstrncpy(setup.voice.callerid, &line[15], VOICE_MAX_CALLERID);
log(L_INFO, "[%2d/%2d] CALLER NUMBER: %s...\n", haverings, needrings, setup.voice.callerid);
voice_user_section(setup.voice.callerid);
log(L_INFO, gettext("[%2d/%2d] CALLER NUMBER: %s (%s)...\n"), haverings, needrings, setup.voice.callerid, setup.voice.name);
if ((setup.voice.rings >= 0) && (setup.voice.rings != needrings))
{
log(L_DEBUG, "New number of rings from \"vboxrc\" are %d...\n", setup.voice.rings);
log(L_DEBUG, gettext("New number of rings from \"vboxrc\" are %d...\n"), setup.voice.rings);
needrings = setup.voice.rings;
}
if ((setup.voice.ringsonnew >= 0) && (setup.voice.ringsonnew != needrings))
{
log(L_DEBUG, "Checking for new messages in \"%s\"...\n", setup.voice.checknewpath);
log(L_DEBUG, gettext("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);
log(L_DEBUG, gettext("Found %d new messages; new number of rings are %d...\n"), n, setup.voice.ringsonnew);
needrings = setup.voice.ringsonnew;
}
@ -961,13 +976,13 @@ int modem_count_rings(int needrings)
{
haverings++;
log(L_INFO, "[%2d/%2d] RING...\n", haverings, needrings);
log(L_INFO, gettext("[%2d/%2d] RING...\n"), haverings, needrings);
}
else
{
log_line(L_JUNK, "Got junk line \"");
log_line(L_JUNK, gettext("Got junk line \""));
log_code(L_JUNK, line);
log_text(L_JUNK, "\"...\n");
log_text(L_JUNK, gettext("\"...\n"));
}
if ((haverings >= needrings) && (havesetup)) returnok();
@ -976,27 +991,27 @@ int modem_count_rings(int needrings)
returnerror();
}
/*************************************************************************
** modem_set_nocarrier_state(): Sets NO CARRIER state. **
*************************************************************************/
/*************************************************************************/
/** modem_set_nocarrier_state(): Sets NO CARRIER state. **/
/*************************************************************************/
void modem_set_nocarrier_state(int state)
{
nocarrier = state;
}
/*************************************************************************
** modem_get_nocarrier_state(): Returns NO CARRIER state. **
*************************************************************************/
/*************************************************************************/
/** modem_get_nocarrier_state(): Returns NO CARRIER state. **/
/*************************************************************************/
int modem_get_nocarrier_state(void)
{
return(nocarrier);
}
/*************************************************************************
** modem_check_input(): Checks for modem input. **
*************************************************************************/
/*************************************************************************/
/** modem_check_input(): Checks for modem input. **/
/*************************************************************************/
int modem_check_input(void)
{

View File

@ -4,6 +4,8 @@
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
*/
#include "config.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@ -15,26 +17,26 @@
#include "perms.h"
#include "libvbox.h"
/*************************************************************************
** permissions_set(): Sets file permissions. **
*************************************************************************/
/*************************************************************************/
/** permissions_set(): Sets file permissions. **/
/*************************************************************************/
int permissions_set(char *name, uid_t uid, gid_t gid, mode_t mode, mode_t mask)
{
mode_t realmode = (mode & ~mask);
log(L_DEBUG, "Setting \"%s\" to %d.%d (%04o)...\n", name, uid, gid, realmode);
log(L_DEBUG, gettext("Setting \"%s\" to %d.%d (%04o)...\n"), name, uid, gid, realmode);
if (chown(name, uid, gid) == -1)
{
log(L_ERROR, "Can't set owner of \"%s\" (%s).\n", name, strerror(errno));
log(L_ERROR, gettext("Can't set owner of \"%s\" (%s).\n"), name, strerror(errno));
returnerror();
}
if (chmod(name, realmode) == -1)
{
log(L_ERROR, "Can't set mode of \"%s\" (%s).\n", name, strerror(errno));
log(L_ERROR, gettext("Can't set mode of \"%s\" (%s).\n"), name, strerror(errno));
returnerror();
}
@ -42,14 +44,14 @@ int permissions_set(char *name, uid_t uid, gid_t gid, mode_t mode, mode_t mask)
returnok();
}
/*************************************************************************
** permissions_drop(): Drops user privilegs and sets some environments **
** for the external commands. **
*************************************************************************/
/*************************************************************************/
/** permissions_drop(): Drops user privilegs and sets some environments **/
/** for the external commands. **/
/*************************************************************************/
int permissions_drop(uid_t uid, gid_t gid, char *name, char *home)
{
log(L_INFO, "Drop permissions to userid %d; groupid %d...\n", uid, gid);
log(L_INFO, gettext("Drop permissions to userid %d; groupid %d...\n"), uid, gid);
if (setregid(gid, gid) == 0)
{
@ -62,11 +64,11 @@ int permissions_drop(uid_t uid, gid_t gid, char *name, char *home)
returnok();
}
else log(L_FATAL, "Can't set working directory to \"%s\" (%s).\n", home, strerror(errno));
else log(L_FATAL, gettext("Can't set working directory to \"%s\" (%s).\n"), home, strerror(errno));
}
else log(L_FATAL, "Can't setreuid() to %d, %d (%s).\n", uid, uid, strerror(errno));
else log(L_FATAL, gettext("Can't setreuid() to %d, %d (%s).\n"), uid, uid, strerror(errno));
}
else log(L_FATAL, "Can't setregid() to %d, %d (%s).\n", gid, gid, strerror(errno));
else log(L_FATAL, gettext("Can't setregid() to %d, %d (%s).\n"), gid, gid, strerror(errno));
returnerror();
}

View File

@ -4,6 +4,8 @@
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
*/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
@ -66,9 +68,9 @@ static struct rctable rct[] =
{ NULL, NULL, 0, 0, NULL}
};
/*************************************************************************
** getty_get_settings(): Reads and parse vboxgetty's settings. **
*************************************************************************/
/*************************************************************************/
/** getty_get_settings(): Reads and parse vboxgetty's settings. **/
/*************************************************************************/
int getty_get_settings(char *rcname)
{
@ -80,7 +82,7 @@ int getty_get_settings(char *rcname)
int result;
int i;
log(L_DEBUG, "Parsing settings in '%s' for port '%s'...\n", rcname, setup.modem.device);
log(L_DEBUG, gettext("Parsing settings in \"%s\" for port \"%s\"...\n"), rcname, setup.modem.device);
xstrncpy(setup.modem.interninita , "AT+FCLASS=8" , MODEM_MAX_INITSTRING);
xstrncpy(setup.modem.interninitb , "ATS18=1S13.2=1S13.4=1" , MODEM_MAX_INITSTRING);
@ -102,8 +104,10 @@ int getty_get_settings(char *rcname)
setup.users.gid = 0;
setup.users.umask = S_IRWXG|S_IRWXO;
/* Parse the configuration and put all correct values into the */
/* global structure. */
/*
* Parse the configuration and put all correct values into the
* global structure.
*/
if ((rc = streamio_open(rcname)))
{
@ -115,7 +119,7 @@ int getty_get_settings(char *rcname)
{
xstrncpy(parsedevice, arg, MODEM_MAX_TTYNAME);
log(L_DEBUG, "Found command '%s = %s'...\n", cmd, arg);
log(L_DEBUG, gettext("Found command '%s = %s'...\n"), cmd, arg);
continue;
}
@ -130,12 +134,12 @@ int getty_get_settings(char *rcname)
{
if (!(msg = rct[i].parsefunction(cmd, arg, rct[i].ptr, rct[i].min, rct[i].max)))
{
log(L_DEBUG, "Found command '%s = %s' (%s)...\n", cmd, arg, parsedevice);
log(L_DEBUG, gettext("Found command '%s = %s' (%s)...\n"), cmd, arg, parsedevice);
}
else
{
log(L_ERROR, "Bad value '%s' for command '%s' ignored (%s)...\n", arg, cmd, parsedevice);
log(L_ERROR, "Parser returns \"%s\" (min %d; max %d).\n", msg, rct[i].min, rct[i].max);
log(L_ERROR, gettext("Bad value \"%s\" for command \"%s\" ignored (%s)...\n"), arg, cmd, parsedevice);
log(L_ERROR, gettext("Parser returns \"%s\" (min %d; max %d).\n"), msg, rct[i].min, rct[i].max);
}
break;
@ -146,7 +150,7 @@ int getty_get_settings(char *rcname)
if (!rct[i].name)
{
log(L_WARN, "Unknown command '%s' ignored (%s)...\n", cmd, parsedevice);
log(L_WARN, gettext("Unknown command \"%s\" ignored (%s)...\n"), cmd, parsedevice);
}
}
}
@ -155,15 +159,15 @@ int getty_get_settings(char *rcname)
if (!result)
{
if (!*cmd) log(L_ERROR, "Error in '%s': Missing command.\n", rcname);
if (!*arg) log(L_ERROR, "Error in '%s': Missing argument (%s).\n", rcname, cmd);
if (!*cmd) log(L_ERROR, gettext("Error in \"%s\": Missing command.\n"), rcname);
if (!*arg) log(L_ERROR, gettext("Error in \"%s\": Missing argument (%s).\n"), rcname, cmd);
returnerror();
}
}
else
{
log(L_ERROR, "Can't open '%s'.\n", rcname);
log(L_ERROR, gettext("Can't open \"%s\".\n"), rcname);
returnerror();
}
@ -171,9 +175,9 @@ int getty_get_settings(char *rcname)
returnok();
}
/*************************************************************************
** parse_line(): Splits a line into command and argument. **
*************************************************************************/
/*************************************************************************/
/** parse_line(): Splits a line into command and argument. **/
/*************************************************************************/
static int parse_line(streamio_t *rc, char *cmd, int maxcmd, char *arg, int maxarg)
{
@ -212,9 +216,9 @@ static int parse_line(streamio_t *rc, char *cmd, int maxcmd, char *arg, int maxa
return(-1);
}
/*************************************************************************
** parse_cmp(): Converts string into compression mode. **
*************************************************************************/
/*************************************************************************/
/** parse_cmp(): Converts string into compression mode. **/
/*************************************************************************/
static char *parse_cmp(char *cmd, char *arg, void *ptr, int min, int max)
{
@ -226,18 +230,18 @@ static char *parse_cmp(char *cmd, char *arg, void *ptr, int min, int max)
if (strcasecmp(arg, "alaw" ) == 0) cmp = 5;
if (strcasecmp(arg, "ulaw" ) == 0) cmp = 6;
if ((cmp < min) || (cmp > max)) return("unknown compression");
if ((cmp < min) || (cmp > max)) return(gettext("unknown compression"));
if (cmp == 5) return("alaw not longer supported");
if (cmp == 5) return(gettext("alaw not longer supported"));
(*(int *)ptr) = cmp;
return(NULL);
}
/*************************************************************************
** parse_int(): Converts string into integer number. **
*************************************************************************/
/*************************************************************************/
/** parse_int(): Converts string into integer number. **/
/*************************************************************************/
static char *parse_int(char *cmd, char *arg, void *ptr, int min, int max)
{
@ -253,15 +257,15 @@ static char *parse_int(char *cmd, char *arg, void *ptr, int min, int max)
return(NULL);
}
if (nr < min) return("value too small");
if (nr > max) return("value too big");
if (nr < min) return(gettext("value too small"));
if (nr > max) return(gettext("value too big"));
return("can't convert value to integer");
return(gettext("can't convert value to integer"));
}
/*************************************************************************
** parse_gid(): Converts string into groupid. **
*************************************************************************/
/*************************************************************************/
/** parse_gid(): Converts string into groupid. **/
/*************************************************************************/
static char *parse_gid(char *cmd, char *arg, void *ptr, int min, int max)
{
@ -274,12 +278,12 @@ static char *parse_gid(char *cmd, char *arg, void *ptr, int min, int max)
return(NULL);
}
return("unknown groupname");
return(gettext("unknown groupname"));
}
/*************************************************************************
** parse_uid(): Converts string into userid. **
*************************************************************************/
/*************************************************************************/
/** parse_uid(): Converts string into userid. **/
/*************************************************************************/
static char *parse_uid(char *cmd, char *arg, void *ptr, int min, int max)
{
@ -292,12 +296,12 @@ static char *parse_uid(char *cmd, char *arg, void *ptr, int min, int max)
return(NULL);
}
return("unknown username");
return(gettext("unknown username"));
}
/*************************************************************************
** parse_str(): Converts string to string (that's magic :-). **
*************************************************************************/
/*************************************************************************/
/** parse_str(): Converts string to string (that's magic :-). **/
/*************************************************************************/
static char *parse_str(char *cmd, char *arg, void *ptr, int min, int max)
{
@ -306,9 +310,9 @@ static char *parse_str(char *cmd, char *arg, void *ptr, int min, int max)
return(NULL);
}
/*************************************************************************
** parse_msk(): Converts string into umask (octal). **
*************************************************************************/
/*************************************************************************/
/** parse_msk(): Converts string into umask (octal). **/
/*************************************************************************/
static char *parse_msk(char *cmd, char *arg, void *ptr, int min, int max)
{
@ -324,5 +328,5 @@ static char *parse_msk(char *cmd, char *arg, void *ptr, int min, int max)
return(NULL);
}
return("unknown umask");
return(gettext("unknown umask"));
}

View File

@ -4,6 +4,8 @@
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -33,10 +35,10 @@ static char *weekdaynames[] =
NULL
};
/*************************************************************************
** vboxrc_return_time(): Converts a time string to seconds since the **
** 1st januar 1970. **
*************************************************************************/
/*************************************************************************/
/** vboxrc_return_time(): Converts a time string to seconds since the **/
/** 1st januar 1970. **/
/*************************************************************************/
static time_t vboxrc_return_time(time_t timenow, char *timestr, int mode)
{
@ -82,10 +84,10 @@ static time_t vboxrc_return_time(time_t timenow, char *timestr, int mode)
return(mktime(&localb));
}
/*************************************************************************
** vboxrc_return_timestr(): Converts a unix time into a string like **
** HH:MM:SS. **
*************************************************************************/
/*************************************************************************/
/** vboxrc_return_timestr(): Converts a unix time into a string like **/
/** HH:MM:SS. **/
/*************************************************************************/
static void vboxrc_return_timestr(time_t timeint, char *timestr)
{
@ -99,10 +101,10 @@ static void vboxrc_return_timestr(time_t timeint, char *timestr)
xstrncpy(timestr, "??:??:??", 8);
}
/*************************************************************************
** vboxrc_parse_time(): Checks if one or more timestring match the **
** current time. **
*************************************************************************/
/*************************************************************************/
/** vboxrc_parse_time(): Checks if one or more timestring match the **/
/** current time. **/
/*************************************************************************/
static int vboxrc_parse_time(char *timestr)
{
@ -118,7 +120,7 @@ static int vboxrc_parse_time(char *timestr)
time_t timesecsbeg;
time_t timesecsend;
log(L_DEBUG, "Parsing time(s) \"%s\"...\n", timestr);
log(L_DEBUG, gettext("Parsing time(s) \"%s\"...\n"), timestr);
xstrncpy(timestring, timestr, VBOXRC_MAX_RCLINE);
@ -129,14 +131,14 @@ static int vboxrc_parse_time(char *timestr)
if (strcmp(timestring, "*") == 0)
{
log(L_DEBUG, "Range **:**:** - **:**:** (%s): match.\n", timevaluenow);
log(L_DEBUG, gettext("Range **:**:** - **:**:** (%s): match.\n"), timevaluenow);
returnok();
}
if ((strcmp(timestring, "!") == 0) || (strcmp(timestring, "-") == 0))
{
log(L_DEBUG, "Range --:--:-- - --:--:-- (%s): don't match.\n", timevaluenow);
log(L_DEBUG, gettext("Range --:--:-- - --:--:-- (%s): don't match.\n"), timevaluenow);
returnerror();
}
@ -166,32 +168,32 @@ static int vboxrc_parse_time(char *timestr)
vboxrc_return_timestr(timesecsend, timevalueend);
vboxrc_return_timestr(timenow , timevaluenow);
log_line(L_DEBUG, "Range %s - %s (%s): ", timevaluebeg, timevalueend, timevaluenow);
log_line(L_DEBUG, gettext("Range %s - %s (%s): "), timevaluebeg, timevalueend, timevaluenow);
if ((timenow >= timesecsbeg) && (timenow <= timesecsend))
{
log_text(L_DEBUG, "match.\n");
log_text(L_DEBUG, gettext("match.\n"));
returnok();
}
else log_text(L_DEBUG, "don't match.\n");
else log_text(L_DEBUG, gettext("don't match.\n"));
}
else log(L_WARN, "Bad time; start greater than end (%s-%s) - ignored...\n", timebeg, timeend);
else log(L_WARN, gettext("Bad time; start greater than end (%s-%s) - ignored...\n"), timebeg, timeend);
}
else log(L_WARN, "Bad time; can't convert timestring (%s-%s) - ignored...\n", timebeg, timeend);
else log(L_WARN, gettext("Bad time; can't convert timestring (%s-%s) - ignored...\n"), timebeg, timeend);
timeptr = timenxt;
}
log(L_JUNK, "String contains no matching time!\n");
log(L_JUNK, gettext("String contains no matching time!\n"));
returnerror();
}
/*************************************************************************
** vboxrc_parse_days(): Checks if one or more daystrings match the **
** current day. **
*************************************************************************/
/*************************************************************************/
/** vboxrc_parse_days(): Checks if one or more daystrings match the **/
/** current day. **/
/*************************************************************************/
static int vboxrc_parse_days(char *strdays)
{
@ -205,18 +207,18 @@ static int vboxrc_parse_days(char *strdays)
xstrncpy(days, strdays, VBOXRC_MAX_RCLINE);
log(L_DEBUG, "Parsing day(s) \"%s\"...\n", days);
log(L_DEBUG, gettext("Parsing day(s) \"%s\"...\n"), days);
if (strcmp(days, "*") == 0)
{
log(L_DEBUG, "Range *: match.\n");
log(L_DEBUG, gettext("Range *: match.\n"));
returnok();
}
if ((strcmp(days, "-") == 0) || (strcmp(days, "!") == 0))
{
log(L_DEBUG, "Range -: don't match.\n");
log(L_DEBUG, gettext("Range -: don't match.\n"));
returnerror();
}
@ -225,7 +227,7 @@ static int vboxrc_parse_days(char *strdays)
if (!(timelocal = localtime(&currenttime)))
{
log(L_ERROR, "Can't get local time (don't match)...\n");
log(L_ERROR, gettext("Can't get local time (don't match)...\n"));
returnerror();
}
@ -234,7 +236,7 @@ static int vboxrc_parse_days(char *strdays)
{
if ((!isalpha(days[i])) && (days[i] != ','))
{
log(L_ERROR, "Error in day string \"%s\" in line #%ld (don't match).\n", days, setup.vboxrc->line);
log(L_ERROR, gettext("Error in day string \"%s\" in line #%ld (don't match).\n"), days, setup.vboxrc->line);
returnerror();
}
@ -255,11 +257,11 @@ static int vboxrc_parse_days(char *strdays)
{
if (d == timelocal->tm_wday)
{
log(L_DEBUG, "Range %s: match.\n", beg);
log(L_DEBUG, gettext("Range %s: match.\n"), beg);
returnok();
}
else log(L_DEBUG, "Range %s: don't match.\n", beg);
else log(L_DEBUG, gettext("Range %s: don't match.\n"), beg);
}
d++;
@ -271,20 +273,20 @@ static int vboxrc_parse_days(char *strdays)
beg = nxt;
}
log(L_JUNK, "String contains no matching day!\n");
log(L_JUNK, gettext("String contains no matching day!\n"));
returnerror();
}
/*************************************************************************
** vboxrc_goto_section(): Jump to a specified section. **
*************************************************************************/
/*************************************************************************/
/** vboxrc_goto_section(): Jump to a specified section. **/
/*************************************************************************/
static int vboxrc_goto_section(char *section)
{
char line[VBOXRC_MAX_RCLINE + 1];
log(L_JUNK, "Jumping to section %s...\n", section);
log(L_JUNK, gettext("Jumping to section \"%s\"...\n"), section);
setup.vboxrc = streamio_reopen(setup.vboxrc);
@ -296,10 +298,10 @@ static int vboxrc_goto_section(char *section)
returnerror();
}
/*************************************************************************
** vboxrc_get_rings_to_wait(): Returns the number of rings to answer **
** call. **
*************************************************************************/
/*************************************************************************/
/** vboxrc_get_rings_to_wait(): Returns the number of rings to answer **/
/** call. **/
/*************************************************************************/
int vboxrc_get_rings_to_wait(void)
{
@ -310,7 +312,7 @@ int vboxrc_get_rings_to_wait(void)
char *stop;
int need;
log(L_DEBUG, "Getting number of rings to wait before answer call...\n");
log(L_DEBUG, gettext("Getting number of rings to wait before answer call...\n"));
need = VBOXRC_DEF_RINGS;
@ -326,7 +328,7 @@ int vboxrc_get_rings_to_wait(void)
if ((!time) || (!ring) || (!days))
{
log(L_ERROR, "Error in vboxrc line #%ld (ignored).\n", setup.vboxrc->line);
log(L_ERROR, gettext("Error in vboxrc line #%ld (ignored).\n"), setup.vboxrc->line);
continue;
}
@ -337,30 +339,30 @@ int vboxrc_get_rings_to_wait(void)
if (*stop != 0)
{
log(L_ERROR, "Bad number of rings in line #%ld (ignored).\n", setup.vboxrc->line);
log(L_ERROR, gettext("Bad number of rings in line #%ld (ignored).\n"), setup.vboxrc->line);
need = VBOXRC_DEF_RINGS;
}
else
{
log(L_DEBUG, "Call will be answered after %ld rings...\n", need);
log(L_DEBUG, gettext("Call will be answered after %ld rings...\n"), need);
return(need);
}
}
}
}
else log(L_WARN, "Unable to locate section [RINGS] (useing defaults)...\n");
else log(L_WARN, gettext("Unable to locate section \"[RINGS]\" (useing defaults)...\n"));
log(L_WARN, "Call will be answered after %ld rings (default)...\n", need);
log(L_WARN, gettext("Call will be answered after %ld rings (default)...\n"), need);
return(need);
}
/*************************************************************************
** vboxrc_find_user_from_id(): Finds a user with a specified caller **
** number. **
*************************************************************************/
/*************************************************************************/
/** vboxrc_find_user_from_id(): Finds a user with a specified caller **/
/** number. **/
/*************************************************************************/
void vboxrc_find_user_from_id(char *id)
{
@ -370,7 +372,7 @@ void vboxrc_find_user_from_id(char *id)
char *owner;
char *dummy;
log(L_DEBUG, "Searching user with caller number \"%s\"...\n", id);
log(L_DEBUG, gettext("Searching user with caller number \"%s\"...\n"), id);
if (vboxrc_goto_section("[CALLERIDS]"))
{
@ -397,7 +399,7 @@ void vboxrc_find_user_from_id(char *id)
if ((!owner) || (!phone) || (!table))
{
log(L_ERROR, "Error in vboxrc line #%ld (ignored).\n", setup.vboxrc->line);
log(L_ERROR, gettext("Error in vboxrc line #%ld (ignored).\n"), setup.vboxrc->line);
continue;
}
@ -413,21 +415,21 @@ void vboxrc_find_user_from_id(char *id)
xstrncpy(setup.voice.name, owner, VOICE_MAX_NAME);
log(L_DEBUG, "Caller number match user \"%s\"...\n", setup.voice.name);
log(L_DEBUG, "Section \"[%s]\" will be used...\n", setup.voice.section);
log(L_DEBUG, gettext("Caller number match user \"%s\"...\n"), setup.voice.name);
log(L_DEBUG, gettext("Section \"[%s]\" will be used...\n"), setup.voice.section);
return;
}
}
}
else log(L_WARN, "Unable to locate section [CALLERIDS] (useing defaults)...\n");
else log(L_WARN, gettext("Unable to locate section \"[CALLERIDS]\" (useing defaults)...\n"));
log(L_WARN, "Section \"[%s]\" will be used (default)...\n", setup.voice.section);
log(L_WARN, gettext("Section \"[%s]\" will be used (default)...\n"), setup.voice.section);
}
/*************************************************************************
** vboxrc_find_user_section(): Finds a specified user section. **
*************************************************************************/
/*************************************************************************/
/** vboxrc_find_user_section(): Finds a specified user section. **/
/*************************************************************************/
void vboxrc_find_user_section(char *section)
{
@ -442,7 +444,7 @@ void vboxrc_find_user_section(char *section)
sprintf(line, "[%s]", section);
log(L_DEBUG, "Parsing settings from section \"%s\"...\n", line);
log(L_DEBUG, gettext("Parsing settings from section \"%s\"...\n"), line);
correct = FALSE;
@ -459,7 +461,7 @@ void vboxrc_find_user_section(char *section)
if ((!time) || (!text) || (!strg) || (!days))
{
log(L_ERROR, "Error in vboxrc line #%ld (ignored).\n", setup.vboxrc->line);
log(L_ERROR, gettext("Error in vboxrc line #%ld (ignored).\n"), setup.vboxrc->line);
continue;
}
@ -470,7 +472,7 @@ void vboxrc_find_user_section(char *section)
if ((*stop != 0) || (setup.voice.recordtime < 0))
{
log(L_ERROR, "Bad record time in line #%ld (using defaults).\n", setup.vboxrc->line);
log(L_ERROR, gettext("Bad record time in line #%ld (using defaults).\n"), setup.vboxrc->line);
setup.voice.recordtime = 60;
}
@ -485,7 +487,7 @@ void vboxrc_find_user_section(char *section)
while ((text = strtok(NULL, "\t ")))
{
log(L_JUNK, "Found Flag \"%s\"...\n", text);
log(L_JUNK, gettext("Found Flag \"%s\"...\n"), text);
if (strcasecmp(text, "NOANSWER" ) == 0) setup.voice.doanswer = FALSE;
if (strcasecmp(text, "NORECORD" ) == 0) setup.voice.dorecord = FALSE;
@ -503,7 +505,7 @@ void vboxrc_find_user_section(char *section)
if ((*stop != 0) || (setup.voice.rings < 0))
{
log(L_ERROR, "Bad flag RINGS in line #%ld (ignored).\n", setup.vboxrc->line);
log(L_ERROR, gettext("Bad flag RINGS in line #%ld (ignored).\n"), setup.vboxrc->line);
setup.voice.rings = -1;
}
@ -520,7 +522,7 @@ void vboxrc_find_user_section(char *section)
if ((*stop != 0) || (setup.voice.ringsonnew < 0))
{
log(L_ERROR, "Bad flag TOLLRINGS in line #%ld (ignored).\n", setup.vboxrc->line);
log(L_ERROR, gettext("Bad flag TOLLRINGS in line #%ld (ignored).\n"), setup.vboxrc->line);
setup.voice.ringsonnew = -1;
}
@ -560,35 +562,34 @@ void vboxrc_find_user_section(char *section)
}
}
}
else log(L_WARN, "Unable to locate section \"%s\" (useing defaults)...\n", line);
else log(L_WARN, gettext("Unable to locate section \"%s\" (useing defaults)...\n"), line);
if (!correct)
{
log(L_WARN, "No (or not all) settings found (using defaults)...\n");
log(L_WARN, gettext("No (or not all) settings found (using defaults)...\n"));
}
log(L_JUNK, "Settings: Message \"%s\".\n", setup.voice.standardmsg);
log(L_JUNK, "Settings: Beep \"%s\".\n", setup.voice.beepmsg);
log(L_JUNK, "Settings: Timeout \"%s\".\n", setup.voice.timeoutmsg);
log(L_JUNK, "Settings: Script \"%s\".\n", setup.voice.tclscriptname);
log(L_JUNK, gettext("Settings: Message \"%s\".\n"), setup.voice.standardmsg);
log(L_JUNK, gettext("Settings: Beep \"%s\".\n"), setup.voice.beepmsg);
log(L_JUNK, gettext("Settings: Timeout \"%s\".\n"), setup.voice.timeoutmsg);
log(L_JUNK, gettext("Settings: Script \"%s\".\n"), setup.voice.tclscriptname);
if (setup.voice.rings > 0)
{
log(L_JUNK, "Settings: Rings changed to %d.\n", setup.voice.rings);
log(L_JUNK, gettext("Settings: Rings changed to %d.\n"), setup.voice.rings);
}
else log(L_JUNK, "Settings: Rings not changed.\n");
else log(L_JUNK, gettext("Settings: Rings not changed.\n"));
if (setup.voice.ringsonnew > 0)
{
log(L_JUNK, "Settings: Rings changed to %d if new message exist.\n", setup.voice.ringsonnew);
log(L_JUNK, "Settings: Check for new messages in \"%s\".\n", setup.voice.checknewpath);
log(L_JUNK, gettext("Settings: Rings changed to %d if new message exist.\n"), setup.voice.ringsonnew);
log(L_JUNK, gettext("Settings: Check for new messages in \"%s\".\n"), setup.voice.checknewpath);
}
log(L_JUNK, "Settings: %d secs record time.\n", setup.voice.recordtime);
log(L_JUNK, "Settings: %s call.\n", setup.voice.doanswer ? "Answer" : "Don't answer");
log(L_JUNK, "Settings: %s a message.\n", setup.voice.dorecord ? "Record" : "Don't record");
log(L_JUNK, "Settings: %s standard message.\n", setup.voice.domessage ? "Play" : "Don't play");
log(L_JUNK, "Settings: %s beep message.\n", setup.voice.dobeep ? "Play" : "Don't play");
log(L_JUNK, "Settings: %s timeout message.\n", setup.voice.dotimeout ? "Play" : "Don't play");
log(L_JUNK, gettext("Settings: %d secs record time.\n"), setup.voice.recordtime);
log(L_JUNK, gettext("Settings: %s.\n"), setup.voice.doanswer ? gettext("Answer call") : gettext("Don't answer call"));
log(L_JUNK, gettext("Settings: %s.\n"), setup.voice.dorecord ? gettext("Record a message") : gettext("Don't record a message"));
log(L_JUNK, gettext("Settings: %s.\n"), setup.voice.domessage ? gettext("Play standard message") : gettext("Don't play standard message"));
log(L_JUNK, gettext("Settings: %s.\n"), setup.voice.dobeep ? gettext("Play beep message") : gettext("Don't play beep message"));
log(L_JUNK, gettext("Settings: %s.\n"), setup.voice.dotimeout ? gettext("Play timeout message") : gettext("Don't play timeout message"));
}

View File

@ -4,14 +4,25 @@
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
*/
#include "config.h"
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include <stdio.h>
#include <stdlib.h>
#include <tcl.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include "runtime.h"
#include "script.h"
#include "log.h"
#include "voice.h"
@ -37,9 +48,9 @@ int vbox_get_nr_all_messages(ClientData, Tcl_Interp *, int, char *[]);
struct minlist breaklist;
/*************************************************************************
** script_run(): Starts a external tcl script. **
*************************************************************************/
/*************************************************************************/
/** script_run(): Starts a external tcl script. **/
/*************************************************************************/
int script_run(char *script)
{
@ -51,7 +62,7 @@ int script_run(char *script)
int havecreated;
int result;
log(L_INFO, "Running tcl script \"%s\"...\n", script);
log(L_INFO, gettext("Running tcl script \"%s\"...\n"), script);
list_init(&breaklist);
@ -111,47 +122,47 @@ int script_run(char *script)
if (Tcl_EvalFile(interpreter, script) != TCL_OK)
{
log(L_ERROR, "In \"%s\": %s (line %d).\n", script, interpreter->result, interpreter->errorLine);
log(L_ERROR, gettext("In \"%s\": %s (line %d).\n"), script, interpreter->result, interpreter->errorLine);
}
else
{
log(L_DEBUG, "Back from tcl script...\n");
log(L_DEBUG, gettext("Back from tcl script...\n"));
result = TRUE;
}
}
else log(L_ERROR, "In \"%s\": %s (line %d).\n", script, interpreter->result, interpreter->errorLine);
else log(L_ERROR, gettext("In \"%s\": %s (line %d).\n"), script, interpreter->result, interpreter->errorLine);
}
else log(L_FATAL, "Can't create all new tcl commands.\n");
else log(L_FATAL, gettext("Can't create all new tcl commands.\n"));
if (Tcl_InterpDeleted(interpreter) == 0)
{
Tcl_DeleteInterp(interpreter);
}
}
else log(L_FATAL, "Can't initialize tcl interpreter.\n");
else log(L_FATAL, gettext("Can't initialize tcl interpreter.\n"));
}
else log(L_FATAL, "Can't create tcl interpreter.\n");
else log(L_FATAL, gettext("Can't create tcl interpreter.\n"));
list_exit(&breaklist);
return(result);
}
/*************************************************************************
** script_check_interpreter(): Checks tcl interpreter versions. **
*************************************************************************/
/*************************************************************************/
/** script_check_interpreter(): Checks tcl interpreter versions. **/
/*************************************************************************/
int script_check_interpreter(void)
{
log(L_INFO, "Tcl interpreter version %s...\n", TCL_VERSION);
log(L_INFO, gettext("Tcl interpreter version %s...\n"), TCL_VERSION);
returnok();
}
/*************************************************************************
** vbox_breaklist(): DTMF sequence support. **
*************************************************************************/
/*************************************************************************/
/** vbox_breaklist(): DTMF sequence support. **/
/*************************************************************************/
int vbox_breaklist(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
{
@ -182,7 +193,7 @@ int vbox_breaklist(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
return(TCL_OK);
}
}
else log(L_ERROR, "[vbox_breaklist] unsupported argument \"%s\"", argv[1]);
else log(L_ERROR, gettext("[vbox_breaklist] unsupported argument \"%s\"."), argv[1]);
}
else
{
@ -194,24 +205,24 @@ int vbox_breaklist(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
while (node)
{
log(L_INFO, "[vbox_breaklist] %s\n", node->ln_name);
log(L_INFO, gettext("[vbox_breaklist] %s\n"), node->ln_name);
node = node->ln_next;
}
return(TCL_OK);
}
else log(L_ERROR, "[vbox_breaklist] unsupported argument \"%s\"", argv[1]);
else log(L_ERROR, gettext("[vbox_breaklist] unsupported argument \"%s\"."), argv[1]);
}
else log(L_ERROR, "[vbox_breaklist] usage: vbox_breaklist <rem|add> <sequence>");
else log(L_ERROR, gettext("[vbox_breaklist] usage: vbox_breaklist <rem|add> <sequence>\n"));
}
return(TCL_OK);
}
/*************************************************************************
** vbox_put_message(): Plays a voice message. **
*************************************************************************/
/*************************************************************************/
/** vbox_put_message(): Plays a voice message. **/
/*************************************************************************/
int vbox_put_message(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
{
@ -219,7 +230,7 @@ int vbox_put_message(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
if (argc != 2)
{
log(L_ERROR, "[vbox_put_message] usage: vbox_put_message <messagename>\n");
log(L_ERROR, gettext("[vbox_put_message] usage: vbox_put_message <messagename>\n"));
printstring(ip->result, "ERROR");
}
@ -248,15 +259,15 @@ int vbox_put_message(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
break;
}
log(L_DEBUG, "[vbox_put_message] result \"%s\".\n", ip->result);
log(L_DEBUG, gettext("[vbox_put_message] result \"%s\".\n"), ip->result);
}
return(TCL_OK);
}
/*************************************************************************
** vbox_get_message(): Records a voice message. **
*************************************************************************/
/*************************************************************************/
/** vbox_get_message(): Records a voice message. **/
/*************************************************************************/
int vbox_get_message(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
{
@ -264,7 +275,7 @@ int vbox_get_message(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
if (argc != 3)
{
log(L_ERROR, "[vbox_get_message] vbox_get_message <messagename> <recordtime>\n");
log(L_ERROR, gettext("[vbox_get_message] usage: vbox_get_message <messagename> <recordtime>\n"));
printstring(ip->result, "ERROR");
}
@ -297,15 +308,15 @@ int vbox_get_message(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
break;
}
log(L_DEBUG, "[vbox_get_message] result \"%s\".\n", ip->result);
log(L_DEBUG, gettext("[vbox_get_message] result \"%s\".\n"), ip->result);
}
return(TCL_OK);
}
/*************************************************************************
** vbox_wait(): Waits for DTMF input. **
*************************************************************************/
/*************************************************************************/
/** vbox_wait(): Waits for DTMF input. **/
/*************************************************************************/
int vbox_wait(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
{
@ -313,7 +324,7 @@ int vbox_wait(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
if (argc != 2)
{
log(L_ERROR, "[vbox_wait] usage: vbox_wait <seconds>\n");
log(L_ERROR, gettext("[vbox_wait] usage: vbox_wait <seconds>\n"));
printstring(ip->result, "ERROR");
}
@ -346,15 +357,15 @@ int vbox_wait(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
break;
}
log(L_DEBUG, "[vbox_wait] result \"%s\".\n", ip->result);
log(L_DEBUG, gettext("[vbox_wait] result \"%s\".\n"), ip->result);
}
return(TCL_OK);
}
/*************************************************************************
** vbox_pause(): Sleeps some milliseconds. **
*************************************************************************/
/*************************************************************************/
/** vbox_pause(): Sleeps some milliseconds. **/
/*************************************************************************/
int vbox_pause(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
{
@ -362,7 +373,7 @@ int vbox_pause(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
if (argc != 2)
{
log(L_ERROR, "[vbox_pause] usage: vbox_pause <ms>\n");
log(L_ERROR, gettext("[vbox_pause] usage: vbox_pause <ms>\n"));
printstring(ip->result, "ERROR");
}
@ -370,7 +381,7 @@ int vbox_pause(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
{
p = xstrtol(argv[1], 800);
log(L_JUNK, "[vbox_pause] waiting %lu ms...\n", p);
log(L_JUNK, gettext("[vbox_pause] waiting %lu ms...\n"), p);
xpause(p);
@ -380,9 +391,9 @@ int vbox_pause(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
return(TCL_OK);
}
/*************************************************************************
** vbox_init_touchtones(): Initialize touchtone sequence. **
*************************************************************************/
/*************************************************************************/
/** vbox_init_touchtones(): Initialize touchtone sequence. **/
/*************************************************************************/
int vbox_init_touchtones(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
{
@ -393,9 +404,9 @@ int vbox_init_touchtones(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
return(TCL_OK);
}
/*************************************************************************
**
*************************************************************************/
/*************************************************************************/
/** vbox_get_nr_new_messages(): Returns the number of new messages. **/
/*************************************************************************/
int vbox_get_nr_new_messages(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
{
@ -403,25 +414,27 @@ int vbox_get_nr_new_messages(ClientData cd, Tcl_Interp *ip, int argc, char *argv
if (argc != 2)
{
log(L_ERROR, "[vbox_get_nr_new_messages] usage: vbox_get_nr_new_messages <path>\n");
log(L_ERROR, gettext("[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]);
log(L_JUNK, gettext("[vbox_get_nr_new_messages] counting new messages in \"%s\"...\n"), argv[1]);
n = get_nr_messages(argv[1], TRUE);
log(L_DEBUG, gettext("[vbox_get_nr_new_messages] result \"%d\".\n"), n);
printstring(ip->result, "%d", n);
}
return(TCL_OK);
}
/*************************************************************************
**
*************************************************************************/
/*************************************************************************/
/** vbox_get_nr_all_messages(): Returns the number of messages. **/
/*************************************************************************/
int vbox_get_nr_all_messages(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
{
@ -429,16 +442,18 @@ int vbox_get_nr_all_messages(ClientData cd, Tcl_Interp *ip, int argc, char *argv
if (argc != 2)
{
log(L_ERROR, "[vbox_get_nr_all_messages] usage: vbox_get_nr_all_messages <path>\n");
log(L_ERROR, gettext("[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]);
log(L_JUNK, gettext("[vbox_get_nr_all_messages] counting all messages in \"%s\"...\n"), argv[1]);
n = get_nr_messages(argv[1], FALSE);
log(L_DEBUG, gettext("[vbox_get_nr_all_messages] result \"%d\".\n"), n);
printstring(ip->result, "%d", n);
}

View File

@ -1,6 +1,25 @@
/*
** $Id$
**
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
*/
#include "config.h"
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
@ -12,20 +31,13 @@
#include <getopt.h>
#include <paths.h>
#include <string.h>
#include <time.h>
#include <dirent.h>
#include <syslog.h>
#include "vboxbeep.h"
#include "libvbox.h"
#include "runtime.h"
#define MAX_MESSAGE_BOXES 10
struct messagebox
{
char *name;
time_t time;
};
/** Variables *************************************************************/
static struct messagebox messageboxes[MAX_MESSAGE_BOXES];
@ -35,6 +47,7 @@ static char *vbasename = NULL;
static char *pidname = NULL;
static int killmode = 0;
static time_t starttime = 0;
static int dodebug = FALSE;
static struct option arguments[] =
{
@ -42,41 +55,55 @@ static struct option arguments[] =
{ "help" , no_argument , NULL, 'h' },
{ "kill" , no_argument , NULL, 'k' },
{ "sound" , required_argument , NULL, 's' },
{ "messagebox" , required_argument , NULL, 'm' },
{ "pause" , required_argument , NULL, 'p' },
{ "debug" , no_argument , NULL, 'x' },
{ NULL , 0 , NULL, 0 }
};
/** Prototypes ************************************************************/
static void lets_hear_the_sound(void);
static int add_dir_to_messagebox(int, char *);
static void free_all_messageboxes(void);
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();
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();
static void log(int, char *, ...);
static void parse_sound_times(char *, int, int);
static void version(void);
static void usage(void);
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** The magic main... **/
/**************************************************************************/
int main(int argc, char **argv)
{
int i;
int b;
int opts;
char timestrings[32];
int i;
int b;
int opts;
int checkpause;
#if HAVE_LOCALE_H
setlocale(LC_ALL, "");
#endif
#if ENABLE_NLS
textdomain("vbox");
#endif
if (!(vbasename = rindex(argv[0], '/')))
{
vbasename = argv[0];
}
else vbasename++;
else
vbasename++;
for (i = 0; i < MAX_MESSAGE_BOXES; i++)
{
@ -84,31 +111,55 @@ int main(int argc, char **argv)
messageboxes[i].time = 0;
}
if (!(pidname = malloc(strlen(PIDFDIR) + strlen("/vboxbeep.pid") + 1)))
parse_sound_times(NULL, 0, 23);
if (!(pidname = malloc(strlen(PIDFILEDIR) + strlen("/vboxbeep.pid") + 1)))
{
fprintf(stderr, "%s: not enough memory to create pid name.\n", vbasename);
log(LOG_ERR, gettext("not enough memory to create pid name.\n"), vbasename);
exit(5);
}
printstring(pidname, "%s/vboxbeep.pid", PIDFDIR);
printstring(pidname, "%s/vboxbeep.pid", PIDFILEDIR);
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++;
checkpause = 5;
b = 0;
while ((opts = getopt_long(argc, argv, "vhk", arguments, (int *)0)) != EOF)
while ((opts = getopt_long(argc, argv, "vhks:m:p:x", arguments, (int *)0)) != EOF)
{
switch (opts)
{
case 'x':
dodebug = TRUE;
break;
case 'k':
killmode = 1;
break;
case 'p':
checkpause = (int)xstrtol(optarg, 5);
break;
case 'm':
if (add_dir_to_messagebox(b, optarg)) b++;
break;
case 's':
parse_sound_times(strdup(optarg), 0, 23);
break;
case 'v':
version();
break;
case 'h':
default:
usage();
break;
}
}
@ -120,27 +171,27 @@ int main(int argc, char **argv)
{
if (killmode == 0)
{
fprintf(stderr, "%s: sending signal to stop beep's to process %d...\n", vbasename, i);
fprintf(stderr, gettext("%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));
fprintf(stderr, gettext("%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);
fprintf(stderr, gettext("%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));
fprintf(stderr, gettext("%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);
fprintf(stderr, gettext("%s: you must be *root* to kill a running %s.\n"), vbasename, vbasename);
}
}
@ -151,7 +202,7 @@ int main(int argc, char **argv)
if (killmode == 1)
{
fprintf(stderr, "%s: can't find running %s process.\n", vbasename, vbasename);
fprintf(stderr, gettext("%s: can't find running %s process.\n"), vbasename, vbasename);
free_resources();
@ -160,15 +211,34 @@ int main(int argc, char **argv)
if (getuid() != 0)
{
fprintf(stderr, "%s: you must be *root* to start %s.\n", vbasename, vbasename);
fprintf(stderr, gettext("%s: you must be *root* to start %s.\n"), vbasename, vbasename);
free_resources();
exit(5);
}
if (!b)
{
log(LOG_CRIT, gettext("there are no directories to watch."));
free_resources();
exit(5);
}
create_pid_file();
for (i = 0, *timestrings = '\0'; i < 24; i++)
{
strcat(timestrings, sound_available_hours[i] ? "x" : "-");
}
if (dodebug)
{
log(LOG_DEBUG, gettext("time range \"%s\"."), timestrings);
}
while (TRUE)
{
for (i = 0; i < MAX_MESSAGE_BOXES; i++)
@ -186,15 +256,51 @@ int main(int argc, char **argv)
}
}
xpause(5000);
xpause(checkpause * 1000);
}
leave_program(0);
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** version(): Displays package version. **/
/**************************************************************************/
static void version(void)
{
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("%s version %s (%s)\n"), vbasename, VERSION, VERDATE);
fprintf(stderr, gettext("\n"));
free_resources();
exit(1);
}
/**************************************************************************/
/** usage(): Displays usage message. **/
/**************************************************************************/
static void usage(void)
{
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("Usage: %s OPTION [ OPTION ] [ ... ]\n"), vbasename);
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("-s, --sound HOURS Hours to signal with sound (default: no time)\n"));
fprintf(stderr, gettext("-m, --messagebox DIR Watch directory DIR for new messages.\n"));
fprintf(stderr, gettext("-p, --pause SECONDS Pause in seconds to sleep between checks (default: 5).\n"));
fprintf(stderr, gettext("-h, --help Displays this help text.\n"));
fprintf(stderr, gettext("-v, --version Displays program version.\n"));
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("Hours to play sound with the pc speaker must be specified in 24-hour-format.\nyou can use ',' or '-' to seperate hours or specify time ranges (eg 9,17-22).\nA '--sound=\"*\"' means at every time and '--sound=\"-\"' means at no time.\n\nThe option '--messagebox' can be used more than one time, so you can watch\nmax. %d seperate directories.\n"), MAX_MESSAGE_BOXES);
fprintf(stderr, gettext("\n"));
free_resources();
exit(1);
}
/**************************************************************************/
/** init_signals(): Initialize the signals. **/
/**************************************************************************/
static void init_signals(void)
{
@ -202,12 +308,12 @@ static void init_signals(void)
signal(SIGHUP , leave_program);
signal(SIGUSR1 , set_new_starttime);
signal(SIGQUIT , SIG_IGN);
signal(SIGINT , SIG_IGN);
signal(SIGINT , leave_program);
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** Free_Resources(): Frees all used resources. **/
/**************************************************************************/
static void free_resources(void)
{
@ -218,68 +324,87 @@ static void free_resources(void)
free_all_messageboxes();
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** leave_program(): Leave the program. **/
/**************************************************************************/
static void leave_program(int sig)
{
int vt;
if ((vt = open("/dev/console", O_RDONLY)) != -1)
{
ioctl(vt, KIOCSOUND, 0);
close(vt);
}
remove_pid_file();
free_resources();
if (dodebug) log(LOG_DEBUG, gettext("terminate..."));
exit(0);
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** set_new_starttime(): Sets new watch start time. **/
/**************************************************************************/
static void set_new_starttime(int sig)
{
init_signals();
starttime = time(NULL);
if (dodebug) log(LOG_DEBUG, gettext("new starttime is %ld."), starttime);
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** lets_hear_the_sound(): Plays one sound sequence. **/
/**************************************************************************/
static void lets_hear_the_sound(void)
{
struct tm *timel;
time_t timec;
int vt;
int i;
int k;
time_t timec;
int vt;
timec = time(NULL);
if (!(timel = localtime(&timec)))
{
fprintf(stderr, "%s: can't get current local time.\n", vbasename);
log(LOG_CRIT, gettext("can't get current local time (%s)."), strerror(errno));
return;
}
if ((vt = open("/dev/console", O_RDWR)) == -1)
if ((timel->tm_hour < 0) || (timel->tm_hour > 23))
{
fprintf(stderr, "%s: can't open \"/dev/console\" (%s).\n", vbasename, strerror(errno));
log(LOG_CRIT, gettext("bad hour in local time structure (%d)."), timel->tm_hour);
return;
}
if (sound_available_hours[timel->tm_hour] == TRUE)
{
if ((vt = open("/dev/console", O_RDWR)) == -1)
{
log(LOG_CRIT, gettext("can't open \"/dev/console\" (%s)."), strerror(errno));
return;
}
beep(vt);
beep(vt);
beep(vt);
beep(vt);
beep(vt);
beep(vt);
close(vt);
close(vt);
}
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** beep(): Plays one beep. **/
/**************************************************************************/
static void beep(int vt)
{
@ -292,9 +417,9 @@ static void beep(int vt)
xpause(25);
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** add_dir_to_messagebox(): Adds a directory to the watchlist. **/
/**************************************************************************/
static int add_dir_to_messagebox(int nr, char *box)
{
@ -306,19 +431,24 @@ static int add_dir_to_messagebox(int nr, char *box)
{
messageboxes[nr].name = name;
messageboxes[nr].time = time(NULL);
if (dodebug)
{
log(LOG_DEBUG, gettext("add directory \"%s\" to watchlist..."), name);
}
returnok();
}
}
fprintf(stderr, "%s: can't add \"%s\" to checklist.\n", vbasename, box);
log(LOG_ERR, gettext("can't add \"%s\" to watchlist."), box);
returnerror();
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** free_all_messageboxes(): Frees messagebox resources. **/
/**************************************************************************/
static void free_all_messageboxes(void)
{
@ -332,9 +462,10 @@ static void free_all_messageboxes(void)
}
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** get_newest_message_time(): Scans a messagebox and returns the time **/
/** of the newest message. **/
/**************************************************************************/
static time_t get_newest_message_time(char *box)
{
@ -361,16 +492,16 @@ static time_t get_newest_message_time(char *box)
closedir(dir);
}
else fprintf(stderr, "%s: can't open \"%s\" (%s).\n", vbasename, box, strerror(errno));
else log(LOG_ERR, gettext("can't open \"%s\" (%s)."), box, strerror(errno));
}
else fprintf(stderr, "%s: can't change to \"%s\" (%s).\n", vbasename, box, strerror(errno));
else log(LOG_ERR, gettext("can't change to \"%s\" (%s)."), box, strerror(errno));
return(newest);
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** create_pid_file(): Creates the program pid lock. **/
/**************************************************************************/
static void create_pid_file(void)
{
@ -378,7 +509,7 @@ static void create_pid_file(void)
if (!(pid = fopen(pidname, "w")))
{
fprintf(stderr, "%s: could not create pid file \"%s\" (%s).\n", vbasename, pidname, strerror(errno));
log(LOG_CRIT, gettext("could not create PID file \"%s\" (%s)."), pidname, strerror(errno));
leave_program(0);
}
@ -388,21 +519,21 @@ static void create_pid_file(void)
fclose(pid);
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** remove_pid_file(): Remove the programs PID lock. **/
/**************************************************************************/
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));
log(LOG_CRIT, gettext("can't remove PID file \"%s\" (%s)."), pidname, strerror(errno));
}
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** get_pid_from_file(): Returns the PID from the PID file. **/
/**************************************************************************/
static int get_pid_from_file(void)
{
@ -420,11 +551,11 @@ static int get_pid_from_file(void)
return(0);
}
/*************************************************************************
**
*************************************************************************/
/**************************************************************************/
/** parse_sound_times(): Parse the string for time zones. **/
/**************************************************************************/
static void parse_numbers(char *string, int min, int max, char field[])
static void parse_sound_times(char *string, int min, int max)
{
char *number;
char *beg;
@ -432,6 +563,28 @@ static void parse_numbers(char *string, int min, int max, char field[])
int begnr;
int endnr;
int i;
if ((!string) || (strcmp(string, "!") == 0) || (strcmp(string, "-") == 0))
{
for (i = min; i <= max; i++)
{
sound_available_hours[i] = FALSE;
}
return;
}
if (strcmp(string, "*") == 0)
{
free(string);
for (i = min; i <= max; i++)
{
sound_available_hours[i] = TRUE;
}
return;
}
number = strtok(string, ",;:");
@ -454,16 +607,32 @@ static void parse_numbers(char *string, int min, int max, char field[])
{
for (i = begnr; i <= endnr; i++)
{
fprintf(stderr, "Set: %d\n", i);
field[i] = 1;
sound_available_hours[i] = TRUE;
}
}
}
else log(LOG_ERR, gettext("starttime must be lower than endtime."));
}
else log(LOG_ERR, gettext("start- or endtime out of range."));
number = strtok(NULL, ",;:");
}
free(string);
}
/**************************************************************************/
/** log(): Writes a message to the syslog. **/
/**************************************************************************/
static void log(int level, char *fmt, ...)
{
va_list arg;
openlog(vbasename, LOG_CONS|LOG_PID, LOG_USER);
va_start(arg, fmt);
vsyslog(level, fmt, arg);
va_end(Arg);
closelog();
}

17
vbox/src/vboxbeep.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef _VBOX_BEEP_H
#define _VBOX_BEEP_H 1
/** Defines ***************************************************************/
#define MAX_MESSAGE_BOXES 10 /* Max. message boxes watch at on time */
/** Struktures ************************************************************/
struct messagebox
{
char *name;
time_t time;
};
#endif /* _VBOX_BEEP_H */

View File

@ -7,51 +7,34 @@
** package - this routines are copyright by there autors!
*/
#include "config.h"
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <fcntl.h>
#include <pwd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <time.h>
#include <pwd.h>
#include <sys/utsname.h>
#include "runtime.h"
#include "libvbox.h"
/** Defines **************************************************************/
#define SND_FORMAT_MULAW_8 1
#define SND_FORMAT_LINEAR_8 2
#define SND_FORMAT_LINEAR_16 3
#define SND_MAGIC (0x2e736e64L)
#define SND_HEADER_SIZE 28
#define SND_UNKNOWN_SIZE ((int)(-1))
#define SUN_FORMAT_MIN 0
#define SUN_FORMAT_MAX 22
/** Structures ***********************************************************/
typedef struct
{
int magic; /* Magic number SND_MAGIC */
int dataLocation; /* Offset or pointer to the data */
int dataSize; /* Number of bytes of data */
int dataFormat; /* The data format code */
int samplingRate; /* The sampling rate */
int channelCount; /* The number of channels */
char info[4]; /* Optional text information */
} SNDSoundStruct;
typedef struct
{
int word;
int nleft;
} state_t;
#include "vboxconvert.h"
/** Variables ************************************************************/
@ -131,7 +114,9 @@ static struct option args_autovbox[] =
{ NULL , 0 , NULL, 0 }
};
static char *vbasename;
static char *vbasename = NULL;
static FILE *vboxtmpfile = NULL;
static char *vboxtmpname = NULL;
/** Prototypes ***********************************************************/
@ -141,6 +126,9 @@ static int start_autovbox(int, char *, char *, char *, char *);
static void usage_vboxtoau(void);
static void usage_vboxmode(void);
static void usage_autovbox(void);
static void leave_vboxtoau(int);
static void leave_autovbox(int);
static void leave_vboxmode(int);
static void version(void);
static int convert_adpcm_to_pvf(int, FILE *, FILE *);
@ -162,9 +150,9 @@ static int get_bits(int, state_t *, FILE *);
static void put_bits(int, int, state_t *, FILE *);
static int check_io_error(FILE *, FILE *);
/*************************************************************************
** The magic main... **
*************************************************************************/
/*************************************************************************/
/** The magic main... **/
/*************************************************************************/
int main(int argc, char **argv)
{
@ -181,10 +169,17 @@ int main(int argc, char **argv)
int i;
if (!(vbasename = rindex(argv[0], '/')))
{
vbasename = argv[0];
}
else vbasename++;
else
vbasename++;
#ifdef HAVE_LOCALE_H
setlocale(LC_ALL, "");
#endif
#ifdef HAVE_LIBINTL_H
textdomain(PACKAGE);
#endif
/* Called as 'vboxtoau' converts a messages saved with vbox to */
/* sun's au format. */
@ -340,66 +335,61 @@ int main(int argc, char **argv)
exit(start_vboxmode(name, mode));
};
fprintf(stderr, "\n");
fprintf(stderr, "The vbox converter can be called as:\n");
fprintf(stderr, "\n");
fprintf(stderr, "vboxtoau - to convert vbox messages to au format.\n");
fprintf(stderr, "autovbox - to convert au format samples to vbox messages.\n");
fprintf(stderr, "vboxmode - to display message information (works also with au).\n");
fprintf(stderr, "\n");
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("The vbox converter can be called as:\n"));
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("vboxtoau - to convert vbox messages to au format.\n"));
fprintf(stderr, gettext("autovbox - to convert au format samples to vbox messages.\n"));
fprintf(stderr, gettext("vboxmode - to display message information (works also with au).\n"));
fprintf(stderr, gettext("\n"));
exit(255);
}
/*************************************************************************
** start_vboxtoau(): Converts vbox messages to sun's au format. **
*************************************************************************/
/*************************************************************************/
/** start_vboxtoau(): Converts vbox messages to sun's au format. **/
/*************************************************************************/
static int start_vboxtoau(int samplemode, int samplerate)
{
vaheader_t header;
int compression;
int result;
FILE *tmpfile;
char *tmpname;
int compression;
int result;
if (!(tmpname = tempnam("/tmp", "vbox")))
vboxtmpname = NULL;
vboxtmpfile = NULL;
signal(SIGINT , leave_vboxtoau);
signal(SIGQUIT, leave_vboxtoau);
signal(SIGTERM, leave_vboxtoau);
signal(SIGHUP , leave_vboxtoau);
if (!(vboxtmpname = tempnam("/tmp", "vbox")))
{
fprintf(stderr, "%s: can't create a temporary file.\n", vbasename);
fprintf(stderr, gettext("%s: can't create a temporary file.\n"), vbasename);
return(255);
leave_vboxtoau(255);
}
if (!(tmpfile = fopen(tmpname, "w+")))
if (!(vboxtmpfile = fopen(vboxtmpname, "w+")))
{
fprintf(stderr, "%s: can't create \"%s\".\n", vbasename, tmpname);
fprintf(stderr, gettext("%s: can't create \"%s\".\n"), vbasename, vboxtmpname);
free(tmpname);
return(255);
leave_vboxtoau(255);
}
if (fread(&header, sizeof(vaheader_t), 1, stdin) != 1)
{
fprintf(stderr, "%s: can't read vbox voice header.\n", vbasename);
fprintf(stderr, gettext("%s: can't read vbox audio header.\n"), vbasename);
fclose(tmpfile);
unlink(tmpname);
free(tmpname);
return(255);
leave_vboxtoau(255);
}
if (strncmp(header.magic, VAH_MAGIC, VAH_MAX_MAGIC) != 0)
{
fprintf(stderr, "%s: sample contains no vbox voice header.\n", vbasename);
fprintf(stderr, gettext("%s: sample contains no vbox audio header.\n"), vbasename);
fclose(tmpfile);
unlink(tmpname);
free(tmpname);
return(255);
leave_vboxtoau(255);
}
compression = (int)ntohl(header.compression);
@ -411,56 +401,68 @@ static int start_vboxtoau(int samplemode, int samplerate)
case 2:
case 3:
case 4:
result = convert_adpcm_to_pvf(compression, stdin, tmpfile);
result = convert_adpcm_to_pvf(compression, stdin, vboxtmpfile);
break;
case 6:
result = convert_ulaw_to_pvf(stdin, tmpfile);
result = convert_ulaw_to_pvf(stdin, vboxtmpfile);
break;
default:
fprintf(stderr, "%s: unknown/unsupported compression %d.\n", vbasename, compression);
fprintf(stderr, gettext("%s: unknown/unsupported compression %d.\n"), vbasename, compression);
break;
}
if (result == 0)
{
result = convert_pvf_to_au(samplemode, samplerate, tmpfile, stdout);
result = convert_pvf_to_au(samplemode, samplerate, vboxtmpfile, stdout);
}
fclose(tmpfile);
unlink(tmpname);
free(tmpname);
return(result);
leave_vboxtoau(result);
}
/*************************************************************************
** usage_vboxtoau(): Usage message for "vboxtoau". **
*************************************************************************/
/**************************************************************************/
/** leave_vboxtoau(): Leave vboxtoau mode. **/
/**************************************************************************/
static void leave_vboxtoau(int sig)
{
if (vboxtmpfile) fclose(vboxtmpfile);
if (vboxtmpname)
{
unlink(vboxtmpname);
free(vboxtmpname);
}
exit(sig);
}
/*************************************************************************/
/** usage_vboxtoau(): Usage message for "vboxtoau". **/
/*************************************************************************/
static void usage_vboxtoau(void)
{
fprintf(stderr, "\n");
fprintf(stderr, "Usage: %s OPTION [ OPTION ] [ ... ] <INFILE >OUTFILE\n", vbasename);
fprintf(stderr, "\n");
fprintf(stderr, "-r, --samplerate RATE Header sampling rate (default 8000).\n");
fprintf(stderr, "-u, --ulaw Use 8-bit uLaw output.\n");
fprintf(stderr, "-1, --linear8 Use 8-bit linear output.\n");
fprintf(stderr, "-2, --linear16 Use 16-Bit linear output (default).\n");
fprintf(stderr, "-h, --help Prints this usage message.\n");
fprintf(stderr, "-v, --version Prints the package version.\n");
fprintf(stderr, "\n");
fprintf(stderr, "Note: The sampling rate is written into the file header only, it\n");
fprintf(stderr, " doesn't do any sampling rate conversion!\n");
fprintf(stderr, "\n");
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("Usage: %s OPTION [ OPTION ] [ ... ] <INFILE >OUTFILE\n"), vbasename);
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("-r, --samplerate RATE Header sampling rate (default 8000).\n"));
fprintf(stderr, gettext("-u, --ulaw Use 8-bit uLaw output.\n"));
fprintf(stderr, gettext("-1, --linear8 Use 8-bit linear output.\n"));
fprintf(stderr, gettext("-2, --linear16 Use 16-Bit linear output (default).\n"));
fprintf(stderr, gettext("-h, --help Prints this usage message.\n"));
fprintf(stderr, gettext("-v, --version Prints the package version.\n"));
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("Note: The sampling rate is written into the file header only, it\n doesn't do any sampling rate conversion!\n"));
fprintf(stderr, gettext("\n"));
exit(255);
}
/*************************************************************************
** start_vboxmode(): Displays sample information. **
*************************************************************************/
/*************************************************************************/
/** start_vboxmode(): Displays sample information. **/
/*************************************************************************/
static int start_vboxmode(char *name, int quiet)
{
@ -475,59 +477,64 @@ static int start_vboxmode(char *name, int quiet)
if (result == 255)
{
fprintf(stderr, "%s: sample contains no vbox or sun au header.\n", vbasename);
fprintf(stderr, gettext("%s: sample contains no vbox or sun au header.\n"), vbasename);
}
return(result);
}
/*************************************************************************
** usage_vboxmode(): Usage message for "vboxmode". **
*************************************************************************/
/*************************************************************************/
/** usage_vboxmode(): Usage message for "vboxmode". **/
/*************************************************************************/
static void usage_vboxmode(void)
{
fprintf(stderr, "\n");
fprintf(stderr, "Usage: %s OPTION [ OPTION ] [ ... ] SAMPLENAME\n", vbasename);
fprintf(stderr, "\n");
fprintf(stderr, "-q, --quiet Returns only the errorcode (no descriptions).\n");
fprintf(stderr, "-h, --help Prints this usage message.\n");
fprintf(stderr, "-v, --version Prints the package version.\n");
fprintf(stderr, "\n");
fprintf(stderr, "The program returns the sample format as errorcode:\n");
fprintf(stderr, "\n");
fprintf(stderr, "- For au samples it returns %d-%d,\n", SUN_FORMAT_MIN + 128, SUN_FORMAT_MAX + 128);
fprintf(stderr, "- For vbox messages it returns 2-6,\n");
fprintf(stderr, "- For unknown formats or on errors it returns 255.\n");
fprintf(stderr, "\n");
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("Usage: %s OPTION [ OPTION ] [ ... ] SAMPLENAME\n"), vbasename);
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("-q, --quiet Returns only the errorcode (no descriptions).\n"));
fprintf(stderr, gettext("-h, --help Prints this usage message.\n"));
fprintf(stderr, gettext("-v, --version Prints the package version.\n"));
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("The program returns the sample format as errorcode:\n"));
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("- For au samples it returns %d-%d,\n"), SUN_FORMAT_MIN + 128, SUN_FORMAT_MAX + 128);
fprintf(stderr, gettext("- For vbox messages it returns 2-6,\n"));
fprintf(stderr, gettext("- For unknown formats or on errors it returns 255.\n"));
fprintf(stderr, gettext("\n"));
exit(255);
}
/*************************************************************************
** start_autovbox(): Converts au samples to vbox messages. **
*************************************************************************/
/*************************************************************************/
/** start_autovbox(): Converts au samples to vbox messages. **/
/*************************************************************************/
static int start_autovbox(int compression, char *name, char *id, char *phone, char *location)
{
vaheader_t header;
int result;
FILE *tmpfile;
char *tmpname;
int result;
vboxtmpname = NULL;
vboxtmpfile = NULL;
if (!(tmpname = tempnam("/tmp", "vbox")))
signal(SIGINT , leave_autovbox);
signal(SIGQUIT, leave_autovbox);
signal(SIGTERM, leave_autovbox);
signal(SIGHUP , leave_autovbox);
if (!(vboxtmpname = tempnam("/tmp", "vbox")))
{
fprintf(stderr, "%s: can't create a temporary file.\n", vbasename);
fprintf(stderr, gettext("%s: can't create a temporary file.\n"), vbasename);
return(255);
}
if (!(tmpfile = fopen(tmpname, "w+")))
if (!(vboxtmpfile = fopen(vboxtmpname, "w+")))
{
fprintf(stderr, "%s: can't create \"%s\".\n", vbasename, tmpname);
fprintf(stderr, gettext("%s: can't create \"%s\".\n"), vbasename, vboxtmpname);
free(tmpname);
free(vboxtmpname);
return(255);
}
@ -543,12 +550,12 @@ static int start_autovbox(int compression, char *name, char *id, char *phone, ch
if (fwrite(&header, sizeof(vaheader_t), 1, stdout) != 1)
{
fprintf(stderr, "%s: can't write vbox audio header.\n", vbasename);
fprintf(stderr, gettext("%s: can't write vbox audio header.\n"), vbasename);
return(255);
}
result = convert_au_to_pvf(stdin, tmpfile);
result = convert_au_to_pvf(stdin, vboxtmpfile);
if (result == 0)
{
@ -559,55 +566,71 @@ static int start_autovbox(int compression, char *name, char *id, char *phone, ch
case 2:
case 3:
case 4:
result = convert_pvf_to_adpcm(compression, tmpfile, stdout);
result = convert_pvf_to_adpcm(compression, vboxtmpfile, stdout);
break;
case 6:
result = convert_pvf_to_ulaw(tmpfile, stdout);
result = convert_pvf_to_ulaw(vboxtmpfile, stdout);
break;
default:
fprintf(stderr, "%s: unsupported compression type.\n", vbasename);
fprintf(stderr, gettext("%s: unsupported compression type.\n"), vbasename);
break;
}
}
fclose(tmpfile);
unlink(tmpname);
free(tmpname);
fclose(vboxtmpfile);
unlink(vboxtmpname);
free(vboxtmpname);
return(result);
}
/*************************************************************************
** usage_autovbox(): Usage message for "autovbox". **
*************************************************************************/
/**************************************************************************/
/** leave_autovbox(): Leave autovbox mode. **/
/**************************************************************************/
static void leave_autovbox(int sig)
{
if (vboxtmpfile) fclose(vboxtmpfile);
if (vboxtmpname)
{
unlink(vboxtmpname);
free(vboxtmpname);
}
exit(sig);
}
/*************************************************************************/
/** usage_autovbox(): Usage message for "autovbox". **/
/*************************************************************************/
static void usage_autovbox(void)
{
fprintf(stderr, "\n");
fprintf(stderr, "Usage: %s OPTION [ OPTION ] [ ... ] <INFILE >OUTFILE\n", vbasename);
fprintf(stderr, "\n");
fprintf(stderr, "-2, --adpcm-2 Converts sample to adpcm-2.\n");
fprintf(stderr, "-3, --adpcm-3 Converts sample to adpcm-3.\n");
fprintf(stderr, "-4, --adpcm-4 Converts sample to adpcm-4 (default).\n");
fprintf(stderr, "-u, --ulaw Converts sample to ulaw.\n");
fprintf(stderr, "-n, --name NAME Sets header information.\n");
fprintf(stderr, "-p, --phone PHONE Sets header information.\n");
fprintf(stderr, "-l, --location LOCATION Sets header information.\n");
fprintf(stderr, "-h, --help Prints this usage message.\n");
fprintf(stderr, "-v, --version Prints the package version.\n");
fprintf(stderr, "\n");
fprintf(stderr, "\n");
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("Usage: %s OPTION [ OPTION ] [ ... ] <INFILE >OUTFILE\n"), vbasename);
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("-2, --adpcm-2 Converts sample to adpcm-2.\n"));
fprintf(stderr, gettext("-3, --adpcm-3 Converts sample to adpcm-3.\n"));
fprintf(stderr, gettext("-4, --adpcm-4 Converts sample to adpcm-4 (default).\n"));
fprintf(stderr, gettext("-u, --ulaw Converts sample to ulaw.\n"));
fprintf(stderr, gettext("-n, --name NAME Sets header information.\n"));
fprintf(stderr, gettext("-p, --phone PHONE Sets header information.\n"));
fprintf(stderr, gettext("-l, --location LOCATION Sets header information.\n"));
fprintf(stderr, gettext("-h, --help Prints this usage message.\n"));
fprintf(stderr, gettext("-v, --version Prints the package version.\n"));
fprintf(stderr, gettext("\n"));
exit(255);
}
/*************************************************************************
** convert_pvf_to_adpcm(): Converts protable voice format to adpcm-2 **
** adpcm-3 or adpcm-4. **
*************************************************************************/
/*************************************************************************/
/** convert_pvf_to_adpcm(): Converts protable voice format to adpcm-2 **/
/** adpcm-3 or adpcm-4. **/
/*************************************************************************/
static int convert_pvf_to_adpcm(int nbits, FILE *in, FILE *out)
{
@ -671,10 +694,10 @@ static int convert_pvf_to_adpcm(int nbits, FILE *in, FILE *out)
return(check_io_error(in, out));
}
/*************************************************************************
** convert_adpcm_to_pvf(): Converts adpcm-2, adpcm-3 or adpcm-4 to **
** portable voice format. **
*************************************************************************/
/*************************************************************************/
/** convert_adpcm_to_pvf(): Converts adpcm-2, adpcm-3 or adpcm-4 to **/
/** portable voice format. **/
/*************************************************************************/
static int convert_adpcm_to_pvf(int nbits, FILE *in, FILE *out)
{
@ -716,10 +739,10 @@ static int convert_adpcm_to_pvf(int nbits, FILE *in, FILE *out)
return(check_io_error(in, out));
}
/*************************************************************************
** convert_au_to_pvf(): Converts sun's au format to portable voice **
** format. **
*************************************************************************/
/*************************************************************************/
/** convert_au_to_pvf(): Converts sun's au format to portable voice **/
/** format. **/
/*************************************************************************/
static int convert_au_to_pvf(FILE *in, FILE *out)
{
@ -740,14 +763,14 @@ static int convert_au_to_pvf(FILE *in, FILE *out)
if (hdr.magic != SND_MAGIC)
{
fprintf(stderr, "%s: illegal magic number for an au file.\n", vbasename);
fprintf(stderr, gettext("%s: illegal magic number for an au file.\n"), vbasename);
return(255);
}
if (hdr.channelCount != 1)
{
fprintf(stderr, "%s: number of channels != 1 (only mono supported).\n", vbasename);
fprintf(stderr, gettext("%s: number of channels != 1 (only mono supported).\n"), vbasename);
return(255);
}
@ -756,7 +779,7 @@ static int convert_au_to_pvf(FILE *in, FILE *out)
{
if (getc(in) == EOF)
{
fprintf(stderr, "%s: unexpected EOF.\n", vbasename);
fprintf(stderr, gettext("%s: unexpected EOF.\n"), vbasename);
return(255);
}
@ -793,17 +816,17 @@ static int convert_au_to_pvf(FILE *in, FILE *out)
break;
default:
fprintf(stderr, "%s: unsupported or illegal sound encoding.\n", vbasename);
fprintf(stderr, gettext("%s: unsupported or illegal sound encoding.\n"), vbasename);
return(255);
}
return(check_io_error(in, out));
}
/*************************************************************************
** convert_pvf_to_au(): Converts portable voice format to sun's au **
** format. **
*************************************************************************/
/*************************************************************************/
/** convert_pvf_to_au(): Converts portable voice format to sun's au **/
/** format. **/
/*************************************************************************/
static int convert_pvf_to_au(int mode, int rate, FILE *in, FILE *out)
{
@ -855,9 +878,9 @@ static int convert_pvf_to_au(int mode, int rate, FILE *in, FILE *out)
return(check_io_error(in, out));
}
/*************************************************************************
** convert_pvf_to_ulaw(): Converts portable voice format to ulaw. **
*************************************************************************/
/*************************************************************************/
/** convert_pvf_to_ulaw(): Converts portable voice format to ulaw. **/
/*************************************************************************/
static int convert_pvf_to_ulaw(FILE *in, FILE *out)
{
@ -877,9 +900,9 @@ static int convert_pvf_to_ulaw(FILE *in, FILE *out)
return(check_io_error(in, out));
}
/*************************************************************************
** convert_ulaw_to_pvf(): Converts ulaw to portable voice format. **
*************************************************************************/
/*************************************************************************/
/** convert_ulaw_to_pvf(): Converts ulaw to portable voice format. **/
/*************************************************************************/
static int convert_ulaw_to_pvf(FILE *in, FILE *out)
{
@ -898,9 +921,9 @@ static int convert_ulaw_to_pvf(FILE *in, FILE *out)
return(check_io_error(in, out));
}
/*************************************************************************
** put_bits(): **
*************************************************************************/
/*************************************************************************/
/** put_bits(): **/
/*************************************************************************/
static void put_bits(int data, int nbits, state_t *s, FILE *out)
{
@ -917,9 +940,9 @@ static void put_bits(int data, int nbits, state_t *s, FILE *out)
}
}
/*************************************************************************
** get_bits(): **
*************************************************************************/
/*************************************************************************/
/** get_bits(): **/
/*************************************************************************/
static int get_bits(int nbits, state_t *state, FILE *in)
{
@ -938,9 +961,9 @@ static int get_bits(int nbits, state_t *state, FILE *in)
return(state->word >> state->nleft) & bitmask[nbits];
}
/*************************************************************************
** zput(): **
*************************************************************************/
/*************************************************************************/
/** zput(): **/
/*************************************************************************/
static void zput(int d, FILE *out)
{
@ -951,9 +974,9 @@ static void zput(int d, FILE *out)
putc(d & 0xFF, out);
}
/*************************************************************************
** zget(): **
*************************************************************************/
/*************************************************************************/
/** zget(): **/
/*************************************************************************/
static int zget(FILE *in)
{
@ -967,9 +990,9 @@ static int zget(FILE *in)
return(d);
}
/*************************************************************************
** write_one_word(): **
*************************************************************************/
/*************************************************************************/
/** write_one_word(): **/
/*************************************************************************/
static void write_one_word(int w, FILE *out)
{
@ -979,9 +1002,9 @@ static void write_one_word(int w, FILE *out)
putc((w & 0x000000FF) , out);
}
/*************************************************************************
** read_one_word(): **
*************************************************************************/
/*************************************************************************/
/** read_one_word(): **/
/*************************************************************************/
static int read_one_word(FILE *in)
{
@ -995,10 +1018,10 @@ static int read_one_word(FILE *in)
return(w);
}
/*************************************************************************
** byte_ulaw_to_linear(): Converts 8 bit ulaw sample to 16 bit linear **
** sample. **
*************************************************************************/
/*************************************************************************/
/** byte_ulaw_to_linear(): Converts 8 bit ulaw sample to 16 bit linear **/
/** sample. **/
/*************************************************************************/
static int byte_ulaw_to_linear(unsigned char ulawbyte)
{
@ -1020,13 +1043,13 @@ static int byte_ulaw_to_linear(unsigned char ulawbyte)
return(sample);
}
/*************************************************************************
** byte_linear_to_ulaw(): Converts from signed 16 bit linear to 8 bit **
** ulaw. **
*************************************************************************
** Sample 16 bit linear sample. **
** <RC> 8 bit ulaw sample. **
*************************************************************************/
/*************************************************************************/
/** byte_linear_to_ulaw(): Converts from signed 16 bit linear to 8 bit **/
/** ulaw. **/
/*************************************************************************/
/** Sample 16 bit linear sample. **/
/** <RC> 8 bit ulaw sample. **/
/*************************************************************************/
#define BIAS 0x84 /* Define the add-in bias for 16 bit samples */
#define CLIP 32635
@ -1072,18 +1095,19 @@ static unsigned char byte_linear_to_ulaw(int sample)
return(ulawbyte);
}
/*************************************************************************
** test_sample_is_vbox(): Tests if the sample is in vbox format. **
*************************************************************************/
/*************************************************************************/
/** test_sample_is_vbox(): Tests if the sample is in vbox format. **/
/*************************************************************************/
static int test_sample_is_vbox(char *name, int quiet)
{
struct stat status;
vaheader_t header;
time_t timestamp;
long int compression;
int fd;
struct tm *timelocal;
struct stat status;
vaheader_t header;
time_t timestamp;
long int compression;
int fd;
char timestring[256];
compression = 255;
@ -1098,32 +1122,38 @@ static int test_sample_is_vbox(char *name, int quiet)
if (fstat(fd, &status) == 0)
{
timestamp = ntohl(header.time);
timelocal = localtime(&timestamp);
if (strftime(timestring, 255, "%c\n", timelocal) == 255)
{
printstring(timestring, "???\n");
}
if (!quiet)
{
fprintf(stdout, "\n");
fprintf(stdout, "Creation time...........: %s", ctime(&timestamp));
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");
fprintf(stdout, gettext("\n"));
fprintf(stdout, gettext("Creation time...........: %s"), timestring);
fprintf(stdout, gettext("Compression.............: %s\n"), compressions[compression]);
fprintf(stdout, gettext("Length..................: %d seconds\n"), get_message_ptime(compression, (status.st_size - sizeof(vaheader_t))));
fprintf(stdout, gettext("Speaker name............: %s\n"), header.name);
fprintf(stdout, gettext("Speaker caller number...: %s\n"), header.callerid);
fprintf(stdout, gettext("Speaker phone number....: %s\n"), header.phone);
fprintf(stdout, gettext("Speaker location........: %s\n"), header.location);
fprintf(stdout, gettext("\n"));
}
}
}
close(fd);
}
else fprintf(stderr, "%s: can't open \"%s\" (vbox sample test).\n", vbasename, name);
else fprintf(stderr, gettext("%s: can't open \"%s\" (vbox sample test).\n"), vbasename, name);
return(compression);
}
/*************************************************************************
** test_sample_is_au(): Tests if the sample is in sun's au format. **
*************************************************************************/
/*************************************************************************/
/** test_sample_is_au(): Tests if the sample is in sun's au format. **/
/*************************************************************************/
static int test_sample_is_au(char *name, int quiet)
{
@ -1133,7 +1163,7 @@ static int test_sample_is_au(char *name, int quiet)
if (!(in = fopen(name, "r")))
{
fprintf(stderr, "%s: can't open \"%s\" (au sample test).\n", vbasename, name);
fprintf(stderr, gettext("%s: can't open \"%s\" (au sample test).\n"), vbasename, name);
return(255);
}
@ -1162,47 +1192,47 @@ static int test_sample_is_au(char *name, int quiet)
if (!quiet)
{
fprintf(stdout, "\n");
fprintf(stdout, "Format..........: %s\n", sun_format_names[snd.dataFormat]);
fprintf(stdout, "Sampling rate...: %d\n", snd.samplingRate);
fprintf(stdout, "Channels........: %d\n", snd.channelCount);
fprintf(stdout, "Size............: %d %s\n", snd.dataSize, snd.dataSize == -1 ? "(unknown size)" : "bytes");
fprintf(stdout, "Data location...: %d\n", snd.dataLocation);
fprintf(stdout, "\n");
fprintf(stdout, gettext("\n"));
fprintf(stdout, gettext("Format..........: %s\n"), sun_format_names[snd.dataFormat]);
fprintf(stdout, gettext("Sampling rate...: %d\n"), snd.samplingRate);
fprintf(stdout, gettext("Channels........: %d\n"), snd.channelCount);
fprintf(stdout, gettext("Size............: %d %s\n"), snd.dataSize, snd.dataSize == -1 ? "(unknown size)" : "bytes");
fprintf(stdout, gettext("Data location...: %d\n"), snd.dataLocation);
fprintf(stdout, gettext("\n"));
}
return(128 + snd.dataFormat);
}
/*************************************************************************
** version(): Package version. **
*************************************************************************/
/*************************************************************************/
/** version(): Package version. **/
/*************************************************************************/
static void version(void)
{
fprintf(stderr, "\n");
fprintf(stderr, "%s version %s (%s)\n", vbasename, VERSION, VERDATE);
fprintf(stderr, "\n");
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("%s version %s (%s)\n"), vbasename, VERSION, VERDATE);
fprintf(stderr, gettext("\n"));
exit(255);
}
/*************************************************************************
** check_io_error(): **
*************************************************************************/
/*************************************************************************/
/** check_io_error(): **/
/*************************************************************************/
static int check_io_error(FILE *in, FILE *out)
{
if (ferror(in) != 0)
{
fprintf(stderr, "%s: can't read input.\n", vbasename);
fprintf(stderr, gettext("%s: can't read input.\n"), vbasename);
return(255);
}
if (ferror(out) != 0)
{
fprintf(stderr, "%s: can't write output.\n", vbasename);
fprintf(stderr, gettext("%s: can't write output.\n"), vbasename);
return(255);
}

35
vbox/src/vboxconvert.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef _VBOX_CONVERT
#define _VBOX_CONVERT 1
/** Defines **************************************************************/
#define SND_FORMAT_MULAW_8 1
#define SND_FORMAT_LINEAR_8 2
#define SND_FORMAT_LINEAR_16 3
#define SND_MAGIC (0x2e736e64L)
#define SND_HEADER_SIZE 28
#define SND_UNKNOWN_SIZE ((int)(-1))
#define SUN_FORMAT_MIN 0
#define SUN_FORMAT_MAX 22
/** Structures ***********************************************************/
typedef struct
{
int magic; /* Magic number SND_MAGIC */
int dataLocation; /* Offset or pointer to the data */
int dataSize; /* Number of bytes of data */
int dataFormat; /* The data format code */
int samplingRate; /* The sampling rate */
int channelCount; /* The number of channels */
char info[4]; /* Optional text information */
} SNDSoundStruct;
typedef struct
{
int word;
int nleft;
} state_t;
#endif /* _VBOX_CONVERT */

View File

@ -12,8 +12,8 @@
#include <getopt.h>
#include <pwd.h>
#include "config.h"
#include "libvbox.h"
#include "runtime.h"
#include "vboxctrl.h"
/** Structures ***********************************************************/
@ -56,14 +56,21 @@ int main(int argc, char **argv)
int opts;
if (!(vbasename = rindex(argv[0], '/')))
{
vbasename = argv[0];
}
else vbasename++;
else
vbasename++;
#ifdef HAVE_LOCALE_H
setlocale(LC_MESSAGES, "");
#endif
#ifdef HAVE_LIBINTL_H
textdomain(PACKAGE);
#endif
if (!(passwd = getpwuid(getuid())))
{
fprintf(stderr, "%s: can't get passwd entry for uid %d.\n", vbasename, getuid());
fprintf(stderr, gettext("%s: can't get passwd entry for uid %d.\n"), vbasename, getuid());
exit(5);
}
@ -122,7 +129,7 @@ int main(int argc, char **argv)
if (!*todo)
{
fprintf(stderr, "%s: you must specify a control name to create/remove.\n", vbasename);
fprintf(stderr, gettext("%s: you must specify a control name to create/remove.\n"), vbasename);
exit(5);
}
@ -131,19 +138,19 @@ int main(int argc, char **argv)
{
if (ctrl_ishere(usespool, todo))
{
fprintf(stderr, "%s: control file '%s' allready exists.\n", vbasename, todo);
fprintf(stderr, gettext("%s: control file \"%s\" allready exists.\n"), vbasename, todo);
exit(5);
}
if (!ctrl_create(usespool, todo))
{
fprintf(stderr, "%s: can't create control file '%s'.\n", vbasename, todo);
fprintf(stderr, gettext("%s: can't create control file \"%s\".\n"), vbasename, todo);
exit(5);
}
fprintf(stderr, "%s: control file '%s' created.\n", vbasename, todo);
fprintf(stderr, gettext("%s: control file \"%s\" created.\n"), vbasename, todo);
exit(0);
}
@ -152,24 +159,24 @@ int main(int argc, char **argv)
{
if (!ctrl_ishere(usespool, todo))
{
fprintf(stderr, "%s: control file '%s' doesn't exist.\n", vbasename, todo);
fprintf(stderr, gettext("%s: control file \"%s\" doesn't exist.\n"), vbasename, todo);
exit(5);
}
if (!ctrl_remove(usespool, todo))
{
fprintf(stderr, "%s: can't remove control file '%s'.\n", vbasename, todo);
fprintf(stderr, gettext("%s: can't remove control file \"%s\".\n"), vbasename, todo);
exit(5);
}
fprintf(stderr, "%s: control file '%s' removed.\n", vbasename, todo);
fprintf(stderr, gettext("%s: control file \"%s\" removed.\n"), vbasename, todo);
exit(0);
}
fprintf(stderr, "%s: oops - don't know what I should do!\n", vbasename);
fprintf(stderr, gettext("%s: oops - don't know what I should do!\n"), vbasename);
exit(5);
}
@ -180,9 +187,9 @@ int main(int argc, char **argv)
static void version(void)
{
fprintf(stderr, "\n");
fprintf(stderr, "%s version %s (%s)\n", vbasename, VERSION, VERDATE);
fprintf(stderr, "\n");
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("%s version %s (%s)\n"), vbasename, VERSION, VERDATE);
fprintf(stderr, gettext("\n"));
exit(1);
}
@ -193,25 +200,25 @@ static void version(void)
static void usage(void)
{
fprintf(stderr, "\n");
fprintf(stderr, "Usage: %s OPTION [ OPTION ] [ ... ]\n", vbasename);
fprintf(stderr, "\n");
fprintf(stderr, "-c, --create Removes a control file (default).\n");
fprintf(stderr, "-r, --remove Creates a control file.\n");
fprintf(stderr, "-n, --answernow Control file \"vboxctrl-answernow\".\n");
fprintf(stderr, "-a, --answerall Control file \"vboxctrl-answerall\".\n");
fprintf(stderr, "-p, --stop Control file \"vboxctrl-stop\".\n");
fprintf(stderr, "-j, --reject Control file \"vboxctrl-reject\".\n");
fprintf(stderr, "-s, --spooldir Spooldirectory to create/remove control files.\n");
fprintf(stderr, "-v, --version Displays package version.\n");
fprintf(stderr, "-h, --help Displays this usage message.\n");
fprintf(stderr, "\n");
fprintf(stderr, "The spool directory is taken from one of the following:\n");
fprintf(stderr, "\n");
fprintf(stderr, " 1) The default (buildin) value (%s).\n", spooldir);
fprintf(stderr, " 2) The value of the environment variable VBOXSPOOL (if set).\n");
fprintf(stderr, " 3) The directory of the command line option --spooldir.\n");
fprintf(stderr, "\n");
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("Usage: %s OPTION [ OPTION ] [ ... ]\n"), vbasename);
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("-c, --create Removes a control file (default).\n"));
fprintf(stderr, gettext("-r, --remove Creates a control file.\n"));
fprintf(stderr, gettext("-n, --answernow Control file \"vboxctrl-answernow\".\n"));
fprintf(stderr, gettext("-a, --answerall Control file \"vboxctrl-answerall\".\n"));
fprintf(stderr, gettext("-p, --stop Control file \"vboxctrl-stop\".\n"));
fprintf(stderr, gettext("-j, --reject Control file \"vboxctrl-reject\".\n"));
fprintf(stderr, gettext("-s, --spooldir Spooldirectory to create/remove control files.\n"));
fprintf(stderr, gettext("-v, --version Displays package version.\n"));
fprintf(stderr, gettext("-h, --help Displays this usage message.\n"));
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("The spool directory is taken from one of the following:\n"));
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext(" 1) The default (buildin) value (%s).\n"), spooldir);
fprintf(stderr, gettext(" 2) The value of the environment variable VBOXSPOOL (if set).\n"));
fprintf(stderr, gettext(" 3) The directory of the command line option \"--spooldir\".\n"));
fprintf(stderr, gettext("\n"));
exit(1);
}

0
vbox/src/vboxd.c Normal file
View File

0
vbox/src/vboxd.h Normal file
View File

View File

@ -4,6 +4,8 @@
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -13,7 +15,6 @@
#include <sys/vfs.h>
#include <signal.h>
#include "runtime.h"
#include "init.h"
#include "vboxgetty.h"
#include "log.h"
@ -40,28 +41,29 @@ static int modemstate;
static struct option arguments[] =
{
{ "version", no_argument , NULL, 'v' },
{ "help" , no_argument , NULL, 'h' },
{ "file" , required_argument, NULL, 'f' },
{ "device" , required_argument, NULL, 'd' },
{ NULL , 0 , NULL, 0 }
{ "version" , no_argument , NULL, 'v' },
{ "help" , no_argument , NULL, 'h' },
{ "file" , required_argument, NULL, 'f' },
{ "device" , required_argument, NULL, 'd' },
{ "language", required_argument, NULL, 'l' },
{ NULL , 0 , NULL, 0 }
};
/*************************************************************************
** The magic main... **
*************************************************************************/
/*************************************************************************/
/** The magic main... **/
/*************************************************************************/
void main(int argc, char **argv)
{
char *usevrc;
char *device;
char *usevrc = NULL;
char *device = NULL;
char *language = NULL;
int opts;
if (!(vbasename = rindex(argv[0], '/')))
{
vbasename = argv[0];
}
else vbasename++;
else
vbasename++;
usevrc = GETTYRC;
device = "";
@ -78,6 +80,10 @@ void main(int argc, char **argv)
device = optarg;
break;
case 'l':
language = optarg;
break;
case 'v':
version();
break;
@ -89,23 +95,33 @@ void main(int argc, char **argv)
}
}
if (language) setenv("LANG", language, 1);
#if HAVE_LOCALE_H
setlocale(LC_ALL, "");
#endif
#if ENABLE_NLS
textdomain(PACKAGE);
#endif
if (getuid() != 0)
{
log(L_STDERR, "%s: must be run by root!\n", vbasename);
log(L_STDERR, gettext("%s: must be run by root!\n"), vbasename);
exit(5);
}
if (access(device, W_OK|R_OK|F_OK) != 0)
{
log(L_STDERR, "%s: device \"%s\" is not accessable.\n", vbasename, device);
log(L_STDERR, gettext("%s: device \"%s\" is not accessable.\n"), vbasename, device);
exit(5);
}
if (access(usevrc, R_OK|F_OK) != 0)
{
log(L_STDERR, "%s: Setup \"%s\" doesn't exist.\n", vbasename, usevrc);
log(L_STDERR, gettext("%s: Setup \"%s\" doesn't exist.\n"), vbasename, usevrc);
exit(5);
}
@ -120,40 +136,57 @@ void main(int argc, char **argv)
exit_program(SIGTERM);
}
/*************************************************************************
** version(): Displays the package version. **
*************************************************************************/
/*************************************************************************/
/** version(): Displays the package version. **/
/*************************************************************************/
static void version(void)
{
fprintf(stderr, "\n");
fprintf(stderr, "%s version %s (%s)\n", vbasename, VERSION, VERDATE);
fprintf(stderr, "\n");
#if HAVE_LOCALE_H
setlocale(LC_ALL, "");
#endif
#if ENABLE_NLS
textdomain(PACKAGE);
#endif
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("%s version %s (%s)\n"), vbasename, VERSION, VERDATE);
fprintf(stderr, gettext("\n"));
exit(1);
}
/*************************************************************************
** usage(): Displays usage message. **
*************************************************************************/
/*************************************************************************/
/** usage(): Displays usage message. **/
/*************************************************************************/
static void usage(void)
{
fprintf(stderr, "\n");
fprintf(stderr, "Usage: %s OPTION [ OPTION ] [ ... ]\n", vbasename);
fprintf(stderr, "\n");
fprintf(stderr, "-f, --file FILE Overwrites \"%s\".\n", GETTYRC);
fprintf(stderr, "-d, --device TTY Use device TTY for modem operations [required].\n");
fprintf(stderr, "-h, --help Displays this short help.\n");
fprintf(stderr, "-v, --version Displays the package version.\n");
fprintf(stderr, "\n");
#if HAVE_LOCALE_H
setlocale(LC_ALL, "");
#endif
#if ENABLE_NLS
textdomain(PACKAGE);
#endif
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("Usage: %s OPTION [ OPTION ] [ ... ]\n"), vbasename);
fprintf(stderr, gettext("\n"));
fprintf(stderr, gettext("-f, --file FILE Overwrites \"%s\".\n"), GETTYRC);
fprintf(stderr, gettext("-d, --device TTY Use device TTY for modem operations [required].\n"));
fprintf(stderr, gettext("-l, --language Overwrites environment LANG.\n"));
fprintf(stderr, gettext("-h, --help Displays this short help.\n"));
fprintf(stderr, gettext("-v, --version Displays the package version.\n"));
fprintf(stderr, gettext("\n"));
exit(1);
}
/*************************************************************************
** main_program(): Mainloop. **
*************************************************************************/
/*************************************************************************/
/** main_program(): Mainloop. **/
/*************************************************************************/
static void main_program(void)
{
@ -179,9 +212,9 @@ static void main_program(void)
modemstate = MODEM_STATE_EXIT;
modeminits = 0;
log(L_FATAL, "Exit program while bad init limit are reached.\n");
log(L_FATAL, gettext("Exit program while bad init limit are reached.\n"));
}
else log(L_WARN, "Bad initialization - Program will exist on %d trys!\n", (setup.modem.badinitsexit - modeminits));
else log(L_WARN, gettext("Bad initialization - Program will exist on %d trys!\n"), (setup.modem.badinitsexit - modeminits));
}
}
else
@ -207,7 +240,7 @@ static void main_program(void)
case MODEM_STATE_CHECK:
log(L_DEBUG, "Checking if modem is still alive...\n");
log(L_DEBUG, gettext("Checking if modem is still alive...\n"));
if (!ctrl_ishere(setup.spool, CTRL_NAME_STOP))
{
@ -220,7 +253,7 @@ static void main_program(void)
}
else
{
log(L_INFO, "Control file '%s' exists - program will quit...\n", CTRL_NAME_STOP);
log(L_INFO, gettext("Control file \"%s\" exists - program will quit...\n"), CTRL_NAME_STOP);
modemstate = MODEM_STATE_EXIT;
}
@ -250,19 +283,19 @@ static void main_program(void)
}
}
/*************************************************************************
** answer_call(): Answers the call and starts the tcl script. **
*************************************************************************/
/*************************************************************************/
/** answer_call(): Answers the call and starts the tcl script. **/
/*************************************************************************/
static void answer_call(void)
{
char run[PATH_MAX + 1];
log(L_INFO, "Answering call...\n");
log(L_INFO, gettext("Answering call...\n"));
if (modem_command("ATA", "VCON|CONNECT") <= 0)
{
log(L_ERROR, "Can't answer call -- hanging up...\n");
log(L_ERROR, gettext("Can't answer call -- hanging up...\n"));
return;
}
@ -278,20 +311,20 @@ static void answer_call(void)
script_run(run);
}
/*************************************************************************
** check_spool_space(): **
*************************************************************************/
/*************************************************************************/
/** check_spool_space(): Checks space on spoolpartition. **/
/*************************************************************************/
static int check_spool_space(unsigned long need)
{
struct statfs stat;
unsigned long have;
log(L_DEBUG, "Checking free space on '%s'...\n", setup.spool);
log(L_DEBUG, gettext("Checking free space on \"%s\"...\n"), setup.spool);
if (need <= 0)
{
log(L_WARN, "Free disc space check disabled!\n");
log(L_WARN, gettext("Free disc space check disabled!\n"));
returnok();
}
@ -300,31 +333,31 @@ static int check_spool_space(unsigned long need)
{
have = (stat.f_bfree * stat.f_bsize);
log_line(L_JUNK, "%ld bytes available; %ld bytes needed... ", have, need);
log_line(L_JUNK, gettext("%ld bytes available; %ld bytes needed... "), have, need);
if (have >= need)
{
log_text(L_JUNK, "enough.\n");
log_text(L_JUNK, gettext("enough.\n"));
returnok();
}
log_text(L_JUNK, "not enough!\n");
log_text(L_JUNK, gettext("not enough!\n"));
}
else log(L_ERROR, "Can't get statistic about disc space!");
else log(L_ERROR, gettext("Can't get statistic about disc space!"));
returnerror();
}
/*************************************************************************
** block_all_signals(): Blocks all signals. **
*************************************************************************/
/*************************************************************************/
/** block_all_signals(): Blocks all signals. **/
/*************************************************************************/
void block_all_signals(void)
{
int i;
log(L_DEBUG, "Blocking all signals (0-%d)...\n", NSIG);
log(L_DEBUG, gettext("Blocking all signals (0-%d)...\n"), NSIG);
for (i = 0; i < NSIG; i++) signal(i, SIG_IGN);
}

View File

@ -1,3 +1,21 @@
/*
** $Id$
**
** Copyright (C) 1996, 1997 Michael 'Ghandi' Herold
*/
#include "config.h"
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include <signal.h>
#include <sys/types.h>
@ -10,7 +28,6 @@
#include <netinet/in.h>
#include <limits.h>
#include <errno.h>
#include <time.h>
#include "voice.h"
#include "init.h"
@ -32,14 +49,13 @@ char touchtones[TOUCHTONE_BUFFER_LEN + 1];
static int voice_set_compression(short);
static void voice_set_header(vaheader_t *);
static void voice_handle_dle(char);
static void voice_handle_touchtone(char);
static void voice_close_or_unlink(int, char *);
static void voice_handle_touchtone_dle(int);
/*************************************************************************
** voice_init_section(): Set the voice setup defaults. **
*************************************************************************/
/*************************************************************************/
/** voice_init_section(): Set the voice setup defaults. **/
/*************************************************************************/
void voice_init_section(void)
{
@ -68,9 +84,9 @@ void voice_init_section(void)
setup.voice.recordtime = TRUE;
}
/*************************************************************************
** voice_user_section(): Loads a user section. **
*************************************************************************/
/*************************************************************************/
/** voice_user_section(): Loads a user section. **/
/*************************************************************************/
void voice_user_section(char *id)
{
@ -78,9 +94,9 @@ void voice_user_section(char *id)
vboxrc_find_user_section(setup.voice.section);
}
/*************************************************************************
** voice_set_compression(): Sets voice compression mode. **
*************************************************************************/
/*************************************************************************/
/** voice_set_compression(): Sets voice compression mode. **/
/*************************************************************************/
static int voice_set_compression(short c)
{
@ -90,19 +106,19 @@ static int voice_set_compression(short c)
{
printstring(command, "AT+VSM=%d+VLS=2", c);
log(L_DEBUG, "Setting voice compression \"%s\"...\n", compressions[c]);
log(L_DEBUG, gettext("Setting voice compression \"%s\"...\n"), compressions[c]);
return(modem_command(command, "OK|VCON"));
}
log(L_FATAL, "Unknown compression %d - can't set.\n", c);
log(L_FATAL, gettext("Unknown compression %d - can't set.\n"), c);
returnerror();
}
/*************************************************************************
**
*************************************************************************/
/*************************************************************************/
/** voice_close_or_unlink(): Close and/or unlink a file. **/
/*************************************************************************/
static void voice_close_or_unlink(int fd, char *name)
{
@ -112,44 +128,41 @@ static void voice_close_or_unlink(int fd, char *name)
if (name) unlink(name);
}
/*************************************************************************
** voice_put_message(): Plays voice message. **
** voice_put_message(): Plays voice message. **
*************************************************************************/
int voice_put_message(char *message)
{
vaheader_t header;
long int compression;
char line_i[MODEM_BUFFER_LEN + 1];
char line_o[MODEM_BUFFER_LEN + MODEM_BUFFER_LEN + 1];
int fd;
int i;
int byte_i;
int byte_o;
int written;
int havedle;
time_t timebeg;
time_t timeend;
int bytetotal;
int secstotal;
long int compression;
char line_i[MODEM_BUFFER_LEN + 1];
char line_o[MODEM_BUFFER_LEN + MODEM_BUFFER_LEN + 1];
int fd;
int i;
int byte_i;
int byte_o;
int written;
int havedle;
time_t timebeg;
time_t timeend;
int bytetotal;
int secstotal;
log(L_INFO, "Playing \"%s\"...\n", message);
log(L_INFO, gettext("Playing \"%s\"...\n"), message);
if ((fd = open(message, O_RDONLY)) == -1)
{
log(L_ERROR, "Can't open \"%s\".\n", message);
log(L_ERROR, gettext("Can't open \"%s\".\n"), message);
return(VOICE_ACTION_ERROR);
}
if (!header_get(fd, &header))
{
log(L_ERROR, "Can't read vbox audio header from message.\n");
log(L_ERROR, gettext("Can't read vbox audio header from message.\n"));
close(fd);
voice_close_or_unlink(fd, NULL);
return(VOICE_ACTION_ERROR);
}
@ -158,29 +171,25 @@ int voice_put_message(char *message)
if (!voice_set_compression(compression))
{
log(L_ERROR, "Can't set voice audio compression or line mode.\n");
log(L_ERROR, gettext("Can't set voice audio compression or line mode.\n"));
close(fd);
voice_close_or_unlink(fd, NULL);
return(VOICE_ACTION_ERROR);
}
if (modem_get_nocarrier_state())
{
close(fd);
voice_close_or_unlink(fd, NULL);
return(VOICE_ACTION_REMOTEHANGUP);
}
/* Ansonsten Modem in den Voice-Play-Modus versetzen und die */
/* Nachricht spielen. AT+VTX liefert ein NO ANSWER wenn kein */
/* Carrier mehr anliegt (gibt es beim ZyXEL nicht)! */
if (modem_command("AT+VTX", "CONNECT") == 0)
{
log(L_ERROR, "Can't start voice play mode.\n");
log(L_ERROR, gettext("Can't start voice play mode.\n"));
close(fd);
voice_close_or_unlink(fd, NULL);
return(VOICE_ACTION_ERROR);
}
@ -196,7 +205,7 @@ int voice_put_message(char *message)
{
if ((byte_i = read(fd, line_i, MODEM_BUFFER_LEN)) <= 0)
{
log(L_DEBUG, "End of audio data (%s).\n", strerror(errno));
log(L_DEBUG, gettext("End of audio data (%s).\n"), strerror(errno));
break;
}
@ -212,10 +221,7 @@ int voice_put_message(char *message)
bytetotal += byte_o;
/* Daten so lange schreiben, bis sie zu Ende sind oder ein */
/* Fehler aufgetreten ist. */
log(L_JUNK, "Play: <DATA %d incoming; %d outgoing>\n", byte_i, byte_o);
log(L_JUNK, gettext("Play: <DATA %d incoming; %d outgoing>\n"), byte_i, byte_o);
if (!modem_get_nocarrier_state())
{
@ -231,7 +237,7 @@ int voice_put_message(char *message)
if ((written != byte_o) || (errno != 0))
{
log(L_ERROR, "Could only write %d of %d bytes (%s).\n", written, byte_o, strerror(errno));
log(L_ERROR, gettext("Could only write %d of %d bytes (%s).\n"), written, byte_o, strerror(errno));
voicestatus = VOICE_ACTION_ERROR;
}
@ -240,7 +246,7 @@ int voice_put_message(char *message)
while ((modem_check_input()) && (voicestatus == VOICE_ACTION_OK))
{
log(L_JUNK, "Have input...\n");
log(L_JUNK, gettext("Have input...\n"));
if (modem_raw_read(line_i, 1) == 1)
{
@ -255,13 +261,13 @@ int voice_put_message(char *message)
case 'd':
case 'q':
case 's':
log_line(L_DEBUG, "Found sequence \"<DLE>");
log_line(L_DEBUG, gettext("Found sequence \"<DLE>"));
log_char(L_DEBUG, *line_i);
log_text(L_DEBUG, "\" (ignored)...\n");
log_text(L_DEBUG, gettext("\" (ignored)...\n"));
break;
case DC4:
log(L_DEBUG, "Found sequence \"<DLE><DC4>\" (remote hangup)...\n");
log(L_DEBUG, gettext("Found sequence \"<DLE><DC4>\" (remote hangup)...\n"));
voicestatus = VOICE_ACTION_REMOTEHANGUP;
break;
@ -276,9 +282,9 @@ int voice_put_message(char *message)
{
if (*line_i != DLE)
{
log_line(L_DEBUG, "Got unneeded character \"");
log_line(L_DEBUG, gettext("Got unneeded character \""));
log_char(L_DEBUG, *line_i);
log_text(L_DEBUG, "\" (need a <DLE>).\n");
log_text(L_DEBUG, gettext("\" (need a \"<DLE>\").\n"));
}
else havedle = TRUE;
}
@ -287,24 +293,24 @@ int voice_put_message(char *message)
{
if ((index(touchtones, '#')) && (index(touchtones, '*')))
{
log(L_DEBUG, "Touchtone sequence \"%s\" found.\n", touchtones);
log(L_DEBUG, gettext("Touchtone sequence \"%s\" found.\n"), touchtones);
if (list_find_node(&breaklist, touchtones))
{
log(L_INFO, "Sequence \"%s\" found in breaklist...\n", touchtones);
log(L_INFO, gettext("Sequence \"%s\" found in breaklist...\n"), touchtones);
voicestatus = VOICE_ACTION_TOUCHTONES;
}
else
{
log(L_DEBUG, "Sequence \"%s\" not in breaklist (ignored)...\n", touchtones);
log(L_DEBUG, gettext("Sequence \"%s\" not in breaklist (ignored)...\n"), touchtones);
*touchtones = '\0';
}
}
}
}
else log(L_ERROR, "Can't read input from modem.\n");
else log(L_ERROR, gettext("Can't read input from modem.\n"));
}
}
@ -315,33 +321,36 @@ int voice_put_message(char *message)
secstotal = (timeend - timebeg);
bytetotal = get_message_ptime(compression, bytetotal);
log(L_JUNK, "Function play %d secs (kernel needs %d secs)...\n", secstotal, bytetotal);
log(L_JUNK, gettext("Function play %d secs (kernel needs %d secs)...\n"), secstotal, bytetotal);
if (secstotal < bytetotal)
{
log(L_JUNK, "Waiting %d secs to complete playing...\n", (bytetotal - secstotal));
log(L_JUNK, gettext("Waiting %d secs to complete playing...\n"), (bytetotal - secstotal));
xpause((bytetotal - secstotal) * 1000);
}
}
else log(L_WARN, "Oops - can't calculate time to wait!\n");
close(fd);
else log(L_WARN, gettext("Oops - can't calculate time to wait!\n"));
voice_close_or_unlink(fd, NULL);
if ((voicestatus == VOICE_ACTION_REMOTEHANGUP) || (modem_get_nocarrier_state()))
{
/* Remote hangup: We have got the sequence <DLE><DC4> in the */
/* modem stream... */
/*
* Remote hangup: We have got the sequence <DLE><DC4> in the
* modem stream...
*/
modem_command("", "NO CARRIER");
}
else
{
/* Local hangup: Send <DLE><ETX> to the modem and wait for the */
/* result VCON... */
/*
* Local hangup: Send <DLE><ETX> to the modem and wait for the
* result VCON...
*/
log(L_JUNK, "Sending \"<DLE><ETX>\"...\n");
log(L_JUNK, gettext("Sending \"<DLE><ETX>\"...\n"));
printstring(line_o, "%c%c", DLE, ETX);
@ -355,11 +364,11 @@ int voice_put_message(char *message)
return(voicestatus);
}
/*************************************************************************
** voice_get_message(): Record a message. **
*************************************************************************
** If save is true the recorded data are not written. **
*************************************************************************/
/*************************************************************************/
/** voice_get_message(): Record a message. **/
/*************************************************************************/
/** If save is not true the recorded data are not written. **/
/*************************************************************************/
int voice_get_message(char *name, char *timestr, int save)
{
@ -376,13 +385,13 @@ int voice_get_message(char *name, char *timestr, int save)
savetimeout = xstrtol(timestr, 90);
if (save)
log(L_INFO, "Recording \"%s\" (%d secs)...\n", name, savetimeout);
log(L_INFO, gettext("Recording \"%s\" (%d secs)...\n"), name, savetimeout);
else
log(L_INFO, "Waiting %d secs for input...\n", savetimeout);
log(L_INFO, gettext("Waiting %d secs for input...\n"), savetimeout);
if (!voice_set_compression(setup.modem.compression))
{
log(L_ERROR, "Can't set voice audio compressen.\n");
log(L_ERROR, gettext("Can't set voice audio compressen.\n"));
return(VOICE_ACTION_ERROR);
}
@ -391,7 +400,7 @@ int voice_get_message(char *name, char *timestr, int save)
{
if ((fd = open(name, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IWGRP|S_IWOTH)) == -1)
{
log(L_ERROR, "Can't create \"%s\".\n", name);
log(L_ERROR, gettext("Can't create \"%s\".\n"), name);
return(VOICE_ACTION_ERROR);
}
@ -402,7 +411,7 @@ int voice_get_message(char *name, char *timestr, int save)
if (!header_put(fd, &header))
{
log(L_ERROR, "Can't write raw voice audio header.\n");
log(L_ERROR, gettext("Can't write raw voice audio header.\n"));
voice_close_or_unlink(fd, name);
@ -420,16 +429,13 @@ int voice_get_message(char *name, char *timestr, int save)
if (modem_command("AT+VRX", "CONNECT") == 0)
{
log(L_ERROR, "Can't start record mode.\n");
log(L_ERROR, gettext("Can't start record mode.\n"));
if (save) voice_close_or_unlink(fd, name);
return(VOICE_ACTION_ERROR);
}
/* Solange Daten aufzeichnen, bis der Timeout abgelaufen ist oder */
/* der Anrufer aufgelegt hat. */
sequencestatus = ST_NO_INPUT;
voicestatus = VOICE_ACTION_OK;
havedle = FALSE;
@ -457,7 +463,7 @@ int voice_get_message(char *name, char *timestr, int save)
break;
case ETX:
log(L_DEBUG, "Found sequence \"<DLE><ETX>\" (remote hangup)...\n");
log(L_DEBUG, gettext("Found sequence \"<DLE><ETX>\" (remote hangup)...\n"));
voicestatus = VOICE_ACTION_REMOTEHANGUP;
break;
@ -484,18 +490,18 @@ int voice_get_message(char *name, char *timestr, int save)
{
if (save)
{
log(L_JUNK, "Record: <DATA %d incoming; %d outgoing>\n", byte_i, byte_o);
log(L_JUNK, gettext("Record: <DATA %d incoming; %d outgoing>\n"), byte_i, byte_o);
write(fd, line_o, byte_o);
}
else log(L_JUNK, "Wait: <DATA %d incoming>\n", byte_i);
else log(L_JUNK, gettext("Wait: <DATA %d incoming>\n"), byte_i);
}
if ((result != 1) || (modem_get_timeout()))
{
if (!modem_get_timeout())
{
log(L_ERROR, "Can't read incoming data (%s).\n", strerror(errno));
log(L_ERROR, gettext("Can't read incoming data (%s).\n"), strerror(errno));
voicestatus = VOICE_ACTION_ERROR;
}
@ -506,17 +512,17 @@ int voice_get_message(char *name, char *timestr, int save)
{
if ((index(touchtones, '#')) && (index(touchtones, '*')))
{
log(L_DEBUG, "Touchtone sequence \"%s\" found.\n", touchtones);
log(L_DEBUG, gettext("Touchtone sequence \"%s\" found.\n"), touchtones);
if (list_find_node(&breaklist, touchtones))
{
log(L_INFO, "Sequence \"%s\" found in breaklist...\n", touchtones);
log(L_INFO, gettext("Sequence \"%s\" found in breaklist...\n"), touchtones);
voicestatus = VOICE_ACTION_TOUCHTONES;
}
else
{
log(L_DEBUG, "Sequence \"%s\" not in breaklist (ignored)...\n", touchtones);
log(L_DEBUG, gettext("Sequence \"%s\" not in breaklist (ignored)...\n"), touchtones);
*touchtones = '\0';
}
@ -528,27 +534,31 @@ int voice_get_message(char *name, char *timestr, int save)
if (save)
{
close(fd);
voice_close_or_unlink(fd, NULL);
permissions_set(name, setup.users.uid, setup.users.gid, S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH, setup.users.umask);
}
if ((voicestatus == VOICE_ACTION_REMOTEHANGUP) || (modem_get_nocarrier_state()))
{
/* Remote hangup: Modem should response with the sequence */
/* NO CARRIER. */
/*
* Remote hangup: Modem should response with the sequence
* NO CARRIER.
*/
modem_command("", "NO CARRIER");
}
else
{
/* Local hangup: send <DLE><DC4> to the modem and read the */
/* response <DLE><ETX> and VCON. */
/*
* Local hangup: send <DLE><DC4> to the modem and read the
* response <DLE><ETX> and VCON.
*/
printstring(line_o, "%c%c", DLE, DC4);
printstring(line_i, "%c%c", DLE, ETX);
log(L_JUNK, "Sending \"<DLE><DC4>\"...\n");
log(L_JUNK, gettext("Sending \"<DLE><DC4>\"...\n"));
modem_raw_write(line_o, strlen(line_o));
@ -562,17 +572,9 @@ int voice_get_message(char *name, char *timestr, int save)
return(voicestatus);
}
/*************************************************************************
** voice_set_header(): Fills the vbox audio header. **
*************************************************************************/
/*************************************************************************/
/** voice_set_header(): Fills the vbox audio header. **/
/*************************************************************************/
static void voice_set_header(vaheader_t *header)
{
@ -582,16 +584,16 @@ static void voice_set_header(vaheader_t *header)
xstrncpy(header->name , setup.voice.name , VAH_MAX_NAME );
xstrncpy(header->callerid, setup.voice.callerid , VAH_MAX_CALLERID);
xstrncpy(header->phone , setup.voice.phone , VAH_MAX_PHONE );
xstrncpy(header->location, "<not supported>" , VAH_MAX_LOCATION);
xstrncpy(header->location, "*** Unknown ***" , VAH_MAX_LOCATION);
header->time = htonl(time(NULL));
header->compression = htonl(setup.modem.compression);
}
/*************************************************************************
** voice_handle_touchtone_dle(): Checks a byte for a touchtone DLE **
** sequence. **
*************************************************************************/
/*************************************************************************/
/** voice_handle_touchtone_dle(): Checks a byte for a touchtone DLE **/
/** sequence. **/
/*************************************************************************/
static void voice_handle_touchtone_dle(int byte)
{
@ -617,144 +619,22 @@ static void voice_handle_touchtone_dle(int byte)
break;
default:
log_line(L_ERROR, "Illeagal <DLE> shielded code \"");
log_line(L_ERROR, gettext("Illeagal \"<DLE>\" shielded code \""));
log_char(L_ERROR, byte);
log_text(L_ERROR, "\" (ignored)...\n");
log_text(L_ERROR, gettext("\" (ignored)...\n"));
break;
}
}
static void voice_handle_dle(char Byte)
{
/*
log_line(L_JUNK, "Sequence: Found \"");
log_char(L_JUNK, Byte);
log_text(L_JUNK, "\"%s.\n", ((sequencestatus == ST_NO_INPUT) ? "" : " (<DLE>)"));
*/
switch (sequencestatus)
{
case ST_NO_INPUT:
switch (Byte)
{
case DLE:
sequencestatus = ST_GOT_DLE;
break;
case XON:
log(L_WARN, "Sequence: Found \"<XON>\".\n");
break;
case XOFF:
log(L_WARN, "Sequence: Found \"<XOFF>\".\n");
break;
default:
log_line(L_ERROR, "Sequence: Found \"");
log_char(L_ERROR, Byte);
log_text(L_ERROR, "\" (illegal).\n");
break;
}
return;
case ST_GOT_DLE:
switch (Byte)
{
case DC4:
log(L_DEBUG, "Sequence: Found \"<DLE><DC4>\" - stop current action...\n");
voicestatus = VOICE_ACTION_LOCALHANGUP;
break;
case ETX:
log(L_DEBUG, "Sequence: Found \"<DLE><ETX>\" - stop current action...\n");
voicestatus = VOICE_ACTION_LOCALHANGUP;
break;
/* MFV-Ton 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, * oder # er- */
/* kannt (Touchtone). */
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '*':
case '#':
voice_handle_touchtone(Byte);
break;
/* Besetztzeichen erkannt */
case 'b':
log(L_DEBUG, "Sequence: Found busytone...\n");
break;
/* T.30 Faxrufton erkannt */
case 'c':
log(L_DEBUG, "Sequence: Found T.30 faxtone...\n");
break;
/* Datenträger eines Modems erkannt */
case 'e':
break;
/* Wählton erkannt */
case 'd':
break;
/* Quiet (Ruhe) erkannt. Das Modem hat erkannt, daß zu- */
/* nächst Sprachdaten angekommen sind und eine Stille */
/* folgte, die länger war als durch AT+VSD definiert. */
case 'q':
log(L_DEBUG, "Sequence: Found quiet...\n");
break;
/* Silence (Stille) erkannt. Das Modem hat bei Beginn */
/* des Sprachmodus keine Sprachdaten erkannt, aber es */
/* wurde eine Stille erkannt, die länger war als dur- */
/* ch AT+VSD definiert. */
case 's':
log(L_DEBUG, "Sequence: Found silence...\n");
break;
default:
log_line(L_ERROR, "Sequence: Illeagal <DLE> shielded code \"");
log_char(L_ERROR, Byte);
log_text(L_ERROR, "\".\n");
break;
}
sequencestatus = ST_NO_INPUT;
return;
}
}
/**************************************************************************/
/** voice_handle_touchtone(): **/
/**************************************************************************/
static void voice_handle_touchtone(char Tone)
{
char Temp[2];
log(L_DEBUG, "Found touchtone \"%c\"...\n", Tone);
log(L_DEBUG, gettext("Found touchtone \"%c\"...\n"), Tone);
if (Tone == '*')
{
@ -799,4 +679,3 @@ static void voice_handle_touchtone(char Tone)
strcat(touchtones, Temp);
}
}

45
vbox/utils/mkpos Executable file
View File

@ -0,0 +1,45 @@
#! /bin/sh
##
## Script to create the misc message catalogs. This is only for development!
# Get all sources (*.c) to a variable #
GETTEXT_SOURCE_FILES=""
for i in ${TOPDIR}/src/*.c
do
GETTEXT_SOURCE_FILES="${GETTEXT_SOURCE_FILES} ${i}"
done
# Process each existing catalog #
for i in ${CATALOGS}
do
OLD_PO_FILE="${TOPDIR}/messages/tmp-o-${i}"
NEW_PO_FILE="${TOPDIR}/messages/tmp-n-${i}"
echo "Creating '${TOPDIR}/messages/${i}.po'..."
if (test -f ${TOPDIR}/messages/${i}.po)
then
cp ${TOPDIR}/messages/${i}.po ${TOPDIR}/messages/backup-${i}.po
mv ${TOPDIR}/messages/${i}.po ${OLD_PO_FILE}.po
fi
xgettext --default-domain=${NEW_PO_FILE} \
--sort-output \
${GETTEXT_SOURCE_FILES}
if (test -f ${OLD_PO_FILE}.po)
then
tupdate ${NEW_PO_FILE}.po ${OLD_PO_FILE}.po >${TOPDIR}/messages/${i}.po 2>/dev/null
rm ${OLD_PO_FILE}.po ${NEW_PO_FILE}.po
else
mv ${NEW_PO_FILE}.po ${TOPDIR}/messages/${i}.po
fi
echo "Creating '${TOPDIR}/messages/${i}.mo'..."
msgfmt --output-file=${TOPDIR}/messages/${i}.mo ${TOPDIR}/messages/${i}.po
done