Hauptseite | Liste aller Namensbereiche | Klassenhierarchie | Übersicht | Auflistung der Dateien | Elemente eines Namensbereiches | Datenstruktur-Elemente | Datei-Elemente

psfaAdmin.cpp

gehe zur Dokumentation dieser Datei
00001 // Copyright (C) 2004 Bernhard Assmann <bernie@tuxomania.net>
00002 //  
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //  
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //  
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 //  
00017 
00018 #include <iostream>
00019 #include <string>
00020 
00021 #include "psfa/Admin.hpp"
00022 
00023 
00024 
00025 void 
00026 usage();
00027 
00028 int main(int argc, 
00029     char *argv[] ) 
00030 {
00031   using std::cout;
00032   using std::endl;
00033   using std::string;
00034     
00035   if ( argc < 2 ) {
00036     usage();
00037     return 0;
00038   }
00039 
00040   enum Action { UNKNOWN, INIT, INDEX, DELETE, CHECK };
00041 
00042   Action action = UNKNOWN;
00043   const string arg1 = argv[1];
00044   
00045   if ( arg1 == "init" ) {
00046     action = INIT;
00047   }
00048   else if ( arg1 == "index" ) {
00049     action = INDEX;
00050   }
00051   else if ( arg1 == "delete" ) {
00052     action = DELETE;
00053   }
00054   else if ( arg1 == "check" ) {
00055     action = CHECK;
00056   }
00057   
00058   string pool;
00059   psfa::Admin admin;
00060   
00061   switch ( action ) {
00062   case INIT :
00063     switch( argc ) {
00064     case 2 :
00065       cout << "Initialisiere die DB" << endl;
00066       admin.init();
00067       break;
00068     default :
00069       usage();
00070       return 1;
00071     }
00072     break;
00073   case INDEX :
00074     switch( argc ) {
00075     case 3:
00076       pool = argv[2];
00077       cout << "Indiziere den Pool " << pool << endl;
00078       admin.index( pool );
00079       break;
00080     default:
00081       usage();
00082       return 1;
00083     }
00084     break;
00085   case DELETE :
00086     switch( argc ) {
00087     case 3 :
00088       pool = argv[2];
00089       cout << "Lösche den Pool " << pool << endl;
00090       admin.del( pool );
00091       break;
00092     default :
00093       usage();
00094       return 1;
00095     }
00096     break;
00097   case CHECK:
00098     switch( argc ) {
00099     case 2 :
00100       cout << "Überprüfe die DB" << endl;
00101       admin.check();
00102       break;
00103     default :
00104       usage();
00105       return 1;
00106     }
00107     break;
00108   default :
00109     usage();
00110     return 1;
00111   }
00112   
00113   if( !admin.isSuccess() ) {
00114     return 1;
00115   }
00116   return 0;
00117 }
00118 
00119 
00120 
00121 void
00122 usage() 
00123 {
00124     using std::cout;
00125     using std::endl;
00126     
00127     cout << "\n"
00128     << "psfa - administriert das Indizierungssystem\n"
00129     << "psfa Aktion [Parameter]\n"
00130     << "Aktion:\n"
00131     << "init        - initialisiert die DB "
00132     << "und bereitet sie auf die Indizierung vor\n"
00133     << "delete pool - löscht den Pool pool\n"
00134     << "index pool  - indiziert den Pool pool\n"
00135     << "check       - überprüft, ob die DB noch aktuell ist\n"
00136     << endl;
00137     return;
00138 }

Erzeugt am Mon Jul 12 11:45:04 2004 für PSFA von doxygen 1.3.4