1 // vim: set noexpandtab tabstop=4 shiftwidth=4:
2 //----------------------------------------------------------------------------
4 //----------------------------------------------------------------------------
5 // This file is part of PlaQui.
7 // PlaQui is free software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the Free Software
9 // Foundation; either version 2 of the License, or (at your option) any later
12 // PlaQui is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 // You should have received a copy of the GNU General Public License along
18 // with PlaQui; if not, write to the Free Software Foundation, Inc., 59 Temple
19 // Place, Suite 330, Boston, MA 02111-1307 USA
20 //----------------------------------------------------------------------------
21 // Creado: Sat Oct 18 18:18:36 2003
22 // Autores: Leandro Lucarella <llucare@fi.uba.ar>
23 //----------------------------------------------------------------------------
28 #include "controlserver.h"
32 using namespace Plaqui;
34 ControlServer::ControlServer(const sockbuf::sockdesc& sd):
37 std::cerr << "Compilado el " << __DATE__ << std::endl;
38 std::cerr << __FILE__ << ": sd = " << sd.sock << std::endl;
42 void ControlServer::real_run(void) {
43 // FIXME se tiene que ir a la clase para poder frenarlo desde afuera.
45 char buf[BUFFER_SIZE];
48 while (!stop && socket.getline(buf, BUFFER_SIZE)) {
50 std::cerr << "Reciviendo (crudo): " << buf << std::endl;
52 int len = strlen(buf);
53 // Si tiene un retorno de carro, lo elimina.
54 if (len && (buf[len-1] == '\r')) {
58 std::cerr << "Reciviendo (sin \\r): " << buf << std::endl;
59 std::cerr << "len: " << len << std::endl;
61 std::cerr << std::hex << "Caracter: " << *buf << std::endl;
64 // Si tiene contenido, lo almaceno en el buffer de comandos.
67 // Si viene la línea vacía, terminan las cabeceras HTTP.
72 // Manda mensaje a la planta.
73 //dispatch_command(parse_command(sstr.str()));
75 std::cerr << "Recivido:" << std::endl << sstr.str() << std::endl;
77 // FIXME - hacer respuesta XML.
78 stringstream response_xml;
79 socket << "HTTP/1.0 200 OK" << std::endl;
81 Date: Sun, 19 Oct 2003 15:11:14 GMT
82 Server: Apache/1.3.28 (Debian GNU/Linux)
83 Last-Modified: Mon, 28 Apr 2003 07:50:08 GMT
84 ETag: "110f4043-11a1-3eacdd30"
87 socket << "Content-Type: text/html; charset=iso-8859-1" << std::endl;
88 response_xml << "<html>" << std::endl;
89 response_xml << " <head>" << std::endl;
90 response_xml << " <title>PlaQui v0.1</title>" << std::endl;
91 response_xml << " </head>" << std::endl;
92 response_xml << " <body>" << std::endl;
93 response_xml << " <h1>PlaQui</h1>" << std::endl;
94 response_xml << " <p>versión 0.1</p>" << std::endl;
95 response_xml << " <h3>Desarrollado por</h3>" << std::endl;
96 response_xml << " <ul>" << std::endl;
97 response_xml << " <li>Nicolás Dimov.</li>" << std::endl;
98 response_xml << " <li>Leandro Lucarella.</li>" << std::endl;
99 response_xml << " <li>Ricardo Markiewicz.</li>" << std::endl;
100 response_xml << " </ul>" << std::endl;
101 response_xml << " <address>" << std::endl;
102 response_xml << " Copyleft 2003 - bajo los " << std::endl;
103 response_xml << " términos de la licencia GPL" << std::endl;
104 response_xml << " </address>" << std::endl;
105 response_xml << " </body>" << std::endl;
106 response_xml << "</html>" << std::endl;
107 //socket << "Content-Length: " << response_xml.str().length() << std::endl;
109 socket << response_xml.str() << std::flush;