MCPcopy Create free account
hub / github.com/aldostools/webMAN-MOD / language

Function language

include/init/language.h:312–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310}
311
312static void language(const char *key_name, char *label, const char *default_str)
313{
314 u64 bytes_read = 0;
315 static size_t p = 0, lang_pos = 0, size = 0;
316 u8 c, i, key_len = strlen(key_name);
317
318 u8 check = 1;
319 u8 do_retry = 1;
320 char buffer[MAX_LINE_LEN];
321
322 if(!lang_roms) close_language();
323
324 retry:
325 if(lang_roms < LANG_CUSTOM) strcpy(label, default_str);
326
327 if(fh == 0)
328 {
329 char lang_path[48];
330
331 if(lang_roms == LANG_CUSTOM)
332 snprintf(lang_path, sizeof(lang_path), "%s/gamelist.txt", default_str);
333 else if(lang_roms)
334 {
335 concat_path(lang_path, WM_LANG_PATH, "LANG_ROMS.TXT");
336 if(not_exists(lang_path))
337 concat_path(lang_path, WM_LANG_PATH, "LANG_EMUS.TXT");
338 }
339 else
340 {
341 if(webman_config->lang >= LANG_XX && (webman_config->lang != LANG_CUSTOM)) webman_config->lang = 0;
342
343 const char *lang_codes[] = {"EN", "FR", "IT", "ES", "DE", "NL", "PT", "RU", "HU", "PL", "GR", "HR", "BG", "IN", "TR", "AR", "CN", "KR", "JP", "ZH", "DK", "CZ", "SK", "XX"};
344
345 i = webman_config->lang; if(i > LANG_XX) i = LANG_XX;
346
347 sprintf(lang_code, "_%.2s", lang_codes[i]);
348 sprintf(lang_path, "%s/LANG%s.TXT", WM_LANG_PATH, lang_code);
349 }
350
351 lang_pos = 0; size = file_size(lang_path); if(!size) return;
352
353 if(cellFsOpen(lang_path, CELL_FS_O_RDONLY, &fh, NULL, 0)) return;
354
355 cellFsLseek(fh, lang_pos, CELL_FS_SEEK_SET, NULL); p = CHUNK_SIZE; check = 1;
356 }
357
358 int fd = fh;
359
360 do {
361 for(i = 0; i < key_len;)
362 {
363 { GET_NEXT_BYTE }
364
365 // check if key is found at start of line
366 if (c == '\n') {check = 1; continue;}
367
368 if (check == 0) break;
369 if (check == 1)

Callers 15

setup_formFunction · 0.85
rom_aliasFunction · 0.85
update_languageFunction · 0.85
mount.hFile · 0.85
refresh.hFile · 0.85
stealth.hFile · 0.85
build_roms_xmlFunction · 0.85
eject_tableFunction · 0.85
setup_tableFunction · 0.85
ps2launcher_tableFunction · 0.85
psplauncher_tableFunction · 0.85
custom_tableFunction · 0.85

Calls 8

close_languageFunction · 0.85
concat_pathFunction · 0.85
file_sizeFunction · 0.85
strlenFunction · 0.50
strcpyFunction · 0.50
snprintfFunction · 0.50
not_existsFunction · 0.50
sprintfFunction · 0.50

Tested by

no test coverage detected