示例#1
0
static void
write_waypt(const waypoint *wpt)
{
    unsigned char wpt_class;
    garmin_fs_p gmsd;
    char *wpt_type;
    char *dspl_mode;
    const char *country;
    double x;
    int i, icon, dynamic;
    char *icon_descr;

    gmsd = GMSD_FIND(wpt);

    i = GMSD_GET(display, 0);
    if (i > GT_DISPLAY_MODE_MAX) i = 0;
    dspl_mode = gt_display_mode_names[i];

    wpt_class = GMSD_GET(wpt_class, 0);
    if (wpt_class <= gt_waypt_class_map_line)
        wpt_type = gt_waypt_class_names[wpt_class];
    else
        wpt_type = gt_waypt_class_names[0];

    gbfprintf(fout, "Waypoint\t%s\t", (wpt->shortname) ? wpt->shortname : "");
    if (wpt_class <= gt_waypt_class_airport_ndb) {
        char *temp = wpt->notes;
        if (temp == NULL) {
            if (wpt->description && (strcmp(wpt->description, wpt->shortname) != 0))
                temp = wpt->description;
            else
                temp = "";
        }
        print_string("%s\t", temp);
    }
    else
        gbfprintf(fout, "\t");
    gbfprintf(fout, "%s\t", wpt_type);

    print_position(wpt);

    if IS_VALID_ALT(wpt->altitude)
        print_distance(wpt->altitude, 1, 0, 0);
    gbfprintf(fout, "\t");

    x = WAYPT_GET(wpt, depth, unknown_alt);
    if (x != unknown_alt)
        print_distance(x, 1, 0, 1);
    gbfprintf(fout, "\t");

    x = WAYPT_GET(wpt, proximity, unknown_alt);
    if (x != unknown_alt)
        print_distance(x, 0, 0, 0);
    gbfprintf(fout, "\t");

    x = WAYPT_GET(wpt, temperature, -999);
    if (x != -999)
        print_temperature(x);
    gbfprintf(fout, "\t%s\t", dspl_mode);

    gbfprintf(fout, "Unknown\t"); 				/* Color is fixed: Unknown */

    icon = GMSD_GET(icon, -1);
    if (icon == -1) {
        icon = gt_find_icon_number_from_desc(wpt->icon_descr, GDB);
    }
    icon_descr = gt_find_desc_from_icon_number(icon, GDB, &dynamic);
    print_string("%s\t", icon_descr);
    if (dynamic) xfree(icon_descr);

    print_string("%s\t", GMSD_GET(facility, ""));
    print_string("%s\t", GMSD_GET(city, ""));
    print_string("%s\t", GMSD_GET(state, ""));
    country = gt_get_icao_country(GMSD_GET(cc, ""));
    print_string("%s\t", (country != NULL) ? country : "");
    print_date_and_time(wpt->creation_time, 0);
    print_string("%s\t", wpt->url ? wpt->url : "");
    print_categories(GMSD_GET(category, 0));

    gbfprintf(fout, "\r\n");
}
示例#2
0
int main ()
{
    // compute and print the values of the LC_XXX constants
    // and their relationship to the std::locale::category
    // constants
    if (print_lc_constants ())
        return 0;

    // try to determine the format of combined locale names
    int  setlocale_environ    = 0;
    int  loc_name_use_cat     = 0;
    int  loc_name_prepend_sep = 0;
    int  loc_name_condense    = 0;
    char loc_name_cat_sep     = '\0';
    char loc_name_cat_eq      = '\0';

    char namebuf [MAX_LOCALE_NAME_LEN];
    namebuf [0] = '\0';

    // determine whether setlocale(LC_ALL, name) returns
    // a string containing the equivalent of `name' for
    // each LC_XXX category or whether it collapses all
    // equivalent names into just a single locale name
    const char *locname = setlocale (LC_ALL, "C");

    char *sep = locname ? rw_strpbrk (locname, cat_seps) : 0;
    if (sep) {
        if ('C' == sep [-1] && 1 == sep - locname)
            loc_name_cat_sep = *sep;
        else {
            loc_name_condense = 1;
            *rw_strchr (cat_seps, *sep) = '\n';
        }
    }
    else {
        loc_name_condense = 1;
    }

    // find the first valid locale name other than "C" or
    // the default locale returned by locale (LC_ALL, "")
    if ((locname = setlocale (LC_ALL, "")))
        strcpy (namebuf, locname);

    unsigned i;

    for (i = 0; i != nlocales; ++i) {

        locname = test_locale_names [i];

#if defined (_MSC_VER) && _MSC_VER <= 1200

        // work around an MSVC libc bug (PR #27990)
        if (rw_strpbrk (locname, ".-"))
            continue;

#endif   // MSVC <= 6.0

        locname = setlocale (LC_ALL, locname);
        if (locname && strcmp (namebuf, locname))
            break;
    }

    if (locname) {
        locname = strcpy (namebuf, locname);

        sep = rw_strpbrk (locname, cat_seps);
        if (sep)
            *sep = '\0';

        // determine if the environment has any effect on setlocale()
        {
            char def_locale [MAX_LOCALE_NAME_LEN];
            def_locale [0] = '\0';

            const char *tmpname = setlocale (LC_ALL, "");
            if (tmpname)
                strcpy (def_locale, tmpname);

            char buf [MAX_LOCALE_NAME_LEN];
            strcpy (buf, "LC_COLLATE=");
            strcat (buf, locname);
            putenv (buf);

            tmpname = setlocale (LC_ALL, "");
            setlocale_environ = tmpname ? strcmp (def_locale, tmpname) : 1;
        }
    }

    print_categories (locname,
                      setlocale_environ,
                      loc_name_use_cat,
                      loc_name_prepend_sep,
                      loc_name_condense,
                      loc_name_cat_sep,
                      loc_name_cat_eq);

    return print_locale_name_format (0 == locname,
                                     setlocale_environ,
                                     loc_name_use_cat,
                                     loc_name_prepend_sep,
                                     loc_name_condense,
                                     loc_name_cat_sep,
                                     loc_name_cat_eq);
}