You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

teletype.cc 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. teletype .way module
  3. Copyright (C) 2002-2014 Robert Lipe, robertlipe+source@gpsbabel.org
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
  15. */
  16. #include "defs.h"
  17. #define MYNAME "teletype"
  18. static
  19. arglist_t teletype_args[] = {
  20. ARG_TERMINATOR
  21. };
  22. /*******************************************************************************
  23. * %%% global callbacks called by gpsbabel main process %%% *
  24. *******************************************************************************/
  25. static uint32_t tty_wpt_count;
  26. static gbfile* fin;
  27. static void
  28. teletype_rd_init(const QString& fname)
  29. {
  30. char header[64];
  31. fin = gbfopen(fname, "r", MYNAME);
  32. gbfread(header, sizeof(header), 1, fin);
  33. tty_wpt_count = gbfgetint32(fin);
  34. }
  35. static void
  36. teletype_rd_deinit(void)
  37. {
  38. gbfclose(fin);
  39. }
  40. static void
  41. teletype_read(void)
  42. {
  43. uint32_t i;
  44. for (i = 0; i < tty_wpt_count; i++) {
  45. Waypoint* wpt = new Waypoint;
  46. wpt->shortname = (gbfgetcstr(fin));
  47. wpt->description = (gbfgetcstr(fin));
  48. if (1) { // needs bit values of NEWFORMAT2
  49. uint32_t direction = gbfgetuint32(fin);
  50. uint32_t mins = gbfgetuint32(fin);
  51. (void) direction ;
  52. (void) mins ;
  53. }
  54. if (1) { // need bit value of NEWFORMAT
  55. int len = gbfgetuint16(fin);
  56. // probably could treat as a pascal string
  57. char* junk = (char*) xmalloc(len);
  58. gbfread(junk, len, 1, fin);
  59. xfree(junk);
  60. }
  61. wpt->latitude = gbfgetint32(fin) / 1000000.0 ;
  62. wpt->longitude = gbfgetint32(fin) / 1000000.0 ;
  63. {
  64. char jibberish[21];
  65. gbfread(jibberish, sizeof(jibberish), 1, fin);
  66. }
  67. waypt_add(wpt);
  68. }
  69. }
  70. static void
  71. teletype_exit(void) /* optional */
  72. {
  73. }
  74. /**************************************************************************/
  75. // capabilities below means: we can only read and write waypoints
  76. // please change this depending on your new module
  77. ff_vecs_t teletype_vecs = {
  78. ff_type_file,
  79. {
  80. (ff_cap)(ff_cap_read) /* waypoints */,
  81. ff_cap_none /* tracks */,
  82. ff_cap_none /* routes */
  83. },
  84. teletype_rd_init,
  85. NULL,
  86. teletype_rd_deinit,
  87. NULL,
  88. teletype_read,
  89. NULL,
  90. teletype_exit,
  91. teletype_args,
  92. CET_CHARSET_ASCII, 0 /* ascii is the expected character set */
  93. /* not fixed, can be changed through command line parameter */
  94. };
  95. /**************************************************************************/