Index: branches/preferences/src/lib/BuildLibs.am
===================================================================
--- branches/preferences/src/lib/BuildLibs.am	(revision 7236)
+++ branches/preferences/src/lib/BuildLibs.am	(revision 7241)
@@ -16,4 +16,5 @@
                 $(LIB_PREFIX)/parser/tinyxml/libtinyxml.a \
                 $(LIB_PREFIX)/parser/ini_parser/libIniParser.a \
+                $(LIB_PREFIX)/parser/cmdline_parser/libCmdLineParser.a \
                 $(LIB_PREFIX)/parser/preferences/libPrefsParser.a \
                 $(LIB_PREFIX)/shell/libORXshell.a \
Index: branches/preferences/src/lib/parser/Makefile.am
===================================================================
--- branches/preferences/src/lib/parser/Makefile.am	(revision 7236)
+++ branches/preferences/src/lib/parser/Makefile.am	(revision 7241)
@@ -1,6 +1,7 @@
 SUBDIRS = \
           tinyxml \
-	  			ini_parser \
-	  			preferences
+	  ini_parser \
+	  preferences \
+	  cmdline_parser
 
 
Index: branches/preferences/src/lib/parser/cmdline_parser/Makefile.am
===================================================================
--- branches/preferences/src/lib/parser/cmdline_parser/Makefile.am	(revision 7241)
+++ branches/preferences/src/lib/parser/cmdline_parser/Makefile.am	(revision 7241)
@@ -0,0 +1,10 @@
+
+noinst_LIBRARIES = libCmdLineParser.a
+
+libCmdLineParser_a_SOURCES = cmdline_parser.cc
+
+libCmdLineParser_a_CPPFLAGS = "-DNO_SHELL"
+
+noinst_HEADERS = cmdline_parser.h
+
+
Index: branches/preferences/src/lib/parser/cmdline_parser/cmdline_parser.cc
===================================================================
--- branches/preferences/src/lib/parser/cmdline_parser/cmdline_parser.cc	(revision 7241)
+++ branches/preferences/src/lib/parser/cmdline_parser/cmdline_parser.cc	(revision 7241)
@@ -0,0 +1,146 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program 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, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: 
+*/
+
+#include "cmdline_parser.h"
+
+using namespace std;
+
+
+/**
+ * standard constructor
+ */
+CmdLineParser::CmdLineParser ()
+{
+}
+
+
+/**
+ * standard deconstructor
+ */
+CmdLineParser::~CmdLineParser ()
+{
+}
+
+
+bool CmdLineParser::add( int id, const std::string & longOption, char shortOption, int numArgs, bool back )
+{
+  ArgTableEntry entry;
+  
+  entry.id = id;
+  entry.longOption = longOption;
+  entry.shortOption = shortOption;
+  entry.numArgs = numArgs;
+  
+  if ( back )
+    argTable.push_back( entry );
+  else
+    argTable.push_front( entry );
+}
+
+
+bool CmdLineParser::parse( ArgParserCallback cb, void * data, int argc, char ** argv )
+{
+  //put all args in vector
+  std::vector<std::string> args;
+  
+  for ( int i = 1; i<argc; i++ )
+    args.push_back( argv[i] );
+  
+  int i = 0;
+  
+  ArgTable::iterator it;
+  bool finish;
+  bool found;
+  
+  while ( i < args.size() )
+  {
+    found = false;
+    for ( it = argTable.begin(); it != argTable.end(); it++ )
+    {
+      if ( matches( *it, args[i], finish ) )
+      {
+        found = true;
+        
+        if ( it->numArgs + i >= args.size() )
+        {
+          PRINTF(1)( "%s needs %d arguments!", args[i].c_str(), it->numArgs );
+        }
+        
+        std::vector<std::string> argArgs;
+        
+        for ( int j = 0; j < it->numArgs; j++ )
+          argArgs.push_back( args[i+j] );
+        
+        if ( !cb( *it, data, args[i], argArgs ) )
+          return false;
+        
+        i += it->numArgs;
+        
+        if ( finish )
+          break;
+        else 
+        {
+          assert( it->numArgs == 0 );
+        }
+      }
+    }
+    
+    if ( !found )
+    {
+      PRINTF(1)("%s: illegal option\n", args[i].c_str());
+      return false;
+    }
+  }
+  
+  return true;
+}
+
+bool CmdLineParser::matches( ArgTableEntry entry, std::string arg, bool & finish )
+{
+  finish = true;
+  
+  if ( arg.length() < 2 )
+    return false;
+  
+  if ( arg[0] == '-' )
+  {
+    if ( arg[1] == '-' )
+    {
+      arg.erase( 0, 2 );
+      
+      if ( arg.find('%') != std::string::npos )
+      {
+        //TODO implement bether match algo
+        assert( arg.find('%') == arg.length()-1 );
+        arg.erase( arg.length()-1, 1 );
+        return entry.longOption.find( arg ) == 0;
+      }
+      else
+      {
+        return entry.longOption == arg;
+      }
+    }
+    else
+    {
+      if ( arg.length() != 2 && entry.numArgs != 0 )
+      {
+        PRINTF(1)("using multiple flags together is only alowed if none needs an arugument. %s needs %d arguments\n", entry.shortOption, entry.numArgs);
+        return false;
+      }
+      finish = false;
+      return arg.find(entry.shortOption) != std::string::npos;
+    }
+  }
+}
Index: branches/preferences/src/lib/parser/cmdline_parser/cmdline_parser.h
===================================================================
--- branches/preferences/src/lib/parser/cmdline_parser/cmdline_parser.h	(revision 7241)
+++ branches/preferences/src/lib/parser/cmdline_parser/cmdline_parser.h	(revision 7241)
@@ -0,0 +1,47 @@
+/*!
+ * @file cmdline_parser.h
+ * @brief Definition of ...
+ */
+
+#ifndef _CMD_LINE_PARSER_H
+#define _CMD_LINE_PARSER_H
+
+#include <list>
+#include <string>
+#include <vector>
+
+#include "src/defs/debug.h"
+
+
+struct ArgTableEntry
+{
+  int         id;
+  std::string longOption;
+  char        shortOption;
+  int         numArgs;
+};
+
+typedef std::list<ArgTableEntry> ArgTable;
+
+typedef bool (ArgParserCallback)( ArgTableEntry, void*, const std::string &, const std::vector<std::string> & );
+
+
+//! A class for parsing command line arguments
+class CmdLineParser {
+
+  public:
+    CmdLineParser();
+    virtual ~CmdLineParser();
+    
+    bool add( int id, const std::string& longOption, char shortOption, int numArgs, bool back=false );
+
+    bool parse( ArgParserCallback cb, void* data, int argc, char** argv );
+    
+  private:
+    ArgTable argTable;
+    
+    inline bool matches( ArgTableEntry entry, std::string arg, bool & finish );
+
+};
+
+#endif /* _CMD_LINE_PARSER_H */
Index: branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc
===================================================================
--- branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc	(revision 7236)
+++ branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.cc	(revision 7241)
@@ -23,5 +23,5 @@
  * standard constructor
 */
