Skip to content

Commit

Permalink
webMAN MOD 1.47.46h
Browse files Browse the repository at this point in the history
- Added check for used logged in to several XMB automation
- Increased lwait <path> timeout to 30 seconds
- Added support for multiple commands in a single line
- Fixed script execution when last line didn't finish in a line-break
- Added new script commands:
wait user
if login / logout
if xmb / ingame
if copying / mounting
if count <value>

while <condition> / loop
break / continue
  • Loading branch information
aldostools committed Jul 3, 2024
1 parent 80dfdc1 commit 6556443
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 19 deletions.
Binary file modified _Projects_/updater/pkgfiles/USRDIR/webftp_server_full.sprx
Binary file not shown.
Binary file modified _Projects_/updater/pkgfiles/USRDIR/webftp_server_lite.sprx
Binary file not shown.
Binary file modified _Projects_/updater/pkgfiles/USRDIR/webftp_server_noncobra.sprx
Binary file not shown.
Binary file not shown.
Binary file modified _Projects_/updater/update/dev_hdd0/plugins/webftp_server.sprx
Binary file not shown.
Binary file modified _Projects_/updater/update/dev_hdd0/plugins/webftp_server_lite.sprx
Binary file not shown.
Binary file not shown.
57 changes: 48 additions & 9 deletions include/feat/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
// if not exist <path>
// if L1
// if R1
// if login/logout
// if xmb/ingame
// if count <value>
// if copying/mounting
// if cobra/nocobra/debug/mamba/ps3hen/dex/firmware x.xx
// if titleid <titleid/pattern>
// abort if exist <path>
// abort if not exist <path>

// while <if-condition>/continue/break/loop (nested loops are not supported)

// :label
// goto label
// map <path>=<path>
Expand All @@ -20,10 +26,11 @@
// swap <path>=<path>
// ren <path>=<path>

// wait user
// wait xmb
// wait <1-9 secs>
// wait <path>
// lwait <path>
// wait <path> (timeout 5 seconds)
// lwait <path> (timeout 30 seconds)

// logfile <pah>
// log <text>
Expand All @@ -46,6 +53,8 @@
#define line buffer /* "line", "path" and "buffer" are synonyms */
#define path buffer /* "line", "path" and "buffer" are synonyms */
#define IS_WEB_COMMAND(line) (islike(line, "/mount") || strstr(line, ".ps3") || strstr(line, "_ps3") || strstr(line, ".lv1?") || strstr(line, ".lv2?"))
#define EXIT_LOOP {mloop = NULL, count = 0; pos = strcasestr(pos + 1, "loop"); if(!pos) break;} // exit loop


