From bb95c06ba5fa63ab90ee148ab8a6e009226a53cf Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 20 Nov 2003 20:26:01 +0000 Subject: [PATCH] Scripts de configuracion a nivel global. --- Makefile.am | 29 ++++++++++ Server/configure.in | 2 +- Server/src/Makefile.am | 29 +++++++++- Server/src/main.cpp | 127 +++++++++++++++++++++++++++++++++++++++++ configure.in | 70 +++++++++++++++++++++++ 5 files changed, 253 insertions(+), 4 deletions(-) create mode 100644 Makefile.am create mode 100644 Server/src/main.cpp create mode 100644 configure.in diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..ce87040 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,29 @@ +## vim: set noexpandtab tabstop=4 shiftwidth=4: +##---------------------------------------------------------------------------- +## PlaQui +##---------------------------------------------------------------------------- +## This file is part of PlaQui. +## +## PlaQui is free software; you can redistribute it and/or modify it under the +## terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## PlaQui is distributed in the hope that it will be useful, but WITHOUT ANY +## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along +## with PlaQui; if not, write to the Free Software Foundation, Inc., 59 Temple +## Place, Suite 330, Boston, MA 02111-1307 USA +##---------------------------------------------------------------------------- +## Creado: jue nov 20 14:33:35 ART 2003 +## Autores: Leandro Lucarella +##---------------------------------------------------------------------------- +## +## $Id$ +## + +SUBDIRS = Model Server Client Constructor + diff --git a/Server/configure.in b/Server/configure.in index 8ea8f73..e5e4434 100644 --- a/Server/configure.in +++ b/Server/configure.in @@ -53,5 +53,5 @@ src/Makefile echo echo "Todo listo. Ahora para compilar solo ejecute make" echo -echo "The PlaQui Developer Team" +echo "The PlaQui Development Team" diff --git a/Server/src/Makefile.am b/Server/src/Makefile.am index bc7875c..7b874b5 100644 --- a/Server/src/Makefile.am +++ b/Server/src/Makefile.am @@ -33,11 +33,12 @@ INCLUDES = \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ @PACKAGE_CFLAGS@ -##bin_PROGRAMS = plaqui-server +bin_PROGRAMS = plaqui-server noinst_LIBRARIES = libplaquiserver.a -libplaquiserver_a_SOURCES = \ +plaqui_server_SOURCES = \ + main.cpp \ command.cpp \ connection.cpp \ controlclient.cpp \ @@ -71,5 +72,27 @@ libplaquiserver_a_SOURCES = \ tcpserver.h \ transmitter.h -##plaqui_server_LDADD = @PACKAGE_LIBS@ +libplaquiserver_a_SOURCES = \ + command.cpp \ + connection.cpp \ + controlclient.cpp \ + controlserver.cpp \ + httperror.cpp \ + httpheaders.cpp \ + httpmessage.cpp \ + httprequest.cpp \ + httpresponse.cpp \ + plant.cpp \ + receiver.cpp \ + runnable.cpp \ + server.cpp \ + string.cpp \ + tcpserver.cpp \ + transmitter.cpp + +plaqui_server_LDADD = \ + @PACKAGE_LIBS@ \ + -lsocket++ \ + ../src/libplaquiserver.a \ + ../../Model/src/libplaquimodel.a diff --git a/Server/src/main.cpp b/Server/src/main.cpp new file mode 100644 index 0000000..1f505ee --- /dev/null +++ b/Server/src/main.cpp @@ -0,0 +1,127 @@ +// vim: set noexpandtab tabstop=4 shiftwidth=4: +//---------------------------------------------------------------------------- +// PlaQui +//---------------------------------------------------------------------------- +// This file is part of PlaQui. +// +// PlaQui is free software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// PlaQui is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along +// with PlaQui; if not, write to the Free Software Foundation, Inc., 59 Temple +// Place, Suite 330, Boston, MA 02111-1307 USA +//---------------------------------------------------------------------------- +// Creado: Sat Oct 18 18:18:36 2003 +// Autores: Leandro Lucarella +//---------------------------------------------------------------------------- +// +// $Id$ +// + +#include "plaqui/server/connection.h" +#include "plaqui/server/server.h" +#include "plaqui/server/string.h" +#include +#include +#include +#include + +using namespace std; +using namespace PlaQui::Server; + +Server* server = NULL; + +void on_error(const Runnable::Error& code, const string& desc) { + cerr << "--------------------------------------------------------" << endl; + cerr << "Error en el servidor:" << endl; + cerr << "Código: " << code << endl; + cerr << "Descripción: " << desc << endl; + cerr << "--------------------------------------------------------" << endl; +} + +void on_finished(void) { + cerr << "Murió el servidor!" << endl; + server = NULL; +} + +int main(int argc, char* argv[]) { + + // Termina con mas informacion si hay una excepcion no manejada. + set_terminate (__gnu_cxx::__verbose_terminate_handler); + + // Bienvenida. + cout << "PlaQui Server. Modo de uso: " << endl; + cout << "\t" << argv[0] << " [planta] [puerto]" << endl; + + // Acepta argumentos. + string filename = "prueba.xml"; + Connection::Port port = 7522; + if (argc > 1) { + // Obtengo nombre del archivo de la planta. + filename = argv[1]; + // Si tiene 2 parámetros. + if (argc > 2) { + // Obtengo puerto. + to(argv[2], port); + } + } + + // Inicializa threads. + Glib::thread_init(); + + try { + // Crea el server (empieza a escuchar). + server = new Server(filename, port); + } catch (const sockerr& e) { + cerr << "Socket Error: " << e.operation() << " | serrno = " + << e.serrno() << " | errstr = " << e.errstr() << endl; + if (e.io()) { + cerr << "Es: non-blocking and interrupt io recoverable error." + << endl; + } else if (e.arg()) { + cerr << "Es: incorrect argument supplied. recoverable error." + << endl; + } else if (e.op()) { + cerr << "Es: operational error. recovery difficult." << endl; + } else if (e.conn()) { + cerr << "Es: connection error." << endl; + } else if (e.addr()) { + cerr << "Es: address error." << endl; + } else if (e.benign()) { + cerr << "Es: recoverable read/write error like EINTR etc." << endl; + } + return e.serrno(); + } catch (const exception& e) { + cerr << "Error: " << e.what() << endl; + return 1; + } catch (const char* e) { + cerr << "Error: " << e << endl; + return 2; + } catch (...) { + cerr << "Error desconocido!" << endl; + return 3; + } + + // Conecto señal para atender errores. + server->signal_error().connect(SigC::slot(on_error)); + + // Corre el server. + server->run(false); + + // Espera a que el server se muera. + while (server) { + Glib::usleep(1000000); + } + + // Como no detachee el server, lo tengo que eliminar a mano. + //delete server; + + return 0; +} diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..27cb5be --- /dev/null +++ b/configure.in @@ -0,0 +1,70 @@ +## vim: set noexpandtab tabstop=4 shiftwidth=4: +##---------------------------------------------------------------------------- +## PlaQui +##---------------------------------------------------------------------------- +## This file is part of PlaQui. +## +## PlaQui is free software; you can redistribute it and/or modify it under the +## terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## PlaQui is distributed in the hope that it will be useful, but WITHOUT ANY +## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along +## with PlaQui; if not, write to the Free Software Foundation, Inc., 59 Temple +## Place, Suite 330, Boston, MA 02111-1307 USA +##---------------------------------------------------------------------------- +## Creado: jue nov 20 14:42:27 ART 2003 +## Autores: Leandro Lucarella +##---------------------------------------------------------------------------- +## +## $Id$ +## + +AC_INIT(configure.in) +AM_INIT_AUTOMAKE(plaqui, 1.0) +AM_MAINTAINER_MODE + +AC_ISC_POSIX +AC_PROG_CXX +AM_PROG_CC_STDC +AC_PROG_RANLIB +AC_HEADER_STDC + +## pkg_modules="libgnomeui-2.0" +PKG_CHECK_MODULES(PACKAGE, + libxml-2.0 >= 0.15.0 \ + gthread-2.0 \ + sigc++-1.2 \ + gtkmm-2.0 >= 2.0.0 \ + libglademm-2.0 >= 2.0.0) + +AC_SUBST(PACKAGE_CFLAGS) +AC_SUBST(PACKAGE_LIBS) + +AC_OUTPUT([ +Makefile +Model/Makefile +Model/src/Makefile +Server/Makefile +Server/src/Makefile +Server/tests/Makefile +Client/Makefile +Client/pixmaps/Makefile +Client/dialogs/Makefile +Client/src/Makefile +Constructor/Makefile +Constructor/pixmaps/Makefile +Constructor/dialogs/Makefile +Constructor/src/Makefile +]) + +echo +echo "Todo listo. Ahora para compilar solo ejecute make" +echo +echo "The PlaQui Development Team" + -- 2.43.0