mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 09:09:18 +01:00
nsysnet: Implement inet_ntop
This commit is contained in:
parent
0bead50065
commit
7886b594a2
@ -1581,7 +1581,7 @@ namespace coreinit
|
||||
return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask);
|
||||
}
|
||||
|
||||
FSA_RESULT __FSPrepareCmd_MakeDir(iosu::fsa::FSAShimBuffer* fsaShimBuffer, IOSDevHandle devHandle, const uint8* path, uint32 uknVal660)
|
||||
FSA_RESULT __FSPrepareCmd_MakeDir(iosu::fsa::FSAShimBuffer* fsaShimBuffer, IOSDevHandle devHandle, const char* path, uint32 uknVal660)
|
||||
{
|
||||
if (fsaShimBuffer == NULL)
|
||||
return FSA_RESULT::INVALID_BUFFER;
|
||||
@ -1608,7 +1608,7 @@ namespace coreinit
|
||||
return FSA_RESULT::OK;
|
||||
}
|
||||
|
||||
sint32 FSMakeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const uint8* dirPath, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams)
|
||||
sint32 FSMakeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* dirPath, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams)
|
||||
{
|
||||
// used by titles: XCX (via SAVEMakeDirAsync)
|
||||
_FSCmdIntro();
|
||||
@ -1625,7 +1625,7 @@ namespace coreinit
|
||||
return (FSStatus)FS_RESULT::SUCCESS;
|
||||
}
|
||||
|
||||
sint32 FSMakeDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const uint8* path, uint32 errorMask)
|
||||
sint32 FSMakeDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, uint32 errorMask)
|
||||
{
|
||||
StackAllocator<FSAsyncParamsNew_t> asyncParams;
|
||||
__FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams);
|
||||
@ -2092,7 +2092,7 @@ namespace coreinit
|
||||
return result;
|
||||
}
|
||||
|
||||
FSA_RESULT FSAMakeDir(FSAClientHandle client, const uint8* path, uint32 uknVal660)
|
||||
FSA_RESULT FSAMakeDir(FSAClientHandle client, const char* path, uint32 uknVal660)
|
||||
{
|
||||
if (!FSAShimCheckClientHandle(client))
|
||||
return FSA_RESULT::INVALID_CLIENT_HANDLE;
|
||||
|
@ -286,8 +286,8 @@ namespace coreinit
|
||||
sint32 FSRename(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* srcPath, char* dstPath, uint32 errorMask);
|
||||
sint32 FSRemoveAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* filePath, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams);
|
||||
sint32 FSRemove(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* filePath, uint32 errorMask);
|
||||
sint32 FSMakeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const uint8* dirPath, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams);
|
||||
sint32 FSMakeDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const uint8* path, uint32 errorMask);
|
||||
sint32 FSMakeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* dirPath, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams);
|
||||
sint32 FSMakeDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, uint32 errorMask);
|
||||
sint32 FSChangeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams);
|
||||
sint32 FSChangeDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask);
|
||||
sint32 FSGetCwdAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* dirPathOut, sint32 dirPathMaxLen, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams);
|
||||
|
@ -346,7 +346,7 @@ namespace save
|
||||
{
|
||||
char fullPath[SAVE_MAX_PATH_SIZE];
|
||||
if (GetAbsoluteFullPath(persistentId, path, fullPath))
|
||||
result = coreinit::FSMakeDirAsync(client, block, (uint8*)fullPath, errHandling, (FSAsyncParamsNew_t*)asyncParams);
|
||||
result = coreinit::FSMakeDirAsync(client, block, fullPath, errHandling, (FSAsyncParamsNew_t*)asyncParams);
|
||||
}
|
||||
else
|
||||
result = (FSStatus)FS_RESULT::NOT_FOUND;
|
||||
|
@ -55,6 +55,7 @@
|
||||
#define WU_SO_ECONNRESET 0x0008
|
||||
#define WU_SO_EINVAL 0x000B
|
||||
#define WU_SO_EINPROGRESS 0x0016
|
||||
#define WU_SO_EAFNOSUPPORT 0x0021
|
||||
|
||||
#define WU_SO_ESHUTDOWN 0x000F
|
||||
|
||||
@ -90,15 +91,12 @@ uint32* __gh_errno_ptr()
|
||||
|
||||
void _setSockError(sint32 errCode)
|
||||
{
|
||||
// todo -> Call __gh_errno_ptr and then write 32bit error code
|
||||
*(uint32*)__gh_errno_ptr() = _swapEndianU32(errCode);
|
||||
//coreinitData->ghsErrno = _swapEndianU32(errCode);
|
||||
*(uint32be*)__gh_errno_ptr() = (uint32)errCode;
|
||||
}
|
||||
|
||||
sint32 _getSockError()
|
||||
{
|
||||
return (sint32)_swapEndianU32(*(uint32*)__gh_errno_ptr());
|
||||
//return (sint32)_swapEndianU32(coreinitData->ghsErrno);
|
||||
return (sint32)*(uint32be*)__gh_errno_ptr();
|
||||
}
|
||||
|
||||
// error translation modes for _translateError
|
||||
@ -644,6 +642,16 @@ void nsysnetExport_getsockopt(PPCInterpreter_t* hCPU)
|
||||
*(uint32*)optval = _swapEndianU32(optvalLE);
|
||||
// used by Lost Reavers after some loading screens
|
||||
}
|
||||
else if (optname == WU_SO_NONBLOCK)
|
||||
{
|
||||
if (memory_readU32(optlenMPTR) != 4)
|
||||
assert_dbg();
|
||||
int optvalLE = 0;
|
||||
socklen_t optlenLE = 4;
|
||||
memory_writeU32(optlenMPTR, 4);
|
||||
*(uint32*)optval = _swapEndianU32(vs->isNonBlocking ? 1 : 0);
|
||||
r = WU_SO_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
cemu_assert_debug(false);
|
||||
@ -712,13 +720,10 @@ void nsysnetExport_inet_pton(PPCInterpreter_t* hCPU)
|
||||
invalidIp = true;
|
||||
if (d3 < 0 || d3 > 255)
|
||||
invalidIp = true;
|
||||
#ifdef CEMU_DEBUG_ASSERT
|
||||
if (invalidIp)
|
||||
assert_dbg();
|
||||
#endif
|
||||
if (invalidIp)
|
||||
{
|
||||
cemuLog_log(LogType::Socket, "inet_pton({}, \"{}\", 0x{:08x}) -> Invalid ip", af, ip, hCPU->gpr[5]);
|
||||
_setSockError(WU_SO_EAFNOSUPPORT);
|
||||
osLib_returnFromFunction(hCPU, 0); // 0 -> invalid address
|
||||
return;
|
||||
}
|
||||
@ -729,6 +734,32 @@ void nsysnetExport_inet_pton(PPCInterpreter_t* hCPU)
|
||||
osLib_returnFromFunction(hCPU, 1); // 1 -> success
|
||||
}
|
||||
|
||||
namespace nsysnet
|
||||
{
|
||||
const char* inet_ntop(sint32 af, const void* src, char* dst, uint32 size)
|
||||
{
|
||||
if( af != WU_AF_INET)
|
||||
{
|
||||
// set error
|
||||
_setSockError(WU_SO_EAFNOSUPPORT);
|
||||
return nullptr;
|
||||
}
|
||||
const uint8* ip = (const uint8*)src;
|
||||
char buf[32];
|
||||
sprintf(buf, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
size_t bufLen = strlen(buf);
|
||||
if( (bufLen+1) > size )
|
||||
{
|
||||
// set error
|
||||
_setSockError(WU_SO_EAFNOSUPPORT);
|
||||
return nullptr;
|
||||
}
|
||||
strcpy(dst, buf);
|
||||
cemuLog_log(LogType::Socket, "inet_ntop -> {}", buf);
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
|
||||
MEMPTR<char> _ntoa_tempString = nullptr;
|
||||
|
||||
void nsysnetExport_inet_ntoa(PPCInterpreter_t* hCPU)
|
||||
@ -2122,13 +2153,22 @@ namespace nsysnet
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace nsysnet
|
||||
{
|
||||
void Initialize()
|
||||
{
|
||||
cafeExportRegister("nsysnet", inet_ntop, LogType::Socket);
|
||||
}
|
||||
}
|
||||
|
||||
// register nsysnet functions
|
||||
void nsysnet_load()
|
||||
{
|
||||
|
||||
osLib_addFunction("nsysnet", "socket_lib_init", nsysnetExport_socket_lib_init);
|
||||
nsysnet::Initialize();
|
||||
|
||||
// the below code is the old way of registering API which is deprecated
|
||||
|
||||
osLib_addFunction("nsysnet", "socket_lib_init", nsysnetExport_socket_lib_init);
|
||||
osLib_addFunction("nsysnet", "socket_lib_finish", nsysnetExport_socket_lib_finish);
|
||||
|
||||
// socket API
|
||||
|
@ -48,52 +48,57 @@ TextureRelationViewerWindow::TextureRelationViewerWindow(wxFrame& parent)
|
||||
textureRelationListA->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "Courier New"));//wxSystemSettings::GetFont(wxSYS_OEM_FIXED_FONT));
|
||||
|
||||
// add columns
|
||||
wxListItem col0;
|
||||
wxListItem colType;
|
||||
sint32 columnIndex = 0;
|
||||
col0.SetId(columnIndex); columnIndex++;
|
||||
col0.SetText("Type");
|
||||
col0.SetWidth(85);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, col0);
|
||||
wxListItem col1;
|
||||
col1.SetId(columnIndex); columnIndex++;
|
||||
col1.SetText("PhysAddr");
|
||||
col1.SetWidth(80);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, col1);
|
||||
wxListItem col2;
|
||||
col2.SetId(columnIndex); columnIndex++;
|
||||
col2.SetText("Dim");
|
||||
col2.SetWidth(80);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, col2);
|
||||
wxListItem col3;
|
||||
col3.SetId(columnIndex); columnIndex++;
|
||||
col3.SetText("Resolution");
|
||||
col3.SetWidth(110);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, col3);
|
||||
wxListItem col5;
|
||||
col5.SetId(columnIndex); columnIndex++;
|
||||
col5.SetText("Format");
|
||||
col5.SetWidth(70);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, col5);
|
||||
wxListItem colPriority;
|
||||
colPriority.SetId(columnIndex); columnIndex++;
|
||||
colPriority.SetText("Pitch");
|
||||
colPriority.SetWidth(80);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, colPriority);
|
||||
wxListItem col6;
|
||||
col6.SetId(columnIndex); columnIndex++;
|
||||
col6.SetText("Tilemode");
|
||||
col6.SetWidth(80);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, col6);
|
||||
wxListItem col7;
|
||||
col7.SetId(columnIndex); columnIndex++;
|
||||
col7.SetText("SliceRange");
|
||||
col7.SetWidth(90);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, col7);
|
||||
wxListItem col8;
|
||||
col8.SetId(columnIndex); columnIndex++;
|
||||
col8.SetText("MipRange");
|
||||
col8.SetWidth(90);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, col8);
|
||||
colType.SetId(columnIndex); columnIndex++;
|
||||
colType.SetText("Type");
|
||||
colType.SetWidth(85);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, colType);
|
||||
wxListItem colPhysAddr;
|
||||
colPhysAddr.SetId(columnIndex); columnIndex++;
|
||||
colPhysAddr.SetText("PhysAddr");
|
||||
colPhysAddr.SetWidth(80);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, colPhysAddr);
|
||||
wxListItem colPhysMipAddr;
|
||||
colPhysMipAddr.SetId(columnIndex); columnIndex++;
|
||||
colPhysMipAddr.SetText("MipPAddr");
|
||||
colPhysMipAddr.SetWidth(80);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, colPhysMipAddr);
|
||||
wxListItem colDim;
|
||||
colDim.SetId(columnIndex); columnIndex++;
|
||||
colDim.SetText("Dim");
|
||||
colDim.SetWidth(80);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, colDim);
|
||||
wxListItem colResolution;
|
||||
colResolution.SetId(columnIndex); columnIndex++;
|
||||
colResolution.SetText("Resolution");
|
||||
colResolution.SetWidth(110);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, colResolution);
|
||||
wxListItem colFormat;
|
||||
colFormat.SetId(columnIndex); columnIndex++;
|
||||
colFormat.SetText("Format");
|
||||
colFormat.SetWidth(70);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, colFormat);
|
||||
wxListItem colPitch;
|
||||
colPitch.SetId(columnIndex); columnIndex++;
|
||||
colPitch.SetText("Pitch");
|
||||
colPitch.SetWidth(80);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, colPitch);
|
||||
wxListItem colTilemode;
|
||||
colTilemode.SetId(columnIndex); columnIndex++;
|
||||
colTilemode.SetText("Tilemode");
|
||||
colTilemode.SetWidth(80);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, colTilemode);
|
||||
wxListItem colSliceRange;
|
||||
colSliceRange.SetId(columnIndex); columnIndex++;
|
||||
colSliceRange.SetText("SliceRange");
|
||||
colSliceRange.SetWidth(90);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, colSliceRange);
|
||||
wxListItem colMipRange;
|
||||
colMipRange.SetId(columnIndex); columnIndex++;
|
||||
colMipRange.SetText("MipRange");
|
||||
colMipRange.SetWidth(90);
|
||||
textureRelationListA->InsertColumn(columnIndex-1, colMipRange);
|
||||
wxListItem colAge;
|
||||
colAge.SetId(columnIndex); columnIndex++;
|
||||
colAge.SetText("Last access");
|
||||
@ -186,10 +191,14 @@ void TextureRelationViewerWindow::_setTextureRelationListItemTexture(wxListCtrl*
|
||||
uiList->InsertItem(item);
|
||||
|
||||
sint32 columnIndex = 1;
|
||||
// phys address
|
||||
sprintf(tempStr, "%08X", texInfo->physAddress);
|
||||
uiList->SetItem(rowIndex, columnIndex, tempStr);
|
||||
columnIndex++;
|
||||
// phys address
|
||||
sprintf(tempStr, "%08X", texInfo->physAddress);
|
||||
uiList->SetItem(rowIndex, columnIndex, tempStr);
|
||||
columnIndex++;
|
||||
// phys mip address
|
||||
sprintf(tempStr, "%08X", texInfo->physMipAddress);
|
||||
uiList->SetItem(rowIndex, columnIndex, tempStr);
|
||||
columnIndex++;
|
||||
// dim
|
||||
if (texInfo->dim == Latte::E_DIM::DIM_2D)
|
||||
strcpy(tempStr, "2D");
|
||||
@ -278,10 +287,14 @@ void TextureRelationViewerWindow::_setTextureRelationListItemView(wxListCtrl* ui
|
||||
uiList->InsertItem(item);
|
||||
//uiList->SetItemPtrData(item, (wxUIntPtr)viewInfo);
|
||||
sint32 columnIndex = 1;
|
||||
// phys address
|
||||
sprintf(tempStr, "");
|
||||
uiList->SetItem(rowIndex, columnIndex, tempStr);
|
||||
columnIndex++;
|
||||
// phys address
|
||||
sprintf(tempStr, "");
|
||||
uiList->SetItem(rowIndex, columnIndex, tempStr);
|
||||
columnIndex++;
|
||||
// phys mip address
|
||||
sprintf(tempStr, "");
|
||||
uiList->SetItem(rowIndex, columnIndex, tempStr);
|
||||
columnIndex++;
|
||||
// dim
|
||||
if (viewInfo->dim == Latte::E_DIM::DIM_2D)
|
||||
strcpy(tempStr, "2D");
|
||||
|
Loading…
Reference in New Issue
Block a user