add more functions
This commit is contained in:
@@ -167,6 +167,7 @@ int filemenu(menu_entry file){
|
|||||||
case FILE_SCRIPT:
|
case FILE_SCRIPT:
|
||||||
//ParseScript(fsutil_getnextloc(currentpath, file.name));
|
//ParseScript(fsutil_getnextloc(currentpath, file.name));
|
||||||
tester(fsutil_getnextloc(currentpath, file.name));
|
tester(fsutil_getnextloc(currentpath, file.name));
|
||||||
|
fsreader_readfolder(currentpath);
|
||||||
break;
|
break;
|
||||||
case FILE_HEXVIEW:
|
case FILE_HEXVIEW:
|
||||||
viewbytes(fsutil_getnextloc(currentpath, file.name));
|
viewbytes(fsutil_getnextloc(currentpath, file.name));
|
||||||
|
|||||||
@@ -63,8 +63,10 @@ int parseStringInput(char *in, char **out){
|
|||||||
u32 currentcolor = COLOR_WHITE;
|
u32 currentcolor = COLOR_WHITE;
|
||||||
int part_printf(){
|
int part_printf(){
|
||||||
char *toprint;
|
char *toprint;
|
||||||
|
if (parseStringInput(argv[0], &toprint))
|
||||||
|
return -1;
|
||||||
|
|
||||||
SWAPCOLOR(currentcolor);
|
SWAPCOLOR(currentcolor);
|
||||||
parseStringInput(argv[0], &toprint);
|
|
||||||
gfx_printf(toprint);
|
gfx_printf(toprint);
|
||||||
gfx_printf("\n");
|
gfx_printf("\n");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -74,6 +76,8 @@ int part_print_int(){
|
|||||||
int toprint;
|
int toprint;
|
||||||
if (parseIntInput(argv[0], &toprint))
|
if (parseIntInput(argv[0], &toprint))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
SWAPCOLOR(currentcolor);
|
||||||
gfx_printf("%s: %d\n", argv[0], toprint);
|
gfx_printf("%s: %d\n", argv[0], toprint);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -363,9 +367,71 @@ int part_fs_MakeDir(){
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DIR dir;
|
||||||
|
FILINFO fno;
|
||||||
|
int isdirvalid = false;
|
||||||
|
int part_fs_OpenDir(){
|
||||||
|
char *path;
|
||||||
|
|
||||||
|
if (parseStringInput(argv[0], &path))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (f_opendir(&dir, path))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
isdirvalid = true;
|
||||||
|
str_int_add("@ISDIRVALID", isdirvalid);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int part_fs_CloseDir(){
|
||||||
|
if (!isdirvalid)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
f_closedir(&dir);
|
||||||
|
isdirvalid = false;
|
||||||
|
str_int_add("@ISDIRVALID", isdirvalid);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int part_fs_ReadDir(){
|
||||||
|
if (!isdirvalid)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (!f_readdir(&dir, &fno) && fno.fname[0]){
|
||||||
|
str_str_add("$FSOBJNAME", fno.fname);
|
||||||
|
str_int_add("@ISDIR", (fno.fattrib & AM_DIR) ? 1 : 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
part_fs_CloseDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int part_setPrintPos(){
|
||||||
|
int left, right;
|
||||||
|
|
||||||
|
if (parseIntInput(argv[0], &left))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (parseIntInput(argv[1], &right))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (left > 42)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (right > 78)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
gfx_con_setpos(left * 16, right * 16);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
str_fnc_struct functions[] = {
|
str_fnc_struct functions[] = {
|
||||||
{"printf", part_printf, 1},
|
{"printf", part_printf, 1},
|
||||||
{"printInt", part_print_int, 1},
|
{"printInt", part_print_int, 1},
|
||||||
|
{"setPrintPos", part_setPrintPos, 2},
|
||||||
{"if", part_if, 1},
|
{"if", part_if, 1},
|
||||||
{"math", part_Math, 3},
|
{"math", part_Math, 3},
|
||||||
{"check", part_Check, 3},
|
{"check", part_Check, 3},
|
||||||
@@ -383,6 +449,9 @@ str_fnc_struct functions[] = {
|
|||||||
{"fs_delRecursive", part_fs_DeleteRecursive, 1},
|
{"fs_delRecursive", part_fs_DeleteRecursive, 1},
|
||||||
{"fs_copy", part_fs_Copy, 2},
|
{"fs_copy", part_fs_Copy, 2},
|
||||||
{"fs_copyRecursive", part_fs_CopyRecursive, 2},
|
{"fs_copyRecursive", part_fs_CopyRecursive, 2},
|
||||||
|
{"fs_openDir", part_fs_OpenDir, 1},
|
||||||
|
{"fs_closeDir", part_fs_CloseDir, 0},
|
||||||
|
{"fs_readDir", part_fs_ReadDir, 0},
|
||||||
{"mmc_connect", part_ConnectMMC, 1},
|
{"mmc_connect", part_ConnectMMC, 1},
|
||||||
{"mmc_mount", part_MountMMC, 1},
|
{"mmc_mount", part_MountMMC, 1},
|
||||||
{"pause", part_Pause, 0},
|
{"pause", part_Pause, 0},
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "../fs/fsactions.h"
|
#include "../fs/fsactions.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
|
#include "../fs/fsreader.h"
|
||||||
|
|
||||||
|
|
||||||
u32 countchars(char* in, char target) {
|
u32 countchars(char* in, char target) {
|
||||||
@@ -133,8 +134,6 @@ char *readtilchar(char end, char ignore){
|
|||||||
char *funcbuff = NULL;
|
char *funcbuff = NULL;
|
||||||
void functionparser(){
|
void functionparser(){
|
||||||
char *unsplitargs;
|
char *unsplitargs;
|
||||||
FSIZE_t fileoffset;
|
|
||||||
u32 argsize = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (funcbuff != NULL)
|
if (funcbuff != NULL)
|
||||||
@@ -162,8 +161,6 @@ void functionparser(){
|
|||||||
|
|
||||||
char *gettargetvar(){
|
char *gettargetvar(){
|
||||||
char *variable = NULL;
|
char *variable = NULL;
|
||||||
FSIZE_t fileoffset;
|
|
||||||
u32 varsize = 0;
|
|
||||||
|
|
||||||
variable = readtilchar('=', ' ');
|
variable = readtilchar('=', ' ');
|
||||||
|
|
||||||
@@ -176,8 +173,6 @@ char *gettargetvar(){
|
|||||||
void mainparser(){
|
void mainparser(){
|
||||||
char *variable = NULL;
|
char *variable = NULL;
|
||||||
int res, out = 0;
|
int res, out = 0;
|
||||||
FSIZE_t fileoffset;
|
|
||||||
u32 varsize = 0;
|
|
||||||
|
|
||||||
getnextvalidchar();
|
getnextvalidchar();
|
||||||
|
|
||||||
@@ -257,6 +252,7 @@ void skipbrackets(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern u32 currentcolor;
|
extern u32 currentcolor;
|
||||||
|
extern char *currentpath;
|
||||||
void tester(char *path){
|
void tester(char *path){
|
||||||
int res;
|
int res;
|
||||||
forceExit = false;
|
forceExit = false;
|
||||||
@@ -278,6 +274,7 @@ void tester(char *path){
|
|||||||
str_int_add("@BTN_POWER", 0);
|
str_int_add("@BTN_POWER", 0);
|
||||||
str_int_add("@BTN_VOL+", 0);
|
str_int_add("@BTN_VOL+", 0);
|
||||||
str_int_add("@BTN_VOL-", 0);
|
str_int_add("@BTN_VOL-", 0);
|
||||||
|
str_str_add("$CURRENTPATH", currentpath);
|
||||||
|
|
||||||
//str_int_printall();
|
//str_int_printall();
|
||||||
|
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ int str_str_index(int index, char **out){
|
|||||||
dict_str_str *temp;
|
dict_str_str *temp;
|
||||||
temp = str_str_table;
|
temp = str_str_table;
|
||||||
|
|
||||||
for (int i = 0; i < (index - 1); i++){
|
for (int i = 0; i < index; i++){
|
||||||
if (temp == NULL)
|
if (temp == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
temp = temp->next;
|
temp = temp->next;
|
||||||
|
|||||||
Reference in New Issue
Block a user