Roxen.git / server / tools / ntroxen / startdll / cmdline.cpp

version» Context lines:

Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:1:   // cmdline.cpp: implementation of the CCmdLine class.   // - // $Id: cmdline.cpp,v 1.8 2001/08/23 13:31:33 tomas Exp $ + // $Id$   //   //////////////////////////////////////////////////////////////////////      #include "stdafx.h"   #include "startdll.h"   #include "cmdline.h"   #include "roxen.h"   #include "enumproc.h"      #ifdef _DEBUG
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:18:      static char *defPikeArgs[] = {       // List terminator    NULL   };      static char *defPikeDefines[] = {    "-DRAM_CACHE",    "-DENABLE_THREADS", +  "-DHTTP_COMPRESSION",       // List terminator    NULL   };      static char *defRoxenArgs[] = {       // List terminator    NULL   };
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:202:   ////////////////////////   //   // CCmdLine class   //      //////////////////////////////////////////////////////////////////////   // Construction/Destruction   //////////////////////////////////////////////////////////////////////      CCmdLine::CCmdLine() - : m_SelfTestDir("etc\\test") + : m_SelfTestDir("etc\\test"), m_LogDir("..\\logs"), +  m_ConfigDir("..\\configurations")   { -  m_bPreloaded = FALSE; +  m_bPreloaded = FALSE; +  m_bParseFinished = FALSE;       m_bInstall = FALSE;    m_bRemove = FALSE;    m_bOnce = FALSE;    m_bHelp = FALSE;    m_bVersion = FALSE;    m_bPassHelp = FALSE;    m_bKeepMysql = FALSE;    m_bMsdev = FALSE; -  +  m_bCheckVersion = TRUE;       m_iVerbose = 1; -  +     m_iDebug = -1;      }      CCmdLine::~CCmdLine()   {   }         /* Check if the string s[0..len[ matches the glob m[0..mlen[ */
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:343:    WriteFile(out, "\r\n", 2, &cWritten, NULL);   }         void CCmdLine::PrintHelp()   {    char * helptext[] =    {    "",    "", -  ".BThis command will start the Roxen WebServerB..", +  ".BThis command will start Roxen CMSB..",    "",    "The environment variable .BROXEN_ARGSB. can be used to specify",    "the default arguments.",    "",    " .BArguments:B.",    "",    " .B--versionB.: Output version information.",    "",    " .B--help -?B.: This information.",    "",    " .B--installB.: Register application and install as",    " an NT service.",    "",    " .B--registerB.: Register application.",    "",    " .B--removeB.: Remove all registry setting and uninstall",    " the NT service.",    "", -  +  " .B--offlineB.: Indicate that there is no network", +  " connection available. Disables DNS and some", +  " other similar things.", +  "",    " .B--remove-dumpedB.: Remove all dumped code, thus forcing",    " a recompile.",    "",    " .B--verbose -vB.: Enable more verbose messages.",    "",    " .B--quiet -qB.: Disable most of the messages.",    "",   /*    " .B--log-dir=DIRB.: Set the log directory. Defaults to .B../logsB..",    "",
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:388:    " .B--pid-file=FILEB.: Store the roxen and startscript pids in this",    " file. Defaults to .B../configurations/_roxen_pidB..",    "",    " .B--silent-startB.: Inhibits output to stdout. If used,",    " this argument must be the first one.",   */    "",    " .B--without-ram-cacheB.: Do not use an in-RAM cache to speed",    " things up. Saves RAM at the cost of speed.",    "", +  " .B--without-new-ram-cacheB.: Do not use a the new RAM cache", +  " introduced in Roxen 5.0-release4.", +  "",    " .B--without-ram-cache-statB.: Disable the stat that is usually done",    " for files in the ram cache to ensure that",    " they are not changed before they are sent.",    " Improves performance at the cost of constant",    " aggravation if the site is edited. Useful for",    " truly static sites.",    "", -  +  " .B--without-http-compressionB.: Disable gzip compression for HTTP requests.", +  "",    " .B--with-threadsB.: If threads are available, use them.",    "",    " .B--without-threadsB.: Even if threads are enabled by default,",    " disable them.",    "",    " .B--with-profileB.: Store runtime profiling information on",    " a directory basis. This information is",    " not saved on permanent storage, it is only",    " available until the next server restart",    " This will enable a new 'action' in the",
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:460:    " truss, shows .BallB. system calls. This is",    " extremely noisy, and is not intented for",    " anything but debug.",    "",    " .B--truss-cB.: (Solaris only). Run the server under",    " truss -c, shows times for all system calls",    " on exit. This is not intented for anything",    " but debug. Slows the server down.",    "",   */ +  " .B--with-snmp-agentB.: Enable internal SNMP agent code.", +  "",    " .BArguments passed to pike:B.",    "",    " .B-DDEFINEB.: Define the symbol .BDEFINEB..",    "",    " .B-d<level>B.: Set the runtime Pike debug to level.",    " This only works if Pike is compiled",    " with debug (i.e. with --rtl-debug to",    " configure).",    "",    " .B-rtB.: Enable runtime typechecking.",
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:784:    *argv++ = NULL;    ++*numargs;   }         ////////////////////////   //   // Parse current argument (always argv[0]) and   // return the number of parameters used   // - int CCmdLine::ParseArg(char *argv[], CCmdLine::tArgType & type) + int CCmdLine::ParseArg(int argc, char *argv[], CCmdLine::tArgType & type)   {    char *value;          /*    -DRAM_CACHE    -DENABLE_THREADS       -DRUN_SELF_TEST    ##
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:806:    ##    */          //'-install'|'--install')    //    if (Match(*argv, "-install", NULL, NULL) ||    Match(*argv, "--install", NULL, NULL) )    {    m_bInstall = TRUE; +  m_bCheckVersion = FALSE;    type = eArgStart;    return 1;    }       //'-register'|'--register')    //    if (Match(*argv, "-register", NULL, NULL) ||    Match(*argv, "--register", NULL, NULL) )    {    m_bRegister = TRUE; -  +  m_bCheckVersion = FALSE;    type = eArgStart;    return 1;    }       //'-remove'|'--remove')    //    if (Match(*argv, "-remove", NULL, NULL) ||    Match(*argv, "--remove", NULL, NULL) )    {    m_bRemove = TRUE; -  +  m_bCheckVersion = FALSE;    type = eArgStart;    return 1;    }       //-D*)    //DEFINES="$DEFINES $1"    if (Match(*argv, "-D*", NULL, NULL))    {    m_saPikeDefines.Add(*argv);    type = eArgPike;
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:890:    //'--with-security'|'--enable-security')    // DEFINES="$DEFINES -DSECURITY"    if (Match(*argv, "--with-security", NULL, NULL) ||    Match(*argv, "--enable-security", NULL, NULL) )    {    m_saPikeDefines.Add("-DSECURITY");    type = eArgPike;    return 1;    }    +  //'--with-snmp-agent'|'--enable-snmp-agent') +  // DEFINES="$DEFINES -DSNMP_AGENT" +  if (Match(*argv, "--with-snmp-agent", NULL, NULL) || +  Match(*argv, "--enable-snmp-agent", NULL, NULL) ) +  { +  m_saPikeDefines.Add("-DSNMP_AGENT"); +  type = eArgPike; +  return 1; +  }       //'--debug'|'--with-debug'|'--enable-debug')    // debug=1    if (Match(*argv, "--debug", NULL, NULL) ||    Match(*argv, "--with-debug", NULL, NULL) ||    Match(*argv, "--enable-debug", NULL, NULL) )    {    m_iDebug = 1;    type = eArgDebug;    return 1;
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:933:    // DEFINES="-DFD_DEBUG $DEFINES"    if (Match(*argv, "--fd-debug", NULL, NULL) ||    Match(*argv, "--with-fd-debug", NULL, NULL) ||    Match(*argv, "--enable-fd-debug", NULL, NULL) )    {    m_saPikeDefines.Add("-DFD_DEBUG");    type = eArgPike;    return 1;    }    +  //'--offline') +  // DEFINES="-DNO_DNS -DOFFLINE $DEFINES" +  if (Match(*argv, "--offline", NULL, NULL) ) +  { +  m_saPikeDefines.Add("-DNO_DNS"); +  m_saPikeDefines.Add("-DOFFLINE"); +  type = eArgPike; +  return 1; +  } +     //'--without-ram-cache'|'--disable-ram-cache')    // DEFINES="`echo $DEFINES | sed -e 's/-DRAM_CACHE//g'`"    if (Match(*argv, "--without-ram-cache", NULL, NULL) ||    Match(*argv, "--disable-ram-cache", NULL, NULL) )    {    m_saPikeDefines.Remove("-DRAM_CACHE");    type = eArgPike;    return 1;    }    -  +  //'--without-http-compression'|'--disable-http-compression') +  // DEFINES="`echo $DEFINES | sed -e 's/-DHTTP_COMPRESSION//g'`" +  //;; +  if (Match(*argv, "--without-http-compression", NULL, NULL) || +  Match(*argv, "--disable-http-compression", NULL, NULL) ) +  { +  m_saPikeDefines.Remove("-DHTTP_COMPRESSION"); +  type = eArgPike; +  return 1; +  } +     //'--without-ram-cache-stat'|'--disable-ram-cache-stat')    // DEFINES="`-DRAM_CACHE_ASUME_STATIC_CONTENT`"    if (Match(*argv, "--without-ram-cache-stat", NULL, NULL) ||    Match(*argv, "--disable-ram-cache-stat", NULL, NULL) )    {    m_saPikeDefines.Add("-DRAM_CACHE_ASUME_STATIC_CONTENT");    type = eArgPike;    return 1;    }   
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:1090:    return 1;    }   */       //'--program')    // program="$2"    // once=1    // passhelp=1    if (Match(*argv, "--program", NULL, NULL) )    { -  m_saRoxenArgs.Add(*argv); -  m_saRoxenArgs.Add(argv[1]); +  if (argc > 1) +  { +  int count; +  for (count=0; count<argc; count++) +  m_saRoxenArgs.Add(argv[count]);    m_bOnce = TRUE;    m_bPassHelp = TRUE;    m_bKeepMysql = TRUE; -  +  m_bCheckVersion = FALSE;    type = eArgNtLoader; -  return 2; +  return count;    } -  +  else +  { +  type = eArgMoreData; +  return 1; +  } +  }       //'--cd')    // cd_to="$2"    // # Use the absolute path...    // roxendir="`pwd`"    // once=1    // shift    if (Match(*argv, "--cd", NULL, NULL) )    { -  +  if (argc > 1) +  {    m_saRoxenArgs.Add(*argv);    m_saRoxenArgs.Add(argv[1]);    m_bOnce = TRUE;    type = eArgNtLoader;    return 2;    } -  +  else +  { +  type = eArgMoreData; +  return 1; +  } +  }       //--debug-without=*|-r*|-d*|-t*|-l*|-w*|-a*|-p*|--*-debug*)    // # Argument passed along to Pike.    // ARGS="$ARGS $1"    if (Match(*argv, "--debug-without=*", NULL, NULL) ||    Match(*argv, "-r*", NULL, NULL) ||    Match(*argv, "-d*", NULL, NULL) ||    Match(*argv, "-t*", NULL, NULL) ||    Match(*argv, "-l*", NULL, NULL) ||    Match(*argv, "-w*", NULL, NULL) ||
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:1166:    // fi    if (Match(*argv, "--version", NULL, NULL))    {    if (m_bPassHelp)    {    m_saRoxenArgs.Add(*argv);    type = eArgRoxen;    }    else    { +  m_bCheckVersion = FALSE;    m_bVersion = TRUE;    type = eArgVersion;    }    return 1;    }       //'--self-test')    // setup_for_tests    if (Match(*argv, "--self-test", NULL, NULL))    {
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:1230:    if (Match(*argv, "--help", NULL, NULL) ||    Match(*argv, "-?", NULL, NULL) )    {    if (m_bPassHelp)    {    m_saRoxenArgs.Add(*argv);    type = eArgRoxen;    }    else    { +  m_bCheckVersion = FALSE;    m_bHelp = TRUE;    type = eArgHelp;    }    return 1;    }          // Unknown option give it to roxen    m_saRoxenArgs.Add(*argv);    type = eArgRoxen;    return 1;   }       -  +  + void CCmdLine::ParseFinish() + { +  // Take care of some special argument handling +  +  //case "x$debug" in +  // "x") +  // DEBUG="-DMODULE_DEBUG " +  // ARGS="$ARGS -w" +  // ;; +  // "x-1") +  // DEBUG="" +  // ;; +  // "x1") +  // DEBUG="-DDEBUG -DMODULE_DEBUG" +  // ARGS="$ARGS -w" +  // ;; +  //esac +  +  if (m_bParseFinished) +  return; +  +  // This must be before CheckVersionChange +  m_bParseFinished = TRUE; +  +  if (m_iDebug == 0) +  { +  m_saPikeDefines.AddIfNew("-DMODULE_DEBUG"); +  m_saPikeArgs.AddIfNew("-w"); +  } +  else if (m_iDebug == -1) +  { +  } +  else if (m_iDebug == 1) +  { +  m_saPikeDefines.AddIfNew("-DDEBUG"); +  m_saPikeDefines.AddIfNew("-DMODULE_DEBUG"); +  m_saPikeArgs.AddIfNew("-w"); +  } +  +  // This must be after anything that changes the PikeDefines +  if (m_bCheckVersion) +  { +  if (CRoxen::CheckVersionChange()) +  { +  m_saRoxenArgs.AddIfNew("--remove-dumped"); +  HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); +  if (m_iVerbose >= 1) +  OutputLine(hOut, " : Removing old precompiled files (defines or pike version changed)"); +  } +  } + } +  +    BOOL CCmdLine::Parse(char * cmdline)   {    int numargs;    int numchars;       SplitCmdline((_TSCHAR *)cmdline, NULL, NULL, &numargs, &numchars);       _TSCHAR *p = new _TSCHAR[numargs * sizeof(_TSCHAR *) + numchars * sizeof(_TSCHAR)];       SplitCmdline((_TSCHAR *)cmdline, (_TSCHAR **)p, p + numargs * sizeof(char *), &numargs, &numchars);
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:1298:    while (defRoxenArgs[i] != NULL)    {    m_saRoxenArgs.Add(defRoxenArgs[i]);    i++;    }    m_bPreloaded = TRUE;    }       // Walk through the argument list    i = 1; // skip argv[0] -  while (i < argc) +  while (i < argc && ret)    { -  int numParsed = ParseArg(&argv[i], type); +  int numParsed = ParseArg(argc-i, &argv[i], type);       switch (type)    {    case eArgStart:    // No extra handling here    //OutputLineFmt(hOut, ".BNtStart argument: %sB.", argv[i]);    break;       case eArgNtLoader:    // No extra handling here
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:1341:    //OutputLineFmt(hOut, ".BNoDebug argument: %sB.", argv[i]);    break;       case eArgVersion:    // No extra handling here    //OutputLineFmt(hOut, ".BVersion argument: %sB.", argv[i]);    break;       case eArgSelfTest:    { -  // Make sure that mysql is not running -  KillMySql(); +  // Make sure the var directory exists +  CreateDirectory("..\\var", NULL);       std::string selfTestDirUnx;    selfTestDirUnx.resize(m_SelfTestDir.length());    for (int i=0; i<m_SelfTestDir.length(); i++)    {    if (m_SelfTestDir[i] == '\\')    selfTestDirUnx[i] = '/';    else    selfTestDirUnx[i] = m_SelfTestDir[i];    }
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:1365:    //rm -rf $VARDIR/test_config*    //cp -R etc/test/config $VARDIR/test_config    //cp etc/test/filesystem/test_rxml_package rxml_packages/test_rxml_package    //DIR=$VARDIR/test_config    //once=1    //remove_dumped=1    m_saPikeArgs.Add("-DRUN_SELF_TEST");    m_saPikeArgs.Add(("-DSELF_TEST_DIR=\\\"" + selfTestDirUnx + "\\\"").c_str());       m_bOnce = TRUE; -  m_saRoxenArgs.Add("--config-dir=../var/test_config"); +  m_iDebug = max(m_iDebug, 1); +  m_ConfigDir = "../var/test_config"; +  m_saRoxenArgs.Add(("--config-dir=" + m_ConfigDir).c_str());    m_saRoxenArgs.Add("--remove-dumped");    -  +  // Make sure that mysql is not running +  KillMySql(m_ConfigDir.c_str()); +     SetEnvironmentVariable("COPYCMD", "/Y");    system("rmdir /Q /S ..\\var\\test_config >NUL:"); -  //system("xcopy etc\\test\\config ..\\var\\test_config\\ /E /Q >NUL:"); -  //system("copy etc\\test\\filesystem\\test_rxml_package rxml_packages\\test_rxml_package >NUL:"); -  system(("xcopy " + m_SelfTestDir + "\\config ..\\var\\test_config\\ /E /Q >NUL:").c_str()); +     -  +     std::string setupCmd = m_SelfTestDir + "\\scripts\\setup.pike";    DWORD attr = GetFileAttributes(setupCmd.c_str());    if (attr != -1 && !(attr & FILE_ATTRIBUTE_DIRECTORY))    {    setupCmd += " " + selfTestDirUnx + " ../var";    CRoxen::RunPike(setupCmd.c_str());    }       }    //OutputLineFmt(hOut, ".BSelfTest argument: %sB.", argv[i]);    break;       case eArgHelp:    // No extra handling here    //OutputLineFmt(hOut, ".BHelp argument: %sB.", argv[i]);    break;       -  +  case eArgMoreData: +  ret = FALSE; +  OutputLineFmt(hOut, ".BArgument requires more data: %sB.", argv[i]); +  break; +  +     case eArgUnsupported:    OutputLineFmt(hOut, ".BArgument not supported: %sB.", argv[i]);    break;          default:    OutputLineFmt(hOut, ".BInternal Error: default case hit with: %sB.", argv[i]);    break;       }       i += numParsed;    }       -  // Take care of some special argument handling -  -  //case "x$debug" in -  // "x") -  // DEBUG="-DMODULE_DEBUG " -  // ARGS="$ARGS -w" -  // ;; -  // "x-1") -  // DEBUG="" -  // ;; -  // "x1") -  // DEBUG="-DDEBUG -DMODULE_DEBUG" -  // ARGS="$ARGS -w" -  // ;; -  //esac -  if (m_iDebug == 0) -  { -  m_saPikeDefines.AddIfNew("-DMODULE_DEBUG"); -  m_saPikeArgs.AddIfNew("-w"); -  } -  else if (m_iDebug == -1) -  { -  } -  else if (m_iDebug == 1) -  { -  m_saPikeDefines.AddIfNew("-DDEBUG"); -  m_saPikeDefines.AddIfNew("-DMODULE_DEBUG"); -  m_saPikeArgs.AddIfNew("-w"); -  } -  +     return ret;   }