Skip to content

Commit

Permalink
[iQue] Decompile string functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alto1772 committed Mar 2, 2024
1 parent 230b19a commit 9e46448
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/bb/sa/common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "PR/os_internal.h"

void* memset(char* s, int c, size_t n) {
int i;

for (i = 0; i < n; i++) {
s[i] = c;
}

return s;
}
9 changes: 9 additions & 0 deletions src/bb/sa/globals.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "PR/os_internal.h"

const char gSaCertFname[] = "cert.sys";
const char gSaRlFname[] = "crl.sys";
const char gSaAppExt[] = "app";
const char gSaRecExt[] = "rec";
const char gSaTicketFname[] = "ticket.sys";
const char gSaRecryptKeyFname[] = "recrypt.sys";
const char gSaClubTitle[] = "iQue Club";
16 changes: 16 additions & 0 deletions src/bb/sa/memcmp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "PR/os_internal.h"

int memcmp(void* s1, void* s2, size_t n) {
u8* a = s1;
u8* b = s2;
u8 a1, b1;

while (n-- > 0) {
b1 = *b++;
a1 = *a++;
if (a1 != b1) {
return a1 - b1;
}
}
return 0;
}
17 changes: 17 additions & 0 deletions src/bb/sa/strcmp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "PR/os_internal.h"

int strcmp(u8* s, u8* t) {
while (*s && *t && *s == *t) {
s++;
t++;
}

if (*s < *t) {
return -1;
}
if (*s > *t) {
return 1;
}

return 0;
}
20 changes: 20 additions & 0 deletions src/bb/sa/strncmp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "PR/os_internal.h"

int strncmp(char* s, char* t, int n) {
int i;

for (i = 0; (*s == *t) && (i < n); i++) {
if (*s == 0) {
if (*t == 0) {
return 0;
}
break;
}
if (*t == 0) {
break;
}
s++;
t++;
}
return (i != n) ? *s - *t : 0;
}

0 comments on commit 9e46448

Please sign in to comment.