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.6 2001/08/09 16:23:45 tomas Exp $ + // $Id: cmdline.cpp,v 1.7 2001/08/14 10:00:00 tomas Exp $   //   //////////////////////////////////////////////////////////////////////      #include "stdafx.h"   #include "startdll.h"   #include "cmdline.h" -  + #include "roxen.h"   #include "enumproc.h"      #ifdef _DEBUG   #undef THIS_FILE   static char THIS_FILE[]=__FILE__;   //#define new DEBUG_NEW   #endif      static char *defPikeArgs[] = {   
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:122:    delete m_pData;    m_pData = p;    m_Size = m_Count + thresh;    }    }       return TRUE;   }       - BOOL CArgList::Exists(char *item) + BOOL CArgList::Exists(const char *item)   {    int ret = FALSE;    int i;       for (i=0; i<m_Count; i++)    {    if (strcmp(m_pData[i], item) == 0)    {    ret = TRUE;    break;    }    }       return ret;   }       - BOOL CArgList::Add(char *item) + BOOL CArgList::Add(const char *item)   {    ReSize(1);       int len = strlen(item);    char *p = new char[len+1];       strcpy(p, item);    m_pData[m_Count++] = p;       return TRUE;   }       - BOOL CArgList::AddIfNew(char *item) + BOOL CArgList::AddIfNew(const char *item)   {    if (Exists(item))    return TRUE;       return Add(item);   }       - BOOL CArgList::Remove(char *item) + BOOL CArgList::Remove(const char *item)   {    int ret = FALSE;    int i;       for (i=0; i<m_Count; i++)    {    if (strcmp(m_pData[i], item) == 0)    {    delete m_pData[i];   
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:201:   ////////////////////////   //   // CCmdLine class   //      //////////////////////////////////////////////////////////////////////   // Construction/Destruction   //////////////////////////////////////////////////////////////////////      CCmdLine::CCmdLine() + : m_SelfTestDir("etc\\test")   {    m_bPreloaded = FALSE;       m_bInstall = FALSE;    m_bRemove = FALSE;    m_bOnce = FALSE;    m_bHelp = FALSE;    m_bVersion = FALSE;    m_bPassHelp = FALSE;    m_bKeepMysql = FALSE;
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:223:    m_iVerbose = 1;    m_iDebug = -1;      }      CCmdLine::~CCmdLine()   {   }       + /* Check if the string s[0..len[ matches the glob m[0..mlen[ */ + static BOOL does_match(char *s, char *p) + { +  for (; *p; p++) +  { +  switch (*p) +  { +  case '?': +  if(!*s++) return 0; +  break;    -  +  case '*': +  p++; +  if (!*p) return 1; //* slut / +  +  for (; *s; s++) +  if (does_match(s, p)) +  return 1; +  +  return 0; +  +  default: +  if(!*s || +  *p != *s) return 0; +  s++; +  } +  } +  +  return *s==0; + } +    ////////////////////////   //   // Match the first string against the pattern in the second   // and optionally splitting the string on a character and   // returning a pointer to the character after the first delim.   //   // The only wildcard character supported in the second string   // is a trailing * which means match all characters to the end   // of the string.   //   BOOL CCmdLine::Match(char *s, char *pattern, char *delim, char **value)   {    BOOL ret = FALSE; -  int len = strlen(pattern); -  int cmp; -  -  // check for trailing * -  if (pattern[len-1] == '*') -  cmp = strncmp(s, pattern, len-1); -  else -  cmp = strcmp(s, pattern); -  -  if (cmp == 0) +  if (does_match(s, pattern))    {    if (delim && value)    {    *value = strpbrk(s, delim);    if (*value != NULL)    {    (*value)++;    ret = TRUE;    }    }
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:390:    " available until the next server restart",    " This will enable a new 'action' in the",    " administration interface",    "",    " .B--with-file-profileB.: Like .B--with-profileB., but save information",    " for each and every file.",    "",    " .B--self-testB.: Runs a testsuite.",    " .B--self-test-verboseB.: Runs a testsuite, report all tests.",   // " .B--self-test-quietB.: Runs a testsuite, only report errors.", -  " .BNOTE:B. You must manually shutdown any", -  " running mysql process both before and", -  " after these commands!", +  " .B--self-test-dir=DIRB.: Use this self test directory instead of", +  " the default .Betc/testB. directory.",    "",    " .B--onceB.: Run the server only once, in the foreground.",    " This is very useful when debugging.",    " Implies --module-debug.",    "", - /* +     " .B--keep-mysqlB.: Don't shut down MySQL process when exiting",    " the start script. Useful during development",    " or any other scenario where the start script",    " is frequently terminated.",    "", - */ +    /*    " .B--gdbB.: Run the server in gdb. Implies .B--onceB..",    "",   */   /*    " .B--msdevB.: Run the server in Microsoft Developer Studio.",    " Implies .B--onceB..",   */    "",    " .B--programB.: Start a different program with the roxen",
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:1094:    if (Match(*argv, "--cd", NULL, NULL) )    {    m_saRoxenArgs.Add(*argv);    m_saRoxenArgs.Add(argv[1]);    m_bOnce = TRUE;    type = eArgNtLoader;    return 2;    }       //--debug-without=*|-r*|-d*|-t*|-l*|-w*|-a*|-p*|--*-debug*) -  // TODO: --*-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) ||    Match(*argv, "-p*", NULL, NULL) || -  Match(*argv, "-a*", NULL, NULL) ) +  Match(*argv, "-a*", NULL, NULL) || +  Match(*argv, "--*-debug*", NULL, NULL) )    {    m_saPikeArgs.Add(*argv);    type = eArgPike;    return 1;    }       //-D*|-M*|-I*|-P*)    // # Argument passed along to Pike.    // DEFINES="$DEFINES $1"    if (Match(*argv, "-D*", NULL, NULL) ||
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:1182:    //'--self-test-verbose')    // pass="$pass --tests-verbose=1"    // setup_for_tests    if (Match(*argv, "--self-test-verbose", NULL, NULL))    {    m_saRoxenArgs.Add("--tests-verbose=1");    type = eArgSelfTest;    return 1;    }    +  //--self-test-dir=*) +  // SELF_TEST_DIR=`echo $1 | sed -e's/--self-test-dir=//'` +  if (Match(*argv, "--self-test-dir=*", "=", &value)) +  { +  m_SelfTestDir.resize(strlen(value)); +  for (int i=0; i<strlen(value); i++) +  { +  if (value[i] == '/') +  m_SelfTestDir[i] = '\\'; +  else +  m_SelfTestDir[i] = value[i]; +  } +  type = eArgStart; +  return 1; +  } +     //'--help'|'-?')    if (Match(*argv, "--help", NULL, NULL) ||    Match(*argv, "-?", NULL, NULL) )    {    if (m_bPassHelp)    {    m_saRoxenArgs.Add(*argv);    type = eArgRoxen;    }    else
Roxen.git/server/tools/ntroxen/startdll/cmdline.cpp:1303:    // No extra handling here    //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();    -  //DEFINES="-DRUN_SELF_TEST $DEFINES" +  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]; +  } +  +  //DEFINES="-DRUN_SELF_TEST -DSELF_TEST_DIR=\"$SELF_TEST_DIR\" $DEFINES"    //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"); -  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:"); +  m_saPikeArgs.Add(("-DSELF_TEST_DIR=\\\"" + selfTestDirUnx + "\\\"").c_str());       m_bOnce = TRUE;    m_saRoxenArgs.Add("--config-dir=../var/test_config");    m_saRoxenArgs.Add("--remove-dumped");    -  +  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 eArgUnsupported: