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.

vecs.cc 33KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738
  1. /*
  2. Describe vectors containing file operations.
  3. Copyright (C) 2002, 2004, 2005, 2006, 2007 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. #include "csv_util.h"
  18. #include "inifile.h"
  19. #include "gbversion.h"
  20. #include <stdio.h>
  21. #include <stdlib.h> // qsort
  22. #define MYNAME "vecs.c"
  23. typedef struct {
  24. ff_vecs_t* vec;
  25. const char* name;
  26. const char* desc;
  27. const char* extension;
  28. const char* parent;
  29. } vecs_t;
  30. extern ff_vecs_t an1_vecs;
  31. extern ff_vecs_t bcr_vecs;
  32. extern ff_vecs_t brauniger_iq_vecs;
  33. extern ff_vecs_t cetus_vecs;
  34. extern ff_vecs_t compegps_vecs;
  35. extern ff_vecs_t copilot_vecs;
  36. extern ff_vecs_t coto_vecs;
  37. extern ff_vecs_t cst_vecs;
  38. extern ff_vecs_t dg100_vecs;
  39. extern ff_vecs_t dg200_vecs;
  40. extern ff_vecs_t easygps_vecs;
  41. extern ff_vecs_t energympro_vecs;
  42. extern ff_vecs_t garmin_vecs;
  43. extern ff_vecs_t garmin_txt_vecs;
  44. extern ff_vecs_t gcdb_vecs;
  45. extern ff_vecs_t gdb_vecs;
  46. extern ff_vecs_t geoniche_vecs;
  47. extern ff_vecs_t geo_vecs;
  48. extern ff_vecs_t geojson_vecs;
  49. extern ff_vecs_t globalsat_sport_vecs;
  50. extern ff_vecs_t glogbook_vecs;
  51. extern ff_vecs_t google_dir_vecs;
  52. extern ff_vecs_t gpilots_vecs;
  53. extern ff_vecs_t gpl_vecs;
  54. extern ff_vecs_t gpssim_vecs;
  55. extern ff_vecs_t gpspilot_vecs;
  56. extern ff_vecs_t gpsutil_vecs;
  57. extern ff_vecs_t gpx_vecs;
  58. extern ff_vecs_t gtm_vecs;
  59. extern ff_vecs_t hiketech_vecs;
  60. extern ff_vecs_t holux_vecs;
  61. extern ff_vecs_t HsaEndeavourNavigator_vecs;
  62. extern ff_vecs_t html_vecs;
  63. extern ff_vecs_t igc_vecs;
  64. extern ff_vecs_t ignr_vecs;
  65. extern ff_vecs_t igo8_vecs;
  66. extern ff_vecs_t kml_vecs;
  67. extern ff_vecs_t lowranceusr_vecs;
  68. extern ff_vecs_t lowranceusr4_vecs;
  69. extern ff_vecs_t mag_fvecs;
  70. extern ff_vecs_t maggeo_vecs;
  71. extern ff_vecs_t magnav_vec;
  72. extern ff_vecs_t mag_svecs;
  73. extern ff_vecs_t magX_fvecs;
  74. extern ff_vecs_t mapsend_vecs;
  75. extern ff_vecs_t mps_vecs;
  76. extern ff_vecs_t mtk_vecs;
  77. extern ff_vecs_t mtk_fvecs;
  78. extern ff_vecs_t mtk_m241_vecs;
  79. extern ff_vecs_t mtk_m241_fvecs;
  80. extern ff_vecs_t mtk_locus_vecs;
  81. extern ff_vecs_t mynav_vecs;
  82. extern ff_vecs_t navicache_vecs;
  83. extern ff_vecs_t netstumbler_vecs;
  84. extern ff_vecs_t nmea_vecs;
  85. extern ff_vecs_t nmn4_vecs;
  86. extern ff_vecs_t ozi_vecs;
  87. extern ff_vecs_t palmdoc_vecs;
  88. extern ff_vecs_t pcx_vecs;
  89. extern ff_vecs_t psit_vecs; /* MRCB */
  90. extern ff_vecs_t quovadis_vecs;
  91. extern ff_vecs_t saroute_vecs;
  92. extern ff_vecs_t shape_vecs;
  93. extern ff_vecs_t skytraq_vecs;
  94. extern ff_vecs_t skytraq_fvecs;
  95. extern ff_vecs_t miniHomer_vecs;
  96. #if CSVFMTS_ENABLED
  97. extern ff_vecs_t stmsdf_vecs;
  98. #endif
  99. #if CSVFMTS_ENABLED
  100. extern ff_vecs_t stmwpp_vecs;
  101. #endif
  102. extern ff_vecs_t tef_xml_vecs;
  103. extern ff_vecs_t text_vecs;
  104. extern ff_vecs_t tiger_vecs;
  105. extern ff_vecs_t tmpro_vecs;
  106. extern ff_vecs_t tomtom_vecs;
  107. extern ff_vecs_t tpg_vecs;
  108. extern ff_vecs_t tpo2_vecs;
  109. extern ff_vecs_t tpo3_vecs;
  110. extern ff_vecs_t unicsv_vecs;
  111. extern ff_vecs_t vcf_vecs;
  112. extern ff_vecs_t vitosmt_vecs;
  113. extern ff_vecs_t wfff_xml_vecs;
  114. extern ff_vecs_t xcsv_vecs;
  115. extern ff_vecs_t yahoo_vecs;
  116. extern ff_vecs_t wbt_svecs;
  117. extern ff_vecs_t wbt_fvecs;
  118. extern ff_vecs_t gtc_vecs;
  119. extern ff_vecs_t dmtlog_vecs;
  120. extern ff_vecs_t raymarine_vecs;
  121. extern ff_vecs_t alanwpr_vecs;
  122. extern ff_vecs_t alantrl_vecs;
  123. extern ff_vecs_t vitovtt_vecs;
  124. extern ff_vecs_t ggv_bin_vecs;
  125. extern ff_vecs_t ggv_log_vecs;
  126. extern ff_vecs_t g7towin_vecs;
  127. extern ff_vecs_t garmin_gpi_vecs;
  128. extern ff_vecs_t lmx_vecs;
  129. extern ff_vecs_t random_vecs;
  130. extern ff_vecs_t xol_vecs;
  131. extern ff_vecs_t navilink_vecs;
  132. extern ff_vecs_t ik3d_vecs;
  133. extern ff_vecs_t osm_vecs;
  134. extern ff_vecs_t destinator_poi_vecs;
  135. extern ff_vecs_t destinator_trl_vecs;
  136. extern ff_vecs_t destinator_itn_vecs;
  137. extern ff_vecs_t exif_vecs;
  138. extern ff_vecs_t vidaone_vecs;
  139. extern ff_vecs_t gopal_vecs;
  140. extern ff_vecs_t humminbird_vecs;
  141. extern ff_vecs_t humminbird_ht_vecs;
  142. extern ff_vecs_t mapasia_tr7_vecs;
  143. extern ff_vecs_t gnav_trl_vecs;
  144. extern ff_vecs_t navitel_trk_vecs;
  145. extern ff_vecs_t ggv_ovl_vecs;
  146. #if CSVFMTS_ENABLED
  147. extern ff_vecs_t jtr_vecs;
  148. #endif
  149. extern ff_vecs_t itracku_vecs;
  150. extern ff_vecs_t itracku_fvecs;
  151. extern ff_vecs_t sbp_vecs;
  152. extern ff_vecs_t ng_vecs;
  153. extern ff_vecs_t sbn_vecs;
  154. extern ff_vecs_t mmo_vecs;
  155. extern ff_vecs_t bushnell_vecs;
  156. extern ff_vecs_t bushnell_trl_vecs;
  157. extern ff_vecs_t skyforce_vecs;
  158. extern ff_vecs_t v900_vecs;
  159. extern ff_vecs_t pocketfms_bc_vecs;
  160. extern ff_vecs_t pocketfms_fp_vecs;
  161. extern ff_vecs_t pocketfms_wp_vecs;
  162. extern ff_vecs_t enigma_vecs;
  163. extern ff_vecs_t vpl_vecs;
  164. extern ff_vecs_t teletype_vecs;
  165. extern ff_vecs_t jogmap_vecs;
  166. extern ff_vecs_t wintec_tes_vecs;
  167. extern ff_vecs_t subrip_vecs;
  168. extern ff_vecs_t format_garmin_xt_vecs;
  169. extern ff_vecs_t format_fit_vecs;
  170. extern ff_vecs_t mapbar_track_vecs;
  171. extern ff_vecs_t f90g_track_vecs;
  172. extern ff_vecs_t mapfactor_vecs;
  173. static
  174. vecs_t vec_list[] = {
  175. #if CSVFMTS_ENABLED
  176. /* XCSV must be the first entry in this table. */
  177. {
  178. &xcsv_vecs,
  179. "xcsv",
  180. "? Character Separated Values",
  181. NULL,
  182. NULL,
  183. },
  184. #endif
  185. {
  186. &geo_vecs,
  187. "geo",
  188. "Geocaching.com .loc",
  189. "loc",
  190. NULL,
  191. },
  192. {
  193. &gpx_vecs,
  194. "gpx",
  195. "GPX XML",
  196. "gpx",
  197. NULL,
  198. },
  199. {
  200. &mag_svecs,
  201. "magellan",
  202. "Magellan serial protocol",
  203. NULL,
  204. NULL,
  205. },
  206. {
  207. &mag_fvecs,
  208. "magellan",
  209. "Magellan SD files (as for Meridian)",
  210. NULL,
  211. NULL,
  212. },
  213. {
  214. &magX_fvecs,
  215. "magellanx",
  216. "Magellan SD files (as for eXplorist)",
  217. "upt",
  218. NULL,
  219. },
  220. {
  221. &garmin_vecs,
  222. "garmin",
  223. "Garmin serial/USB protocol",
  224. NULL,
  225. NULL,
  226. },
  227. {
  228. &gdb_vecs,
  229. "gdb",
  230. "Garmin MapSource - gdb",
  231. "gdb",
  232. NULL,
  233. },
  234. {
  235. &gtc_vecs,
  236. "gtrnctr",
  237. "Garmin Training Center (.xml)",
  238. "xml",
  239. NULL,
  240. },
  241. {
  242. &mapsend_vecs,
  243. "mapsend",
  244. "Magellan Mapsend",
  245. NULL,
  246. NULL,
  247. },
  248. {
  249. &mps_vecs,
  250. "mapsource",
  251. "Garmin MapSource - mps",
  252. "mps",
  253. NULL,
  254. },
  255. {
  256. &nmea_vecs,
  257. "nmea",
  258. "NMEA 0183 sentences",
  259. NULL,
  260. NULL,
  261. },
  262. {
  263. &ozi_vecs,
  264. "ozi",
  265. "OziExplorer",
  266. NULL,
  267. NULL,
  268. },
  269. {
  270. &pcx_vecs,
  271. "pcx",
  272. "Garmin PCX5",
  273. "pcx",
  274. NULL,
  275. },
  276. {
  277. &kml_vecs,
  278. "kml",
  279. "Google Earth (Keyhole) Markup Language",
  280. "kml",
  281. NULL,
  282. },
  283. #if MAXIMAL_ENABLED
  284. {
  285. &gpsutil_vecs,
  286. "gpsutil",
  287. "gpsutil",
  288. NULL,
  289. NULL,
  290. },
  291. {
  292. &lowranceusr_vecs,
  293. "lowranceusr",
  294. "Lowrance USR",
  295. "usr",
  296. NULL,
  297. },
  298. {
  299. &lowranceusr4_vecs,
  300. "lowranceusr4",
  301. "Lowrance USR version 4",
  302. "usr",
  303. NULL,
  304. },
  305. {
  306. &holux_vecs,
  307. "holux",
  308. "Holux (gm-100) .wpo Format",
  309. "wpo",
  310. NULL,
  311. },
  312. {
  313. &tpg_vecs,
  314. "tpg",
  315. "National Geographic Topo .tpg (waypoints)",
  316. "tpg",
  317. NULL,
  318. },
  319. {
  320. &tpo2_vecs,
  321. "tpo2",
  322. "National Geographic Topo 2.x .tpo",
  323. "tpo",
  324. NULL,
  325. },
  326. {
  327. &tpo3_vecs,
  328. "tpo3",
  329. "National Geographic Topo 3.x/4.x .tpo",
  330. "tpo",
  331. NULL,
  332. },
  333. {
  334. &tmpro_vecs,
  335. "tmpro",
  336. "TopoMapPro Places File",
  337. "tmpro",
  338. NULL,
  339. },
  340. {
  341. &tiger_vecs,
  342. "tiger",
  343. "U.S. Census Bureau Tiger Mapping Service",
  344. NULL,
  345. NULL,
  346. },
  347. {
  348. &easygps_vecs,
  349. "easygps",
  350. "EasyGPS binary format",
  351. "loc",
  352. NULL,
  353. },
  354. {
  355. &saroute_vecs,
  356. "saroute",
  357. "DeLorme Street Atlas Route",
  358. "anr",
  359. NULL,
  360. },
  361. {
  362. &navicache_vecs,
  363. "navicache",
  364. "Navicache.com XML",
  365. NULL,
  366. NULL,
  367. },
  368. { /* MRCB */
  369. &psit_vecs,
  370. "psitrex",
  371. "KuDaTa PsiTrex text",
  372. NULL,
  373. NULL,
  374. },
  375. #if SHAPELIB_ENABLED
  376. {
  377. &shape_vecs,
  378. "shape",
  379. "ESRI shapefile",
  380. "shp",
  381. NULL,
  382. },
  383. #endif
  384. {
  385. &gpl_vecs,
  386. "gpl",
  387. "DeLorme GPL",
  388. "gpl",
  389. NULL,
  390. },
  391. {
  392. &text_vecs,
  393. "text",
  394. "Textual Output",
  395. "txt",
  396. NULL,
  397. },
  398. {
  399. &html_vecs,
  400. "html",
  401. "HTML Output",
  402. "html",
  403. NULL,
  404. },
  405. {
  406. &netstumbler_vecs,
  407. "netstumbler",
  408. "NetStumbler Summary File (text)",
  409. NULL,
  410. NULL,
  411. },
  412. {
  413. &igc_vecs,
  414. "igc",
  415. "FAI/IGC Flight Recorder Data Format",
  416. NULL,
  417. NULL,
  418. },
  419. {
  420. &brauniger_iq_vecs,
  421. "baroiq",
  422. "Brauniger IQ Series Barograph Download",
  423. NULL,
  424. NULL,
  425. },
  426. {
  427. &mtk_vecs,
  428. "mtk",
  429. "MTK Logger (iBlue 747,Qstarz BT-1000,...) download",
  430. NULL,
  431. NULL,
  432. },
  433. {
  434. &mtk_fvecs,
  435. "mtk-bin",
  436. "MTK Logger (iBlue 747,...) Binary File Format",
  437. "bin",
  438. NULL,
  439. },
  440. {
  441. &mtk_m241_vecs,
  442. "m241",
  443. "Holux M-241 (MTK based) download",
  444. NULL,
  445. NULL,
  446. },
  447. {
  448. &mtk_m241_fvecs,
  449. "m241-bin",
  450. "Holux M-241 (MTK based) Binary File Format",
  451. "bin",
  452. NULL,
  453. },
  454. {
  455. &mtk_locus_vecs,
  456. "mtk_locus",
  457. "MediaTek Locus",
  458. NULL,
  459. NULL,
  460. },
  461. #endif // MAXIMAL_ENABLED
  462. {
  463. &wbt_svecs,
  464. "wbt",
  465. "Wintec WBT-100/200 GPS Download",
  466. NULL,
  467. NULL,
  468. },
  469. #if MAXIMAL_ENABLED
  470. {
  471. &vpl_vecs,
  472. "vpl",
  473. "Honda/Acura Navigation System VP Log File Format",
  474. NULL,
  475. NULL,
  476. },
  477. {
  478. &wbt_fvecs,
  479. "wbt-bin",
  480. "Wintec WBT-100/200 Binary File Format",
  481. "bin",
  482. NULL,
  483. },
  484. {
  485. &wbt_fvecs,
  486. "wbt-tk1",
  487. "Wintec WBT-201/G-Rays 2 Binary File Format",
  488. "tk1",
  489. NULL,
  490. },
  491. {
  492. &hiketech_vecs,
  493. "hiketech",
  494. "HikeTech",
  495. "gps",
  496. NULL,
  497. },
  498. {
  499. &glogbook_vecs,
  500. "glogbook",
  501. "Garmin Logbook XML",
  502. "xml",
  503. NULL,
  504. },
  505. {
  506. &vcf_vecs,
  507. "vcard",
  508. "Vcard Output (for iPod)",
  509. "vcf",
  510. NULL,
  511. },
  512. {
  513. &google_dir_vecs,
  514. "googledir",
  515. "Google Directions XML",
  516. "xml",
  517. NULL,
  518. },
  519. {
  520. &maggeo_vecs,
  521. "maggeo",
  522. "Magellan Explorist Geocaching",
  523. "gs",
  524. NULL,
  525. },
  526. {
  527. &an1_vecs,
  528. "an1",
  529. "DeLorme .an1 (drawing) file",
  530. "an1",
  531. NULL,
  532. },
  533. {
  534. &tomtom_vecs,
  535. "tomtom",
  536. "TomTom POI file (.ov2)",
  537. "ov2",
  538. NULL,
  539. },
  540. {
  541. &tef_xml_vecs,
  542. "tef",
  543. "Map&Guide 'TourExchangeFormat' XML",
  544. "xml",
  545. NULL,
  546. },
  547. {
  548. &vitosmt_vecs,
  549. "vitosmt",
  550. "Vito Navigator II tracks",
  551. "smt",
  552. NULL,
  553. },
  554. {
  555. &wfff_xml_vecs,
  556. "wfff",
  557. "WiFiFoFum 2.0 for PocketPC XML",
  558. "xml",
  559. NULL,
  560. },
  561. {
  562. &bcr_vecs,
  563. "bcr",
  564. "Motorrad Routenplaner (Map&Guide) .bcr files",
  565. "bcr",
  566. NULL,
  567. },
  568. {
  569. &ignr_vecs,
  570. "ignrando",
  571. "IGN Rando track files",
  572. "rdn",
  573. NULL,
  574. },
  575. #if CSVFMTS_ENABLED
  576. {
  577. &stmsdf_vecs,
  578. "stmsdf",
  579. "Suunto Trek Manager (STM) .sdf files",
  580. "sdf",
  581. NULL,
  582. },
  583. #endif
  584. #if CSVFMTS_ENABLED
  585. {
  586. &stmwpp_vecs,
  587. "stmwpp",
  588. "Suunto Trek Manager (STM) WaypointPlus files",
  589. "txt",
  590. NULL,
  591. },
  592. #endif // CSVFMTS_ENABLED
  593. {
  594. &cst_vecs,
  595. "cst",
  596. "CarteSurTable data file",
  597. "cst",
  598. NULL,
  599. },
  600. {
  601. &nmn4_vecs,
  602. "nmn4",
  603. "Navigon Mobile Navigator .rte files",
  604. "rte",
  605. NULL,
  606. },
  607. #if CSVFMTS_ENABLED
  608. {
  609. &compegps_vecs,
  610. "compegps",
  611. "CompeGPS data files (.wpt/.trk/.rte)",
  612. NULL,
  613. NULL,
  614. },
  615. #endif //CSVFMTS_ENABLED
  616. {
  617. &yahoo_vecs,
  618. "yahoo",
  619. "Yahoo Geocode API data",
  620. NULL,
  621. NULL,
  622. },
  623. {
  624. &unicsv_vecs,
  625. "unicsv",
  626. "Universal csv with field structure in first line",
  627. NULL,
  628. NULL,
  629. },
  630. {
  631. &gtm_vecs,
  632. "gtm",
  633. "GPS TrackMaker",
  634. "gtm",
  635. NULL,
  636. },
  637. {
  638. &gpssim_vecs,
  639. "gpssim",
  640. "Franson GPSGate Simulation",
  641. "gpssim",
  642. NULL,
  643. },
  644. #if CSVFMTS_ENABLED
  645. {
  646. &garmin_txt_vecs,
  647. "garmin_txt",
  648. "Garmin MapSource - txt (tab delimited)",
  649. "txt",
  650. NULL,
  651. },
  652. #endif // CSVFMTS_ENABLED
  653. {
  654. &gtc_vecs,
  655. "gtrnctr",
  656. "Garmin Training Center (.tcx)",
  657. "xml",
  658. NULL,
  659. },
  660. {
  661. &dmtlog_vecs,
  662. "dmtlog",
  663. "TrackLogs digital mapping (.trl)",
  664. "trl",
  665. NULL,
  666. },
  667. {
  668. &raymarine_vecs,
  669. "raymarine",
  670. "Raymarine Waypoint File (.rwf)",
  671. "rwf",
  672. NULL,
  673. },
  674. {
  675. &alanwpr_vecs,
  676. "alanwpr",
  677. "Alan Map500 waypoints and routes (.wpr)",
  678. "wpr",
  679. NULL,
  680. },
  681. {
  682. &alantrl_vecs,
  683. "alantrl",
  684. "Alan Map500 tracklogs (.trl)",
  685. "trl",
  686. NULL,
  687. },
  688. {
  689. &vitovtt_vecs,
  690. "vitovtt",
  691. "Vito SmartMap tracks (.vtt)",
  692. "vtt",
  693. NULL,
  694. },
  695. {
  696. &ggv_log_vecs,
  697. "ggv_log",
  698. "Geogrid-Viewer tracklogs (.log)",
  699. "log",
  700. NULL,
  701. },
  702. #if CSVFMTS_ENABLED
  703. {
  704. &g7towin_vecs,
  705. "g7towin",
  706. "G7ToWin data files (.g7t)",
  707. "g7t",
  708. NULL,
  709. },
  710. #endif
  711. {
  712. &garmin_gpi_vecs,
  713. "garmin_gpi",
  714. "Garmin Points of Interest (.gpi)",
  715. "gpi",
  716. NULL,
  717. },
  718. {
  719. &lmx_vecs,
  720. "lmx",
  721. "Nokia Landmark Exchange",
  722. NULL,
  723. NULL,
  724. },
  725. {
  726. &random_vecs,
  727. "random",
  728. "Internal GPS data generator",
  729. NULL,
  730. NULL,
  731. },
  732. {
  733. &xol_vecs,
  734. "xol",
  735. "Swiss Map 25/50/100 (.xol)",
  736. "xol",
  737. NULL,
  738. },
  739. {
  740. &dg100_vecs,
  741. "dg-100",
  742. "GlobalSat DG-100/BT-335 Download",
  743. NULL,
  744. NULL,
  745. },
  746. {
  747. &dg200_vecs,
  748. "dg-200",
  749. "GlobalSat DG-200 Download",
  750. NULL,
  751. NULL,
  752. },
  753. {
  754. &navilink_vecs,
  755. "navilink",
  756. "NaviGPS GT-11/BGT-11 Download",
  757. NULL,
  758. NULL,
  759. },
  760. {
  761. &ik3d_vecs,
  762. "ik3d",
  763. "MagicMaps IK3D project file (.ikt)",
  764. "ikt",
  765. NULL,
  766. },
  767. {
  768. &osm_vecs,
  769. "osm",
  770. "OpenStreetMap data files",
  771. "osm",
  772. NULL,
  773. },
  774. {
  775. &destinator_poi_vecs,
  776. "destinator_poi",
  777. "Destinator Points of Interest (.dat)",
  778. "dat",
  779. NULL,
  780. },
  781. {
  782. &destinator_itn_vecs,
  783. "destinator_itn",
  784. "Destinator Itineraries (.dat)",
  785. "dat",
  786. NULL,
  787. },
  788. {
  789. &destinator_trl_vecs,
  790. "destinator_trl",
  791. "Destinator TrackLogs (.dat)",
  792. "dat",
  793. NULL,
  794. },
  795. {
  796. &exif_vecs,
  797. "exif",
  798. "Embedded Exif-GPS data (.jpg)",
  799. "jpg",
  800. NULL,
  801. },
  802. {
  803. &vidaone_vecs,
  804. "vidaone",
  805. "VidaOne GPS for Pocket PC (.gpb)",
  806. "gpb",
  807. NULL,
  808. },
  809. {
  810. &igo8_vecs,
  811. "igo8",
  812. "IGO8 .trk",
  813. "trk",
  814. NULL,
  815. },
  816. {
  817. &gopal_vecs,
  818. "gopal",
  819. "GoPal GPS track log (.trk)",
  820. "trk",
  821. NULL,
  822. },
  823. {
  824. &humminbird_vecs,
  825. "humminbird",
  826. "Humminbird waypoints and routes (.hwr)",
  827. "hwr",
  828. NULL,
  829. },
  830. {
  831. &humminbird_ht_vecs,
  832. "humminbird_ht",
  833. "Humminbird tracks (.ht)",
  834. "ht",
  835. NULL,
  836. },
  837. {
  838. &mapasia_tr7_vecs,
  839. "mapasia_tr7",
  840. "MapAsia track file (.tr7)",
  841. "tr7",
  842. NULL,
  843. },
  844. {
  845. &gnav_trl_vecs,
  846. "gnav_trl",
  847. "Google Navigator Tracklines (.trl)",
  848. "trl",
  849. NULL,
  850. },
  851. {
  852. &navitel_trk_vecs,
  853. "navitel_trk",
  854. "Navitel binary track (.bin)",
  855. "bin",
  856. NULL,
  857. },
  858. {
  859. &ggv_ovl_vecs,
  860. "ggv_ovl",
  861. "Geogrid-Viewer ascii overlay file (.ovl)",
  862. "ovl",
  863. NULL,
  864. },
  865. #if CSVFMTS_ENABLED
  866. {
  867. &jtr_vecs,
  868. "jtr",
  869. "Jelbert GeoTagger data file",
  870. "jtr",
  871. NULL,
  872. },
  873. #endif
  874. {
  875. &itracku_vecs,
  876. "itracku",
  877. "XAiOX iTrackU Logger",
  878. NULL,
  879. NULL,
  880. },
  881. {
  882. &itracku_fvecs,
  883. "itracku-bin",
  884. "XAiOX iTrackU Logger Binary File Format",
  885. "bin",
  886. NULL,
  887. },
  888. {
  889. &sbp_vecs,
  890. "sbp",
  891. "NaviGPS GT-31/BGT-31 datalogger (.sbp)",
  892. "sbp",
  893. NULL,
  894. },
  895. {
  896. &sbn_vecs,
  897. "sbn",
  898. "NaviGPS GT-31/BGT-31 SiRF binary logfile (.sbn)",
  899. "sbn",
  900. NULL,
  901. },
  902. {
  903. &mmo_vecs,
  904. "mmo",
  905. "Memory-Map Navigator overlay files (.mmo)",
  906. "mmo",
  907. NULL,
  908. },
  909. {
  910. &bushnell_vecs,
  911. "bushnell",
  912. "Bushnell GPS Waypoint file",
  913. "wpt",
  914. NULL,
  915. },
  916. {
  917. &bushnell_trl_vecs,
  918. "bushnell_trl",
  919. "Bushnell GPS Trail file",
  920. "trl",
  921. NULL,
  922. },
  923. {
  924. &skyforce_vecs,
  925. "skyforce",
  926. "Skymap / KMD150 ascii files",
  927. NULL,
  928. NULL,
  929. },
  930. {
  931. &pocketfms_bc_vecs,
  932. "pocketfms_bc",
  933. "PocketFMS breadcrumbs",
  934. NULL,
  935. NULL,
  936. },
  937. {
  938. &pocketfms_fp_vecs,
  939. "pocketfms_fp",
  940. "PocketFMS flightplan (.xml)",
  941. "xml",
  942. NULL,
  943. },
  944. {
  945. &pocketfms_wp_vecs,
  946. "pocketfms_wp",
  947. "PocketFMS waypoints (.txt)",
  948. "txt",
  949. NULL,
  950. },
  951. {
  952. &v900_vecs,
  953. "v900",
  954. "Columbus/Visiontac V900 files (.csv)",
  955. NULL,
  956. NULL,
  957. },
  958. {
  959. &ng_vecs,
  960. "naviguide",
  961. "Naviguide binary route file (.twl)",
  962. "twl",
  963. NULL,
  964. },
  965. {
  966. &enigma_vecs,
  967. "enigma",
  968. "Enigma binary waypoint file (.ert)",
  969. "ert",
  970. NULL,
  971. },
  972. {
  973. &skytraq_vecs,
  974. "skytraq",
  975. "SkyTraq Venus based loggers (download)",
  976. NULL,
  977. NULL,
  978. },
  979. {
  980. &teletype_vecs,
  981. "teletype",
  982. "Teletype [ Get Jonathon Johnson to describe",
  983. NULL,
  984. NULL,
  985. },
  986. {
  987. &skytraq_fvecs,
  988. "skytraq-bin",
  989. "SkyTraq Venus based loggers Binary File Format",
  990. "bin",
  991. NULL,
  992. },
  993. {
  994. &miniHomer_vecs,
  995. "miniHomer",
  996. "MiniHomer, a skyTraq Venus 6 based logger (download tracks, waypoints and get/set POI)",
  997. NULL,
  998. NULL,
  999. },
  1000. {
  1001. &jogmap_vecs,
  1002. "jogmap",
  1003. "Jogmap.de XML format",
  1004. "xml",
  1005. NULL,
  1006. },
  1007. {
  1008. &wintec_tes_vecs,
  1009. "wintec_tes",
  1010. "Wintec TES file",
  1011. "tes",
  1012. NULL,
  1013. },
  1014. {
  1015. &subrip_vecs,
  1016. "subrip",
  1017. "SubRip subtitles for video mapping (.srt)",
  1018. "srt",
  1019. NULL,
  1020. },
  1021. {
  1022. &format_garmin_xt_vecs,
  1023. "garmin_xt",
  1024. "Mobile Garmin XT Track files",
  1025. NULL,
  1026. NULL,
  1027. },
  1028. {
  1029. &format_fit_vecs,
  1030. "garmin_fit",
  1031. "Flexible and Interoperable Data Transfer (FIT) Activity file",
  1032. "fit",
  1033. NULL,
  1034. },
  1035. {
  1036. &mapbar_track_vecs,
  1037. "mapbar",
  1038. "Mapbar (China) navigation track for Sonim Xp3300",
  1039. "trk",
  1040. NULL,
  1041. },
  1042. {
  1043. &f90g_track_vecs,
  1044. "f90g",
  1045. "F90G Automobile DVR GPS log file",
  1046. "map",
  1047. NULL,
  1048. },
  1049. {
  1050. &mapfactor_vecs,
  1051. "mapfactor",
  1052. "Mapfactor Navigator",
  1053. "xml",
  1054. NULL,
  1055. },
  1056. {
  1057. &energympro_vecs,
  1058. "energympro",
  1059. "Energympro GPS training watch",
  1060. "cpo",
  1061. NULL,
  1062. },
  1063. {
  1064. &mynav_vecs,
  1065. "mynav",
  1066. "MyNav TRC format",
  1067. "trc",
  1068. NULL,
  1069. },
  1070. {
  1071. &geojson_vecs,
  1072. "geojson",
  1073. "GeoJson",
  1074. "json",
  1075. NULL,
  1076. },
  1077. {
  1078. &ggv_bin_vecs,
  1079. "ggv_bin",
  1080. "Geogrid-Viewer binary overlay file (.ovl)",
  1081. "ovl",
  1082. NULL,
  1083. },
  1084. {
  1085. &globalsat_sport_vecs,
  1086. "globalsat",
  1087. "GlobalSat GH625XT GPS training watch",
  1088. NULL,
  1089. NULL,
  1090. },
  1091. #endif // MAXIMAL_ENABLED
  1092. {
  1093. NULL,
  1094. NULL,
  1095. NULL,
  1096. NULL,
  1097. NULL,
  1098. }
  1099. };
  1100. void
  1101. init_vecs(void)
  1102. {
  1103. vecs_t* vec = vec_list;
  1104. while (vec->vec) {
  1105. arglist_t* ap;
  1106. if (vec->vec->args) {
  1107. for (ap = vec->vec->args; ap->argstring; ap++) {
  1108. ap->argvalptr = NULL;
  1109. if (ap->argval) {
  1110. *ap->argval = NULL;
  1111. }
  1112. }
  1113. }
  1114. vec++;
  1115. }
  1116. }
  1117. int
  1118. is_integer(const char* c)
  1119. {
  1120. return isdigit(c[0]) || ((c[0] == '+' || c[0] == '-') && isdigit(c[1]));
  1121. }
  1122. void
  1123. exit_vecs(void)
  1124. {
  1125. vecs_t* vec = vec_list;
  1126. while (vec->vec) {
  1127. arglist_t* ap;
  1128. if (vec->vec->exit) {
  1129. (*vec->vec->exit)();
  1130. }
  1131. if (vec->vec->args) {
  1132. for (ap = vec->vec->args; ap->argstring; ap++) {
  1133. if (ap->defaultvalue &&
  1134. (ap->argtype == ARGTYPE_INT) &&
  1135. ! is_integer(ap->defaultvalue)) {
  1136. warning("%s: not an integer\n", ap->argstring);
  1137. }
  1138. if (ap->argvalptr) {
  1139. xfree(ap->argvalptr);
  1140. *ap->argval = ap->argvalptr = NULL;
  1141. }
  1142. }
  1143. }
  1144. vec++;
  1145. }
  1146. }
  1147. void
  1148. assign_option(const char* module, arglist_t* ap, const char* val)
  1149. {
  1150. const char* c;
  1151. if (ap->argval == NULL) {
  1152. fatal("%s: No local variable defined for option \"%s\"!", module, ap->argstring);
  1153. }
  1154. if (ap->argvalptr != NULL) {
  1155. xfree(ap->argvalptr);
  1156. ap->argvalptr = NULL;
  1157. }
  1158. if (ap->argval) {
  1159. *ap->argval = NULL;
  1160. }
  1161. if (val == NULL) {
  1162. return;
  1163. }
  1164. // Fixme - this is probably somewhere between wrong and less than great. If you have an option "foo"
  1165. // and want to set it to the value "foo", this code will prevent that from happening, but we seem to have
  1166. // code all over the place that relies on this. :-/
  1167. if (case_ignore_strcmp(val, ap->argstring) == 0) {
  1168. c = "";
  1169. } else {
  1170. c = (char*)val;
  1171. }
  1172. switch (ap->argtype & ARGTYPE_TYPEMASK) {
  1173. case ARGTYPE_INT:
  1174. if (*c == '\0') {
  1175. c = "0";
  1176. } else {
  1177. int test;
  1178. is_fatal(1 != sscanf(c, "%d", &test),
  1179. "%s: Invalid parameter value %s for option %s", module, val, ap->argstring);
  1180. }
  1181. break;
  1182. case ARGTYPE_FLOAT:
  1183. if (*c == '\0') {
  1184. c = "0";
  1185. } else {
  1186. double test;
  1187. is_fatal(1 != sscanf(c, "%lf", &test),
  1188. "%s: Invalid parameter value %s for option %s", module, val, ap->argstring);
  1189. }
  1190. break;
  1191. case ARGTYPE_BOOL:
  1192. if (*c == '\0') {
  1193. c = "1";
  1194. } else {
  1195. switch (*c) {
  1196. case 'Y':
  1197. case 'y':
  1198. c = "1";
  1199. break;
  1200. case 'N':
  1201. case 'n':
  1202. c = "0";
  1203. break;
  1204. default:
  1205. if (isdigit(*c)) {
  1206. if (*c == '0') {
  1207. c = "0";
  1208. } else {
  1209. c = "1";
  1210. }
  1211. } else {
  1212. warning(MYNAME ": Invalid logical value '%s' (%s)!\n", c, module);
  1213. c = "0";
  1214. }
  1215. break;
  1216. }
  1217. }
  1218. break;
  1219. }
  1220. /* for bool options without default: don't set argval if "FALSE" */
  1221. if (((ap->argtype & ARGTYPE_TYPEMASK) == ARGTYPE_BOOL) &&
  1222. (*c == '0') && (ap->defaultvalue == NULL)) {
  1223. return;
  1224. }
  1225. *ap->argval = ap->argvalptr = xstrdup(c);
  1226. }
  1227. void
  1228. disp_vec_options(const char* vecname, arglist_t* ap)
  1229. {
  1230. for (; ap && ap->argstring; ap++) {
  1231. if (*ap->argval && ap->argval) {
  1232. printf("options: module/option=value: %s/%s=\"%s\"",
  1233. vecname, ap->argstring, *ap->argval);
  1234. if (ap->defaultvalue && (case_ignore_strcmp(ap->defaultvalue, *ap->argval) == 0)) {
  1235. printf(" (=default)");
  1236. }
  1237. printf("\n");
  1238. }
  1239. }
  1240. }
  1241. ff_vecs_t*
  1242. find_vec(const char* vecname, const char** opts)
  1243. {
  1244. vecs_t* vec = vec_list;
  1245. style_vecs_t* svec = style_list;
  1246. char* v = xstrdup(vecname);
  1247. char* svecname = strtok(v, ",");
  1248. int found = 0;
  1249. if (vecname == NULL) {
  1250. fatal("A format name is required.\n");
  1251. }
  1252. while (vec->vec) {
  1253. if (case_ignore_strcmp(svecname, vec->name)) {
  1254. vec++;
  1255. continue;
  1256. }
  1257. const char* res = strchr(vecname, ',');
  1258. if (res) {
  1259. *opts = strchr(vecname, ',')+1;
  1260. } else {
  1261. *opts = NULL;
  1262. }
  1263. if (vec->vec->args) {
  1264. for (arglist_t* ap = vec->vec->args; ap->argstring; ap++) {
  1265. const char* opt;
  1266. if (res) {
  1267. opt = get_option(*opts, ap->argstring);
  1268. if (opt) {
  1269. found = 1;
  1270. assign_option(svecname, ap, opt);
  1271. xfree((char*)opt);
  1272. continue;
  1273. }
  1274. }
  1275. opt = inifile_readstr(global_opts.inifile, vec->name, ap->argstring);
  1276. if (opt == NULL) {
  1277. opt = inifile_readstr(global_opts.inifile, "Common format settings", ap->argstring);
  1278. }
  1279. if (opt == NULL) {
  1280. opt = ap->defaultvalue;
  1281. }
  1282. assign_option(vec->name, ap, opt);
  1283. }
  1284. }
  1285. if (opts && opts[0] && !found) {
  1286. warning("'%s' is an unknown option to %s.\n", *opts, vec->name);
  1287. }
  1288. if (global_opts.debug_level >= 1) {
  1289. disp_vec_options(vec->name, vec->vec->args);
  1290. }
  1291. #if CSVFMTS_ENABLED
  1292. // xcsv_setup_internal_style( NULL );
  1293. #endif // CSVFMTS_ENABLED
  1294. xfree(v);
  1295. vec->vec->name = vec->name; /* needed for session information */
  1296. return vec->vec;
  1297. }
  1298. /*
  1299. * Didn't find it in the table of "real" file types, so plan B
  1300. * is to search the list of xcsv styles.
  1301. */
  1302. while (svec->name) {
  1303. if (case_ignore_strcmp(svecname, svec->name)) {
  1304. svec++;
  1305. continue;
  1306. }
  1307. const char* res = strchr(vecname, ',');
  1308. if (res) {
  1309. *opts = strchr(vecname, ',') + 1;
  1310. } else {
  1311. *opts = NULL;
  1312. }
  1313. if (vec_list[0].vec->args) {
  1314. for (arglist_t* ap = vec_list[0].vec->args; ap->argstring; ap++) {
  1315. const char* opt;
  1316. if (res) {
  1317. opt = get_option(*opts, ap->argstring);
  1318. if (opt) {
  1319. found = 1;
  1320. assign_option(svecname, ap, opt);
  1321. xfree((char*)opt);
  1322. continue;
  1323. }
  1324. }
  1325. opt = inifile_readstr(global_opts.inifile, svec->name, ap->argstring);
  1326. if (opt == NULL) {
  1327. opt = inifile_readstr(global_opts.inifile, "Common format settings", ap->argstring);
  1328. }
  1329. if (opt == NULL) {
  1330. opt = ap->defaultvalue;
  1331. }
  1332. assign_option(svec->name, ap, opt);
  1333. }
  1334. }
  1335. if (opts && opts[0] && !found) {
  1336. warning("'%s' is an unknown option to %s.\n", *opts, svec->name);
  1337. }
  1338. if (global_opts.debug_level >= 1) {
  1339. disp_vec_options(svec->name, vec_list[0].vec->args);
  1340. }
  1341. #if CSVFMTS_ENABLED
  1342. xcsv_setup_internal_style(svec->style_buf);
  1343. #endif // CSVFMTS_ENABLED
  1344. xfree(v);
  1345. vec_list[0].vec->name = svec->name; /* needed for session information */
  1346. return vec_list[0].vec;
  1347. }
  1348. /*
  1349. * Not found.
  1350. */
  1351. xfree(v);
  1352. return NULL;
  1353. }
  1354. /*
  1355. * Find and return a specific argument in an arg list.
  1356. * Modelled approximately after getenv.
  1357. */
  1358. char*
  1359. #ifdef DEBUG_MEM
  1360. GET_OPTION(const char* iarglist, const char* argname, DEBUG_PARAMS)
  1361. #else
  1362. get_option(const char* iarglist, const char* argname)
  1363. #endif
  1364. {
  1365. const size_t arglen = strlen(argname);
  1366. char* arglist;
  1367. char* rval = NULL;
  1368. char* arg;
  1369. char* argp;
  1370. if (!iarglist) {
  1371. return NULL;
  1372. }
  1373. arglist = xstrdup(iarglist);
  1374. for (arg = arglist; argp = strtok(arg, ","), NULL != argp; arg = NULL) {
  1375. if (0 == case_ignore_strncmp(argp, argname, arglen)) {
  1376. /*
  1377. * If we have something of the form "foo=bar"
  1378. * return "bar". Otherwise, we assume we have
  1379. * simply "foo" so we return that.
  1380. */
  1381. if (argp[arglen] == '=') {
  1382. rval = argp + arglen + 1;
  1383. break;
  1384. } else if (argp[arglen] == '\0') {
  1385. rval = argp;
  1386. break;
  1387. }
  1388. }
  1389. }
  1390. /*
  1391. * Return an offset into the allocated copy.
  1392. * The caller mustn't free or otherwise get froggy with
  1393. * this data.
  1394. */
  1395. if (rval) {
  1396. rval = xxstrdup(rval,file, line);
  1397. }
  1398. xfree(arglist);
  1399. return rval;
  1400. }
  1401. /*
  1402. * Display the available formats in a format that's easy for humans to
  1403. * parse for help on available command line options.
  1404. */
  1405. static signed int
  1406. alpha(const void* a, const void* b)
  1407. {
  1408. const vecs_t* const* ap = (const vecs_t *const*) a;
  1409. const vecs_t* const* bp = (const vecs_t *const*) b;
  1410. return case_ignore_strcmp((*ap)->desc , (*bp)->desc);
  1411. }
  1412. /*
  1413. * Smoosh the vecs list and style lists together and sort them
  1414. * alphabetically. Returns an allocated copy of a style_vecs_array
  1415. * that's populated and sorted.
  1416. */
  1417. vecs_t**
  1418. sort_and_unify_vecs(int* ctp)
  1419. {
  1420. int vc;
  1421. vecs_t** svp;
  1422. vecs_t* vec;
  1423. #if CSVFMTS_ENABLED
  1424. style_vecs_t* svec;
  1425. #endif
  1426. int i = 0;
  1427. /* Get a count from both the vec (normal) and the svec (csv) lists */
  1428. #if CSVFMTS_ENABLED
  1429. extern size_t nstyles;
  1430. vc = sizeof vec_list / sizeof vec_list[0] - 1 + nstyles;
  1431. #else
  1432. vc = sizeof vec_list / sizeof vec_list[0] - 1;
  1433. #endif // CSVFMTS_ENABLED
  1434. svp = (vecs_t**)xcalloc(vc, sizeof(style_vecs_t*));
  1435. /* Normal vecs are easy; populate the first part of the array. */
  1436. for (vec = vec_list; vec->vec; vec++, i++) {
  1437. svp[i] = vec;
  1438. if (svp[i]->parent == NULL) {
  1439. svp[i]->parent = svp[i]->name;
  1440. }
  1441. }
  1442. #if CSVFMTS_ENABLED
  1443. /* Walk the style list, parse the entries, dummy up a "normal" vec */
  1444. for (svec = style_list; svec->name; svec++, i++) {
  1445. xcsv_read_internal_style(svec->style_buf);
  1446. svp[i] = (vecs_t*) xcalloc(1, sizeof** svp);
  1447. svp[i]->name = svec->name;
  1448. svp[i]->vec = (ff_vecs_t*) xmalloc(sizeof(*svp[i]->vec));
  1449. svp[i]->extension = xcsv_file.extension;
  1450. *svp[i]->vec = *vec_list[0].vec; /* Interits xcsv opts */
  1451. /* Reset file type to inherit ff_type from xcsv for everything
  1452. * except the xcsv format itself, which we leave as "internal"
  1453. */
  1454. if (case_ignore_strcmp(svec->name, "xcsv")) {
  1455. svp[i]->vec->type = xcsv_file.type;
  1456. /* Skip over the first help entry for all but the
  1457. * actual 'xcsv' format - so we don't expose the
  1458. * 'full path to xcsv style file' argument to any
  1459. * GUIs for an internal format.
  1460. */
  1461. svp[i]->vec->args++;
  1462. }
  1463. memset(&svp[i]->vec->cap, 0, sizeof(svp[i]->vec->cap));
  1464. switch (xcsv_file.datatype) {
  1465. case 0:
  1466. case wptdata:
  1467. svp[i]->vec->cap[ff_cap_rw_wpt] = (ff_cap)(ff_cap_read | ff_cap_write);
  1468. break;
  1469. case trkdata:
  1470. svp[i]->vec->cap[ff_cap_rw_trk] = (ff_cap)(ff_cap_read | ff_cap_write);
  1471. break;
  1472. case rtedata:
  1473. svp[i]->vec->cap[ff_cap_rw_rte] = (ff_cap)(ff_cap_read | ff_cap_write);
  1474. break;
  1475. default:
  1476. ;
  1477. }
  1478. svp[i]->desc = xcsv_file.description;
  1479. svp[i]->parent = "xcsv";
  1480. }
  1481. #endif // CSVFMTS_ENABLED
  1482. /* Now that we have everything in an array, alphabetize them */
  1483. qsort(svp, vc, sizeof(*svp), alpha);
  1484. *ctp = i;
  1485. return svp;
  1486. }
  1487. #define VEC_FMT " %-20.20s %-.50s\n"
  1488. void
  1489. disp_vecs(void)
  1490. {
  1491. vecs_t** svp;
  1492. arglist_t* ap;
  1493. int vc;
  1494. int i = 0;
  1495. svp = sort_and_unify_vecs(&vc);
  1496. for (i=0; i<vc; i++) {
  1497. if (svp[i]->vec->type == ff_type_internal) {
  1498. continue;
  1499. }
  1500. printf(VEC_FMT, svp[i]->name, svp[i]->desc);
  1501. for (ap = svp[i]->vec->args; ap && ap->argstring; ap++) {
  1502. if (!(ap->argtype & ARGTYPE_HIDDEN))
  1503. printf(" %-18.18s %s%-.50s %s\n",
  1504. ap->argstring,
  1505. (ap->argtype & ARGTYPE_TYPEMASK) ==
  1506. ARGTYPE_BOOL ? "(0/1) " : "",
  1507. ap->helpstring,
  1508. (ap->argtype & ARGTYPE_REQUIRED)?"(required)":"");
  1509. }
  1510. }
  1511. xfree(svp);
  1512. return;
  1513. }
  1514. void
  1515. disp_vec(const char* vecname)
  1516. {
  1517. vecs_t** svp;
  1518. arglist_t* ap;
  1519. int vc;
  1520. int i = 0;
  1521. svp = sort_and_unify_vecs(&vc);
  1522. for (i=0; i<vc; i++) {
  1523. if (case_ignore_strcmp(svp[i]->name, vecname)) {
  1524. continue;
  1525. }
  1526. printf(VEC_FMT, svp[i]->name, svp[i]->desc);
  1527. for (ap = svp[i]->vec->args; ap && ap->argstring; ap++) {
  1528. if (!(ap->argtype & ARGTYPE_HIDDEN))
  1529. printf(" %-18.18s %s%-.50s %s\n",
  1530. ap->argstring,
  1531. (ap->argtype & ARGTYPE_TYPEMASK) ==
  1532. ARGTYPE_BOOL ? "(0/1) " : "",
  1533. ap->helpstring,
  1534. (ap->argtype & ARGTYPE_REQUIRED)?"(required)":"");
  1535. }
  1536. }
  1537. xfree(svp);
  1538. return;
  1539. }
  1540. /*
  1541. * Additional information for V1.
  1542. * Output format type at front of line.
  1543. */
  1544. static void
  1545. disp_v1(ff_type t)
  1546. {
  1547. const char* tstring;
  1548. switch (t) {
  1549. case ff_type_file:
  1550. tstring = "file";
  1551. break;
  1552. case ff_type_serial:
  1553. tstring = "serial";
  1554. break;
  1555. case ff_type_internal:
  1556. tstring = "internal";
  1557. break;
  1558. default:
  1559. tstring = "unknown";
  1560. break;
  1561. }
  1562. printf("%s\t", tstring);
  1563. }
  1564. static void
  1565. disp_v2(ff_vecs_t* v)
  1566. {
  1567. int i;
  1568. for (i = 0; i < 3; i++) {
  1569. putchar(v->cap[i] & ff_cap_read ? 'r' : '-');
  1570. putchar(v->cap[i] & ff_cap_write ? 'w' : '-');
  1571. }
  1572. putchar('\t');
  1573. }
  1574. const char*
  1575. name_option(long type)
  1576. {
  1577. const char* at[] = {
  1578. "unknown",
  1579. "integer",
  1580. "float",
  1581. "string",
  1582. "boolean",
  1583. "file",
  1584. "outfile"
  1585. };
  1586. if ((type & ARGTYPE_TYPEMASK) <= 6) {
  1587. return at[type & ARGTYPE_TYPEMASK];
  1588. }
  1589. return at[0];
  1590. }
  1591. static
  1592. void disp_help_url(const vecs_t* vec, arglist_t* arg)
  1593. {
  1594. printf("\t" WEB_DOC_DIR "/fmt_%s.html", vec->name);
  1595. if (arg) {
  1596. printf("#fmt_%s_o_%s",vec->name, arg->argstring);
  1597. }
  1598. printf("\n");
  1599. }
  1600. static void
  1601. disp_v3(const vecs_t* vec)
  1602. {
  1603. arglist_t* ap;
  1604. disp_help_url(vec, NULL);
  1605. for (ap = vec->vec->args; ap && ap->argstring; ap++) {
  1606. if (!(ap->argtype & ARGTYPE_HIDDEN)) {
  1607. printf("option\t%s\t%s\t%s\t%s\t%s\t%s\t%s",
  1608. vec->name,
  1609. ap->argstring,
  1610. ap->helpstring,
  1611. name_option(ap->argtype),
  1612. ap->defaultvalue? ap->defaultvalue : "",
  1613. ap->minvalue? ap->minvalue : "",
  1614. ap->maxvalue? ap->maxvalue : "");
  1615. }
  1616. disp_help_url(vec, ap);
  1617. printf("\n");
  1618. }
  1619. }
  1620. /*
  1621. * Display the available formats in a format that's easy to machine
  1622. * parse. Typically invoked by programs like graphical wrappers to
  1623. * determine what formats are supported.
  1624. */
  1625. void
  1626. disp_formats(int version)
  1627. {
  1628. vecs_t** svp;
  1629. vecs_t* vec;
  1630. int i, vc = 0;
  1631. switch (version) {
  1632. case 0:
  1633. case 1:
  1634. case 2:
  1635. case 3:
  1636. svp = sort_and_unify_vecs(&vc);
  1637. for (i=0; i<vc; i++,vec++) {
  1638. vec = svp[i];
  1639. /* Version 1 displays type at front of all types.
  1640. * Version 0 skips internal types.
  1641. */
  1642. if (version > 0) {
  1643. disp_v1(vec->vec->type);
  1644. } else {
  1645. if (vec->vec->type == ff_type_internal) {
  1646. continue;
  1647. }
  1648. }
  1649. if (version >= 2) {
  1650. disp_v2(vec->vec);
  1651. }
  1652. printf("%s\t%s\t%s%s%s\n", vec->name,
  1653. vec->extension? vec->extension : "",
  1654. vec->desc,
  1655. version >= 3 ? "\t" : "",
  1656. version >= 3 ? vec->parent : "");
  1657. if (version >= 3) {
  1658. disp_v3(vec);
  1659. }
  1660. }
  1661. xfree(svp);
  1662. break;
  1663. default:
  1664. ;
  1665. }
  1666. }