Firewall-Masquerade avec interface http

crabs_firewall-3.0.1 ©2005-2011 - Christophe CAZAJUS (crabs-mettre_le_signe_at-crabs-world.com)

cgi_shell~~ / WWW / SHELL / main.cpp
Makefile main.cpp
    1 /*
    2 **=============================================================================
    3 ** crabs_firewall-3.0.1 : Firewall-Masquerade avec interface http
    4 ** Copyright (C) 2005-2011 : Christophe CAZAJUS (crabs-mettre_le_signe_at-crabs-world.com)
    5 **
    6 ** Ce source fait partie d'un projet logiciel libre. Vous pouvez le distribuer
    7 ** et/ou le modifier en respectant les termes de la GNU General Public License
    8 ** version 2 ou (suite a votre propre choix) une version ulterieure.
    9 **
   10 ** Ce programme est distribue dans l'espoir qu'il puisse etre utile, mais
   11 ** sans aucune garantie, meme si il est associe a un produit qui vous en
   12 ** propose une. Conformez-vous a la GNU General Public License pour avoir
   13 ** plus de precisions.
   14 **
   15 ** L'auteur ne peut etre tenu responsable de l'utilisation faite des
   16 ** composantes associees a ce projet (en partie ou dans leur totalite).
   17 **
   18 ** Une copie du fichier de la GNU GPL est fournie dans le repertoire DOC
   19 ** de ce projet sous le nom gnu_gpl.txt
   20 **
   21 **=============================================================================
   22 */
   23 //  -------------------------------------------------------------------------
   24 //  Programme cgi_shell
   25 //  Usage : cgi_shell CSH|SH
   26 //
   27 //  A utiliser dans un script CGI/Apache C-shell ou Shell pour obtenir en
   28 //  variables le contenu des GET et POST
   29 //      +-----------------------------------------------------------+
   30 //      | #!/bin/csh -f                                             |
   31 //      | eval `cgi_shell CSH`                                      |
   32 //      | ...                                                       |
   33 //      +-----------------------------------------------------------+
   34 //
   35 //  -------------------------------------------------------------------------
   36 #include <cgi.h>
   37 #include <string.h>
   38 #include <iostream>
   39 using namespace std ;
   40 
   41 //
   42 // -=> CLASSE CgiShell
   43 //
   44 class CgiShell: public Cgi
   45     {
   46     public :
   47         enum SHELL { NONE, CSH, SH } ;
   48         CgiShell():Cgi() { first=false ; shell=NONE; }
   49         virtual ~CgiShell() {}
   50         virtual int main( int argc, char** argv ) ;
   51         virtual void affVar(const char* src,const char* var,const char* val ) ;
   52     private :
   53         bool    first   ;
   54         SHELL   shell   ;
   55     } ;
   56 int CgiShell::main( int argc, char** argv )
   57     {
   58     if ( argv[1] )
   59         {
   60         if ( strcmp( argv[1], "CSH" ) == 0 ) shell = CSH ;
   61         if ( strcmp( argv[1], "SH"  ) == 0 ) shell = SH ;
   62         }
   63     aff( false, true, true ) ;
   64     return 0 ;
   65     }
   66 void CgiShell::affVar( const char* src, const char* var, const char* val )
   67     {
   68     switch( shell )
   69         {
   70         case CSH :
   71             if ( first ) { cout << "set " ; first=false ; }
   72         case SH :
   73             cout << var << "=\"" << val << "\"" << endl ;
   74         break ;
   75         default :
   76             cout << src << "::" << var << "=\"" << val << "\"" << endl ;
   77         }
   78     }
   79 
   80 //
   81 // -=> PROGRAMME PRINCIPAL
   82 //
   83 int main( int argc, char** argv )
   84     {
   85     CgiShell* cs = new CgiShell() ;
   86     return cs->start( argc, argv ) ;
   87     }
Makefile main.cpp
cgi_shell~~ / WWW / SHELL / main.cpp

Haut de page

Contacter crabs

Date de génération : 22/09/2011 21:48