<pre>
<h1>Build Log</h1>
<h3>
---------------------Configuration: libctsim - Win32 Debug--------------------
-</h3>
-<h3>Command Lines</h3>
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP35.tmp" with contents
-[
-/nologo /G6 /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\..\..\zlib" /I "..\..\INCLUDE" /I "..\..\getopt" /I "..\..\..\lpng108" /I "..\..\..\fftw-2.1.3\fftw" /I "..\..\..\fftw-2.1.3\rfftw" /I "..\..\..\wx2\include" /D "_DEBUG" /D "HAVE_WXWIN" /D "HAVE_STRING_H" /D "HAVE_GETOPT_H" /D "WIN32" /D "_MBCS" /D "_LIB" /D "MSVC" /D "HAVE_FFTW" /D "HAVE_PNG" /D "HAVE_SGP" /D "HAVE_WXWINDOWS" /D "__WXMSW__" /FR"Debug/" /Fp"Debug/libctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
-"C:\ctsim\libctsim\projections.cpp"
-]
-Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP35.tmp"
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP36.tmp" with contents
-[
-/nologo /out:"Debug\libctsim.lib"
-.\Debug\array2dfile.obj
-.\Debug\backprojectors.obj
-.\Debug\clip.obj
-.\Debug\consoleio.obj
-.\Debug\ezplot.obj
-.\Debug\ezset.obj
-.\Debug\ezsupport.obj
-.\Debug\filter.obj
-.\Debug\fnetorderstream.obj
-.\Debug\fourier.obj
-.\Debug\getopt.obj
-.\Debug\getopt1.obj
-.\Debug\hashtable.obj
-.\Debug\imagefile.obj
-.\Debug\mathfuncs.obj
-.\Debug\phantom.obj
-.\Debug\plotfile.obj
-.\Debug\pol.obj
-.\Debug\procsignal.obj
-.\Debug\projections.obj
-.\Debug\reconstruct.obj
-.\Debug\scanner.obj
-.\Debug\sgp.obj
-.\Debug\strfuncs.obj
-.\Debug\syserror.obj
-.\Debug\trace.obj
-.\Debug\transformmatrix.obj
-.\Debug\xform.obj
-]
-Creating command line "link.exe -lib @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP36.tmp"
-<h3>Output Window</h3>
-Compiling...
-projections.cpp
-Creating library...
-<h3>
--------------------Configuration: ctsim - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP37.tmp" with contents
-[
-comctl32.lib winmm.lib rpcrt4.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ../libctsim/Debug/libctsim.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\..\lpng108\msvc\win32\libpng\lib_dbg\libpng.lib ..\..\..\lpng108\msvc\win32\zlib\lib_dbg\zlib.lib libcmtd.lib ..\..\..\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib ..\..\..\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib ../../../wx2/lib/wxd.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/ctsim.pdb" /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrtd.lib" /out:"Debug/ctsim.exe" /pdbtype:sept /libpath:"..\..\..\lpng108\msvc\win32\libpng\lib" /libpath:"..\..\..\lpng108\msvc\win32\zlib\lib"
-.\Debug\ctsim.obj
-.\Debug\dialogs.obj
-.\Debug\dlgprojections.obj
-.\Debug\dlgreconstruct.obj
-.\Debug\docs.obj
-.\Debug\views.obj
-.\Debug\wx.res
-\ctsim\msvc\libctsim\Debug\libctsim.lib
-"\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib"
-"\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib"
-\wx2\lib\wxd.lib
-]
-Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSP37.tmp"
-<h3>Output Window</h3>
-Linking...
** This is part of the CTSim program
** Copyright (C) 1983-2000 Kevin Rosenberg
**
-** $Id: ctsimtext.cpp,v 1.2 2001/01/08 03:06:37 kevin Exp $
+** $Id: ctsimtext.cpp,v 1.3 2001/01/09 20:38:53 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
#include "ct.h"
-static const char* g_szIdStr = "$Id: ctsimtext.cpp,v 1.2 2001/01/08 03:06:37 kevin Exp $";
+#ifdef HAVE_READLINE
+#include <readline.h>
+#include <history.h>
+#endif
+
+
+// Master shell for all command-line tools
+// If called as ctsimtext, program will look to next token on command-line as the function name
+// If linked to ctsimtext, but executed as another name, eg pjrec, then program will use that
+// linked name as name of function.
+
+static const char* const g_szIdStr = "$Id: ctsimtext.cpp,v 1.3 2001/01/09 20:38:53 kevin Exp $";
+static const char* const s_szProgramName = "ctsimtext";
extern int if1_main (int argc, char* const argv[]);
extern int if2_main (int argc, char* const argv[]);
extern int pjinfo_main (int argc, char* const argv[]);
extern int pjrec_main (int argc, char* const argv[]);
+static int processCommand (int argc, char* const argv[]);
+static void convertStringToArgcv (char* szLine, int* piArgc, char*** pppArgv);
+
+
void
ctsimtext_usage (const char *program)
int
ctsimtext_main (int argc, char * argv[])
{
- if (argc < 2) {
- ctsimtext_usage (argv[0]);
- return (1);
+ int iReturn = 0;
+
+ if (strcmp(argv[0],s_szProgramName) == 0) {
+ argv = &argv[1];
+ argc--;
+ iReturn = processCommand (argc, argv);
+ } else if (argc > 1){
+ iReturn = processCommand (argc, argv);
+ } else {
+ char szPrompt[] = "CTSim> ";
+ std::string strInput;
+ while (1) {
+ std::cout << "CTSimText Interactive mode\nType quit to end";
+#ifdef HAVE_READLINE
+ char* pszInput = readline (szPrompt);
+#else
+ std::cout << szPrompt;
+ std::cin >> strInput;
+ char* pszInput = new char [strInput.length() + 1];
+ strncpy (pszInput, strInput.c_str(), sizeof(pszInput));
+#endif
+ if (strncasecmp (pszInput, "quit", 4) == 0) {
+ delete pszInput;
+ break;
+ }
+ convertStringToArgcv (pszInput, &argc, &argv);
+ delete pszInput;
+ iReturn = processCommand (argc, argv);
+ }
+ }
+
+ return iReturn;
+}
+
+static void
+convertStringToArgcv (char* pszLine, int* piArgc, char*** pppArgv)
+{
+ char* pCurrentPos = pszLine;
+ int nTokens = 0;
+ std::vector<char*> vecpszToken;
+
+ // Process line
+ bool bInDoubleQuote = false;
+ bool bInSingleQuote = false;
+ bool bInToken = false;
+
+ while (*pCurrentPos) {
+ if (iswhite (*pCurrentPos)) {
+ if (! bInToken)
+ *pCurrentPos = 0;
+ else if (bInSingleQuote || bInDoubleQuote)
+ ;
+ else { // in non-quote token
+ *pCurrentPos = 0;
+ bInToken = false;
+ }
+ }
+ else if (*pCurrentPos = '\"') {
+ if (bInSingleQuote) {
+ bInSingleQuote = false;
+ } else {
+ bInSingleQuote = true;
+ if (! bInToken) {
+ bInToken = true;
+ nTokens++;
+ vecpszToken.push_back (pCurrentPos+1);
+ }
+ }
+ } else if (*pCurrentPos = '\'') {
+ if (bInDoubleQuote) {
+ bInDoubleQuote = false;
+ } else {
+ bInDoubleQuote = true;
+ if (! bInToken) {
+ bInToken = true;
+ nTokens++;
+ vecpszToken.push_back (pCurrentPos+1);
+ }
+ }
+ } else if (! bInToken) { // nonwhite, non-quote character
+ bInToken = true;
+ nTokens++;
+ vecpszToken.push_back (pCurrentPos);
+ }
+
+ pCurrentPos++;
}
- const char* const pszFunction = argv[1];
- argv = &argv[1];
- argc--;
+ *piArgc = nTokens;
+ pppArgv = new char** [nTokens];
+ for (unsigned int iToken = 0; iToken < vecpszToken.size(); iToken++)
+ (*pppArgv)[iToken] = vecpszToken[iToken];
+}
+
+static int
+processCommand (int argc, char* const argv[])
+{
+ const char* const pszFunction = argv[0];
if (strcasecmp (pszFunction, "if1") == 0)
return if1_main (argc, argv);