Introduce a strcat replacement
This commit is contained in:
parent
f221915a95
commit
a76c15d018
@ -26,20 +26,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
|
#include "strings.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
|
||||||
static inline int strlen(const char *string)
|
|
||||||
{
|
|
||||||
char *stringEnd = (char *)string;
|
|
||||||
|
|
||||||
while(*stringEnd) stringEnd++;
|
|
||||||
|
|
||||||
return stringEnd - string;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool loadSplash(void)
|
bool loadSplash(void)
|
||||||
{
|
{
|
||||||
//Don't delay boot nor init the screens if no splash image is on the SD
|
//Don't delay boot nor init the screens if no splash image is on the SD
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "strings.h"
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "fatfs/ff.h"
|
#include "fatfs/ff.h"
|
||||||
@ -127,8 +128,8 @@ void loadPayload(u32 pressed)
|
|||||||
|
|
||||||
memcpy(loaderAddress, loader, loader_size);
|
memcpy(loaderAddress, loader, loader_size);
|
||||||
|
|
||||||
path[14] = '/';
|
concatenateStrings(path, "/");
|
||||||
memcpy(&path[15], info.altname, 13);
|
concatenateStrings(path, info.altname);
|
||||||
|
|
||||||
loaderAddress[1] = fileRead((void *)0x24F00000, path);
|
loaderAddress[1] = fileRead((void *)0x24F00000, path);
|
||||||
|
|
||||||
@ -147,7 +148,7 @@ u32 firmRead(void *dest, u32 firmType)
|
|||||||
{ "00000003", "20000003" }};
|
{ "00000003", "20000003" }};
|
||||||
|
|
||||||
char path[48] = "1:/title/00040138/00000000/content";
|
char path[48] = "1:/title/00040138/00000000/content";
|
||||||
memcpy(&path[18], firmFolders[firmType][isN3DS ? 1 : 0], 8);
|
concatenateStrings(path, firmFolders[firmType][isN3DS ? 1 : 0]);
|
||||||
|
|
||||||
DIR dir;
|
DIR dir;
|
||||||
FILINFO info;
|
FILINFO info;
|
||||||
@ -177,7 +178,7 @@ u32 firmRead(void *dest, u32 firmType)
|
|||||||
f_closedir(&dir);
|
f_closedir(&dir);
|
||||||
|
|
||||||
//Complete the string with the .app name
|
//Complete the string with the .app name
|
||||||
memcpy(&path[34], "/00000000.app", 14);
|
concatenateStrings(path, "/00000000.app");
|
||||||
|
|
||||||
//Last digit of the .app
|
//Last digit of the .app
|
||||||
u32 i = 42;
|
u32 i = 42;
|
||||||
|
41
source/strings.c
Normal file
41
source/strings.c
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Luma3DS
|
||||||
|
* Copyright (C) 2016 Aurora Wright, TuxSH
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Additional Terms 7.b of GPLv3 applies to this file: Requiring preservation of specified
|
||||||
|
* reasonable legal notices or author attributions in that material or in the Appropriate Legal
|
||||||
|
* Notices displayed by works containing it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "strings.h"
|
||||||
|
#include "memory.h"
|
||||||
|
|
||||||
|
int strlen(const char *string)
|
||||||
|
{
|
||||||
|
char *stringEnd = (char *)string;
|
||||||
|
|
||||||
|
while(*stringEnd) stringEnd++;
|
||||||
|
|
||||||
|
return stringEnd - string;
|
||||||
|
}
|
||||||
|
|
||||||
|
void concatenateStrings(char *destination, const char *source)
|
||||||
|
{
|
||||||
|
int i = strlen(source),
|
||||||
|
j = strlen(destination);
|
||||||
|
|
||||||
|
memcpy(&destination[j], source, i + 1);
|
||||||
|
}
|
28
source/strings.h
Normal file
28
source/strings.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Luma3DS
|
||||||
|
* Copyright (C) 2016 Aurora Wright, TuxSH
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Additional Terms 7.b of GPLv3 applies to this file: Requiring preservation of specified
|
||||||
|
* reasonable legal notices or author attributions in that material or in the Appropriate Legal
|
||||||
|
* Notices displayed by works containing it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
int strlen(const char *string);
|
||||||
|
void concatenateStrings(char *destination, const char *source);
|
Reference in New Issue
Block a user