Пример #1
0
int
main(int argc, char **argv)
{
  Args args(argc, argv, "FILE.igc");
  const auto path = args.ExpectNextPath();
  args.ExpectEnd();

  GRecord g;
  g.Initialize();

  Error error;
  if (!g.LoadFileToBuffer(path, error)) {
    fprintf(stderr, "%s\n", error.GetMessage());
    return 2;
  }

  g.FinalizeBuffer();

  if (!g.AppendGRecordToFile(path)) {
    fprintf(stderr, "Failed to write file\n");
    return 2;
  }

  return 0;
}
Пример #2
0
int
main(int argc, char **argv)
{
  if (argc != 2) {
    fprintf(stderr, "Usage: %s FILE.igc\n", argv[0]);
    return 1;
  }

#ifdef _UNICODE
  TCHAR path[PATH_MAX];
  int length = ::MultiByteToWideChar(CP_ACP, 0, argv[1], -1, path, PATH_MAX);
  if (length == 0)
    return 2;
#else
  const char *path = argv[1];
#endif

  GRecord g;
  g.Init();
  g.SetFileName(path);

  if (!g.LoadFileToBuffer()) {
    fprintf(stderr, "Failed to read file\n");
    return 2;
  }

  g.FinalizeBuffer();

  if (!g.AppendGRecordToFile(true)) {
    fprintf(stderr, "Failed to write file\n");
    return 2;
  }

  return 0;
}
Пример #3
0
static bool
FixGRecord(NLineReader &reader, TextWriter &writer)
{
  GRecord grecord;
  grecord.Initialize();

  char digest[GRecord::DIGEST_LENGTH + 1];
  grecord.GetDigest(digest);

  char *line;
  while ((line = reader.ReadLine()) != nullptr) {
    if (line[0] == 'G')
      break;

    if (memcmp(line, "HFFTYFRTYPE:XCSOAR,XCSOAR ", 26) == 0) {
      char *v = strstr(line + 25, " 6.5 ");
      if (v != nullptr) {
        static char buffer[1024], *p = buffer;

        size_t n = v + 4 - line;
        memcpy(p, line, n);
        p += n;

        memcpy(p, "fix", 3);
        p += 3;

        strcpy(p, v + 4);

        line = buffer;
      }
    }

    grecord.AppendRecordToBuffer(line);

    if (!writer.WriteLine(line))
      return false;
  }

  grecord.FinalizeBuffer();
  grecord.WriteTo(writer);
  return true;
}
Пример #4
0
int
main(int argc, char **argv)
{
  Args args(argc, argv, "FILE.igc");
  tstring path = args.ExpectNextT();
  args.ExpectEnd();

  GRecord g;
  g.Initialize();

  if (!g.LoadFileToBuffer(path.c_str())) {
    fprintf(stderr, "Failed to read file\n");
    return 2;
  }

  g.FinalizeBuffer();

  if (!g.AppendGRecordToFile(path.c_str())) {
    fprintf(stderr, "Failed to write file\n");
    return 2;
  }

  return 0;
}