+ int iReturn = 0;
+
+ if (argc > 1 && strcmp(argv[0], fileBasename (s_szProgramName)) == 0) {
+ argv = &argv[1];
+ argc--;
+ iReturn = processCommand (argc, argv);
+ } else if (argc > 1){
+ iReturn = processCommand (argc, argv);
+ } else {
+ s_bInteractive = true;
+ char szPrompt[] = "CTSim> ";
+ std::cout << "CTSim Text Shell (Type \"quit\" to end)\n\n";
+
+ while (1) {
+#ifdef HAVE_READLINE
+ char* pszInputLine = readline (szPrompt);
+ if (! pszInputLine)
+ break;
+ if (*pszInputLine != EOS)
+ add_history (pszInputLine);
+
+#else // DONT_HAVE_READLINE
+
+ static const int s_MaxLineLength = 1024;
+ char* pszInputLine = new char [s_MaxLineLength+1];
+ std::cout << szPrompt;
+ std::cin.getline (pszInputLine, s_MaxLineLength);
+
+#ifdef DEBUG
+ std::cout << "#" << pszInputLine << "#\n";
+#endif
+
+ std::cout << std::flush;
+ std::cout << "\n";
+#endif // DONT_HAVE_READLINE
+
+ if (strncasecmp (pszInputLine, "quit", 4) == 0)
+ break;
+
+ convertStringToArgcv (pszInputLine, &argc, &argv);
+#ifdef DEBUG
+ for (unsigned int i = 0; i < argc; i++)
+ std::cout << "Token " << i << ": " << argv[i] << "\n";
+#endif
+ iReturn = processCommand (argc, argv);
+
+ delete pszInputLine;
+ }