const std::string &Resource::Get(const std::string &token) const { std::map<std::string,std::string>::const_iterator i = m_strings.find(token); if (i == m_strings.end()) { if(s_defaultLangResource->GetLangCode() != GetLangCode()) { return s_defaultLangResource->Get(token); } static const std::string empty; return empty; } return (*i).second; }
int main(int argc, char **argv) { int lastfail = 0; if(argc<4) { printf("getwiimsg v1.1 by yellowstar6.\n"); printf("Download Wii Message Board mail from server, decrypt, and dump to .eml and text files.\n"); printf("Local encrypted mail can be decrypted and dumped as well.\n"); printf("Internal KD WC24 AES key is needed.\n"); printf("Usage:\n"); printf("getwiimsg <country code number> <language code> <wc24msgboardkey.bin or wc24pubk.mod for title mail> <options> <optional list of\nalternate msg files to process from a server or locally>\n"); printf("language code can be one of the following: ja, en, de, fr, es, it, nl.\n"); printf("Options:\n"); printf("--cache: Cache the download, don't delete it before downloading and don't disable sending the If-Modified header. Default is no cache."); } else { unsigned int country_code, language_code, argi, index = 0, cache = 0, numoptions = 0; int retval; memset(str, 0, 256); sscanf(argv[1], "%d", &country_code); language_code = GetLangCode(argv[2]); if(argc>4) { for(argi=4; argi<argc; argi++) { if(strcmp(argv[argi], "--cache")==0) { cache = 1; numoptions++; } } } if(argc-numoptions==4) { for(argi=1; argi<5; argi++) { snprintf(str, 255, "wc24decrypt http://cfh.wapp.wii.com/announce/%03d/%d/%d.bin decrypt%d.txt %s", country_code, language_code, argi, index, argv[3]); if(cache)strncat(str, " --cache", 255); printf("%s\n", str); retval = WEXITSTATUS(system(str)); memset(str, 0, 256); if(retval!=0) { lastfail = retval; if(retval==34) { printf("Not modified.\n"); } else if(retval==44) { printf("Not found.\n"); } else { printf("HTTP fail.\n"); } } else { retval = ProcessMail(index); if(retval!=0)lastfail = retval; } index++; } } else if(argc-numoptions>4) { for(argi=4+numoptions; argi<argc; argi++) { snprintf(str, 255, "wc24decrypt %s decrypt%d.txt %s", argv[argi], index, argv[3]); if(cache)strncat(str, " --cache", 255); printf("%s\n", str); retval = WEXITSTATUS(system(str)); memset(str, 0, 256); if(retval!=0) { lastfail = retval; if(retval==34) { printf("Not modified.\n"); } else if(retval==44) { printf("Not found.\n"); } else { printf("HTTP fail.\n"); } } else { retval = ProcessMail(index); if(retval!=0)lastfail = retval; } index++; } } } return lastfail; }
bool CSettings::LoadLanguage(const char *path, int lang) { bool ret = false; if (path && strlen(path) > 3) { ret = gettextLoadLanguage(path); if (ret) { strlcpy(language_path, path, sizeof(language_path)); strlcpy(db_language, GetLangCode(language_path), sizeof(db_language)); } else return LoadLanguage(NULL, CONSOLE_DEFAULT); } else if (lang >= 0) { char filepath[150]; char langpath[150]; strlcpy(langpath, languagefiles_path, sizeof(langpath)); if (langpath[strlen(langpath) - 1] != '/') { char * ptr = strrchr(langpath, '/'); if (ptr) { ptr++; ptr[0] = '\0'; } } if (lang == CONSOLE_DEFAULT) { return LoadLanguage(NULL, CONF_GetLanguage()); } else if (lang == JAPANESE) { snprintf(filepath, sizeof(filepath), "%s/japanese.lang", langpath); } else if (lang == ENGLISH) { snprintf(filepath, sizeof(filepath), "%s/english.lang", langpath); } else if (lang == GERMAN) { snprintf(filepath, sizeof(filepath), "%s/german.lang", langpath); } else if (lang == FRENCH) { snprintf(filepath, sizeof(filepath), "%s/french.lang", langpath); } else if (lang == SPANISH) { snprintf(filepath, sizeof(filepath), "%s/spanish.lang", langpath); } else if (lang == ITALIAN) { snprintf(filepath, sizeof(filepath), "%s/italian.lang", langpath); } else if (lang == DUTCH) { snprintf(filepath, sizeof(filepath), "%s/dutch.lang", langpath); } else if (lang == S_CHINESE) { snprintf(filepath, sizeof(filepath), "%s/schinese.lang", langpath); } else if (lang == T_CHINESE) { snprintf(filepath, sizeof(filepath), "%s/tchinese.lang", langpath); } else if (lang == KOREAN) { snprintf(filepath, sizeof(filepath), "%s/korean.lang", langpath); } strlcpy(db_language, GetLangCode(filepath), sizeof(db_language)); ret = gettextLoadLanguage(filepath); if (ret) strlcpy(language_path, filepath, sizeof(language_path)); } return ret; }