Compare commits
1 Commits
agent/fix/
...
agent/w092
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da9e84ba8b |
@@ -122,6 +122,7 @@ struct NUPContextInfo {
|
||||
OSThread thread;
|
||||
OSMutex mutex;
|
||||
u64 threadStack[0x400];
|
||||
s32 __nupGetBootVersion(ESTitleVersion* title);
|
||||
};
|
||||
|
||||
static const char* __nupStatusMessage[6] = {
|
||||
@@ -486,7 +487,7 @@ static void __nupBase64Encode(u8* output, u8* input, unsigned long length) {
|
||||
u8* end = input + length;
|
||||
u32 value = 0;
|
||||
u32 count = 0;
|
||||
static char fillByte = '=';
|
||||
static char pad = '=';
|
||||
|
||||
while (input != end) {
|
||||
count++;
|
||||
@@ -495,39 +496,30 @@ static void __nupBase64Encode(u8* output, u8* input, unsigned long length) {
|
||||
if (count < 3) {
|
||||
continue;
|
||||
}
|
||||
u8 encodedSecond = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 12 & 0x3f];
|
||||
u8 encodedFirst = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 18 & 0x3f];
|
||||
output[0] = encodedFirst;
|
||||
u8 encodedThird = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 6 & 0x3f];
|
||||
output[1] = encodedSecond;
|
||||
u8 encodedFourth = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value & 0x3f];
|
||||
output[2] = encodedThird;
|
||||
output[3] = encodedFourth;
|
||||
output[0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 18 & 0x3f];
|
||||
count = 0;
|
||||
output[1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 12 & 0x3f];
|
||||
output[2] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 6 & 0x3f];
|
||||
output[3] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value & 0x3f];
|
||||
output += 4;
|
||||
}
|
||||
|
||||
if (count == 2) {
|
||||
value <<= 8;
|
||||
u8 encodedSecond = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 12 & 0x3f];
|
||||
u8 encodedFirst = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 18 & 0x3f];
|
||||
output[0] = encodedFirst;
|
||||
u8 encodedThird = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 6 & 0x3f];
|
||||
output[1] = encodedSecond;
|
||||
output[2] = encodedThird;
|
||||
output[3] = fillByte;
|
||||
output[0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 18 & 0x3f];
|
||||
output[1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 12 & 0x3f];
|
||||
output[2] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 6 & 0x3f];
|
||||
output[3] = pad;
|
||||
return;
|
||||
}
|
||||
if (count != 1) {
|
||||
return;
|
||||
}
|
||||
value <<= 16;
|
||||
u8 encodedSecond = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 12 & 0x3f];
|
||||
u8 encodedFirst = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 18 & 0x3f];
|
||||
output[0] = encodedFirst;
|
||||
output[1] = encodedSecond;
|
||||
output[2] = fillByte;
|
||||
output[3] = fillByte;
|
||||
output[0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 18 & 0x3f];
|
||||
output[1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[value >> 12 & 0x3f];
|
||||
output[2] = pad;
|
||||
output[3] = pad;
|
||||
}
|
||||
|
||||
static s32 __nupGetAuditData(NUPContextInfo* context, char** auditData) {
|
||||
@@ -695,8 +687,8 @@ static inline BOOL __nupHasContent(const Title* title, ESContentId contentId) {
|
||||
return index < title->contentCount;
|
||||
}
|
||||
|
||||
static inline BOOL __nupHasInstalledContent(const ESTitleVersion* title, ESContentId contentId,
|
||||
u32 contentCount) {
|
||||
static inline BOOL __nupHasInstalledContent(const ESTitleVersion* title, u32 contentCount,
|
||||
ESContentId contentId) {
|
||||
if (contentCount == 0 || title->contentIds == 0) {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -724,7 +716,7 @@ static inline s32 __nupSetBootTitleVersion(ESTitleVersion* title) {
|
||||
return result;
|
||||
}
|
||||
|
||||
static s32 __nupGetBootVersion(NUPContextInfo* context, ESTitleVersion* title) {
|
||||
s32 NUPContextInfo::__nupGetBootVersion(ESTitleVersion* title) {
|
||||
s32 result;
|
||||
ESTmdView* tmdView = 0;
|
||||
|
||||
@@ -735,12 +727,12 @@ static s32 __nupGetBootVersion(NUPContextInfo* context, ESTitleVersion* title) {
|
||||
result = __nupSetBootTitleVersion(title);
|
||||
} else {
|
||||
u32 i;
|
||||
for (i = 0; i < context->ownedTitleCount; i++) {
|
||||
if (context->ownedTitleIds[i] == title->titleId) {
|
||||
for (i = 0; i < ownedTitleCount; i++) {
|
||||
if (ownedTitleIds[i] == title->titleId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < context->ownedTitleCount) {
|
||||
if (i < ownedTitleCount) {
|
||||
title->hasTicket = 1;
|
||||
}
|
||||
|
||||
@@ -777,8 +769,8 @@ static s32 __nupGetBootVersion(NUPContextInfo* context, ESTitleVersion* title) {
|
||||
}
|
||||
s32 contentIndex;
|
||||
for (contentIndex = 0; contentIndex < tmdView->head.numContents; contentIndex++) {
|
||||
if (!__nupHasInstalledContent(title, tmdView->contents[contentIndex].cid,
|
||||
installedContentCount)) {
|
||||
if (!__nupHasInstalledContent(title, installedContentCount,
|
||||
tmdView->contents[contentIndex].cid)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1173,8 +1165,10 @@ static inline s32 __nupGetBoot2Version(u16* version) {
|
||||
s32 result = ES_GetBoot2Version(&bootVersion);
|
||||
if (result == 0) {
|
||||
u16 checkedVersion = bootVersion;
|
||||
if (checkedVersion != bootVersion) {
|
||||
result = -0x1389;
|
||||
}
|
||||
*version = checkedVersion;
|
||||
result = checkedVersion == bootVersion ? result : -0x1389;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1193,7 +1187,7 @@ static inline s32 __nupGetOwnedTitles(NUPContextInfo* context) {
|
||||
}
|
||||
|
||||
static inline s32 __nupCheckTitleVersion(NUPContextInfo* context, NUPTitleInfo* title) {
|
||||
s32 result = __nupGetBootVersion(context, (ESTitleVersion*)title);
|
||||
s32 result = context->__nupGetBootVersion((ESTitleVersion*)title);
|
||||
if (result == 0) {
|
||||
if (title->hasTicket && title->hasTmd && title->hasContent &&
|
||||
title->installedVersion >= title->serverVersion) {
|
||||
@@ -1228,7 +1222,7 @@ extern "C" void* __nupOp(void* argument) {
|
||||
u32 needsAudit;
|
||||
u32 currentDeviceId;
|
||||
s32 result;
|
||||
u16 serverBootVersion = 0;
|
||||
u16 serverBootVersion;
|
||||
u16 bootTitleVersion;
|
||||
u16 systemMenuVersion;
|
||||
ESTitleId currentTitleId;
|
||||
|
||||
@@ -55,7 +55,7 @@ static u8* __nupNhttpBufFull(u8** buffer, unsigned long* length, unsigned long r
|
||||
if (state->progress != NULL && *length != 0) {
|
||||
state->progress(state->progressContext, *length);
|
||||
}
|
||||
if ((state->received + *length) < state->received) {
|
||||
if (state->received + *length < state->received) {
|
||||
if (state->error == 0) state->error = -5012;
|
||||
}
|
||||
state->received += *length;
|
||||
@@ -70,7 +70,7 @@ static u8* __nupNhttpBufFull(u8** buffer, unsigned long* length, unsigned long r
|
||||
}
|
||||
next = *buffer;
|
||||
if (next == NULL) {
|
||||
if (requested != 0 && requested < 0x8000) {} else requested = 0x8000;
|
||||
if (requested == 0 || requested >= 0x8000) requested = 0x8000;
|
||||
next = (u8*)nup::__nupMalloc(requested);
|
||||
if (next == NULL) {
|
||||
state->error = -5000;
|
||||
@@ -83,8 +83,8 @@ static u8* __nupNhttpBufFull(u8** buffer, unsigned long* length, unsigned long r
|
||||
}
|
||||
done:
|
||||
if (state->error != 0) {
|
||||
next = NULL;
|
||||
*length = 0;
|
||||
next = NULL;
|
||||
}
|
||||
return next;
|
||||
}
|
||||
@@ -101,12 +101,13 @@ static void __nupNhttpReqDone(int result, void* response, HttpState* state) {
|
||||
}
|
||||
|
||||
static int __nupNhttpOp(char* url, NHTTPReqMethod method, char* headers, u8* body, unsigned long bodyLength, unsigned long limit, ProgressCallback progress, void* progressContext, FlushCallback flush, void* flushContext) {
|
||||
unsigned long transferred, expected;
|
||||
int length;
|
||||
char* responseHeaders = NULL;
|
||||
u8* responseBody = NULL;
|
||||
HttpState state;
|
||||
int result = 0;
|
||||
int status;
|
||||
u8* responseBody = NULL;
|
||||
char* responseHeaders = NULL;
|
||||
int length;
|
||||
unsigned long expected, transferred;
|
||||
HttpState state;
|
||||
state.error = 0;
|
||||
state.limit = limit;
|
||||
state.received = 0;
|
||||
@@ -118,8 +119,7 @@ static int __nupNhttpOp(char* url, NHTTPReqMethod method, char* headers, u8* bod
|
||||
state.done = 0;
|
||||
state.result = 0;
|
||||
state.lastActivity = 0;
|
||||
int result = 0;
|
||||
int requestId = 0;
|
||||
int requestId;
|
||||
char* headerCopy = NULL;
|
||||
void* request = NHTTPCreateRequestEx(url, method, NULL, 0, __nupNhttpReqDone, &state, __nupNhttpBufFull, __nupNhttpBufFree);
|
||||
if (request == NULL) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
@@ -130,16 +130,15 @@ static int __nupNhttpOp(char* url, NHTTPReqMethod method, char* headers, u8* bod
|
||||
if (headerCopy == NULL) { result = -5000; goto cleanup; }
|
||||
memcpy(headerCopy, headers, size);
|
||||
char* field = headerCopy;
|
||||
while (*field != 0) {
|
||||
char* colon = strchr(field, ':');
|
||||
if (colon == NULL) break;
|
||||
char* end = strstr(colon, "\r\n");
|
||||
if (end == NULL) break;
|
||||
char* colon;
|
||||
char* end;
|
||||
while (*field != 0 && (colon = strchr(field, ':')) != NULL && (end = strstr(colon, "\r\n")) != NULL) {
|
||||
*colon = 0;
|
||||
*end = 0;
|
||||
while (*field && isspace(*field)) field++;
|
||||
do { colon++; } while (*colon && isspace(*colon));
|
||||
if (NHTTPAddHeaderField(request, field, colon) != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
char* value = colon + 1;
|
||||
while (*value && isspace(*value)) value++;
|
||||
if (NHTTPAddHeaderField(request, field, value) != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
field = end + 2;
|
||||
}
|
||||
}
|
||||
@@ -153,40 +152,40 @@ static int __nupNhttpOp(char* url, NHTTPReqMethod method, char* headers, u8* bod
|
||||
if (method == NHTTP_POST && body != NULL && bodyLength != 0 && NHTTPAddPostDataRaw(request, body, bodyLength) != 0) { result = -7000 - NHTTPGetError(); goto cleanup; }
|
||||
requestId = NHTTPSendRequestAsync(request);
|
||||
if (requestId < 0) {
|
||||
int error = NHTTPGetError();
|
||||
result = -7000 - NHTTPGetError();
|
||||
NHTTPDeleteRequest(request);
|
||||
result = -7000 - error;
|
||||
goto cleanup;
|
||||
}
|
||||
state.lastActivity = OSGetTime();
|
||||
for (;;) {
|
||||
if (NHTTPGetProgress(&expected, &transferred) != 0 && state.done != 0) {
|
||||
if (state.result != 0) { result = -7000 - state.result; goto cleanup; }
|
||||
if (state.response != NULL) {
|
||||
length = NHTTPGetBodyAll(state.response, &responseBody);
|
||||
if (length < 0) { result = -5007; goto cleanup; }
|
||||
__nupNhttpBufFull(&responseBody, (unsigned long*)&length, 0, NULL, NULL, &state);
|
||||
}
|
||||
result = state.error;
|
||||
if (result != 0 || state.response == NULL) goto cleanup;
|
||||
length = NHTTPGetHeaderAll(state.response, &responseHeaders);
|
||||
if (length < 0) { result = -5007; goto cleanup; }
|
||||
char* protocol = strstr(responseHeaders, "HTTP/");
|
||||
if (protocol != NULL && sscanf(protocol, "HTTP/%*d.%*d %d", &status) == 1) {
|
||||
if (status != 200 && status != 202) result = -5000 - status;
|
||||
goto cleanup;
|
||||
while (NHTTPGetProgress(&expected, &transferred) == 0 || state.done == 0) {
|
||||
if (OSGetTime() - state.lastActivity >= OSMillisecondsToTicks(90000LL)) {
|
||||
if (requestId >= 0) {
|
||||
NHTTPCancelRequestAsync(requestId);
|
||||
NCDSleep(OSMillisecondsToTicks(100));
|
||||
}
|
||||
result = -5009;
|
||||
goto cleanup;
|
||||
}
|
||||
NCDSleep(OSMillisecondsToTicks(100));
|
||||
}
|
||||
if (state.result != 0) { result = -7000 - state.result; goto cleanup; }
|
||||
if (state.response != NULL) {
|
||||
length = NHTTPGetBodyAll(state.response, &responseBody);
|
||||
if (length < 0) { result = -5007; goto cleanup; }
|
||||
__nupNhttpBufFull(&responseBody, (unsigned long*)&length, 0, NULL, NULL, &state);
|
||||
}
|
||||
if (state.error != 0) { result = state.error; goto cleanup; }
|
||||
if (state.response == NULL) goto cleanup;
|
||||
length = NHTTPGetHeaderAll(state.response, &responseHeaders);
|
||||
if (length < 0) { result = -5007; goto cleanup; }
|
||||
{
|
||||
char* protocol = strstr(responseHeaders, "HTTP/");
|
||||
if (protocol == NULL || sscanf(protocol, "HTTP/%*d.%*d %d", &status) != 1) {
|
||||
result = -5007;
|
||||
goto cleanup;
|
||||
}
|
||||
if (OSGetTime() - state.lastActivity >= OSMillisecondsToTicks(90000)) break;
|
||||
NCDSleep(OSMillisecondsToTicks(100));
|
||||
if (status != 200 && status != 202) result = -5000 - status;
|
||||
}
|
||||
if (requestId >= 0) {
|
||||
NHTTPCancelRequestAsync(requestId);
|
||||
NCDSleep(OSMillisecondsToTicks(100));
|
||||
}
|
||||
result = -5009;
|
||||
cleanup:
|
||||
if (state.response != NULL || result == -5009) NHTTPDestroyResponse(state.response);
|
||||
if (headerCopy != NULL) nup::__nupFree(headerCopy);
|
||||
@@ -196,14 +195,16 @@ cleanup:
|
||||
extern "C" {
|
||||
static long __nupHttpStringFlush(u8* data, unsigned long length, unsigned long requested, void* context) {
|
||||
HttpString* text = (HttpString*)context;
|
||||
unsigned long total;
|
||||
total = length + text->length;
|
||||
unsigned long dataLength = length;
|
||||
unsigned long total = length + text->length;
|
||||
long result = 0;
|
||||
if (total > text->capacity) {
|
||||
if (requested >= total) {} else {
|
||||
if (requested < total) {
|
||||
requested = text->growth + total;
|
||||
text->growth <<= 1;
|
||||
if (text->growth < text->maximumGrowth) {} else text->growth = text->maximumGrowth;
|
||||
if (text->growth >= text->maximumGrowth) {
|
||||
text->growth = text->maximumGrowth;
|
||||
}
|
||||
}
|
||||
u8* next = (u8*)nup::__nupMalloc(requested);
|
||||
if (next == NULL) { result = -5000; goto done; }
|
||||
@@ -213,8 +214,8 @@ static long __nupHttpStringFlush(u8* data, unsigned long length, unsigned long r
|
||||
}
|
||||
text->buffer = next;
|
||||
}
|
||||
memcpy(text->buffer + text->length, data, length);
|
||||
text->length += length;
|
||||
memcpy(text->buffer + text->length, data, dataLength);
|
||||
text->length += dataLength;
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -404,10 +404,14 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
|
||||
u32 index;
|
||||
u32 skipTitleMeta = flags & 4;
|
||||
WADFileHeader* fileHeader;
|
||||
void* titleMetaCopy;
|
||||
void* contentListCopy;
|
||||
|
||||
streamOpened = FALSE;
|
||||
fileOffset = 0;
|
||||
allocatedFiles = 0;
|
||||
titleMetaCopy = 0;
|
||||
contentListCopy = 0;
|
||||
memset(&workspace.unpackInfo, 0, sizeof(WADUnpackInfo));
|
||||
if (fileListOut != 0) {
|
||||
*fileListOut = 0;
|
||||
@@ -520,6 +524,12 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
|
||||
|
||||
cleanup:
|
||||
_WADFreeMemory(&workspace.unpackInfo, allocator);
|
||||
if (titleMetaCopy != 0) {
|
||||
_WADMemFree(allocator, titleMetaCopy);
|
||||
}
|
||||
if (contentListCopy != 0) {
|
||||
_WADMemFree(allocator, contentListCopy);
|
||||
}
|
||||
if ((fileListOut != 0) && (result != 0)) {
|
||||
if (allocatedFiles != 0) {
|
||||
_WADMemFree(allocator, allocatedFiles);
|
||||
@@ -963,6 +973,7 @@ s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 o
|
||||
(unpackInfo.fileCount == 0)) {
|
||||
goto cleanup;
|
||||
}
|
||||
fileHeaderBuffer = &backupHeader;
|
||||
if (firstBuffer == 0) {
|
||||
firstBuffer = _WADMemAlloc(allocator, 0x10000);
|
||||
if (firstBuffer == 0) {
|
||||
@@ -970,7 +981,6 @@ s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 o
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
fileHeaderBuffer = &backupHeader;
|
||||
if (secondBuffer == 0) {
|
||||
secondBuffer = _WADMemAlloc(allocator, 0x10000);
|
||||
if (secondBuffer == 0) {
|
||||
|
||||
@@ -13,7 +13,7 @@ int SOiIsBufferAddrCheck(void);
|
||||
void* SOiAlloc(u32, s32);
|
||||
void SOiFree(u32, void*, s32);
|
||||
|
||||
static int soSocketRegistered;
|
||||
static int soSocketRegistered[2];
|
||||
const char* __SOCKETVersion="<< RVL_SDK - SOCKET \trelease build: Dec 12 2008 03:06:17 (0x4199_60831) >>";
|
||||
|
||||
typedef struct SocketRequest { int socket; int type; int protocol; } SocketRequest;
|
||||
@@ -47,7 +47,7 @@ int SOSocket(int family, int type, int protocol) {
|
||||
s32 rm;
|
||||
SocketRequest* request;
|
||||
int result;
|
||||
if(!soSocketRegistered) { OSRegisterVersion(__SOCKETVersion); soSocketRegistered=1; }
|
||||
if(!soSocketRegistered[0]) { OSRegisterVersion(__SOCKETVersion); soSocketRegistered[0]=1; }
|
||||
if((result=SOiPrepare(NULL,&rm))==0) {
|
||||
if(family==23) result=-5;
|
||||
else {
|
||||
@@ -129,9 +129,9 @@ int SOGetSockName(int socket, void* address) {
|
||||
int size;
|
||||
int result;
|
||||
s32 rm;
|
||||
SOSockAddr* addr;
|
||||
SOSockAddr* reply;
|
||||
NameRequest* request;
|
||||
SOSockAddr* reply;
|
||||
SOSockAddr* addr;
|
||||
addr=address;
|
||||
if((result=SOiPrepare(NULL,&rm))==0) {
|
||||
if(!addr || addr->len>8 || addr->len<8) result=-28;
|
||||
@@ -199,7 +199,7 @@ int SOShutdown(int socket, int how) {
|
||||
|
||||
int SOPoll(SOPollFD* fds, unsigned int count, s64 timeout) {
|
||||
s32 rm;
|
||||
s32 result,bytes,size;
|
||||
s32 size,bytes,result;
|
||||
PollRequest* request;
|
||||
SOPollFD* reply;
|
||||
if((result=SOiPrepare(NULL,&rm))==0) {
|
||||
@@ -256,11 +256,11 @@ char* SOInetNtoA(SOInAddr address) {
|
||||
|
||||
int SOInetPtoN(int family, const char* text, void* address) {
|
||||
s32 rm;
|
||||
int temporary,result,size,bytes;
|
||||
int temporary,size,result,bytes;
|
||||
InetRequest* request;
|
||||
if((result=SOiPrepareTempRm(NULL,&rm,&temporary))==0) {
|
||||
bytes=0;
|
||||
if(family==2) bytes=4;
|
||||
switch(family) { case 2: bytes=4; break; default: break; }
|
||||
if(!bytes) result=-5;
|
||||
else if(!text) result=-28;
|
||||
else {
|
||||
@@ -316,7 +316,7 @@ static int RecvFrom(const char* name, int socket, void* data, int length, int fl
|
||||
else {
|
||||
direct=TRUE;
|
||||
if(length && !DirectBuffer(data,length)) direct=FALSE;
|
||||
size=((address ? address->len : 0)+95)&~31;
|
||||
size=((address==NULL ? 0 : address->len)+95)&~31;
|
||||
request=SOiAlloc(12,size);
|
||||
if(!direct) buffer=SOiAlloc(13,(length+31)&~31);
|
||||
else buffer=data;
|
||||
|
||||
@@ -48,13 +48,13 @@ s32 SOGetHostID(void) {
|
||||
}
|
||||
|
||||
SOHostEnt* SOGetHostByName(const char* name) {
|
||||
char* request;
|
||||
HostReply* reply;
|
||||
int result;
|
||||
int size;
|
||||
int length;
|
||||
SOHostEnt* host;
|
||||
int result;
|
||||
s32 rm;
|
||||
char* request;
|
||||
host = NULL;
|
||||
if((result=SOiPrepare(NULL,&rm))==0) {
|
||||
if(!name) result=-28;
|
||||
@@ -84,18 +84,21 @@ SOHostEnt* SOGetHostByName(const char* name) {
|
||||
return host;
|
||||
}
|
||||
|
||||
static int NameSize(const char* name) { return name ? strlen(name)+1 : 0; }
|
||||
static int NameSize(const char* name) { return name==NULL ? 0 : strlen(name)+1; }
|
||||
|
||||
int SOGetAddrInfo(const char* nodeName, const char* servName, const SOAddrInfo* hints, SOAddrInfo** resultInfo) {
|
||||
s32 rm;
|
||||
int result,size;
|
||||
AddrInfoRequest* request;
|
||||
AddrInfoReply* reply;
|
||||
int servLen,nodeLen;
|
||||
char* node;
|
||||
char* service;
|
||||
SOAddrInfo* requestHints;
|
||||
if((result=SOiPrepare(NULL,&rm))==0) {
|
||||
size=(((NameSize(nodeName)+31)&~31)+((servName ? strlen(nodeName)+32 : 31)&~31)+95)&~31;
|
||||
if(servName==NULL) servLen=0; else servLen=strlen(nodeName)+1;
|
||||
nodeLen=NameSize(nodeName);
|
||||
size=(((nodeLen+31)&~31)+((servLen+31)&~31)+95)&~31;
|
||||
request=SOiAlloc(12,size);
|
||||
if(!request) result=-49;
|
||||
else {
|
||||
@@ -104,13 +107,15 @@ int SOGetAddrInfo(const char* nodeName, const char* servName, const SOAddrInfo*
|
||||
else {
|
||||
node=(char*)request->storage;
|
||||
service=node+((NameSize(nodeName)+31)&~31);
|
||||
requestHints=(SOAddrInfo*)(service+((servName ? strlen(nodeName)+32 : 31)&~31));
|
||||
requestHints=(SOAddrInfo*)(service+(((servName==NULL ? 0 : strlen(nodeName)+1)+31)&~31));
|
||||
if(nodeName) strcpy(node,nodeName);
|
||||
request->vectors[0].base=nodeName ? (u8*)node : NULL;
|
||||
request->vectors[0].length=nodeName ? strlen(nodeName) : 0;
|
||||
node=nodeName ? node : NULL;
|
||||
request->vectors[0].base=(u8*)node;
|
||||
request->vectors[0].length=nodeName==NULL ? 0 : strlen(nodeName);
|
||||
if(servName) strcpy(service,servName);
|
||||
request->vectors[1].base=servName ? (u8*)service : NULL;
|
||||
request->vectors[1].length=servName ? strlen(servName) : 0;
|
||||
service=servName ? service : NULL;
|
||||
request->vectors[1].base=(u8*)service;
|
||||
request->vectors[1].length=servName==NULL ? 0 : strlen(servName);
|
||||
if(hints) memcpy(requestHints,hints,32);
|
||||
else memset(requestHints,0,32);
|
||||
if(requestHints->family==0) requestHints->family=2;
|
||||
|
||||
@@ -111,8 +111,8 @@ int SOGetInterfaceOpt(void* interface, int level, int option, void* value, int*
|
||||
else {
|
||||
command=&request->command;
|
||||
command->level=level; command->option=option;
|
||||
returnedLength=&request->length;
|
||||
reply=request->value;
|
||||
returnedLength=(int*)((u8*)command+0x20);
|
||||
reply=(u8*)returnedLength+0x20;
|
||||
*returnedLength=OptionLength(length);
|
||||
request->vectors[0].base=(u8*)command;
|
||||
request->vectors[0].length=8;
|
||||
@@ -152,7 +152,7 @@ int SOSetInterfaceOpt(void* interface, int level, int option, const void* value,
|
||||
else {
|
||||
command=&request->command;
|
||||
command->level=level; command->option=option;
|
||||
reply=request->value;
|
||||
reply=(u8*)command+0x20;
|
||||
if(value) memcpy(reply,value,length);
|
||||
else memset(reply,0,length);
|
||||
request->vectors[0].base=(u8*)command; request->vectors[0].length=8;
|
||||
|
||||
Reference in New Issue
Block a user