void ProcessArgStr(const char *ArgStr) { const int MAX_ARGS = 64; char *argv[MAX_ARGS]; if (0 == ArgStr) return; // Modifiable copy char *StrCopy = strsave(ArgStr); int argc = 0; bool bInArg = false; char *Str = StrCopy; while (char c = *Str) { if (isspace(c)) { *Str = 0; bInArg = false; } else if (!bInArg) { bInArg = true; if (argc >= MAX_ARGS) Quit("Too many args in MUSCLE_CMDLINE"); argv[argc++] = Str; } Str++; } ProcessArgVect(argc, argv); free(StrCopy); }
int xmain(int argc, char **argv) { MuscleContext *ctx = getMuscleContext(); #if WIN32 // Multi-tasking does not work well in CPU-bound // console apps running under Win32. // Reducing the process priority allows GUI apps // to run responsively in parallel. SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); #endif ctx->muscle.g_argc = argc; ctx->muscle.g_argv = argv; SetNewHandler(); SetStartTime(); ProcessArgVect(argc - 1, argv + 1); SetParams(); SetLogFile(); //extern void TestSubFams(const char *); //TestSubFams(g_pstrInFileName); //return 0; if (ctx->params.g_bVersion) { printf(MUSCLE_LONG_VERSION "\n"); exit(EXIT_SUCCESS); } if (!ctx->params.g_bQuiet) //Credits(); if (MissingCommand() && isatty(0)) { Usage(); exit(EXIT_SUCCESS); } if (ctx->params.g_bCatchExceptions) { try { Run(); } catch (...) { OnException(); exit(EXIT_Except); } } else Run(); #ifdef _CRTDBG_MAP_ALLOC delete ctx; _CrtDumpMemoryLeaks(); //to Output window of MSVC #endif exit(EXIT_Success); }