/* (C) 2003 XDA Developers * Author: Willem Jan Hengeveld * Web: http://www.xda-developers.com/ * * $Header$ */ #include #include "debug.h" #include #include using namespace std; #include "stringutils.h" #include "processfile.h" bool ParseCommandLine(const string& cmdline, StringList& files, StringList& commands) { StringList args; if (!SplitString(cmdline, args)) return false; for (StringList::iterator i= args.begin() ; i!=args.end() ; ++i) { if (*i=="-e" && i+1 != args.end()) { commands.push_back(*++i); debug("command %hs\n", (*i).c_str()); } else if ((*i)[0]!='-') { debug("file %hs\n", (*i).c_str()); files.push_back(*i); } else { debug("ERROR: unknown commandline option\n"); return false; } } return true; } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { StringList files; StringList commands; if (!ParseCommandLine(ToString(lpCmdLine), files, commands)) return 1; for (StringList::iterator i=files.begin() ; i!= files.end() ; ++i) { if (!ProcessFile(*i)) return 1; } return 0; }