Client related changes.

git-svn-id: http://voip.null.ro/svn/yate@330 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2005-05-05 17:02:18 +00:00
parent fe00f50c29
commit c12436858d
11 changed files with 189 additions and 47 deletions

View File

@ -1,3 +1,12 @@
Thu May 05 2005 Paul Chitescu <paulc-devel@null.ro>
- Separate client directory and executables
- Support for passing arguments to client programs
- Put some usefull tools in their own directory
Mon Apr 02 2005 Paul Chitescu <paulc-devel@null.ro>
- Windows directory and Visual Studio 6 project files
- Started changes to make the engine cross-platform
Fri Mar 18 2005 Paul Chitescu <paulc-devel@null.ro>
- Bumped version to 0.8.8
- Rearranged directories and file names

View File

@ -44,15 +44,16 @@ moddir = @libdir@/yate
confdir = @sysconfdir@/yate
.PHONY: all everything
all: engine modules
all: engine modules clients
everything: engine contrib modules test apidocs
everything: engine contrib modules clients test apidocs
.PHONY: clean distclean cvsclean clean-config-files clean-tables clean-apidocs
clean:
@-$(RM) $(CLEANS) 2>/dev/null
$(MAKE) -C ./engine $@
$(MAKE) -C ./modules $@
$(MAKE) -C ./clients $@
$(MAKE) -C ./test $@
@for i in contrib/*; do \
test -f "$$i/Makefile" && $(MAKE) -C "$$i" clean ; \
@ -77,7 +78,7 @@ distclean: check-topdir clean clean-config-files
cvsclean: check-topdir clean clean-tables clean-apidocs clean-config-files
-rm -f configure
.PHONY: engine contrib modules test apidocs-build check-topdir windows
.PHONY: engine contrib modules clients test apidocs-build check-topdir windows
engine: tables library libyate.so $(PROGS)
apidocs-build: check-topdir
@ -102,11 +103,8 @@ love:
war:
@echo 'Please make love instead!'
test: engine
$(MAKE) -C ./test all
modules: engine
$(MAKE) -C ./modules all
modules clients test: engine
$(MAKE) -C ./$@ all
contrib: engine
@for i in contrib/*; do \
@ -141,6 +139,7 @@ install-noapi: all
@mkdir -p "$(DESTDIR)$(bindir)/" && \
install $(PROGS) yate-config "$(DESTDIR)$(bindir)/"
$(MAKE) -C ./modules install
$(MAKE) -C ./clients install
$(MAKE) -C ./scripts install
$(MAKE) -C ./conf.d install
@mkdir -p "$(DESTDIR)$(mandir)/man8/" && \
@ -169,6 +168,7 @@ uninstall uninstall-root:
@-for i in $(SLIBS) ; do \
rm "$(DESTDIR)$(libdir)/$$i" ; \
done; \
$(MAKE) -C ./clients uninstall
$(LDCONFIG)
@-for i in $(PROGS) yate-config ; do \
rm "$(DESTDIR)$(bindir)/$$i" ; \
@ -244,7 +244,7 @@ library $(YLIB): yatepaths.h
.PHONY: help
help:
@echo -e 'Usual make targets:\n\
all engine contrib modules apidocs test everything\n\
all engine contrib modules clients apidocs test everything\n\
install uninstall install-noapi install-root uninstall-root\n\
clean distclean cvsclean (avoid this one!)\n\
snapshot tarball'

9
clients/.cvsignore Normal file
View File

@ -0,0 +1,9 @@
Makefile
core*
yate-*
*.o
*.a
*.so
*.orig
*~
.*.swp

93
clients/Makefile.in Normal file
View File

@ -0,0 +1,93 @@
# Makefile
# This file holds the make rules for the Telephony Engine clients
# override DESTDIR at install time to prefix the install directory
DESTDIR :=
# override DEBUG at compile time to enable full debug or remove it all
DEBUG :=
CXX := @CXX@ -Wall
SED := sed
DEFS :=
LIBTHR:= -lpthread
INCLUDES := -I.. -I@top_srcdir@
CFLAGS := -O2 @MODULE_CPPFLAGS@ @INLINE_FLAGS@
LDFLAGS:= -L.. -lyate
INCFILES := @top_srcdir@/yatengine.h @top_srcdir@/yatephone.h ../yateversn.h
SUBDIRS :=
MKDEPS := ../config.status
PROGS :=
LIBS :=
ifneq (@HAVE_GTK@,no)
PROGS := $(PROGS) yate-gtk
endif
ifneq (@HAVE_QT@,no)
PROGS := $(PROGS) yate-qt
endif
LOCALFLAGS =
LOCALLIBS =
COMPILE = $(CXX) $(DEFS) $(DEBUG) $(INCLUDES) $(CFLAGS)
LINK = $(CXX) $(LDFLAGS)
EXECOMP = $(COMPILE) $(LIBTHR) $(LDFLAGS)
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
moddir = @libdir@/yate
.PHONY: all
all: do-all $(LIBS) $(PROGS)
.PHONY: strip
strip: all do-strip
strip --strip-debug --discard-locals $(PROGS)
.PHONY: clean
clean: do-clean
@-$(RM) $(PROGS) $(LIBS) *.o core 2>/dev/null
.PHONY: install
install: all do-install
@mkdir -p "$(DESTDIR)$(bindir)/" && \
install $(PROGS) "$(DESTDIR)$(bindir)/"
.PHONY: uninstall
uninstall: do-uninstall
@-for i in $(PROGS) ; do \
rm "$(DESTDIR)$(bindir)/$$i" ; \
done; \
rmdir "$(DESTDIR)$(bindir)"
%.o: @srcdir@/%.cpp $(MKDEPS) $(INCFILES)
$(COMPILE) -c $<
do-all do-strip do-clean do-install do-uninstall:
$(if $(SUBDIRS),\
@target=`echo $@ | $(SED) -e 's/^do-//'`; \
for i in $(SUBDIRS) ; do \
if test -f ./$$i/Makefile ; then \
$(MAKE) -C ./$$i $${target} || exit 1;\
fi; \
done \
)
Makefile: @srcdir@/Makefile.in $(MKDEPS)
cd .. && ./config.status
yate-%: @srcdir@/main-%.cpp $(MKDEPS) ../libyate.so $(INCFILES)
$(EXECOMP) -o $@ $(LOCALFLAGS) $< $(LOCALLIBS)
yate-gtk: LOCALFLAGS = @GTK_INC@
yate-gtk: LOCALLIBS = @GTK_LIB@
yate-qt: ../contrib/qt/libqtclientform.a
yate-qt: LOCALFLAGS = -I@QT_INC@
yate-qt: LOCALLIBS = ../contrib/qt/libqtclientform.a -L@QT_DIR@/lib -lqt-mt
../contrib/qt/libqtclientform.a:
$(MAKE) -C ../contrib/qt

9
clients/run-gtk Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
# Run this to generate a new configure script
if [ -x yate-gtk -a -x ../run ]; then
cd ..; exec ./run --executable clients/yate-gtk "$@"
else
echo "Could not find client executable or run script" >&2
fi

9
clients/run-qt Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
# Run this to generate a new configure script
if [ -x yate-qt -a -x ../run ]; then
cd ..; exec ./run --executable clients/yate-qt "$@"
else
echo "Could not find client executable or run script" >&2
fi

View File

@ -579,6 +579,7 @@ AC_CONFIG_FILES([yate.spec
Makefile
engine/Makefile
modules/Makefile
clients/Makefile
scripts/Makefile
conf.d/Makefile
contrib/iax/Makefile

View File

@ -632,17 +632,17 @@ static int supervise(void)
}
#endif /* _WINDOWS */
static void usage(FILE* f)
static void usage(bool client, FILE* f)
{
#ifdef _WINDOWS
client = true;
#endif
::fprintf(f,
"Usage: yate [options] [commands ...]\n"
" -h Help message (this one)\n"
" -v Verbose debugging (you can use more than once)\n"
" -q Quieter debugging (you can use more than once)\n"
#ifndef _WINDOWS
" -d Daemonify, suppress output unless logged\n"
" -s Supervised, restart if crashes or locks up\n"
#endif
"%s"
" -p filename Write PID to file\n"
" -l filename Log to file\n"
" -n configname Use specified configuration name (%s)\n"
@ -657,25 +657,28 @@ static void usage(FILE* f)
" w Delay creation of 1st worker thread\n"
" t Timestamp debugging messages\n"
#endif
,client ? "" :
" -d Daemonify, suppress output unless logged\n"
" -s Supervised, restart if crashes or locks up\n"
,s_cfgfile);
}
static void badopt(char chr, const char* opt)
static void badopt(bool client, char chr, const char* opt)
{
if (chr)
::fprintf(stderr,"Invalid character '%c' in option '%s'\n",chr,opt);
else
::fprintf(stderr,"Invalid option '%s'\n",opt);
usage(stderr);
usage(client,stderr);
}
static void noarg(const char* opt)
static void noarg(bool client, const char* opt)
{
::fprintf(stderr,"Missing parameter to option '%s'\n",opt);
usage(stderr);
usage(client,stderr);
}
int Engine::main(int argc, const char** argv, const char** env)
int Engine::main(int argc, const char** argv, const char** env, bool client, bool fail)
{
#ifndef _WINDOWS
bool daemonic = false;
@ -709,14 +712,14 @@ int Engine::main(int argc, const char** argv, const char** env)
continue;
}
if (!::strcmp(pc,"help")) {
usage(stdout);
usage(client,stdout);
return 0;
}
badopt(0,argv[i]);
badopt(client,0,argv[i]);
return EINVAL;
break;
case 'h':
usage(stdout);
usage(client,stdout);
return 0;
case 'v':
debug_level++;
@ -734,7 +737,7 @@ int Engine::main(int argc, const char** argv, const char** env)
#endif
case 'p':
if (i+1 >= argc) {
noarg(argv[i]);
noarg(client,argv[i]);
return ENOENT;
}
pc = 0;
@ -742,7 +745,7 @@ int Engine::main(int argc, const char** argv, const char** env)
break;
case 'l':
if (i+1 >= argc) {
noarg(argv[i]);
noarg(client,argv[i]);
return ENOENT;
}
pc = 0;
@ -750,7 +753,7 @@ int Engine::main(int argc, const char** argv, const char** env)
break;
case 'n':
if (i+1 >= argc) {
noarg(argv[i]);
noarg(client,argv[i]);
return ENOENT;
}
pc = 0;
@ -758,7 +761,7 @@ int Engine::main(int argc, const char** argv, const char** env)
break;
case 'c':
if (i+1 >= argc) {
noarg(argv[i]);
noarg(client,argv[i]);
return ENOENT;
}
pc = 0;
@ -766,7 +769,7 @@ int Engine::main(int argc, const char** argv, const char** env)
break;
case 'm':
if (i+1 >= argc) {
noarg(argv[i]);
noarg(client,argv[i]);
return ENOENT;
}
pc = 0;
@ -795,7 +798,7 @@ int Engine::main(int argc, const char** argv, const char** env)
tstamp = true;
break;
default:
badopt(*pc,argv[i]);
badopt(client,*pc,argv[i]);
return EINVAL;
}
}
@ -803,7 +806,7 @@ int Engine::main(int argc, const char** argv, const char** env)
break;
#endif
default:
badopt(*pc,argv[i]);
badopt(client,*pc,argv[i]);
return EINVAL;
}
}
@ -815,7 +818,14 @@ int Engine::main(int argc, const char** argv, const char** env)
}
}
if (fail)
return EINVAL;
#ifndef _WINDOWS
if (client && (daemonic || supervised)) {
::fprintf(stderr,"Options -d and -s not supported in client mode\n");
return EINVAL;
}
if (daemonic) {
Debugger::enableOutput(false);
// Make sure X client modules fail initialization in daemon mode
@ -872,4 +882,9 @@ int Engine::main(int argc, const char** argv, const char** env)
return retcode;
}
void Engine::help(bool client, bool errout)
{
usage(client, errout ? stderr : stdout);
}
/* vi: set ts=8 sw=4 sts=4 noet: */