-CmdLinePrefsReader::CmdLinePrefsReader(int argc, char** argv)
+CmdLinePrefsReader::CmdLinePrefsReader( )
 {
 
@@ -36,3 +36,12 @@
 }
 
+bool CmdLinePrefsReader::callBack( ArgTableEntry entry, void * data, const std::string & arg, const std::vector< std::string > & argArgs )
+{
+}
 
+bool CmdLinePrefsReader::parse( int argc, char ** argv )
+{
+  CmdLineParser parser;
+}
+
+
Index: branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h
===================================================================
--- branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h	(revision 7236)
+++ branches/preferences/src/lib/parser/preferences/cmd_line_prefs_reader.h	(revision 7241)
@@ -10,11 +10,18 @@
 #include "debug.h"
 
+#include "src/lib/parser/cmdline_parser/cmdline_parser.h"
+
 //! A class for reading commandline arguments into Preferences
-class CmdLinePrefsReader {
+class CmdLinePrefsReader 
+{
 
  public:
-   CmdLinePrefsReader(int argc, char** argv);
+   CmdLinePrefsReader();
    virtual ~CmdLinePrefsReader();
 
+    bool parse(int argc, char** argv);
+    
+  private:
+    static bool callBack( ArgTableEntry entry, void* data, const std::string & arg, const std::vector<std::string> & argArgs );
 
 };
Index: branches/preferences/src/orxonox.cc
===================================================================
--- branches/preferences/src/orxonox.cc	(revision 7236)
+++ branches/preferences/src/orxonox.cc	(revision 7241)
@@ -403,5 +403,6 @@
 int main(int argc, char** argv)
 {
-  CmdLinePrefsReader prefs(argc, argv);
+  CmdLinePrefsReader prefs;
+  prefs.parse(argc, argv);
 
   int i;
