Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused shortname options #1239

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
90 changes: 73 additions & 17 deletions garmin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,82 @@


#define MYNAME "GARMIN"
static const char* portname;
static short_handle mkshort_handle;
static GPS_PWay* tx_waylist;
static GPS_PWay* tx_routelist;
static GPS_PWay* cur_tx_routelist_entry;
static GPS_PTrack* tx_tracklist;
static GPS_PTrack* cur_tx_tracklist_entry;
static int my_track_count = 0;
static char* getposn = nullptr;
static char* poweroff = nullptr;
static char* eraset = nullptr;
static char* resettime = nullptr;
static char* snlen = nullptr;
static char* deficon = nullptr;
static char* category = nullptr;
static char* categorybitsopt = nullptr;
static char* baudopt = nullptr;
static int baud = 0;
static int categorybits;
static int receiver_must_upper = 1;
static QTextCodec* codec{nullptr};

static Vecs::fmtinfo_t gpx_vec;

#define MILITANT_VALID_WAYPT_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"


QByteArray GarminFormat::str_from_unicode(const QString& qstr)
{
return codec->fromUnicode(qstr);
}
QString GarminFormat::str_to_unicode(const QByteArray& cstr)
{
return codec->toUnicode(cstr);
}

void
GarminFormat::write_char_string(char* dest, const char* source, size_t destsize)
/* Technically, even this is a little loose as spaces arent allowed */
static const char* valid_waypt_chars = MILITANT_VALID_WAYPT_CHARS " ";

static
QVector<arglist_t> garmin_args = {
{
"snlen", &snlen, "Length of generated shortnames", nullptr,
ARGTYPE_INT, "1", nullptr, nullptr
},
{ "deficon", &deficon, "Default icon name", nullptr, ARGTYPE_STRING, ARG_NOMINMAX, nullptr },
{
"get_posn", &getposn, "Return current position as a waypoint",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"power_off", &poweroff, "Command unit to power itself down",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"erase_t", &eraset, "Erase existing courses when writing new ones",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"resettime", &resettime, "Sync GPS time to computer time",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"category", &category, "Category number to use for written waypoints",
nullptr, ARGTYPE_INT, "1", "16", nullptr
},
{
"bitscategory", &categorybitsopt, "Bitmap of categories",
nullptr, ARGTYPE_INT, "1", "65535", nullptr
},
{
"baud", &baudopt, "Speed in bits per second of serial port (baud=9600)",
nullptr, ARGTYPE_INT, ARG_NOMINMAX, nullptr },

};

static const char* d103_symbol_from_icon_number(unsigned int n);
static int d103_icon_number_from_symbol(const QString& s);
static void garmin_fs_garmin_after_read(GPS_PWay way, Waypoint* wpt, int protoid);
static void garmin_fs_garmin_before_write(const Waypoint* wpt, GPS_PWay way, int protoid);

static QByteArray str_from_unicode(const QString& qstr) {return codec->fromUnicode(qstr);}
static QString str_to_unicode(const QByteArray& cstr) {return codec->toUnicode(cstr);}

static void
rw_init(const QString& fname)
{
// we zero fill and always terminate within the dest buffer.
strncpy(dest, source, destsize - 1);
Expand Down Expand Up @@ -205,7 +266,6 @@ GarminFormat::rw_init(const QString& fname)
case 786: /* HC model */
case 957: /* Legend HC */
receiver_short_length = 14;
snwhiteopt = xstrdup("1");
receiver_must_upper = false;
/* This might be 8859-1 */
receiver_charset = "windows-1252";
Expand Down Expand Up @@ -263,10 +323,6 @@ GarminFormat::rw_init(const QString& fname)
mkshort_handle->set_length(receiver_short_length);
}

if (snwhiteopt) {
mkshort_handle->set_whitespace_ok(xstrtoi(snwhiteopt, nullptr, 10));
}

/*
* Until Garmin documents how to determine valid character space
* for the new models, we just release this safety check manually.
Expand Down
98 changes: 81 additions & 17 deletions ozi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,86 @@
#define BADCHARS ",\r\n"
#define DAYS_SINCE_1990 25569

void
OziFormat::ozi_open_io(const QString& fname, QIODevice::OpenModeFlag mode)
struct ozi_fsdata : FormatSpecificData {
ozi_fsdata() : FormatSpecificData(kFsOzi) {}

ozi_fsdata* clone() const override
{
return new ozi_fsdata(*this);
}

int fgcolor{0};
int bgcolor{65535};
};

static gpsbabel::TextStream* stream = nullptr;

static short_handle mkshort_handle;
static route_head* trk_head;
static route_head* rte_head;

static int track_out_count;
static int route_out_count;
static int route_wpt_count;
static int new_track;

static char* snlenopt = nullptr;
static char* wptfgcolor = nullptr;
static char* wptbgcolor = nullptr;
static char* pack_opt = nullptr;
static int datum;
static char* proximityarg = nullptr;
static double proximity;
static char* altunit_opt;
static char* proxunit_opt;
static char altunit;
static char proxunit;
static double alt_scale;
static double prox_scale;
static char* opt_codec;

static
QVector<arglist_t> ozi_args = {
{
"pack", &pack_opt, "Write all tracks into one file",
nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
},
{
"snlen", &snlenopt, "Max synthesized shortname length",
"32", ARGTYPE_INT, "1", nullptr, nullptr
},
{
"wptfgcolor", &wptfgcolor, "Waypoint foreground color",
"black", ARGTYPE_STRING, ARG_NOMINMAX, nullptr
},
{
"wptbgcolor", &wptbgcolor, "Waypoint background color",
"yellow", ARGTYPE_STRING, ARG_NOMINMAX, nullptr
},
{
"proximity", &proximityarg, "Proximity distance",
"0", ARGTYPE_STRING, ARG_NOMINMAX, nullptr
},
{
"altunit", &altunit_opt, "Unit used in altitude values",
"feet", ARGTYPE_STRING, ARG_NOMINMAX, nullptr
},
{
"proxunit", &proxunit_opt, "Unit used in proximity values",
"miles", ARGTYPE_STRING, ARG_NOMINMAX, nullptr
},
{
"codec", &opt_codec, "codec to use for reading and writing strings (default windows-1252)",
"windows-1252", ARGTYPE_STRING, ARG_NOMINMAX, nullptr
},
};

static gpsdata_type ozi_objective;

static QString ozi_ofname;

static void
ozi_open_io(const QString& fname, QIODevice::OpenModeFlag mode)
{
stream = new gpsbabel::TextStream;
stream->open(fname, mode, MYNAME, opt_codec);
Expand Down Expand Up @@ -386,22 +464,8 @@ OziFormat::wr_init(const QString& fname)

/* set mkshort options from the command line if applicable */
if (global_opts.synthesize_shortnames) {

mkshort_handle->set_length(xstrtoi(snlenopt, nullptr, 10));

if (snwhiteopt) {
mkshort_handle->set_whitespace_ok(xstrtoi(snwhiteopt, nullptr, 10));
}

if (snupperopt) {
mkshort_handle->set_mustupper(xstrtoi(snupperopt, nullptr, 10));
}

if (snuniqueopt) {
mkshort_handle->set_mustuniq(xstrtoi(snuniqueopt, nullptr, 10));
}

mkshort_handle->set_badchars("\",");
setshort_badchars(mkshort_handle, "\",");
}

ozi_init_units(1);
Expand Down
Loading
Loading