NWC24 fixes for USA and other versions (#2170)

* Fix NWC24StdAPI

* NWC24MsgCommit

* NWC24Download (99.80%!)

* address review
This commit is contained in:
ThePlayerRolo authored and GitHub committed 2026-10-24 17:30:56 -04:00
1 parent f3defb7b21
commit f11d55d6f8
4 files changed
+102 -30

No files matched your search

+3 -3
View File
@@ -2936,7 +2936,7 @@ config.libs = [
SDKLib_NWC24(
"nwc24",
[
Object(MatchingFor(KOR), "RVL_SDK/nwc24/NWC24StdAPI.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24StdAPI.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24FileAPI.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24Config.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24Utils.c"),
@@ -2945,7 +2945,7 @@ config.libs = [
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24MBoxCtrl.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24Mime.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24Parser.c"),
Object(MatchingFor(KOR), "RVL_SDK/nwc24/NWC24MsgCommit.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24MsgCommit.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24Schedule.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24DateParser.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24FriendList.c"),
@@ -2953,7 +2953,7 @@ config.libs = [
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24UserId.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24Time.c"),
Object(MatchingFor(KOR), "RVL_SDK/nwc24/NWC24Ipc.c"),
Object(MatchingFor(KOR), "RVL_SDK/nwc24/NWC24Download.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24Download.c"),
Object(MatchingFor(ALL), "RVL_SDK/nwc24/NWC24System.c"),
],
),
+16 -11
View File
@@ -36,14 +36,16 @@ NWC24Err NWC24CheckDlTask(const NWC24DlTask* pTask, BOOL wantWrite) {
return NWC24_ERR_LIB_NOT_OPENED;
}
if (pTaskImpl->appId == 0 || pTaskImpl->titleIdLo == 0) {
return NWC24_ERR_INVALID_VALUE;
}
if (wantWrite && !NWC24IsMsgLibOpenedByTool() && !IsMyApp(pTaskImpl->appId)) {
if (!IsGroupWritable(pTaskImpl->groupId, pTaskImpl->flags)) {
return NWC24_ERR_PROTECTED;
#if (VERSION == RMGK01)
if (pTaskImpl->appId == 0 || pTaskImpl->titleIdLo == 0) {
return NWC24_ERR_INVALID_VALUE;
}
}
if (wantWrite && !NWC24IsMsgLibOpenedByTool() && !IsMyApp(pTaskImpl->appId)) {
if (!IsGroupWritable(pTaskImpl->groupId, pTaskImpl->flags)) {
return NWC24_ERR_PROTECTED;
}
}
#endif
if (pTaskImpl->id != 0xFFFF && pTaskImpl->id >= pHeader->maxTasks) {
return NWC24_ERR_INVALID_VALUE;
}
@@ -74,10 +76,13 @@ NWC24Err NWC24DeleteDlTaskForced(NWC24DlTask* pTask) {
return result;
}
result = CheckDlEntryAvailable(pTaskImpl->id);
if (result < 0) {
return result;
}
#if (VERSION == RMGK01)
result = CheckDlEntryAvailable(pTaskImpl->id);
if (result < 0) {
return result;
}
#endif
result = DeleteDlTask(pTaskImpl);
if (result < 0) {
return result;
+63 -16
View File
@@ -101,11 +101,12 @@ NWC24Err NWC24CommitMsgInternal(NWC24iMsgObj* pMsg, NWC24MsgBoxId id) {
NWC24iSetErrorCode(NWC24_OK);
#if (VERSION == RMGK01)
err = CorrectHeadersForMBDelay(pMsg);
if (err != NWC24_OK) {
goto _exit;
}
#endif
err = CheckMsgObject(pMsg);
if (err != NWC24_OK) {
goto _exit;
@@ -456,7 +457,9 @@ static NWC24Err WriteSMTP_MAILFROM(NWC24iMsgObj* pMsg) {
u32 addrFlags;
u32 addrLen;
s32 totalLen;
s32 remainSize;
#if (VERSION == RMGK01)
s32 remainSize;
#endif
NWC24Err result;
totalLen = 0;
@@ -473,8 +476,13 @@ static NWC24Err WriteSMTP_MAILFROM(NWC24iMsgObj* pMsg) {
addrFlags = NWC24_MSGOBJ_FOR_PUBLIC;
}
remainSize = MSG_WORK_SIZE - (NWC24i_KSTRLEN("MAIL FROM: ") - 1) - (NWC24i_KSTRLEN("\r\n") - 1);
result = SynthesizeAddrStr(&pMsg->from, addrFlags, pWork, remainSize, &addrLen);
#if (VERSION == RMGJ01 || VERSION == RMGE01 || VERSION == RMGP01)
result = SynthesizeAddrStr(&pMsg->from, addrFlags, pWork, MSG_WORK_SIZE, &addrLen);
#elif (VERSION == RMGK01)
remainSize = MSG_WORK_SIZE - (NWC24i_KSTRLEN("MAIL FROM: ") - 1) - (NWC24i_KSTRLEN("\r\n") - 1);
result = SynthesizeAddrStr(&pMsg->from, addrFlags, pWork, remainSize, &addrLen);
#endif
if (result != NWC24_OK) {
return result;
}
@@ -483,10 +491,16 @@ static NWC24Err WriteSMTP_MAILFROM(NWC24iMsgObj* pMsg) {
*pWork++ = '\r';
*pWork++ = '\n';
remainSize -= addrLen;
#if (VERSION == RMGK01)
remainSize -= addrLen;
#endif
totalLen = addrLen + NWC24i_KSTRLEN("MAIL FROM: ") - 1 + NWC24i_KSTRLEN("\r\n") - 1;
if (remainSize <= 0) {
#if (VERSION == RMGJ01 || VERSION == RMGE01 || VERSION == RMGP01)
if (MSG_WORK_SIZE - totalLen <= 0) {
#elif (VERSION == RMGK01)
if (remainSize <= 0) {
#endif
return NWC24_ERR_NOMEM;
}
@@ -521,8 +535,13 @@ static NWC24Err WriteSMTP_RCPTTO(NWC24iMsgObj* pMsg) {
Mail_strncat(pWork, "RCPT TO: ", remainSize);
pWork += NWC24i_KSTRLEN("RCPT TO: ") - 1;
remainSize -= (NWC24i_KSTRLEN("RCPT TO: ") - 1) + (NWC24i_KSTRLEN("\r\n") - 1);
result = SynthesizeAddrStr(&pMsg->to[i], pMsg->flags, pWork, remainSize, &addrLen);
#if (VERSION == RMGJ01 || VERSION == RMGE01 || VERSION == RMGP01)
result = SynthesizeAddrStr(&pMsg->to[i], pMsg->flags, pWork, remainSize, &addrLen);
#elif (VERSION == RMGK01)
remainSize -= (NWC24i_KSTRLEN("RCPT TO: ") - 1) + (NWC24i_KSTRLEN("\r\n") - 1);
result = SynthesizeAddrStr(&pMsg->to[i], pMsg->flags, pWork, remainSize, &addrLen);
#endif
if (result != NWC24_OK) {
break;
}
@@ -531,7 +550,11 @@ static NWC24Err WriteSMTP_RCPTTO(NWC24iMsgObj* pMsg) {
*pWork++ = '\r';
*pWork++ = '\n';
remainSize -= addrLen;
#if (VERSION == RMGJ01 || VERSION == RMGE01 || VERSION == RMGP01)
remainSize -= addrLen + NWC24i_KSTRLEN("RCPT TO: ") - 1 + NWC24i_KSTRLEN("\r\n") - 1;
#elif (VERSION == RMGK01)
remainSize -= addrLen;
#endif
totalLen += addrLen + NWC24i_KSTRLEN("RCPT TO: ") - 1 + NWC24i_KSTRLEN("\r\n") - 1;
@@ -574,7 +597,9 @@ static NWC24Err WriteFromField(NWC24iMsgObj* pMsg) {
u32 addrFlags;
u32 addrLen;
s32 totalLen;
s32 remainSize;
#if (VERSION == RMGK01)
s32 remainSize;
#endif
NWC24Err result;
pWork = NWC24WorkP->stringWork;
@@ -590,8 +615,13 @@ static NWC24Err WriteFromField(NWC24iMsgObj* pMsg) {
addrFlags = NWC24_MSGOBJ_FOR_PUBLIC;
}
remainSize = MSG_WORK_SIZE - (NWC24i_KSTRLEN("From: ") - 1) - (NWC24i_KSTRLEN("\r\n") - 1);
result = SynthesizeAddrStr(&pMsg->from, addrFlags, pWork, remainSize, &addrLen);
#if (VERSION == RMGJ01 || VERSION == RMGE01 || VERSION == RMGP01)
result = SynthesizeAddrStr(&pMsg->from, addrFlags, pWork, MSG_WORK_SIZE, &addrLen);
#elif (VERSION == RMGK01)
remainSize = MSG_WORK_SIZE - (NWC24i_KSTRLEN("From: ") - 1) - (NWC24i_KSTRLEN("\r\n") - 1);
result = SynthesizeAddrStr(&pMsg->from, addrFlags, pWork, remainSize, &addrLen);
#endif
if (result != NWC24_OK) {
return result;
}
@@ -600,10 +630,17 @@ static NWC24Err WriteFromField(NWC24iMsgObj* pMsg) {
*pWork++ = '\r';
*pWork++ = '\n';
remainSize -= addrLen;
#if (VERSION == RMGK01)
remainSize -= addrLen;
#endif
totalLen = addrLen + NWC24i_KSTRLEN("From: ") - 1 + NWC24i_KSTRLEN("\r\n") - 1;
if (remainSize <= 0) {
#if (VERSION == RMGJ01 || VERSION == RMGE01 || VERSION == RMGP01)
if (MSG_WORK_SIZE - totalLen <= 0) {
#elif (VERSION == RMGK01)
if (remainSize <= 0) {
#endif
return NWC24_ERR_NOMEM;
}
@@ -633,12 +670,22 @@ static NWC24Err WriteToField(NWC24iMsgObj* pMsg) {
pWork = NWC24WorkP->stringWork;
Mail_memset(pWork, 0, NWC24i_STRING_WORK_SIZE);
Mail_strncat(pWork, "To: ", MSG_WORK_SIZE);
#if (VERSION == RMGJ01 || VERSION == RMGE01 || VERSION == RMGP01)
Mail_strncat(pWork, "To: ", NWC24i_STRING_WORK_SIZE);
#elif (VERSION == RMGK01)
Mail_strncat(pWork, "To: ", MSG_WORK_SIZE);
#endif
pWork += NWC24i_KSTRLEN("To: ") - 1;
i = 0;
totalLen = NWC24i_KSTRLEN("To: ") - 1;
remainSize = MSG_WORK_SIZE - (NWC24i_KSTRLEN("To: ") - 1);
#if (VERSION == RMGJ01 || VERSION == RMGE01 || VERSION == RMGP01)
remainSize = NWC24i_STRING_WORK_SIZE - (NWC24i_KSTRLEN("To: ") - 1);
#elif (VERSION == RMGK01)
remainSize = MSG_WORK_SIZE - (NWC24i_KSTRLEN("To: ") - 1);
#endif
pMsg->toField.offset = pMsg->length + NWC24i_KSTRLEN("To: ") - 1;
+20
View File
@@ -35,11 +35,31 @@ int STD_strnlen(const char* pStr, size_t maxlen) {
}
void* Mail_memcpy(void* dst, const void* src, size_t n) {
#if (VERSION == RMGJ01 || VERSION == RMGE01 || VERSION == RMGP01)
size_t i;
for (i = 0; i < n; i++) {
((u8*)dst)[i] = ((u8*)src)[i];
}
return dst;
#elif (VERSION == RMGK01)
NETMemCpy(dst, src, n);
#endif
}
void* Mail_memset(void* dst, int ch, size_t n) {
#if (VERSION == RMGJ01 || VERSION == RMGE01 || VERSION == RMGP01)
size_t i;
for (i = 0; i < n; i++) {
((u8*)dst)[i] = ch;
}
return dst;
#elif (VERSION == RMGK01)
NETMemSet(dst, ch, n);
#endif
}
char* Mail_strcat(char* pDst, const char* pSrc) {