static void pfread(const PFTBL *item, const OEMCHAR *string) { switch(item->itemtype & PFTYPE_MASK) { case PFTYPE_ARGS16: inirdargs16(string, item); break; case PFTYPE_BYTE3: inirdbyte3(string, item); break; case PFTYPE_KB: inirdkb(string, item); break; } }
/** * コールバック * @param[in] item アイテム * @param[in] lpString 文字列 */ static void UserReadItem(const PFTBL* item, LPCTSTR lpString) { switch (item->itemtype & PFTYPE_MASK) { case PFTYPE_ARGS16: inirdargs16(lpString, item); break; case PFTYPE_BYTE3: inirdbyte3(lpString, item); break; case PFTYPE_KB: inirdkb(lpString, item); break; } }
/** * 設定読み出し * @param[in] lpPath パス * @param[in] lpTitle タイトル * @param[in] lpTable 設定テーブル * @param[in] nCount 設定テーブル アイテム数 */ void ini_read(LPCTSTR lpPath, LPCTSTR lpTitle, const PFTBL* lpTable, UINT nCount) { const PFTBL* p = lpTable; const PFTBL* pTerminate = p + nCount; while (p < pTerminate) { TCHAR szWork[512]; UINT32 val; switch (p->itemtype & PFTYPE_MASK) { case PFTYPE_STR: GetPrivateProfileString(lpTitle, p->item, static_cast<LPCTSTR>(p->value), static_cast<LPTSTR>(p->value), p->arg, lpPath); break; case PFTYPE_BOOL: GetPrivateProfileString(lpTitle, p->item, (*(static_cast<const UINT8*>(p->value))) ? str_true : str_false, szWork, NELEMENTS(szWork), lpPath); *(static_cast<UINT8*>(p->value)) = (!milstr_cmp(szWork, str_true)) ? 1 : 0; break; case PFTYPE_BITMAP: GetPrivateProfileString(lpTitle, p->item, (bitmapget(p->value, p->arg)) ? str_true : str_false, szWork, _countof(szWork), lpPath); bitmapset(p->value, p->arg, (milstr_cmp(szWork, str_true) == 0)); break; case PFTYPE_BIN: GetPrivateProfileString(lpTitle, p->item, str_null, szWork, _countof(szWork), lpPath); binset(p->value, p->arg, szWork); break; case PFTYPE_SINT8: case PFTYPE_UINT8: val = GetPrivateProfileInt(lpTitle, p->item, *(static_cast<const UINT8*>(p->value)), lpPath); *(static_cast<UINT8*>(p->value)) = static_cast<UINT8>(val); break; case PFTYPE_SINT16: case PFTYPE_UINT16: val = GetPrivateProfileInt(lpTitle, p->item, *(static_cast<const UINT16*>(p->value)), lpPath); *(static_cast<UINT16*>(p->value)) = static_cast<UINT16>(val); break; case PFTYPE_SINT32: case PFTYPE_UINT32: val = GetPrivateProfileInt(lpTitle, p->item, *(static_cast<const UINT32*>(p->value)), lpPath); *(static_cast<UINT32*>(p->value)) = static_cast<UINT32>(val); break; case PFTYPE_HEX8: wsprintf(szWork, str_x, *(static_cast<const UINT8*>(p->value))); GetPrivateProfileString(lpTitle, p->item, szWork, szWork, _countof(szWork), lpPath); *(static_cast<UINT8*>(p->value)) = static_cast<UINT8>(milstr_solveHEX(szWork)); break; case PFTYPE_HEX16: wsprintf(szWork, str_x, *(static_cast<const UINT16*>(p->value))); GetPrivateProfileString(lpTitle, p->item, szWork, szWork, _countof(szWork), lpPath); *(static_cast<UINT16*>(p->value)) = static_cast<UINT16>(milstr_solveHEX(szWork)); break; case PFTYPE_HEX32: wsprintf(szWork, str_x, *(static_cast<const UINT32*>(p->value))); GetPrivateProfileString(lpTitle, p->item, szWork, szWork, _countof(szWork), lpPath); *(static_cast<UINT32*>(p->value)) = static_cast<UINT32>(milstr_solveHEX(szWork)); break; case PFTYPE_ARGS16: GetPrivateProfileString(lpTitle, p->item, str_null, szWork, _countof(szWork), lpPath); inirdargs16(szWork, p); break; case PFTYPE_BYTE3: GetPrivateProfileString(lpTitle, p->item, str_null, szWork, _countof(szWork), lpPath); inirdbyte3(szWork, p); break; case PFTYPE_KB: GetPrivateProfileString(lpTitle, p->item, str_null, szWork, _countof(szWork), lpPath); inirdkb(szWork, p); break; } p++; } }
void ini_read(const OEMCHAR *path, const OEMCHAR *title, const PFTBL *tbl, UINT count) { const PFTBL *p; const PFTBL *pterm; OEMCHAR work[512]; UINT32 val; p = tbl; pterm = tbl + count; while(p < pterm) { switch(p->itemtype & PFTYPE_MASK) { case PFTYPE_STR: GetPrivateProfileString(title, p->item, (OEMCHAR *)p->value, (OEMCHAR *)p->value, p->arg, path); break; case PFTYPE_BOOL: GetPrivateProfileString(title, p->item, (*((UINT8 *)p->value))?str_true:str_false, work, NELEMENTS(work), path); *((UINT8 *)p->value) = (!milstr_cmp(work, str_true))?1:0; break; case PFTYPE_BITMAP: GetPrivateProfileString(title, p->item, (bitmapget((UINT8 *)p->value, p->arg))?str_true:str_false, work, NELEMENTS(work), path); bitmapset((UINT8 *)p->value, p->arg, (milstr_cmp(work, str_true) == 0)); break; case PFTYPE_BIN: GetPrivateProfileString(title, p->item, str_null, work, NELEMENTS(work), path); binset((UINT8 *)p->value, p->arg, work); break; case PFTYPE_SINT8: case PFTYPE_UINT8: val = (UINT8)GetPrivateProfileInt(title, p->item, *(UINT8 *)p->value, path); *(UINT8 *)p->value = (UINT8)val; break; case PFTYPE_SINT16: case PFTYPE_UINT16: val = (UINT16)GetPrivateProfileInt(title, p->item, *(UINT16 *)p->value, path); *(UINT16 *)p->value = (UINT16)val; break; case PFTYPE_SINT32: case PFTYPE_UINT32: val = (UINT32)GetPrivateProfileInt(title, p->item, *(UINT32 *)p->value, path); *(UINT32 *)p->value = (UINT32)val; break; case PFTYPE_HEX8: OEMSPRINTF(work, str_x, *(UINT8 *)p->value), GetPrivateProfileString(title, p->item, work, work, NELEMENTS(work), path); val = (UINT8)milstr_solveHEX(work); *(UINT8 *)p->value = (UINT8)val; break; case PFTYPE_HEX16: OEMSPRINTF(work, str_x, *(UINT16 *)p->value), GetPrivateProfileString(title, p->item, work, work, NELEMENTS(work), path); val = (UINT16)milstr_solveHEX(work); *(UINT16 *)p->value = (UINT16)val; break; case PFTYPE_HEX32: OEMSPRINTF(work, str_x, *(UINT32 *)p->value), GetPrivateProfileString(title, p->item, work, work, NELEMENTS(work), path); val = (UINT32)milstr_solveHEX(work); *(UINT32 *)p->value = (UINT32)val; break; case PFTYPE_ARGS16: GetPrivateProfileString(title, p->item, str_null, work, NELEMENTS(work), path); inirdargs16(work, p); break; case PFTYPE_BYTE3: GetPrivateProfileString(title, p->item, str_null, work, NELEMENTS(work), path); inirdbyte3(work, p); break; case PFTYPE_KB: GetPrivateProfileString(title, p->item, str_null, work, NELEMENTS(work), path); inirdkb(work, p); break; } p++; } }
static BOOL inireadcb(void *arg, const char *para, const char *key, const char *data) { const INITBL *p; char work[512]; if (arg == NULL) { return(FAILURE); } if (milstr_cmp(para, ((INIARG)arg)->title)) { return(SUCCESS); } p = ((INIARG)arg)->tbl; while(p < ((INIARG)arg)->tblterm) { if (!milstr_cmp(key, p->item)) { switch(p->itemtype) { case INITYPE_STR: milstr_ncpy((char *)p->value, data, p->size); break; case INITYPE_BOOL: *((BYTE *)p->value) = (!milstr_cmp(data, str_true))?1:0; break; case INITYPE_ARGS16: milstr_ncpy(work, data, sizeof(work)); inirdargs16(work, p); break; case INITYPE_BYTEARG: inirdarg8((BYTE *)p->value, p->size, data); break; case INITYPE_SINT8: case INITYPE_UINT8: *((BYTE *)p->value) = (BYTE)milstr_solveINT(data); break; case INITYPE_SINT16: case INITYPE_UINT16: *((UINT16 *)p->value) = (UINT16)milstr_solveINT(data); break; case INITYPE_SINT32: case INITYPE_UINT32: *((UINT32 *)p->value) = (UINT32)milstr_solveINT(data); break; case INITYPE_HEX8: *((BYTE *)p->value) = (BYTE)milstr_solveHEX(data); break; case INITYPE_HEX16: *((UINT16 *)p->value) = (UINT16)milstr_solveHEX(data); break; case INITYPE_HEX32: *((UINT32 *)p->value) = (UINT32)milstr_solveHEX(data); break; } } p++; } return(SUCCESS); }
static BRESULT inireadcb(void *arg, const char *para, const char *key, const char *data) { char work[512]; INITBL *p; BOOL rv; if (arg == NULL) { return(FAILURE); } if (milstr_cmp(para, ((INIARG)arg)->title)) { return(SUCCESS); } p = ((INIARG)arg)->tbl; while (p < ((INIARG)arg)->tblterm) { if (!milstr_cmp(key, p->item)) { rv = TRUE; switch (p->itemtype & INITYPE_MASK) { case INITYPE_STR: milstr_ncpy((char *)p->value, data, p->arg); break; case INITYPE_BOOL: *((UINT8 *)p->value) = (!milstr_cmp(data, str_true))?1:0; break; case INITYPE_BITMAP: inisetbmp((UINT8 *)p->value, p->arg, milstr_cmp(data, str_true) == 0); break; case INITYPE_ARGS16: milstr_ncpy(work, data, 512); inirdargs16(work, p); break; case INITYPE_ARGH8: milstr_ncpy(work, data, 512); inirdargh8(work, p); break; case INITYPE_SINT8: case INITYPE_UINT8: *((UINT8 *)p->value) = (UINT8)milstr_solveINT(data); break; case INITYPE_SINT16: case INITYPE_UINT16: *((UINT16 *)p->value) = (UINT16)milstr_solveINT(data); break; case INITYPE_SINT32: case INITYPE_UINT32: *((UINT32 *)p->value) = (UINT32)milstr_solveINT(data); break; case INITYPE_HEX8: *((UINT8 *)p->value) = (UINT8)milstr_solveHEX(data); break; case INITYPE_HEX16: *((UINT16 *)p->value) = (UINT16)milstr_solveHEX(data); break; case INITYPE_HEX32: *((UINT32 *)p->value) = (UINT32)milstr_solveHEX(data); break; case INITYPE_BYTE3: milstr_ncpy(work, data, 512); inirdbyte3(work, p); break; case INITYPE_KB: milstr_ncpy(work, data, 512); inirdkb(work, p); break; case INITYPE_SNDDRV: milstr_ncpy(work, data, 512); inirdsnddrv(work, p); break; case INITYPE_INTERP: milstr_ncpy(work, data, 512); inirdinterp(work, p); break; default: rv = FALSE; break; } if (rv) { update_iniread_flag(p); } } p++; } return (SUCCESS); }