Beispiel #1
0
// get first next word or quoted string
CTString GetNextParam(void)
{
    // strip leading spaces/tabs
    _strCmd.TrimSpacesLeft();
    // if nothing left
    if (_strCmd=="") {
        // no word to return
        return "";
    }

    // if the first char is quote
    if (_strCmd[0]=='"') {
        // find first next quote
        const char* pCmd = _strCmd;
        char *pchClosingQuote = strchr((char*)pCmd+1, '"');
        // if not found
        if (pchClosingQuote==NULL) {
            // error in command line
            cmd_strOutput+=CTString(0, TRANS("Command line error!\n"));
            // finish parsing
            _strCmd = "";
            return "";
        }
        INDEX iQuote = pchClosingQuote-_strCmd;

        // get the quoted string
        CTString strWord;
        CTString strRest;
        _strCmd.Split(iQuote, strWord, strRest);
        // remove the quotes
        strWord.DeleteChar(0);
        strRest.DeleteChar(0);
        // get the word
        _strCmd = strRest;
        return strWord;

        // if the first char is not quote
    } else {
        // find first next space
        INDEX iSpace;
        INDEX ctChars = strlen(_strCmd);
        for(iSpace=0; iSpace<ctChars; iSpace++) {
            if (isspace(_strCmd[iSpace])) {
                break;
            }
        }
        // get the word string
        CTString strWord;
        CTString strRest;
        _strCmd.Split(iSpace, strWord, strRest);
        // remove the space
        strRest.DeleteChar(0);
        // get the word
        _strCmd = strRest;
        return strWord;
    }
}
Beispiel #2
0
CTString IFeel_GetProjectFileName()
{
  CTString strIFeelTable;
  CTFileName fnIFeelTable = (CTString)"Data\\IFeel.txt";
  CTString strDefaultProjectFile = "Data\\Default.ifr";
  // get product name
  CTString strProduct = IFeel_GetProductName();
  try
  {
    strIFeelTable.Load_t(fnIFeelTable);
  }
  catch(char *strErr)
  {
    CPrintF("%s\n",strErr);
    return "";
  }

  CTString strLine;
  // read up to 1000 devices
  for(INDEX idev=0;idev<1000;idev++)
  {
    char strDeviceName[256];
    char strProjectFile[256];
    strLine = strIFeelTable;
    // read first line
    strLine.OnlyFirstLine();
    if(strLine==strIFeelTable)
    {
      break;
    }
    // remove that line 
    strIFeelTable.RemovePrefix(strLine);
    strIFeelTable.DeleteChar(0);
    // read device name and project file name
    strIFeelTable.ScanF("\"%256[^\"]\" \"%256[^\"]\"",&strDeviceName,&strProjectFile);
    // check if this is default 
    if(strcmp(strDeviceName,"Default")==0) strDefaultProjectFile = strProjectFile;
    // check if this is current device 
    if(strProduct == strDeviceName) return strProjectFile;
  }
  // device was not found, return default project file
  CPrintF("No project file specified for device '%s'.\nUsing default project file\n",strProduct);
  return strDefaultProjectFile;
}
Beispiel #3
0
void InitStreams(void)
{
  // obtain information about system
// !!! FIXME: Move this into an abstraction of some sort...
#ifdef PLATFORM_WIN32
  SYSTEM_INFO siSystemInfo;
  GetSystemInfo( &siSystemInfo);
  // and remember page size
  _ulPageSize = siSystemInfo.dwPageSize*16;   // cca. 64kB on WinNT/Win95
#else
  _ulPageSize = PAGESIZE;
#endif

  // keep a copy of path for setting purposes
  _fnmApp = _fnmApplicationPath;

  // if no mod defined yet
  if (_fnmMod=="") {
    // check for 'default mod' file
    LoadStringVar(CTString("DefaultMod.txt"), _fnmMod);
  }

  CPrintF(TRANSV("Current mod: %s\n"),
            (_fnmMod=="") ? TRANS("<none>") :
                            (const char *) (CTString&)_fnmMod);
  // if there is a mod active
  if (_fnmMod!="") {
    // load mod's include/exclude lists
    CPrintF(TRANSV("Loading mod include/exclude lists...\n"));
    BOOL bOK = FALSE;
    bOK |= LoadFileList(_afnmBaseWriteInc , CTString("BaseWriteInclude.lst"));
    bOK |= LoadFileList(_afnmBaseWriteExc , CTString("BaseWriteExclude.lst"));
    bOK |= LoadFileList(_afnmBaseBrowseInc, CTString("BaseBrowseInclude.lst"));
    bOK |= LoadFileList(_afnmBaseBrowseExc, CTString("BaseBrowseExclude.lst"));

    // if none found
    if (!bOK) {
      // the mod is not valid
      _fnmMod = CTString("");
      CPrintF(TRANSV("Error: MOD not found!\n"));
    // if mod is ok
    } else {
      // remember mod name (the parameter that is passed on cmdline)
      _strModName = _fnmMod;
      _strModName.DeleteChar(_strModName.Length()-1);
      _strModName = CTFileName(_strModName).FileName();
    }
  }
  // find eventual extension for the mod's dlls
  _strModExt = "";
  LoadStringVar(CTString("ModExt.txt"), _strModExt);


  CPrintF(TRANSV("Loading group files...\n"));

  CDynamicArray<CTString> *files = NULL;

  // for each group file in base directory
  files = _pFileSystem->FindFiles(_fnmApplicationPath, "*.gro");
  int max = files->Count();
  int i;

  // for each .gro file in the directory
  for (i = 0; i < max; i++) {
    // add it to active set
    UNZIPAddArchive( _fnmApplicationPath+((*files)[i]) );
  }
  delete files;

  // if there is a mod active
  if (_fnmMod!="") {
    // for each group file in mod directory
     files = _pFileSystem->FindFiles(_fnmApplicationPath+_fnmMod, "*.gro");
     max = files->Count();
     for (i = 0; i < max; i++) {
       UNZIPAddArchive( _fnmApplicationPath + _fnmMod + ((*files)[i]) );
     }
     delete files;
  }

  // if there is a CD path
  if (_fnmCDPath!="") {
    // for each group file on the CD
    files = _pFileSystem->FindFiles(_fnmCDPath, "*.gro");
    max = files->Count();
    for (i = 0; i < max; i++) {
      UNZIPAddArchive( _fnmCDPath + ((*files)[i]) );
    }
    delete files;

    // if there is a mod active
    if (_fnmMod!="") {
      // for each group file in mod directory
      files = _pFileSystem->FindFiles(_fnmCDPath+_fnmMod, "*.gro");
      max = files->Count();
      for (i = 0; i < max; i++) {
        UNZIPAddArchive( _fnmCDPath + _fnmMod + ((*files)[i]) );
      }
      delete files;
    }
  }

  // try to
  try {
    // read the zip directories
    UNZIPReadDirectoriesReverse_t();
  // if failed
  } catch( char *strError) {
    // report warning
    CPrintF( TRANS("There were group file errors:\n%s"), strError);
  }
  CPrintF("\n");

  const char *dirsep = CFileSystem::GetDirSeparator();
  LoadFileList(_afnmNoCRC, CTFILENAME("Data") + CTString(dirsep) + CTString("NoCRC.lst"));

  _pShell->SetINDEX(CTString("sys")+"_iCPU"+"Misc", 1);
}