static int mp3_get_info(struct music_info *info) { if (info->type & MD_GET_CURTIME) { info->cur_time = g_play_time; } if (info->type & MD_GET_CPUFREQ) { if (use_me) { if (mp3_data.use_buffer) info->psp_freq[0] = 49; else info->psp_freq[0] = 33; info->psp_freq[1] = 16; } else { info->psp_freq[0] = 66 + (133 - 66) * g_info.avg_bps / 1000 / 320; info->psp_freq[1] = 111; } } if (info->type & MD_GET_DECODERNAME) { if (use_me) { STRCPY_S(info->decoder_name, "mp3"); } else { STRCPY_S(info->decoder_name, "madmp3"); } } if (info->type & MD_GET_ENCODEMSG) { if (config.show_encoder_msg && mp3info.lame_encoded) { char lame_method[80]; switch (mp3info.lame_mode) { case ABR: STRCPY_S(lame_method, "ABR"); break; case CBR: STRCPY_S(lame_method, "CBR"); break; case VBR: SPRINTF_S(lame_method, "VBR V%1d", mp3info.lame_vbr_quality); break; default: break; } if (mp3info.lame_str[strlen(mp3info.lame_str) - 1] == ' ') SPRINTF_S(info->encode_msg, "%s%s", mp3info.lame_str, lame_method); else SPRINTF_S(info->encode_msg, "%s %s", mp3info.lame_str, lame_method); } else { info->encode_msg[0] = '\0'; } } if (info->type & MD_GET_INSKBPS) { info->ins_kbps = get_inst_bitrate(&g_inst_br) / 1000; } return generic_get_info(info); }
extern bool conf_load(p_conf conf) { conf_default(conf); if (ini_conf_load(conf_filename, conf) == false) return false; /* if (conf->confver != XREADER_VERSION_NUM) conf_default(conf); */ #ifndef ENABLE_USB conf->enableusb = false; #endif #ifndef ENABLE_BG STRCPY_S(conf->bgfile, ""); STRCPY_S(conf->bgarch, ""); conf->bgwhere = scene_in_dir; #endif #ifndef ENABLE_MUSIC conf->autoplay = false; conf->hprmctrl = true; #else #ifndef ENABLE_LYRIC conf->lyricex = 0; #endif #endif ini_conf_save(conf); return true; }
/** * 得到TTA音乐文件相关信息 * * @param pinfo 信息结构体指针 * * @return */ static int tta_get_info(struct music_info *pinfo) { generic_get_info(pinfo); if (pinfo->type & MD_GET_TITLE) { if (g_info.tag.title[0] == '\0') { pinfo->encode = conf_encode_gbk; STRCPY_S(pinfo->title, (const char *) ttainfo.ID3.title); } } if (pinfo->type & MD_GET_ARTIST) { if (g_info.tag.artist[0] == '\0') { pinfo->encode = conf_encode_gbk; STRCPY_S(pinfo->artist, (const char *) ttainfo.ID3.artist); } } if (pinfo->type & MD_GET_ALBUM) { if (g_info.tag.album[0] == '\0') { pinfo->encode = conf_encode_gbk; STRCPY_S(pinfo->album, (const char *) ttainfo.ID3.album); } } if (pinfo->type & MD_GET_CURTIME) { pinfo->cur_time = g_play_time; } if (pinfo->type & MD_GET_CPUFREQ) { #ifdef _DEBUG pinfo->psp_freq[0] = 222; #else pinfo->psp_freq[0] = 111; #endif pinfo->psp_freq[1] = pinfo->psp_freq[0] / 2; } if (pinfo->type & MD_GET_FREQ) { pinfo->freq = ttainfo.SAMPLERATE; } if (pinfo->type & MD_GET_CHANNELS) { pinfo->channels = ttainfo.NCH; } if (pinfo->type & MD_GET_AVGKBPS) { pinfo->avg_kbps = ttainfo.BITRATE; } if (pinfo->type & MD_GET_DECODERNAME) { STRCPY_S(pinfo->decoder_name, "tta"); } if (pinfo->type & MD_GET_ENCODEMSG) { if (config.show_encoder_msg && g_status != ST_UNKNOWN) { SPRINTF_S(pinfo->encode_msg, "%s: %.2f", _("压缩率"), ttainfo.COMPRESS); } else { pinfo->encode_msg[0] = '\0'; } } return 0; }
int generic_get_info(struct music_info *info) { if (info->type & MD_GET_TITLE) { info->encode = g_info.tag.encode; if (info->encode != conf_encode_ucs) STRCPY_S(info->title, g_info.tag.title); else memcpy(info->title, g_info.tag.title, sizeof(info->title)); } if (info->type & MD_GET_ALBUM) { info->encode = g_info.tag.encode; if (info->encode != conf_encode_ucs) STRCPY_S(info->album, g_info.tag.album); else memcpy(info->album, g_info.tag.album, sizeof(info->album)); } if (info->type & MD_GET_ARTIST) { info->encode = g_info.tag.encode; if (info->encode != conf_encode_ucs) STRCPY_S(info->artist, g_info.tag.artist); else memcpy(info->artist, g_info.tag.artist, sizeof(info->artist)); } if (info->type & MD_GET_COMMENT) { info->encode = g_info.tag.encode; if (info->encode != conf_encode_ucs) STRCPY_S(info->comment, g_info.tag.comment); else memcpy(info->comment, g_info.tag.comment, sizeof(info->comment)); } if (info->type & MD_GET_DURATION) { info->duration = g_info.duration; } if (info->type & MD_GET_FREQ) { info->freq = g_info.sample_freq; } if (info->type & MD_GET_CHANNELS) { info->channels = g_info.channels; } if (info->type & MD_GET_AVGKBPS) { info->avg_kbps = g_info.avg_bps / 1000; } return 0; }
BOOL CXTPEyeDropper::SetClipboardText(LPCTSTR lpszClipText) { if (::OpenClipboard(m_hWnd)) { ::EmptyClipboard(); HGLOBAL hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, (_tcslen(lpszClipText) + 1) * sizeof(TCHAR)); if (!hGlobal) return FALSE; LPTSTR lpszGlobal = (LPTSTR)::GlobalLock(hGlobal); STRCPY_S(lpszGlobal, _tcslen(lpszClipText) + 1, lpszClipText); ::GlobalUnlock(hGlobal); #ifdef _UNICODE HANDLE hData = ::SetClipboardData(CF_UNICODETEXT, hGlobal); #else HANDLE hData = ::SetClipboardData(CF_TEXT, hGlobal); #endif ::CloseClipboard(); return (hData != NULL); } return FALSE; }
bool save_passwords(void) { password *pwd; SceUID fd; char path[PATH_MAX]; u32 magic; STRCPY_S(path, scene_appdir()); STRCAT_S(path, "password.lst"); rc4_prepare_key((u8 *) CRYPT_KEY, sizeof(CRYPT_KEY) - 1, &g_key); fd = sceIoOpen(path, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777); if (fd < 0) { return false; } magic = CRYPT_MAGIC; sceIoWrite(fd, &magic, sizeof(magic)); for (pwd = g_pwd_head.next; pwd != NULL; pwd = pwd->next) { write_chars(fd, pwd->b->ptr, strlen(pwd->b->ptr)); write_chars(fd, "\r\n", sizeof("\r\n") - 1); } sceIoClose(fd); return true; }
void CXTPTabPaintManager::SetFontIndirect(LOGFONT* pLogFont, BOOL bUseStandardFont /*= FALSE*/) { m_bUseStandardFont = bUseStandardFont; if (!pLogFont) return; if (m_bClearTypeTextQuality && XTPSystemVersion()->IsClearTypeTextQualitySupported()) { pLogFont->lfQuality = 5; } m_fntNormal.DeleteObject(); m_fntBold.DeleteObject(); m_fntVerticalNormal.DeleteObject(); m_fntVerticalBold.DeleteObject(); pLogFont->lfWeight = m_bBoldNormal ? FW_BOLD : FW_NORMAL; VERIFY(m_fntNormal.CreateFontIndirect(pLogFont)); pLogFont->lfWeight = FW_BOLD; VERIFY(m_fntBold.CreateFontIndirect(pLogFont)); STRCPY_S(pLogFont->lfFaceName, LF_FACESIZE, CXTPDrawHelpers::GetVerticalFontName(FALSE)); pLogFont->lfOrientation = 900; pLogFont->lfEscapement = 2700; pLogFont->lfHeight = pLogFont->lfHeight < 0 ? __min(-11, pLogFont->lfHeight) : pLogFont->lfHeight; pLogFont->lfWeight = m_bBoldNormal ? FW_BOLD : FW_NORMAL; VERIFY(m_fntVerticalNormal.CreateFontIndirect(pLogFont)); pLogFont->lfWeight = FW_BOLD; VERIFY(m_fntVerticalBold.CreateFontIndirect(pLogFont)); }
VOID ACLStr::_UpperCase ( IN LPCTSTR strToFind, IN OUT LPTSTR upperFind, IN const int sizeUpperFind, IN OUT LPTSTR internalBuff, IN const int sizeInternalBuff ) { // First copy the buffer sent to us to the new // uppercase buffer. STRCPY_S(upperFind, sizeUpperFind, strToFind); AnsiUpper(upperFind); // Now copy the internal ACLStr buffer to the new // tempory Upper case version. if (_string) { STRCPY_S(internalBuff, sizeInternalBuff, _string); AnsiUpper(internalBuff); } } // _UpperCase
bool CXTPShellListCtrlEx::BrowseToFolder(LPCTSTR lpszPath) { XTP_TVITEMDATA lpTVID; LPITEMIDLIST pidl; LPSHELLFOLDER pDesktopFolder; OLECHAR szOleChar[MAX_PATH]; ULONG chEaten; ULONG dwAttributes; HRESULT hr; // Get a pointer to the Desktop's IShellFolder interface. if (SUCCEEDED(::SHGetDesktopFolder(&pDesktopFolder))) { // IShellFolder::ParseDisplayName requires the file name be in // Unicode. #if !defined(_UNICODE) ::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszPath, -1, szOleChar, MAX_PATH); #else STRCPY_S(szOleChar, MAX_PATH, lpszPath); #endif // Convert the path to an ITEMIDLIST. hr = pDesktopFolder->ParseDisplayName(NULL, NULL, szOleChar, &chEaten, &pidl, &dwAttributes); if (SUCCEEDED(hr)) { IShellFolder *psfMyFolder; lpTVID.lpi = lpTVID.lpifq = pidl; pDesktopFolder->BindToObject(lpTVID.lpifq, NULL, IID_IShellFolder, (LPVOID*)&psfMyFolder); lpTVID.lpsfParent = psfMyFolder; PopulateListView(&lpTVID, lpTVID.lpsfParent); m_strItemPath = lpszPath; pDesktopFolder->Release(); return true; } pDesktopFolder->Release(); } return false; }
void filename_to_itemname(p_win_menuitem item, const char *filename) { if ((item->width = strlen(filename)) > MAX_ITEM_NAME_LEN) { mbcsncpy_s(((unsigned char *) item->name), MAX_ITEM_NAME_LEN - 2, ((const unsigned char *) filename), -1); if (strlen(item->name) < MAX_ITEM_NAME_LEN - 3) { mbcsncpy_s(((unsigned char *) item->name), MAX_ITEM_NAME_LEN, ((const unsigned char *) filename), -1); STRCAT_S(item->name, ".."); } else STRCAT_S(item->name, "..."); item->width = MAX_ITEM_NAME_LEN; } else { STRCPY_S(item->name, filename); } }
// P R I V A T E M E T H O D S int ACLStr::_FindCh ( IN const TCHAR charToFind, IN BOOL caseSensitive /*=TRUE*/, IN BOOL reverseFind /*=FALSE*/ ) { LPTSTR string = NULL; TCHAR ib[MAX_STRING]; // Initialize this to the // internal buffer. LPTSTR ibPtr = _string; TCHAR chToFind = charToFind; // If the internal string is NULL or the lenght is // zero then we will just bail and say we couldn't // find the string we were searching for. if (ibPtr != NULL || 0 != _length) { if (caseSensitive == TRUE) { chToFind = TOUPPER(charToFind); // Now copy the internal ACLStr buffer to the new // tempory Upper case version. if (_string) { // NOTE: STRCPY_S(target, length, source) - The length parameter is for // the length of the target string, not the source string. STRCPY_S(ib, MAX_STRING, _string); AnsiUpper(ib); ibPtr = ib; } } // case sensitive search? // Go look for the starting point of the string. // if we do NOT find it return STR_NOTFOUND if (reverseFind == TRUE) { string = STRRCHR(ibPtr, chToFind); } else { string = STRCHR(ibPtr, chToFind); } } // search string NULL? return (string == NULL) ? STR_NOTFOUND : (int)(string - ibPtr); } // ::_FindCh
void readMP3ApeTag(const char *spath) { APETag *tag = apetag_load(spath); if (tag != NULL) { char *title = apetag_get(tag, "Title"); char *artist = apetag_get(tag, "Artist"); char *album = apetag_get(tag, "Album"); if (title) { STRCPY_S(g_info.tag.title, title); free(title); title = NULL; } if (artist) { STRCPY_S(g_info.tag.artist, artist); free(artist); artist = NULL; } else { artist = apetag_get(tag, "Album artist"); if (artist) { STRCPY_S(g_info.tag.artist, artist); free(artist); artist = NULL; } } if (album) { STRCPY_S(g_info.tag.album, album); free(album); album = NULL; } apetag_free(tag); g_info.tag.encode = conf_encode_utf8; } }
crGetLastErrorMsgA(LPSTR pszBuffer, UINT uBuffSize) { if(pszBuffer==NULL || uBuffSize==0) return -1; strconv_t strconv; WCHAR* pwszBuffer = new WCHAR[uBuffSize]; int res = crGetLastErrorMsgW(pwszBuffer, uBuffSize); LPCSTR paszBuffer = strconv.w2a(pwszBuffer); STRCPY_S(pszBuffer, uBuffSize, paszBuffer); delete [] pwszBuffer; return res; }
void CXTPSyntaxEditPropertiesPageFont::OnSelChangeComboNames() { if (!m_wndComboName.GetListBox().SelChanged()) return; if (GetLBText(m_wndComboName, m_csName) == CB_ERR) return; LOGFONT lf = {0}; if (!GetSafeLogFont(lf)) return; STRCPY_S(lf.lfFaceName, m_csName.GetLength() + 1, m_csName); if (CreateSafeFontIndirect(m_editFont, lf)) { UpdateSampleFont(); InitSizeCombo(); InitScriptCombo(); SetModified(TRUE); } }
static int add_parent_to_menu(p_win_menu menu, u32 icolor, u32 selicolor, u32 selrcolor, u32 selbcolor) { t_win_menuitem item; if (menu == NULL) { return -1; } win_menuitem_new(&item); STRCPY_S(item.name, "<..>"); buffer_copy_string(item.compname, ".."); buffer_copy_string(item.shortname, ".."); item.data = (void *) fs_filetype_dir; item.width = 4; item.selected = false; item.icolor = icolor; item.selicolor = selicolor; item.selrcolor = selrcolor; item.selbcolor = selbcolor; win_menu_add(menu, &item); return 0; }
VOID ACLStr::_Grow(IN const size_t appendSize) { // If the string doesn't need growing then // just bail. if (appendSize) { size_t strSize(Len()); // Check to see if we've run out of room, remember the // string is padded by xxx bytes. Where xxx is the next // eight byte boundry if (_realLength <= (_length+appendSize)) { size_t newRealLength(0); LPTSTR newString(NULL); size_t newLength(__Alloc(strSize+appendSize, &newString, &newRealLength)); if (newString && newLength && newRealLength) { MEMSET(newString, 0, newRealLength); STRCPY_S(newString, newRealLength, _string); ARRAY_DELETE(_string); _string = newString; _length = newLength; _realLength = newRealLength; } } else { // If the append size is less than the size of // the REAL buffer size then don't worry about // growing the buffer. Just tell this string // that its' size is now larger. _length = (strSize+appendSize); } } } // ::grow
bool load_passwords(void) { SceUID fd; char linebuf[LINEBUF], path[PATH_MAX]; rc4_key *pkey; STRCPY_S(path, scene_appdir()); STRCAT_S(path, "password.lst"); if (is_encrypted(path)) { rc4_prepare_key((u8 *) CRYPT_KEY, sizeof(CRYPT_KEY) - 1, &g_key); pkey = &g_key; } else { pkey = NULL; } fd = sceIoOpen(path, PSP_O_RDONLY, 0); if (fd < 0) { return false; } if (pkey != NULL) { sceIoLseek(fd, 4, PSP_SEEK_SET); } linebuf[sizeof(linebuf) - 1] = '\0'; while (read_lines(fd, linebuf, sizeof(linebuf) - 1, pkey) >= 0) { add_password(linebuf); } sceIoClose(fd); return true; }
static int scene_reloadimage(dword selidx) { int result; reset_image_ptr(); if (where == scene_in_zip || where == scene_in_chm || where == scene_in_rar) STRCPY_S(filename, filelist[selidx].compname->ptr); else { STRCPY_S(filename, config.shortpath); STRCAT_S(filename, filelist[selidx].shortname->ptr); } if (config.use_image_queue) { result = cache_get_image(selidx); } else { result = open_image(selidx); } if (result != 0) { report_image_error(result); return -1; } // already calc brightness in cacher if (!config.use_image_queue && config.imgbrightness != 100) { recalc_brightness(); } STRCPY_S(config.lastfile, filelist[selidx].compname->ptr); STRCPY_S(prev_path, config.path); STRCPY_S(prev_shortpath, config.shortpath); STRCPY_S(prev_lastfile, filelist[selidx].compname->ptr); prev_where = where; oldangle = 0; return 0; }
int vpbp_dread(SceUID fd, SceIoDirent * dir) { int result, cur_idx, ret; struct IoDirentEntry *entry; lock(); entry = dirent_search(fd); if(entry == NULL) { result = -44; goto exit; } result = sceIoDread(entry->iso_dfd, dir); if(sceKernelFindModuleByName("Game_Categories_Light") == NULL) { while(result > 0 && !is_iso(dir)) { result = sceIoDread(entry->iso_dfd, dir); } } if (result > 0 && is_iso(dir)) { VirtualPBP *vpbp; vpbp = vpbp_realloc(g_vpbps, g_vpbps_cnt+1); if(vpbp == NULL) { result = -42; goto exit; } g_vpbps = vpbp; g_vpbps_cnt++; cur_idx = g_vpbps_cnt-1; vpbp = &g_vpbps[cur_idx]; STRCPY_S(vpbp->name, entry->path); vpbp->name[4] = '\0'; STRCAT_S(vpbp->name, "/ISO"); STRCAT_S(vpbp->name, entry->path + sizeof("xxx:/PSP/GAME") - 1); STRCAT_S(vpbp->name, "/"); STRCAT_S(vpbp->name, dir->d_name); memcpy(&vpbp->ctime, &dir->d_stat.st_ctime, sizeof(vpbp->ctime)); memcpy(&vpbp->mtime, &dir->d_stat.st_mtime, sizeof(vpbp->mtime)); ret = get_cache(vpbp->name, &vpbp->mtime, vpbp); if (ret < 0) { ret = build_vpbp(vpbp); if (ret < 0) { result = -43; goto exit; } } result = add_fake_dirent(dir, cur_idx); } exit: unlock(); return result; }
static int mp3_load(const char *spath, const char *lpath) { int ret; __init(); dbg_printf(d, "%s: loading %s", __func__, spath); g_status = ST_UNKNOWN; mp3_data.use_buffer = true; mp3_data.fd = xrIoOpen(spath, PSP_O_RDONLY, 0777); if (mp3_data.fd < 0) return -1; g_info.filesize = xrIoLseek(mp3_data.fd, 0, PSP_SEEK_END); xrIoLseek(mp3_data.fd, 0, PSP_SEEK_SET); mp3_data.size = g_info.filesize; if (g_info.filesize < 0) return g_info.filesize; xrIoLseek(mp3_data.fd, 0, PSP_SEEK_SET); mad_stream_init(&stream); mad_frame_init(&frame); mad_synth_init(&synth); if (use_me) { if ((ret = me_init()) < 0) { dbg_printf(d, "me_init failed: %d", ret); use_me = false; } } mp3info.check_crc = check_crc; mp3info.have_crc = false; if (use_brute_method) { if (read_mp3_info_brute(&mp3info, &mp3_data) < 0) { __end(); return -1; } } else { if (read_mp3_info(&mp3info, &mp3_data) < 0) { __end(); return -1; } } g_info.channels = mp3info.channels; g_info.sample_freq = mp3info.sample_freq; g_info.avg_bps = mp3info.average_bitrate; g_info.samples = mp3info.frames; g_info.duration = mp3info.duration; generic_readtag(&g_info, spath); if (mp3_data.use_buffer) { SceOff cur = xrIoLseek(mp3_data.fd, 0, PSP_SEEK_CUR); xrIoClose(mp3_data.fd); mp3_data.fd = -1; mp3_data.r = buffered_reader_open(spath, g_io_buffer_size, 1); if (mp3_data.r == NULL) { __end(); return -1; } buffered_reader_seek(mp3_data.r, cur); } dbg_printf(d, "[%d channel(s), %d Hz, %.2f kbps, %02d:%02d%sframes %d%s]", g_info.channels, g_info.sample_freq, g_info.avg_bps / 1000, (int) (g_info.duration / 60), (int) g_info.duration % 60, mp3info.frameoff != NULL ? ", frame table, " : ", ", g_info.samples, mp3info.have_crc ? ", crc passed" : ""); #ifdef _DEBUG if (mp3info.lame_encoded) { char lame_method[80]; char encode_msg[80]; switch (mp3info.lame_mode) { case ABR: STRCPY_S(lame_method, "ABR"); break; case CBR: STRCPY_S(lame_method, "CBR"); break; case VBR: SPRINTF_S(lame_method, "VBR V%1d", mp3info.lame_vbr_quality); break; default: break; } if (mp3info.lame_str[strlen(mp3info.lame_str) - 1] == ' ') SPRINTF_S(encode_msg, "%s%s", mp3info.lame_str, lame_method); else SPRINTF_S(encode_msg, "%s %s", mp3info.lame_str, lame_method); dbg_printf(d, "[ %s ]", encode_msg); } #endif ret = xAudioInit(); if (ret < 0) { __end(); return -1; } ret = xAudioSetFrequency(g_info.sample_freq); if (ret < 0) { __end(); return -1; } g_buff = xAudioAlloc(0, BUFF_SIZE); if (g_buff == NULL) { __end(); return -1; } if (use_me) xAudioSetChannelCallback(0, memp3_audiocallback, NULL); else xAudioSetChannelCallback(0, mp3_audiocallback, NULL); generic_lock(); g_status = ST_LOADED; generic_unlock(); return 0; }
extern u32 fs_list_device(const char *dir, const char *sdir, u32 icolor, u32 selicolor, u32 selrcolor, u32 selbcolor) { enum { PSP_GO = 4, }; t_win_menuitem item; strcpy_s((char *) sdir, 256, dir); if (menu_renew(&g_menu) == NULL) { return 0; } win_menuitem_new(&item); STRCPY_S(item.name, "<MemoryStick>"); buffer_copy_string(item.compname, "ms0:"); buffer_copy_string(item.shortname, "ms0:"); item.data = (void *) fs_filetype_dir; item.width = 13; item.selected = false; item.icolor = icolor; item.selicolor = selicolor; item.selrcolor = selrcolor; item.selbcolor = selbcolor; win_menu_add(g_menu, &item); if (config.hide_flash == false) { win_menuitem_new(&item); STRCPY_S(item.name, "<NandFlash 0>"); buffer_copy_string(item.compname, "flash0:"); item.data = (void *) fs_filetype_dir; item.width = 13; item.selected = false; item.icolor = icolor; item.selicolor = selicolor; item.selrcolor = selrcolor; item.selbcolor = selbcolor; win_menu_add(g_menu, &item); win_menuitem_new(&item); STRCPY_S(item.name, "<NandFlash 1>"); buffer_copy_string(item.compname, "flash1:"); item.data = (void *) fs_filetype_dir; item.width = 13; item.selected = false; item.icolor = icolor; item.selicolor = selicolor; item.selrcolor = selrcolor; item.selbcolor = selbcolor; win_menu_add(g_menu, &item); } #ifdef _DEBUG if(psp_model == PSP_GO) { win_menuitem_new(&item); STRCPY_S(item.name, "<Internal Memory>"); buffer_copy_string(item.compname, "ef0:"); buffer_copy_string(item.shortname, "ef0:"); item.data = (void *) fs_filetype_dir; item.width = sizeof("<Internal Memory>")-1; item.selected = false; item.icolor = icolor; item.selicolor = selicolor; item.selrcolor = selrcolor; item.selbcolor = selbcolor; win_menu_add(g_menu, &item); } #endif return g_menu->size; }
void CXTPMDIWndTab::RefreshTabLabels() { // Loop through all of the tabs to find the view that has activated. POSITION pos = m_arMDIChildern.GetHeadPosition(); while (pos != NULL) { bool bSetItem = false; MDICHILD* pMDIChild = m_arMDIChildern.GetNext(pos); ASSERT(pMDIChild != NULL); if (!pMDIChild) continue; // Get the window text for the child frame and the tab item. CString strWindowText = GetChildWndText(pMDIChild->hWnd); TCHAR szText[_MAX_PATH]; szText[0] = 0; TC_ITEM tci; tci.mask = TCIF_TEXT | TCIF_IMAGE; tci.cchTextMax = _countof(szText); tci.pszText = szText; // Get the item data for the tab. if (GetItem(pMDIChild->iItem, &tci)) { CString strTabLabel = szText; if (m_pTheme->GetThemeStyle() != xtpControlThemeOffice2000) { OnAddPadding(strWindowText); } // If they do not match then update the tab item label. if (strTabLabel != strWindowText) { STRCPY_S(szText, _MAX_PATH, strWindowText); tci.cchTextMax = strWindowText.GetLength(); bSetItem = true; } if (!m_bNoIcons) { // Check to see if the user set the icon for the tab label. HICON hIcon = 0; if (!m_mapTabIcons.Lookup(pMDIChild->hWnd, hIcon)) { // The user may have set the icon for the child by calling WM_SETICON. If // WM_GETICON returns an icon we need to make sure the tab icon has been updated. hIcon = (HICON)::SendMessage(pMDIChild->hWnd, WM_GETICON, FALSE, 0); // Insert the icon into map to avoid failed Lookup(). m_mapTabIcons.SetAt(pMDIChild->hWnd, hIcon); } // Replace the image in image list ONLY when Lookup() failed. if ((hIcon != NULL) && (tci.iImage != -1)) { bSetItem = true; m_imageList.Replace(tci.iImage, hIcon); } } if (bSetItem) { VERIFY(SetItem(pMDIChild->iItem, &tci)); } } } }
extern bool ini_conf_load(const char *inifilename, p_conf conf) { dictionary *dict; char buf[80]; int i; extern void get_language(void); if (conf == NULL || inifilename == NULL) { return false; } dict = iniparser_load(inifilename); if (dict == NULL) return false; conf_default(conf); STRCPY_S(conf->path, iniparser_getstring(dict, "Global:path", conf->path)); conf->forecolor = iniparser_getunsigned(dict, "UI:forecolor", conf->forecolor); conf->giftranscolor = iniparser_getunsigned(dict, "Image:giftranscolor", conf->giftranscolor); conf->bgcolor = iniparser_getunsigned(dict, "UI:bgcolor", conf->bgcolor); conf->have_bg = iniparser_getboolean(dict, "UI:have_bg", conf->have_bg); conf->titlecolor = iniparser_getunsigned(dict, "UI:titlecolor", conf->titlecolor); conf->menutextcolor = iniparser_getunsigned(dict, "UI:menutextcolor", conf->menutextcolor); conf->menubcolor = iniparser_getunsigned(dict, "UI:menubcolor", conf->menubcolor); conf->selicolor = iniparser_getunsigned(dict, "UI:selicolor", conf->selicolor); conf->selbcolor = iniparser_getunsigned(dict, "UI:selbcolor", conf->selbcolor); conf->msgbcolor = iniparser_getunsigned(dict, "UI:msgbcolor", conf->msgbcolor); conf->usedyncolor = iniparser_getboolean(dict, "UI:usedyncolor", conf->usedyncolor); conf->rowspace = iniparser_getint(dict, "Text:rowspace", conf->rowspace); conf->infobar = stringToInfobar(iniparser_getstring (dict, "Text:infobar", infobarToString(buf, sizeof(buf), conf->infobar))); conf->infobar_style = iniparser_getint(dict, "Text:infobar_style", conf->infobar_style); conf->infobar_fontsize = iniparser_getunsigned(dict, "Text:infobar_fontsize", conf->infobar_fontsize); conf->rlastrow = iniparser_getboolean(dict, "Text:rlastrow", conf->rlastrow); conf->autobm = iniparser_getboolean(dict, "Text:autobm", conf->autobm); conf->vertread = stringToVertread(iniparser_getstring (dict, "Text:vertread", vertreadToString(buf, sizeof(buf), conf->vertread))); conf->encode = stringToEncode(iniparser_getstring (dict, "Text:encode", encodeToString(buf, sizeof(buf), conf->encode))); conf->fit = stringToFit(iniparser_getstring (dict, "Image:fit", fitToString(buf, sizeof(buf), conf->fit))); conf->imginfobar = iniparser_getboolean(dict, "Image:imginfobar", conf->imginfobar); conf->scrollbar = iniparser_getboolean(dict, "Text:scrollbar", conf->scrollbar); conf->scale = iniparser_getint(dict, "Image:scale", conf->scale); conf->rotate = stringToRotate(iniparser_getstring (dict, "Image:rotate", rotateToString(buf, sizeof(buf), conf->rotate))); for (i = 0; i < 20; ++i) { char key[20]; SPRINTF_S(key, "Text:txtkey1_%02d", i); conf->txtkey[i] = iniparser_getint(dict, key, conf->txtkey[i]); SPRINTF_S(key, "Image:imgkey1_%02d", i); conf->imgkey[i] = iniparser_getint(dict, key, conf->imgkey[i]); } check_empty_imgkey(conf); STRCPY_S(conf->shortpath, iniparser_getstring(dict, "Global:shortpath", conf->shortpath)); conf->confver = iniparser_getint(dict, "Global:confver", conf->confver); conf->bicubic = iniparser_getboolean(dict, "Image:bicubic", conf->bicubic); conf->wordspace = iniparser_getint(dict, "Text:wordspace", conf->wordspace); conf->borderspace = iniparser_getunsigned(dict, "Text:borderspace", conf->borderspace); STRCPY_S(conf->lastfile, iniparser_getstring(dict, "Global:lastfile", conf->lastfile)); conf->mp3encode = stringToEncode(iniparser_getstring (dict, "Music:mp3encode", encodeToString(buf, sizeof(buf), conf->mp3encode))); conf->lyricencode = stringToEncode(iniparser_getstring (dict, "Music:lyricencode", encodeToString(buf, sizeof(buf), conf->lyricencode))); conf->mp3cycle = stringToCycle(iniparser_getstring (dict, "Music:mp3cycle", cycleToString(buf, sizeof(buf), conf->mp3cycle))); conf->isreading = iniparser_getboolean(dict, "Global:isreading", conf->isreading); STRCPY_S(conf->bgarch, iniparser_getstring(dict, "UI:bgarch", conf->bgarch)); STRCPY_S(conf->bgfile, iniparser_getstring(dict, "UI:bgfile", conf->bgfile)); conf->bgwhere = iniparser_getint(dict, "UI:bgwhere", conf->bgwhere); conf->slideinterval = iniparser_getint(dict, "Image:slideinterval", conf->slideinterval); conf->hprmctrl = iniparser_getboolean(dict, "Music:hprmctrl", conf->hprmctrl); conf->grayscale = iniparser_getint(dict, "UI:grayscale", conf->grayscale); conf->showhidden = iniparser_getboolean(dict, "Global:showhidden", conf->showhidden); conf->showunknown = iniparser_getboolean(dict, "Global:showunknown", conf->showunknown); conf->showfinfo = iniparser_getboolean(dict, "Global:showfinfo", conf->showfinfo); conf->allowdelete = iniparser_getboolean(dict, "Global:allowdelete", conf->allowdelete); conf->arrange = stringToArrange(iniparser_getstring (dict, "Global:arrange", arrangeToString(buf, sizeof(buf), conf->arrange))); conf->enableusb = iniparser_getboolean(dict, "Global:enableusb", conf->enableusb); conf->viewpos = stringToViewpos(iniparser_getstring (dict, "Image:viewpos", viewposToString(buf, sizeof(buf), conf->viewpos))); conf->imgmvspd = iniparser_getint(dict, "Image:imgmvspd", conf->imgmvspd); conf->imgpaging = stringToImgpaging(iniparser_getstring (dict, "Image:imgpaging", imgpagingToString(buf, sizeof(buf), conf->imgpaging))); conf->imgpaging_spd = iniparser_getint(dict, "Image:imgpaging_spd", conf->imgpaging_spd); conf->imgpaging_interval = iniparser_getint(dict, "Image:imgpaging_interval", conf->imgpaging_interval); conf->imgpaging_duration = iniparser_getint(dict, "Image:imgpaging_duration", conf->imgpaging_duration); for (i = 0; i < 20; ++i) { char key[20]; SPRINTF_S(key, "Global:flkey1_%02d", i); conf->flkey[i] = iniparser_getint(dict, key, conf->flkey[i]); } conf->fontsize = iniparser_getint(dict, "UI:fontsize", conf->fontsize); conf->reordertxt = iniparser_getboolean(dict, "Text:reordertxt", conf->reordertxt); conf->pagetonext = iniparser_getboolean(dict, "Text:pagetonext", conf->pagetonext); conf->autopage = iniparser_getint(dict, "Text:autopage", conf->autopage); conf->prev_autopage = iniparser_getint(dict, "Text:prev_autopage", conf->prev_autopage); conf->autopagetype = iniparser_getint(dict, "Text:autopagetype", conf->autopagetype); conf->autolinedelay = iniparser_getint(dict, "Text:autolinedelay", conf->autolinedelay); conf->thumb = stringToThumb(iniparser_getstring (dict, "Image:thumb", thumbToString(buf, sizeof(buf), conf->thumb))); conf->bookfontsize = iniparser_getint(dict, "Text:bookfontsize", conf->bookfontsize); conf->enable_analog = iniparser_getboolean(dict, "Text:enable_analog", conf->enable_analog); conf->img_enable_analog = iniparser_getboolean(dict, "Image:img_enable_analog", conf->img_enable_analog); for (i = 0; i < 20; ++i) { char key[20]; SPRINTF_S(key, "Text:txtkey2_%02d", i); conf->txtkey2[i] = iniparser_getint(dict, key, conf->txtkey2[i]); SPRINTF_S(key, "Image:imgkey2_%02d", i); conf->imgkey2[i] = iniparser_getint(dict, key, conf->imgkey2[i]); SPRINTF_S(key, "Global:flkey2_%02d", i); conf->flkey2[i] = iniparser_getint(dict, key, conf->flkey2[i]); } conf->imgpagereserve = iniparser_getint(dict, "Image:imgpagereserve", conf->imgpagereserve); conf->lyricex = iniparser_getint(dict, "Music:lyricex", conf->lyricex); conf->autoplay = iniparser_getboolean(dict, "Music:autoplay", conf->autoplay); conf->usettf = iniparser_getboolean(dict, "Text:usettf", conf->usettf); STRCPY_S(conf->cttfarch, iniparser_getstring(dict, "Text:cttfarch", conf->cttfarch)); STRCPY_S(conf->cttfpath, iniparser_getstring(dict, "Text:cttfpath", conf->cttfpath)); STRCPY_S(conf->ettfarch, iniparser_getstring(dict, "Text:ettfarch", conf->ettfarch)); STRCPY_S(conf->ettfpath, iniparser_getstring(dict, "Text:ettfpath", conf->ettfpath)); for (i = 0; i < 3; ++i) { char key[20]; SPRINTF_S(key, "Global:freqs_%d", i); conf->freqs[i] = iniparser_getint(dict, key, conf->freqs[i]); } conf->imgbrightness = iniparser_getint(dict, "Image:imgbrightness", conf->imgbrightness); conf->dis_scrsave = iniparser_getboolean(dict, "Global:dis_scrsave", conf->dis_scrsave); conf->autosleep = iniparser_getint(dict, "Global:autosleep", conf->autosleep); conf->load_exif = iniparser_getboolean(dict, "Image:load_exif", conf->load_exif); conf->launchtype = iniparser_getint(dict, "Global:launchtype", conf->launchtype); conf->infobar_use_ttf_mode = iniparser_getboolean(dict, "Text:infobar_use_ttf_mode", conf->infobar_use_ttf_mode); conf->img_no_repeat = iniparser_getboolean(dict, "Image:no_repeat", conf->img_no_repeat); conf->hide_flash = iniparser_getboolean(dict, "Global:hide_flash", conf->hide_flash); conf->tabstop = iniparser_getunsigned(dict, "Text:tabstop", conf->tabstop); conf->apetagorder = iniparser_getboolean(dict, "Music:apetagorder", conf->apetagorder); STRCPY_S(conf->language, iniparser_getstring(dict, "UI:language", conf->language)); get_language(); conf->filelistwidth = iniparser_getint(dict, "UI:filelistwidth", conf->filelistwidth); if (conf->filelistwidth < 0 || conf->filelistwidth > 240) conf->filelistwidth = 160; conf->ttf_load_to_memory = iniparser_getboolean(dict, "Text:ttf_load_to_memory", conf->ttf_load_to_memory); conf->save_password = iniparser_getboolean(dict, "Global:save_password", conf->save_password); conf->scrollbar_width = iniparser_getint(dict, "Text:scrollbar_width", conf->scrollbar_width); conf->hide_last_row = iniparser_getboolean(dict, "Text:hide_last_row", conf->hide_last_row); conf->infobar_show_timer = iniparser_getboolean(dict, "Text:infobar_show_timer", conf->infobar_show_timer); conf->englishtruncate = iniparser_getboolean(dict, "Text:englishtruncate", conf->englishtruncate); conf->image_scroll_chgn_speed = iniparser_getboolean(dict, "Image:image_scroll_chgn_speed", conf->image_scroll_chgn_speed); conf->ttf_haste_up = iniparser_getboolean(dict, "Text:ttf_haste_up", conf->ttf_haste_up); conf->linenum_style = iniparser_getboolean(dict, "Text:linenum_style", conf->linenum_style); conf->infobar_align = stringToAlign(iniparser_getstring(dict, "Text:infobar_align", "")); STRCPY_S(conf->musicdrv_opts, iniparser_getstring(dict, "Music:musicdrv_opts", conf->musicdrv_opts)); conf->magnetic_scrolling = iniparser_getboolean(dict, "Image:magnetic_scrolling", conf->magnetic_scrolling); conf->use_image_queue = iniparser_getboolean(dict, "Image:use_image_queue", conf->use_image_queue); conf->max_cache_img = iniparser_getunsigned(dict, "Image:max_cache_img", conf->max_cache_img); conf->show_encoder_msg = iniparser_getboolean(dict, "Music:show_encoder_msg", conf->show_encoder_msg); if (conf->max_cache_img == 0) { conf->use_image_queue = false; } dictionary_del(dict); return true; }
extern void conf_set_file(const char *filename) { STRCPY_S(conf_filename, filename); }
static void conf_default(p_conf conf) { memset(conf, 0, sizeof(t_conf)); STRCPY_S(conf->path, "ms0:/"); STRCPY_S(conf->shortpath, "ms0:/"); STRCPY_S(conf->lastfile, ""); STRCPY_S(conf->bgarch, ""); STRCPY_S(conf->bgfile, scene_appdir()); STRCAT_S(conf->bgfile, "bg.png"); conf->bgwhere = scene_in_zip; conf->confver = XREADER_VERSION_NUM; conf->forecolor = 0xFFFFFFFF; conf->giftranscolor = 0xFFFFFFFF; conf->bgcolor = 0; conf->have_bg = true; conf->rowspace = 2; conf->wordspace = 0; conf->borderspace = 0; conf->vertread = 0; conf->infobar = conf_infobar_info; conf->infobar_style = 0; conf->rlastrow = false; conf->autobm = true; conf->encode = conf_encode_gbk; conf->fit = conf_fit_none; conf->imginfobar = false; conf->scrollbar = false; conf->scale = 0; conf->rotate = conf_rotate_0; conf->enable_analog = true; conf->img_enable_analog = true; conf->txtkey[0] = PSP_CTRL_SQUARE; conf->txtkey[1] = PSP_CTRL_LTRIGGER; conf->txtkey[2] = PSP_CTRL_RTRIGGER; conf->txtkey[3] = PSP_CTRL_UP | PSP_CTRL_CIRCLE; conf->txtkey[4] = PSP_CTRL_DOWN | PSP_CTRL_CIRCLE; conf->txtkey[5] = PSP_CTRL_LEFT | PSP_CTRL_CIRCLE; conf->txtkey[6] = PSP_CTRL_RIGHT | PSP_CTRL_CIRCLE; conf->txtkey[7] = PSP_CTRL_LTRIGGER | PSP_CTRL_CIRCLE; conf->txtkey[8] = PSP_CTRL_RTRIGGER | PSP_CTRL_CIRCLE; conf->txtkey[9] = 0; conf->txtkey[10] = 0; conf->txtkey[11] = PSP_CTRL_CROSS; conf->txtkey[12] = PSP_CTRL_TRIANGLE; conf->imgkey[0] = PSP_CTRL_LTRIGGER; conf->imgkey[1] = PSP_CTRL_RTRIGGER; conf->imgkey[2] = PSP_CTRL_TRIANGLE; conf->imgkey[3] = PSP_CTRL_UP | PSP_CTRL_CIRCLE; conf->imgkey[4] = PSP_CTRL_DOWN | PSP_CTRL_CIRCLE; conf->imgkey[5] = PSP_CTRL_LEFT | PSP_CTRL_CIRCLE; conf->imgkey[6] = PSP_CTRL_RIGHT | PSP_CTRL_CIRCLE; conf->imgkey[7] = PSP_CTRL_SQUARE; conf->imgkey[8] = PSP_CTRL_CIRCLE; conf->imgkey[9] = PSP_CTRL_CROSS; conf->imgkey[10] = PSP_CTRL_LTRIGGER | PSP_CTRL_CIRCLE; conf->imgkey[11] = 0; conf->imgkey[12] = PSP_CTRL_UP; conf->imgkey[13] = PSP_CTRL_DOWN; conf->imgkey[14] = PSP_CTRL_LEFT; conf->imgkey[15] = PSP_CTRL_RIGHT; conf->flkey[0] = PSP_CTRL_CIRCLE; conf->flkey[1] = PSP_CTRL_LTRIGGER; conf->flkey[2] = PSP_CTRL_RTRIGGER; conf->flkey[3] = PSP_CTRL_CROSS; conf->flkey[4] = 0; conf->flkey[5] = PSP_CTRL_TRIANGLE; conf->flkey[6] = PSP_CTRL_SQUARE; conf->flkey[7] = PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER; conf->bicubic = false; conf->mp3encode = conf_encode_gbk; conf->lyricencode = conf_encode_gbk; conf->mp3cycle = conf_cycle_repeat; conf->isreading = false; conf->slideinterval = 5; conf->hprmctrl = false; conf->grayscale = 30; conf->showhidden = true; conf->showunknown = true; conf->showfinfo = true; conf->allowdelete = true; conf->arrange = conf_arrange_name; conf->enableusb = false; conf->viewpos = conf_viewpos_leftup; conf->imgmvspd = 8; conf->imgpaging = conf_imgpaging_direct; conf->imgpaging_spd = 8; conf->imgpaging_interval = 10; conf->imgpaging_duration = 10; conf->fontsize = 12; conf->bookfontsize = 12; conf->reordertxt = false; conf->pagetonext = false; conf->autopage = 0; conf->autopagetype = 2; conf->autolinedelay = 0; conf->thumb = conf_thumb_scroll; conf->imgpagereserve = 0; #if defined(ENABLE_MUSIC) && defined(ENABLE_LYRIC) conf->lyricex = 1; #else conf->lyricex = 0; #endif conf->autoplay = false; conf->usettf = 0; conf->freqs[0] = 1; conf->freqs[1] = 5; conf->freqs[2] = 8; conf->imgbrightness = 100; conf->dis_scrsave = false; conf->autosleep = 0; conf->load_exif = true; conf->prev_autopage = 2; conf->launchtype = 2; /* conf->titlecolor = RGB(0x80, 0x10, 0x10); conf->menutextcolor = RGB(0xDF, 0xDF, 0xDF); conf->menubcolor = RGB(0x40, 0x10, 0x10); conf->selicolor = RGB(0xFF, 0xFF, 0x40); conf->selbcolor = RGB(0x20, 0x20, 0xDF); conf->msgbcolor = RGB(0x18, 0x28, 0x50); */ conf->titlecolor = RGB(0x30, 0x60, 0x30); conf->menutextcolor = RGB(0xDF, 0xDF, 0xDF); conf->menubcolor = RGB(0x10, 0x30, 0x20); conf->selicolor = RGB(0xFF, 0xFF, 0x40); conf->selbcolor = RGB(0x20, 0x20, 0xDF); conf->msgbcolor = RGB(0x18, 0x28, 0x50); conf->usedyncolor = false; STRCPY_S(conf->cttfpath, scene_appdir()); STRCAT_S(conf->cttfpath, "fonts/gbk.ttf"); STRCPY_S(conf->ettfpath, scene_appdir()); STRCAT_S(conf->ettfpath, "fonts/asc.ttf"); conf->infobar_use_ttf_mode = true; conf->img_no_repeat = false; conf->hide_flash = true; conf->tabstop = 4; conf->apetagorder = true; STRCPY_S(conf->language, "zh_CN"); conf->filelistwidth = 160; if (kuKernelGetModel() == PSP_MODEL_STANDARD) { conf->ttf_load_to_memory = false; } else { conf->ttf_load_to_memory = true; } conf->save_password = true; conf->scrollbar_width = 5; conf->hide_last_row = false; conf->infobar_show_timer = true; conf->infobar_fontsize = 12; conf->englishtruncate = true; conf->image_scroll_chgn_speed = true; conf->ttf_haste_up = true; conf->linenum_style = false; conf->infobar_align = conf_align_left; conf->show_encoder_msg = false; SPRINTF_S(conf->musicdrv_opts, "mp3_brute_mode=off mp3_use_me=on mp3_check_crc=off mp3_buffer_size=%d " "wma_buffer_size=%d aac_buffer_size=%d wav_buffer_size=%d wv_buffer_size=%d " "aa3_buffer_size=%d at3_buffer_size=%d m4a_buffer_size=%d " "flac_buffer_size=%d", BUFFERED_READER_BUFFER_SIZE, BUFFERED_READER_BUFFER_SIZE, BUFFERED_READER_BUFFER_SIZE, BUFFERED_READER_BUFFER_SIZE, WVPACK_BUFFERED_READER_BUFFER_SIZE, BUFFERED_READER_BUFFER_SIZE, BUFFERED_READER_BUFFER_SIZE, BUFFERED_READER_BUFFER_SIZE, BUFFERED_READER_BUFFER_SIZE); conf->magnetic_scrolling = true; conf->use_image_queue = true; conf->max_cache_img = 10; }
int start_cache_next_image(void) { cache_image_t *p = NULL; cache_image_t tmp; t_fs_filetype ft; dword free_memory; int fid; if (avoid_times && curr_times++ < avoid_times) { // dbg_printf(d, "%s: curr_times %d avoid time %d", __func__, curr_times, avoid_times); return -1; } free_memory = get_free_mem(); if (config.scale >= 100) { if (free_memory < 8 * 1024 * 1024) { return -1; } } else if (free_memory < 1024 * 1024) { return -1; } cache_lock(); for (p = ccacher.caches; p != ccacher.caches + ccacher.caches_size; ++p) { if (p->status == CACHE_INIT || p->status == CACHE_FAILED) { break; } } // if we ecounter FAILED cache, abort the caching, because user will quit when the image shows up if (p == ccacher.caches + ccacher.caches_size || p->status == CACHE_FAILED) { cache_unlock(); return 0; } copy_cache_image(&tmp, p); cache_unlock(); ft = fs_file_get_type(tmp.filename); fid = freq_enter_hotzone(); if (tmp.where == scene_in_dir) { char fullpath[PATH_MAX]; STRCPY_S(fullpath, tmp.archname); STRCAT_S(fullpath, tmp.filename); tmp.result = image_open_archive(fullpath, tmp.archname, ft, &tmp.width, &tmp.height, &tmp.data, &tmp.bgc, tmp.where, &tmp.exif_array); } else { tmp.result = image_open_archive(tmp.filename, tmp.archname, ft, &tmp.width, &tmp.height, &tmp.data, &tmp.bgc, tmp.where, &tmp.exif_array); } if (tmp.result == 0 && tmp.data != NULL && config.imgbrightness != 100) { pixel *t = tmp.data; short b = 100 - config.imgbrightness; dword i; for (i = 0; i < tmp.height * tmp.width; i++) { *t = disp_grayscale(*t, 0, 0, 0, b); t++; } } freq_leave(fid); cache_lock(); for (p = ccacher.caches; p != ccacher.caches + ccacher.caches_size; ++p) { if (p->status == CACHE_INIT || p->status == CACHE_FAILED) { break; } } // recheck the first unloaded (and not failed) image, for we haven't locked cache for a while if (p == ccacher.caches + ccacher.caches_size || p->status == CACHE_FAILED) { free_cache_image(&tmp); cache_unlock(); return 0; } if (tmp.result == 0) { dword memory_used; memory_used = tmp.width * tmp.height * sizeof(pixel); // dbg_printf(d, "SERVER: Image %u finished loading", (unsigned)tmp.selidx); // dbg_printf(d, "%s: Memory usage %uKB", __func__, (unsigned) ccacher.memory_usage / 1024); ccacher.memory_usage += memory_used; cacher_cleared = false; tmp.status = CACHE_OK; copy_cache_image(p, &tmp); tmp.data = NULL; tmp.exif_array = NULL; free_cache_image(&tmp); curr_times = avoid_times = 0; } else if ((tmp.result == 4 || tmp.result == 5) || (tmp.where == scene_in_rar && tmp.result == 6)) { // out of memory // if unrar throwed a bad_cast exception when run out of memory, result can be 6 also. // is memory completely out of memory? if (ccacher.memory_usage == 0) { // dbg_printf(d, "SERVER: Image %u finished failed(%u), giving up", (unsigned)tmp.selidx, tmp.result); tmp.status = CACHE_FAILED; copy_cache_image(p, &tmp); p->data = NULL; p->exif_array = NULL; } else { // retry later // dbg_printf(d, "SERVER: Image %u finished failed(%u), retring", (unsigned)tmp.selidx, tmp.result); // dbg_printf(d, "%s: Memory usage %uKB", __func__, (unsigned) ccacher.memory_usage / 1024); if (avoid_times) { avoid_times *= 2; } else { avoid_times = 1; } avoid_times = min(avoid_times, 32767); curr_times = 0; } free_cache_image(&tmp); } else { // dbg_printf(d, "SERVER: Image %u finished failed(%u)", (unsigned)tmp.selidx, tmp.result); tmp.status = CACHE_FAILED; copy_cache_image(p, &tmp); p->data = NULL; p->exif_array = NULL; free_cache_image(&tmp); } cache_unlock(); return 0; }
extern void bookmark_init(const char *fn) { STRCPY_S(bmfile, fn); }
dword scene_imgkey(dword * selidx) { win_menu_predraw_data prev; t_win_menuitem item[16]; dword i, index; memcpy(&prev, &g_predraw, sizeof(win_menu_predraw_data)); STRCPY_S(item[0].name, _("上一张图")); STRCPY_S(item[1].name, _("下一张图")); STRCPY_S(item[2].name, _("缩放模式")); STRCPY_S(item[3].name, _("缩小图片")); STRCPY_S(item[4].name, _("放大图片")); STRCPY_S(item[5].name, _("左旋90度")); STRCPY_S(item[6].name, _("右旋90度")); STRCPY_S(item[7].name, _(" 信息栏")); STRCPY_S(item[8].name, _("显示信息")); STRCPY_S(item[9].name, _("退出浏览")); STRCPY_S(item[10].name, _("缩放引擎")); STRCPY_S(item[11].name, _("幻灯播放")); STRCPY_S(item[12].name, _("上")); STRCPY_S(item[13].name, _("下")); STRCPY_S(item[14].name, _("左")); STRCPY_S(item[15].name, _("右")); g_predraw.max_item_len = win_get_max_length(item, NELEMS(item)); for (i = 0; i < NELEMS(item); i++) { item[i].width = g_predraw.max_item_len; item[i].selected = false; item[i].icolor = config.menutextcolor; item[i].selicolor = config.selicolor; item[i].selrcolor = config.menubcolor; item[i].selbcolor = config.selbcolor; item[i].data = NULL; } if (DISP_FONTSIZE >= 14) g_predraw.item_count = 12; else g_predraw.item_count = NELEMS(item); g_predraw.x = 240; g_predraw.y = 123; g_predraw.left = g_predraw.x - DISP_FONTSIZE * g_predraw.max_item_len / 2; g_predraw.upper = g_predraw.y - DISP_FONTSIZE * g_predraw.item_count / 2; g_predraw.linespace = 0; while ((index = win_menu(g_predraw.left, g_predraw.upper, g_predraw.max_item_len, g_predraw.item_count, item, g_predraw.item_count, 0, g_predraw.linespace, config.usedyncolor ? get_bgcolor_by_time() : config. menubcolor, true, scene_imgkey_predraw, NULL, scene_imgkey_menucb)) != INVALID); memcpy(&g_predraw, &prev, sizeof(win_menu_predraw_data)); return 0; }