static void handle_file_request(const char *wm_url)
{
Expand All @@ -65,16 +74,17 @@ static void parse_script(const char *script_file)
sys_addr_t sysmem = sys_mem_allocate(max_size);
if(!sysmem) return;

char *buffer, *pos, *dest = NULL, label[24]; u16 l;
char *buffer, *sep, *pos, *mloop = NULL, *dest = NULL, label[24]; u16 l, count = 0;
u8 exec_mode = true, enable_db = true, do_else = true; size_t buffer_size;
char log_file[STD_PATH_LEN]; strcpy(log_file, SC_LOG_FILE); *label = NULL;

reload_script:
buffer = (char*)sysmem; buffer_size = read_file(script_file, buffer, max_size, 0); buffer[buffer_size] = 0;
if(*buffer && !strchr(buffer, '\n')) strcat(buffer, "\n");
if(*buffer) strcat(buffer + buffer_size, "\n");

l = 0, script_running = true;

if(mloop) {buffer = mloop; mloop = NULL;}
if(*label) {pos = strcasestr(buffer, label); if(pos) buffer = pos; else *buffer = NULL; *label = NULL;}

while(*buffer)
Expand All @@ -88,6 +98,9 @@ static void parse_script(const char *script_file)
// process line
pos = strchr(line, '\n'); if(!pos) pos = line;

// process line separator ;
if(BETWEEN('A', *line, 'z')) {sep = strchr(line, ';'); if(sep && (sep < pos)) pos = sep;}

if(pos)
{
*pos = NULL; //EOL
Expand Down Expand Up @@ -130,13 +143,16 @@ static void parse_script(const char *script_file)
else if(exec_mode)
{
if(*line == '/') {if(islike(line, "/dev_blind?0")) disable_dev_blind(); else if(IS_WEB_COMMAND(line)) handle_file_request(line);} else
if(_islike(line, "goto ")) {snprintf(label, 24, ":%s", line + 5); goto reload_script;} else
if(_islike(line, "goto ")) {mloop = NULL, snprintf(label, 24, ":%s", line + 5); goto reload_script;} else
if(_islike(line, "loop") || _islike(line, "continue")) goto reload_script; else
if(_islike(line, "break")) {EXIT_LOOP;} else
if(_islike(line, "del /")) {path += 4; check_path_tags(path); char *wildcard = strchr(path, '*'); if(wildcard) {*wildcard++ = NULL; scan(path, true, wildcard, SCAN_DELETE, NULL);} else del(path, RECURSIVE_DELETE);} else
if(_islike(line, "md /")) {path += 3; check_path_tags(path); mkdir_tree(path);} else
if(_islike(line, "wait xmb")) {wait_for_xmb();} else
if(_islike(line, "wait user")) {wait_for_user();} else
if(_islike(line, "wait /")) {path += 5; check_path_tags(path); wait_for(path, 5);} else
if(_islike(line, "wait ")) {line += 5; sys_ppu_thread_sleep((u8)val(line));} else
if(_islike(line, "lwait /")) {path += 6; check_path_tags(path); wait_for(path, 10);} else
if(_islike(line, "lwait /")) {path += 6; check_path_tags(path); wait_for(path, 30);} else
#ifdef PS3MAPI
if(_islike(line, "beep")) {play_sound_id((u8)(line[4]));} else
#else
Expand All @@ -157,16 +173,27 @@ static void parse_script(const char *script_file)
}
else
#endif
if(_islike(line, "if ") || _islike(line, "abort if "))
if(_islike(line, "if ") || _islike(line, "abort if ") || _islike(line, "while "))
{
#define DO_WHILE 6
#define ABORT_IF 9

bool ret = false; u8 ifmode = (_islike(line, "if ")) ? 3 : ABORT_IF; line += ifmode; do_else = true;
u8 ifmode;
if(_islike(line, "while ")) {ifmode = DO_WHILE, mloop = line;} else ifmode = _islike(line, "if ") ? 3 : ABORT_IF;
line += ifmode;

bool ret = false; do_else = true;

if(_islike(line, "exist /")) {path += 6; check_path_tags(path); ret = file_exists(path);} else
if(_islike(line, "not exist /")) {path += 10; check_path_tags(path); ret = not_exists(path);} else
if(_islike(line, "Firmware")) {line += 9; ret = IS(fw_version, line);} else
if(_islike(line, "noCobra")) {ret = !cobra_version;} else
if(_islike(line, "xmb")) {ret = IS_ON_XMB;} else
if(_islike(line, "ingame")) {ret = IS_INGAME;} else
if(_islike(line, "count ")) {if(!count) {count = (u16)val(line + 6); ret = count;} else ret = --count;} else
if(_islike(line, "copying")) {ret = copy_in_progress;} else
if(_islike(line, "mounting")) {ret = is_mounting;} else
if(_islike(line, "log")) {ret = USER_LOGGEDIN; if(strstr(line, "out")) ret = !ret;} else
#if defined(PS3MAPI) || defined(DEBUG_MEM)
if(_islike(line, "titleid ")){path += 8; get_game_info(); ret = (strlen(_game_TitleID) >= strlen(path)) ? bcompare(_game_TitleID, path, strlen(path), path) : 0;} else
#endif
Expand All @@ -183,7 +210,19 @@ static void parse_script(const char *script_file)
if(_islike(line, "R1")) ret = is_pressed(CELL_PAD_CTRL_R1);
}

if(ifmode == ABORT_IF) {if(ret) break;} else if(!ret) exec_mode = false;
if(ifmode == ABORT_IF)
{
if(ret) break; // about script if true
}
else if(!ret) // if condition is false
{
if(ifmode == DO_WHILE)
{
EXIT_LOOP;
}
else
exec_mode = false; // do else or go to end
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions include/file/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ static u8 wait_for_xmb(void)
return (t > MAX_WAIT); // true = timeout
}

static void wait_for_user(void)
{
while(working && !USER_LOGGEDIN) sys_ppu_thread_sleep(3); wait_for_xmb();
}

static void check_reload(void)
{
from_reboot = file_exists(WM_NOSCAN_FILE);
Expand Down
18 changes: 11 additions & 7 deletions include/init/vsh.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Explore_Plugin Commands: https://www.psdevwiki.com/ps3/Explore_plugin

#define USER_LOGGEDIN (xusers()->GetCurrentUserNumber() > 0)
#define EXPLORE_CLOSE_ALL 3

static void * getNIDfunc(const char * vsh_module, u32 fnid, s32 offset)
Expand Down Expand Up @@ -55,11 +56,14 @@ static sys_addr_t sys_mem_allocate(u32 bytes)

static explore_plugin_interface *get_explore_interface(void)
{
int view = View_Find("explore_plugin");
if(view)
explore_interface = (explore_plugin_interface *)plugin_GetInterface(view, 1);
else
explore_interface = NULL;
explore_interface = NULL;

if(USER_LOGGEDIN)
{
int view = View_Find("explore_plugin");
if(view)
explore_interface = (explore_plugin_interface *)plugin_GetInterface(view, 1);
}

return explore_interface;
}
Expand Down Expand Up @@ -400,7 +404,7 @@ static int count_items(const char *path)
#ifdef COBRA_ONLY
static void reload_xmb(u8 use_app)
{
if(IS_ON_XMB)
if(IS_ON_XMB && USER_LOGGEDIN)
{
#ifdef LITE_EDITION
if(!cobra_version)
Expand Down Expand Up @@ -439,7 +443,7 @@ static void reload_xmb(u8 use_app)
// hold L2 to cancel reload xmb
if(is_pressed(CELL_PAD_CTRL_L2)) return; // hold L2 to cancel reload xmb

if(IS_ON_XMB)
if(IS_ON_XMB && USER_LOGGEDIN)
{
if((webman_config->reloadxmb == 2) || (!use_app && count_items(HDD0_HOME_DIR) <= 1)) use_app = true;

Expand Down
5 changes: 3 additions & 2 deletions include/www/www_start.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ static void start_www(u64 conn_s_p)
#endif

#ifdef PLAY_MUSIC
if(wait_for_abort(1)) sys_ppu_thread_exit(0);
if(webman_config->music)
if(webman_config->music && USER_LOGGEDIN)
{
if(wait_for_abort(1)) sys_ppu_thread_exit(0);

bool is_video = (webman_config->music == 2);
sprintf(templn, "Starting %s...\n"
"Press O to abort",
Expand Down
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ SYS_MODULE_STOP(wwwd_stop);
SYS_MODULE_EXIT(wwwd_stop);

#define WM_APPNAME "webMAN"
#define WM_VERSION "1.47.46g MOD"
#define WM_VERSION "1.47.46h MOD"
#define WM_APP_VERSION WM_APPNAME " " WM_VERSION
#define WEBMAN_MOD WM_APPNAME " MOD"

Expand Down

0 comments on commit 6556443

Please sign in to comment.