Fix according to review
This commit is contained in:
parent
b1592a3539
commit
51ac5111c5
@ -1,31 +1,27 @@
|
|||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <3ds/types.h>
|
#include <3ds/types.h>
|
||||||
#include <3ds/result.h>
|
|
||||||
#include <3ds/svc.h>
|
#include <3ds/svc.h>
|
||||||
#include <3ds/synchronization.h>
|
#include <3ds/synchronization.h>
|
||||||
#include <3ds/services/apt.h>
|
#include <3ds/services/apt.h>
|
||||||
#include <3ds/ipc.h>
|
|
||||||
#include <3ds/env.h>
|
|
||||||
#include <3ds/util/utf.h>
|
#include <3ds/util/utf.h>
|
||||||
#include <3ds/applets/error.h>
|
#include <3ds/applets/error.h>
|
||||||
|
|
||||||
void error_Init(ErrConf* err, ErrorType type, err_lang lang)
|
void error_Init(ErrConf* err, ErrorType type, err_lang lang)
|
||||||
{
|
{
|
||||||
memset(err, 0, sizeof(*err));
|
memset(err, 0, sizeof(*err));
|
||||||
err->errorType= type;
|
err->errorType=type;
|
||||||
err->useLanguage= lang;
|
err->useLanguage=lang;
|
||||||
err->upperScreenFlag= NORMAL;
|
err->upperScreenFlag= NORMAL;
|
||||||
err->eulaVersion = 0;
|
err->eulaVersion = 0;
|
||||||
err->homeButton = true;
|
err->homeButton = true;
|
||||||
err->softwareReset = false;
|
err->softwareReset = false;
|
||||||
err->appJump = false;
|
err->appJump = false;
|
||||||
err-> returnCode = UNKNOWN;
|
err-> returnCode = UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void errorConvertToUTF16(u16* out, const char* in, int max)
|
static void errorConvertToUTF16(u16* out, const char* in, size_t max)
|
||||||
{
|
{
|
||||||
if (!in || !*in)
|
if (!in || !*in)
|
||||||
{
|
{
|
||||||
@ -33,7 +29,7 @@ static void errorConvertToUTF16(u16* out, const char* in, int max)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t units = utf8_to_utf16(out, (const uint8_t*)in, max);
|
ssize_t units = utf8_to_utf16(out, (const uint8_t*)in, max-1);
|
||||||
if (units < 0)
|
if (units < 0)
|
||||||
{
|
{
|
||||||
out[0] = 0;
|
out[0] = 0;
|
||||||
@ -42,33 +38,31 @@ static void errorConvertToUTF16(u16* out, const char* in, int max)
|
|||||||
|
|
||||||
out[units] = 0;
|
out[units] = 0;
|
||||||
}
|
}
|
||||||
char k[1900];
|
|
||||||
char *c_shift(char text[])
|
static char* c_shift(const char *text)
|
||||||
{
|
{
|
||||||
int i=strlen(text);
|
size_t len = strlen(text);
|
||||||
char tex[i];
|
char *str = (char*)malloc(len + 2);
|
||||||
tex[0]=text[0];
|
if(str)
|
||||||
int j=1;
|
{
|
||||||
for(int a=0;a<=i;a++)
|
str[0] = text[0];
|
||||||
{
|
strcpy(&str[1], text);
|
||||||
tex[j]=text[a];
|
}
|
||||||
j++;
|
return str;
|
||||||
}
|
|
||||||
strncpy(k, tex, i+1);
|
|
||||||
return k;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void error_code(ErrConf* err,int error)
|
void error_code(ErrConf* err,int error)
|
||||||
{
|
{
|
||||||
err->errorCode = error;
|
err->errorCode = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void error_text(ErrConf *err, char* text)
|
void error_text(ErrConf *err, char* text)
|
||||||
{
|
{ char *tex=c_shift(text);
|
||||||
char *tex=c_shift(text);
|
errorConvertToUTF16(err->Text, tex, 1900);
|
||||||
errorConvertToUTF16(err->Text, tex,1900);
|
free(tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void error_disp(ErrConf* err)
|
void error_disp(ErrConf* err)
|
||||||
{
|
{
|
||||||
aptLaunchLibraryApplet(APPID_ERROR , err, sizeof(*err), 0);
|
aptLaunchLibraryApplet(APPID_ERROR, err, sizeof(*err), 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user