static void _parse_config(struct querycache *cache, const char *elt) { struct game_config *config = (struct game_config *) cache->container; char *tag_name = get_info_first(elt, "<", " />", NULL); if (0 == strcmp(tag_name, "ui_menu_unlock")) { _parse_ui_menu_unlock(config, elt); } else if (0 == strcmp(tag_name, "rating_curve")) { _parse_rating_curve(config, elt); } else if (0 == strcmp(tag_name, "rating_season_rule")) { _parse_rating_season_rule(config, elt); } else if (0 == strcmp(tag_name, "ratingseason")) { _parse_ratingseason(config, elt); } else if (0 == strcmp(tag_name, "abuse_manager_config")) { _parse_abuse_manager_config(config, elt); } else if (0 == strcmp(tag_name, "consecutive_login_bonus")) { _parse_consecutive_login_bonus(config, elt); } else if (0 == strcmp(tag_name, "consecutive_login_bonus_holiday")) { _parse_consecutive_login_bonus_holiday(config, elt); } else if (0 == strcmp(tag_name, "profile_progression_config")) { _parse_profile_progression_config(config, elt); } else if (0 == strcmp(tag_name, "special_reward_configuration")) { _parse_special_reward_configuration(config, elt); } else if (0 == strcmp(tag_name, "votes")) { _parse_votes(config, elt); } else if (0 == strcmp(tag_name, "regions")) { _parse_regions(config, elt); } else { #ifdef DEBUG xprintf("FIXME: Unhandled config '%s'\n", tag_name); #endif /* DEBUG */ } free(tag_name); }
char *wf_compress_query(const char *iq) { if (iq == NULL) return NULL; size_t total_size = strlen(iq); if (total_size < MAX_PLAIN_QUERY_SIZE) return strdup(iq); char *query = get_info(iq, "urn:cryonline:k01'>", "</query>", NULL); if (query == NULL) { free(query); return strdup(iq); } char *query_name = get_info_first(query, "<", " />", NULL); if (query_name == NULL || 0 == strcmp(query_name, "data")) { free(query); free(query_name); return strdup(iq); } char *prologue = get_info(iq, "<", "urn:cryonline:k01'>", NULL); char *epilogue = get_info(iq, "</query>", "</iq>", NULL); if (prologue == NULL || epilogue == NULL) { free(query); free(query_name); free(prologue); free(epilogue); return strdup(iq); } size_t osize = strlen(query); char *compressed = zlibb64encode(query, osize); char *ret = NULL; FORMAT(ret, "<%surn:cryonline:k01'>" "<data query_name='%s'" " compressedData='%s'" " originalSize='%ld'" "/>" "</query>%s</iq>", prologue, query_name, compressed, osize, epilogue); free(query); free(prologue); free(epilogue); free(compressed); free(query_name); return ret; }
static void _parse_special_reward_configuration(struct game_config *config, const char *elt) { config->special_rewards.events = list_new((f_list_cmp) special_reward_event_cmp, (f_list_free) special_reward_event_free); const char *m2 = elt; while ((m2 = strstr(m2, "<event>"))) { char *event_node = get_info(m2, "<event ", "</event>", NULL); char *event_head = get_info(m2, "<event ", ">", NULL); struct special_reward_event *event = calloc(1, sizeof (struct special_reward_event)); char use_notification = 1; if (NULL != strstr(event_head, "use_notification=")) use_notification = get_info_int(event_head, "use_notification='", "'", NULL); else use_notification = 1; event->name = get_info(event_head, "name='", "'", NULL); event->rewards = list_new((f_list_cmp) special_reward_cmp, (f_list_free) special_reward_free); unsigned int i = 0; const char *m = event_node; while ((m = strstr(m, "<"))) { char *node = get_info(m, "<", "/>", NULL); char *node_name = get_info_first(m, "<", " />", NULL); char node_use_notification = 1; if (NULL != strstr(node, "use_notification=")) node_use_notification = get_info_int(node, "use_notification='", "'", NULL); else node_use_notification = use_notification; struct special_reward *reward = NULL; if (0 == strcmp(node_name, "item")) { struct special_reward_item *item = calloc(1, sizeof (struct special_reward_item)); reward = &item->base; item->base.type = SPECIAL_REWARD_ITEM; item->name = get_info(node, "name='", "'", NULL); item->expiration = get_info(node, "expiration='", "'", NULL); item->max_amount = get_info_int(node, "max_amount='", "'", NULL); item->amount = get_info_int(node, "amount='", "'", NULL); } else if (0 == strcmp(node_name, "money")) { struct special_reward_money *money = calloc(1, sizeof (struct special_reward_money)); reward = &money->base; money->base.type = SPECIAL_REWARD_MONEY; money->currency = get_info(node, "currency='", "'", NULL); money->amount = get_info_int(node, "amount='", "'", NULL); } else if (0 == strcmp(node_name, "achievement")) { struct special_reward_achievement *achievement = calloc(1, sizeof (struct special_reward_achievement)); reward = &achievement->base; achievement->base.type = SPECIAL_REWARD_ACHIEVEMENT; achievement->id = get_info_int(node, "id='", "'", NULL); achievement->progress = get_info_int(node, "progress='", "'", NULL); } else { #ifdef DEBUG xprintf("Unhandled special reward '%s'\n'", node_name); #endif /* DEBUG */ } if (reward != NULL) { reward->use_notification = node_use_notification; reward->id = i++; list_add(event->rewards, reward); } m += strlen(node); free(node); free(node_name); } list_add(config->special_rewards.events, event); m2 += strlen(event_node); free(event_node); free(event_head); } }