Пример #1
0
static void
LoadChecklist()
{
  nLists = 0;

  free(ChecklistText[0]);
  ChecklistText[0] = NULL;

  free(ChecklistTitle[0]);
  ChecklistTitle[0] = NULL;

  TLineReader *reader = OpenDataTextFile(_T(XCSCHKLIST));
  if (reader == NULL) {
    addChecklist(_("No checklist loaded"),_("Create xcsoar-checklist.txt\n"));
    return;
  }

  TCHAR Details[MAXDETAILS];
  TCHAR Name[100];
  bool inDetails = false;
  int i;

  Details[0] = 0;
  Name[0] = 0;

  TCHAR *TempString;
  while ((TempString = reader->read()) != NULL) {
    // Look for start
    if (TempString[0] == '[') {
      if (inDetails) {
        addChecklist(Name, Details);
        Details[0] = 0;
        Name[0] = 0;
      }

      // extract name
      for (i = 1; i < MAXTITLE; i++) {
        if (TempString[i] == ']')
          break;

        Name[i - 1] = TempString[i];
      }
      Name[i - 1] = 0;

      inDetails = true;
    } else {
      // append text to details string
      _tcsncat(Details, TempString, MAXDETAILS - 2);
      _tcscat(Details, _T("\n"));
      // TODO code: check the string is not too long
    }
  }

  delete reader;

  if (inDetails) {
    addChecklist(Name, Details);
  }
}
Пример #2
0
static void
LoadChecklist()
{
  nLists = 0;

  free(ChecklistText[0]);
  ChecklistText[0] = NULL;

  free(ChecklistTitle[0]);
  ChecklistTitle[0] = NULL;

  TLineReader *reader = OpenDataTextFile(_T(XCSCHKLIST));
  if (reader == NULL) {
    addChecklist(_("No checklist loaded"), _("Create xcsoar-checklist.txt"));
    return;
  }

  StaticString<MAXDETAILS> Details;
  TCHAR Name[100];
  bool inDetails = false;
  int i;

  Details.clear();
  Name[0] = 0;

  TCHAR *TempString;
  while ((TempString = reader->ReadLine()) != NULL) {
    // Look for start
    if (TempString[0] == '[') {
      if (inDetails) {
        addChecklist(Name, Details);
        Details.clear();
        Name[0] = 0;
      }

      // extract name
      for (i = 1; i < MAXTITLE; i++) {
        if (TempString[i] == ']')
          break;

        Name[i - 1] = TempString[i];
      }
      Name[i - 1] = 0;

      inDetails = true;
    } else {
      // append text to details string
      Details.append(TempString);
      Details.Append(_T('\n'));
    }
  }

  delete reader;

  if (inDetails) {
    addChecklist(Name, Details);
  }
}
Пример #3
0
/**
 * Opens XCSoars own FLARM details file, parses it and
 * adds its entries as FlarmLookupItems
 * @see AddSecondaryItem
 */
static void
LoadSecondary(FlarmNameDatabase &db)
try {
  LogFormat("OpenFLARMDetails");

  auto reader = OpenDataTextFile(_T("xcsoar-flarm.txt"));
  LoadFlarmNameFile(*reader, db);
} catch (const std::runtime_error &e) {
  LogError(e);
}
Пример #4
0
/**
 * Opens XCSoars own FLARM details file, parses it and
 * adds its entries as FlarmLookupItems
 * @see AddSecondaryItem
 */
static void
LoadSecondary(FlarmNameDatabase &db)
{
  LogFormat("OpenFLARMDetails");

  TLineReader *reader = OpenDataTextFile(_T("xcsoar-flarm.txt"));
  if (reader != NULL) {
    LoadFlarmNameFile(*reader, db);
    delete reader;
  }
}
void
FlarmDetails::LoadSecondary()
{
  LogStartUp(_T("OpenFLARMDetails"));

  // if (FLARM Details already there) delete them;
  if (!FLARM_Names.empty())
    FLARM_Names.clear();

  TLineReader *reader = OpenDataTextFile(_T("xcsoar-flarm.txt"));
  if (reader != NULL) {
    LoadSecondaryFile(*reader);
    delete reader;
  }
}