static void metar_tok_pres (gchar *tokp, WeatherInfo *info) { if (*tokp == 'A') { gchar sintg[3], sfract[3]; gint intg, fract; strncpy (sintg, tokp + 1, 2); sintg[2] = 0; intg = atoi (sintg); strncpy (sfract, tokp + 3, 2); sfract[2] = 0; fract = atoi (sfract); info->pressure = (WeatherPressure)intg + (((WeatherPressure)fract)/100.0); } else { /* *tokp == 'Q' */ gchar spres[5]; gint pres; strncpy (spres, tokp + 1, 4); spres[4] = 0; pres = atoi (spres); info->pressure = PRESSURE_MBAR_TO_INCH ((WeatherPressure)pres); } }
static inline void read_pressure (GWeatherInfo *info, xmlNodePtr node) { xmlChar *unit; xmlChar *val; double hpa; /* hPa == mbar */ unit = xmlGetProp (node, XC("unit")); if (unit == NULL || strcmp ((char*)unit, "hPa")) return; val = xmlGetProp (node, XC("value")); if (val == NULL) return; hpa = g_ascii_strtod ((char*) val, NULL); info->priv->pressure = PRESSURE_MBAR_TO_INCH (hpa); }