diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 36 |
1 files changed, 30 insertions, 6 deletions
@@ -23,6 +23,7 @@ #include <stdlib.h> #include <string.h> #include "game.h" +#include "locale.h" #include "output.h" #include "xml.h" @@ -214,6 +215,7 @@ _db_game_xml_game_el_start(void *pv, const char *name, const char **attr) XML_Parser p; struct db_game *game; char *lang; + char *lc_messages; db_dbg(" <%s> (game child)", name); @@ -226,26 +228,48 @@ _db_game_xml_game_el_start(void *pv, const char *name, const char **attr) if (lang == NULL) { return; } - db_dbg(" lang=\"%s\"", lang); + lc_messages = strdup(db_lc_messages_get()); + db_dbg(" lang=\"%s\" (looking for \"%s\")", + lang, lc_messages); + if (strcasecmp(lang, lc_messages) == 0) { + goto name_ok; + } + db_xml_node_push(p, game, _db_game_xml_invalid_start, + _db_game_xml_name_end, + NULL); + goto name_err; + name_ok: game->xml_parsing = DB_GAME_XML_PARSING_NAME; - /* TODO */ - free(lang); db_xml_node_push(p, game, _db_game_xml_invalid_start, _db_game_xml_name_end, _db_game_xml_cdata); + name_err: + free(lang); + free(lc_messages); } else if (db_xml_check_tag(name, "description")) { lang = NULL; db_xml_get_string_attr(p, attr, "lang", &lang, 1); if (lang == NULL) { return; } - db_dbg(" lang=\"%s\"", lang); + lc_messages = strdup(db_lc_messages_get()); + db_dbg(" lang=\"%s\" (looking for \"%s\")", + lang, lc_messages); + if (strcasecmp(lang, lc_messages) == 0) { + goto desc_ok; + } + db_xml_node_push(p, game, _db_game_xml_invalid_start, + _db_game_xml_description_end, + NULL); + goto desc_err; + desc_ok: game->xml_parsing = DB_GAME_XML_PARSING_DESCRIPTION; - /* TODO */ - free(lang); db_xml_node_push(p, game, _db_game_xml_invalid_start, _db_game_xml_description_end, _db_game_xml_cdata); + desc_err: + free(lang); + free(lc_messages); } else if (db_xml_check_tag(name, "levels")) { db_xml_node_push(p, game, _db_game_xml_levels_el_start, _db_game_xml_levels_end, NULL); |