View File

@ -57,14 +57,6 @@ ifneq (@HAVE_GSM@,no)
PROGS := $(PROGS) gsmcodec.yate
endif
ifneq (@HAVE_GTK@,no)
PROGS := $(PROGS) gtkclient.yate
endif
ifneq (@HAVE_QT@,no)
PROGS := $(PROGS) qtclient.yate
endif
LOCALFLAGS =
LOCALLIBS =
COMPILE = $(CXX) $(DEFS) $(DEBUG) $(INCLUDES) $(CFLAGS)
@ -148,12 +140,6 @@ faxchan.yate: LOCALFLAGS = @SPANDSP_INC@
gsmcodec.yate: LOCALLIBS = -lgsm
gsmcodec.yate: LOCALFLAGS = @GSM_INC@
gtkclient.yate: LOCALFLAGS = @GTK_INC@ @GTK_LIB@
qtclient.yate: ../contrib/qt/libqtclientform.a
qtclient.yate: LOCALFLAGS = -I@QT_INC@
qtclient.yate: LOCALLIBS = ../contrib/qt/libqtclientform.a -L@QT_DIR@/lib -lqt-mt
ysipchan.yate: ../contrib/ysip/libyatesip.a
ysipchan.yate: LOCALFLAGS = -I@top_srcdir@/contrib/ysip
ysipchan.yate: LOCALLIBS = ../contrib/ysip/libyatesip.a
@ -168,9 +154,6 @@ yrtpchan.yate: LOCALLIBS = ../contrib/yrtp/libyatertp.a
../contrib/ortp/libortp.a:
$(MAKE) -C ../contrib/ortp
../contrib/qt/libqtclientform.a:
$(MAKE) -C ../contrib/qt
../contrib/ysip/libyatesip.a:
$(MAKE) -C ../contrib/ysip

5
run.in
View File

@ -3,6 +3,11 @@
yate="./yate"
set_conf="-c ./conf.d"
set_mods="-m ./modules"
if [ "$1" = "--executable" ]; then
shift
yate="$1"
shift
fi
if [ "$1" = "--gdb" ]; then
shift
yate="gdb --args $yate"

View File

@ -581,9 +581,18 @@ public:
* @param argc Argument count
* @param argv Argument array
* @param env Environment variables
* @param client True to parse arguments and run as a client
* @param fail Fail and return after parsing command line arguments
* @return Program exit code
*/
static int main(int argc, const char** argv, const char** env);
static int main(int argc, const char** argv, const char** env,
bool client = false, bool fail = false);
/**
* Display the help information on console
* @param errout Display on stderr intead of stdout
*/
static void help(bool client, bool errout = false);
/**
* Run the engine.