1 // httpd.hxx -- FGFS http property manager interface / external script
4 // Written by Curtis Olson, started June 2001.
6 // Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
8 // Jpeg Image Support added August 2001
9 // by Norman Vine - nhv@cape.com
11 // This program is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU General Public License as
13 // published by the Free Software Foundation; either version 2 of the
14 // License, or (at your option) any later version.
16 // This program is distributed in the hope that it will be useful, but
17 // WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #ifndef _FG_JPEG_HTTPD_HXX
29 #define _FG_JPEG_HTTPD_HXX
35 #include <plib/netChat.h>
38 # include <simgear/screen/jpgfactory.hxx>
41 #include "protocol.hxx"
46 /* simple httpd server that makes an hasty stab at following the http
49 class HttpdImageChannel : public netChat
53 trJpgFactory *JpgFactory;
57 HttpdImageChannel() : buffer(512) {
58 setTerminator("\r\n");
59 JpgFactory = new trJpgFactory();
61 // This is a terrible hack but it can't be initialized until
62 // after OpenGL is up an running
63 JpgFactory->init(400,300);
66 ~HttpdImageChannel() {
67 JpgFactory->destroy();
71 virtual void collectIncomingData (const char* s, int n) {
75 // Handle the actual http request
76 virtual void foundTerminator (void);
80 class HttpdImageServer : private netChannel
82 virtual bool writable (void) { return false ; }
84 virtual void handleAccept (void) {
86 int handle = accept ( &addr ) ;
87 printf("Client %s:%d connected\n", addr.getHost(), addr.getPort());
89 HttpdImageChannel *hc = new HttpdImageChannel;
90 hc->setHandle ( handle ) ;
95 HttpdImageServer ( int port ) {
100 printf( "HttpdImage server started on port %d\n", port ) ;
106 class FGJpegHttpd : public FGProtocol {
109 HttpdImageServer *imageServer;
113 inline FGJpegHttpd( int p ) { port = p; }
115 inline ~FGJpegHttpd() { }
125 #endif // _FG_JPEG_HTTPD_HXX