static int country_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) { struct country_search *this_=priv_data; struct country *country=this_->country; attr->type=attr_type; switch (attr_type) { case attr_any: while (this_->attr_next != attr_none) { if (country_attr_get(this_, this_->attr_next, attr)) return 1; } return 0; // Cast to char* necessary but safe, because our callers know // not to modify attr->u.str (hopefully). case attr_label: attr->u.str=(char*)navit_nls_gettext(country->name); this_->attr_next=attr_country_id; return 1; case attr_country_id: attr->u.num=country->id; this_->attr_next=country->car ? attr_country_car : attr_country_iso2; return 1; case attr_country_car: attr->u.str=(char*)country->car; this_->attr_next=attr_country_iso2; return attr->u.str ? 1 : 0; case attr_country_iso2: attr->u.str=(char*)country->iso2; this_->attr_next=attr_country_iso3; return 1; case attr_country_iso3: attr->u.str=(char*)country->iso3; this_->attr_next=attr_country_name; return 1; case attr_country_name: attr->u.str=(char*)navit_nls_gettext(country->name); this_->attr_next=attr_none; return 1; default: return 0; } }
static int country_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) { struct country_search *this_=priv_data; struct country *country=this_->country; attr->type=attr_type; switch (attr_type) { case attr_any: while (this_->attr_next != attr_none) { if (country_attr_get(this_, this_->attr_next, attr)) return 1; } return 0; case attr_label: attr->u.str=gettext(country->name); this_->attr_next=attr_country_id; return 1; case attr_country_id: attr->u.num=country->id; this_->attr_next=country->car ? attr_country_car : attr_country_iso2; return 1; case attr_country_car: attr->u.str=country->car; this_->attr_next=attr_country_iso2; return attr->u.str ? 1 : 0; case attr_country_iso2: attr->u.str=country->iso2; this_->attr_next=attr_country_iso3; return 1; case attr_country_iso3: attr->u.str=country->iso3; this_->attr_next=attr_country_name; return 1; case attr_country_name: attr->u.str=gettext(country->name); this_->attr_next=attr_none; return 1; default: return 0; } }