Branch: Tag:

2015-10-23

2015-10-23 13:54:40 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Merge commit '8a2ce4a87' into patches/bug7582

* commit '8a2ce4a87': (7413 commits)

1:   // cmdline.cpp: implementation of the CCmdLine class.   // - // $Id: cmdline.cpp,v 1.8 2001/08/23 13:31:33 tomas Exp $ + // $Id$   //   //////////////////////////////////////////////////////////////////////   
25:   static char *defPikeDefines[] = {    "-DRAM_CACHE",    "-DENABLE_THREADS", +  "-DHTTP_COMPRESSION",       // List terminator    NULL
209:   //////////////////////////////////////////////////////////////////////      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;
221:    m_bPassHelp = FALSE;    m_bKeepMysql = FALSE;    m_bMsdev = FALSE; +  m_bCheckVersion = TRUE;       m_iVerbose = 1; -  +     m_iDebug = -1;      }
350:    {    "",    "", -  ".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.",
369:    " .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.",    "",
395:    " .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.",
402:    " 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,",
467:    " 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..",
791:   // 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;   
813:    Match(*argv, "--install", NULL, NULL) )    {    m_bInstall = TRUE; +  m_bCheckVersion = FALSE;    type = eArgStart;    return 1;    }
823:    Match(*argv, "--register", NULL, NULL) )    {    m_bRegister = TRUE; +  m_bCheckVersion = FALSE;    type = eArgStart;    return 1;    }
833:    Match(*argv, "--remove", NULL, NULL) )    {    m_bRemove = TRUE; +  m_bCheckVersion = FALSE;    type = eArgStart;    return 1;    }
897:    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
940:    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) ||
950:    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) ||
1097:    // 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"
1114:    // 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.
1173:    }    else    { +  m_bCheckVersion = FALSE;    m_bVersion = TRUE;    type = eArgVersion;    }
1237:    }    else    { +  m_bCheckVersion = FALSE;    m_bHelp = TRUE;    type = eArgHelp;    }
1251:   }       +  + 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;
1305:       // 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)    {
1348:       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());
1372:    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))
1400:    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;
1415:    }       -  // 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;   }