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.

format_skeleton.cc 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. Format converter module skeleton.
  3. Steps to create a new format.
  4. 1) Copy this file to <your_format_name>.c
  5. 2) Rename all format_skeleton tokens to <your_format_name>.
  6. 3) Replace the fictional name and address in the Copyright section below.
  7. ** As your work is likely built on the work of others, please retain
  8. the original line. **
  9. 4) Create a new section in vecs.c.
  10. 5) Add compilation instructions to Makefile.
  11. 6) Add sample files (it's better when they're created by the "real"
  12. application and not our own output) to reference/ along with
  13. files in a well supported (preferably non-binary) format and
  14. entries in our 'testo' program. This allows users of different
  15. OSes and hardware to exercise your module.
  16. Copyright (C) YYYY John Doe, anybody@wherever.com
  17. Copyright (C) 2001-YYYY Robert Lipe, robertlipe+source@gpsbabel.org
  18. This program is free software; you can redistribute it and/or modify
  19. it under the terms of the GNU General Public License as published by
  20. the Free Software Foundation; either version 2 of the License, or
  21. (at your option) any later version.
  22. This program is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. GNU General Public License for more details.
  26. You should have received a copy of the GNU General Public License
  27. along with this program; if not, write to the Free Software
  28. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
  29. */
  30. #include "defs.h"
  31. #define MYNAME "format_skeleton"
  32. // Any arg in this list will appear in command line help and will be
  33. // populated for you.
  34. // Values for ARGTYPE_xxx can be found in defs.h and are used to
  35. // select the type of option.
  36. static
  37. arglist_t format_skeleton_args[] = {
  38. // {"foo", &fooopt, "The text of the foo option in help",
  39. // "default", ARGYTPE_STRING, ARG_NOMINMAX} ,
  40. ARG_TERMINATOR
  41. };
  42. /*******************************************************************************
  43. * %%% global callbacks called by gpsbabel main process %%% *
  44. *******************************************************************************/
  45. static void
  46. format_skeleton_rd_init(const char* fname)
  47. {
  48. // fin = gbfopen(fname, "r", MYNAME);
  49. }
  50. static void
  51. format_skeleton_rd_deinit(void)
  52. {
  53. // gbfclose(fin);
  54. }
  55. static void
  56. format_skeleton_read(void)
  57. {
  58. // your special code to extract waypoint, route and track
  59. // information from gbfile "fin"
  60. //
  61. // Sample text-file read code:
  62. // char *s;
  63. // while ((s = gbfgetstr(fin))) {
  64. // do_anything(s);
  65. // }
  66. //
  67. //
  68. // For waypoints:
  69. // while (have waypoints) {
  70. // waypoint = new waypoint
  71. // populate waypoint
  72. // waypt_add(waypoint);
  73. // }
  74. //
  75. // For routes:
  76. //
  77. // route = route_head_alloc();
  78. // populate struct route_hdr
  79. // route_add_head(route);
  80. // while (have more routepoints) {
  81. // waypoint = new waypoint
  82. // populate waypoint
  83. // route_add_wpt(route, waypoint)
  84. // }
  85. //
  86. // Tracks are just like routes, except the word "track" replaces "routes".
  87. //
  88. }
  89. static void
  90. format_skeleton_wr_init(const char* fname)
  91. {
  92. // fout = gbfopen(fname, "w", MYNAME);
  93. }
  94. static void
  95. format_skeleton_wr_deinit(void)
  96. {
  97. // gbfclose(fout);
  98. }
  99. static void
  100. format_skeleton_write(void)
  101. {
  102. // Here is how you register callbacks for all waypoints, routes, tracks.
  103. // waypt_disp_all(waypt)
  104. // route_disp_all(head, tail, rtept);
  105. // track_disp_all(head, tail, trkpt);
  106. }
  107. static void
  108. format_skeleton_exit(void) /* optional */
  109. {
  110. }
  111. /**************************************************************************/
  112. // capabilities below means: we can only read and write waypoints
  113. // please change this depending on your new module
  114. ff_vecs_t format_skeleton_vecs = {
  115. ff_type_file,
  116. {
  117. (ff_cap)(ff_cap_read | ff_cap_write) /* waypoints */,
  118. ff_cap_none /* tracks */,
  119. ff_cap_none /* routes */
  120. },
  121. format_skeleton_rd_init,
  122. format_skeleton_wr_init,
  123. format_skeleton_rd_deinit,
  124. format_skeleton_wr_deinit,
  125. format_skeleton_read,
  126. format_skeleton_write,
  127. format_skeleton_exit,
  128. format_skeleton_args,
  129. CET_CHARSET_ASCII, 0 /* ascii is the expected character set */
  130. /* not fixed, can be changed through command line parameter */
  131. };
  132. /**************************************************************************/