MCPcopy Create free account
hub / github.com/aldostools/webMAN-MOD / parse_script

Function parse_script

include/feat/script.h:67–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67static void parse_script(const char *script_file)
68{
69 if(script_running) return;
70
71 if(file_exists(script_file))
72 {
73 u32 max_size = _64KB_;
74 sys_addr_t sysmem = sys_mem_allocate(max_size);
75 if(!sysmem) return;
76
77 char *buffer, *sep, *pos, *mloop = NULL, *dest = NULL, label[24]; u16 l, count = 0;
78 u8 exec_mode = true, enable_db = true, do_else = true; size_t buffer_size;
79 char log_file[STD_PATH_LEN]; strcpy(log_file, SC_LOG_FILE); *label = NULL;
80
81 reload_script:
82 buffer = (char*)sysmem; buffer_size = read_file(script_file, buffer, max_size, 0); buffer[buffer_size] = 0;
83 if(*buffer) strcat(buffer + buffer_size, "\n");
84
85 l = 0, script_running = true;
86
87 if(mloop) {buffer = mloop; mloop = NULL;}
88 if(*label) {pos = strcasestr(buffer, label); if(pos) buffer = pos; else *buffer = NULL; *label = NULL;}
89
90 while(*buffer)
91 {
92 if(++l > 9999 || !working) break;
93
94 while( *buffer && (*buffer <= ' ')) buffer++; // skip blank chars \n \r \t
95
96 if(*buffer == '\0') break;
97
98 // process line
99 pos = strchr(line, '\n'); if(!pos) pos = line;
100
101 // process line separator ;
102 if(BETWEEN('A', *line, 'z')) {sep = strchr(line, ';'); if(sep && (sep < pos)) pos = sep;}
103
104 if(pos)
105 {
106 *pos = NULL; //EOL
107 replace_char(line, '\r', 0); // crlf
108
109 if(exec_mode)
110 {
111 if(IS_WEB_COMMAND(line))
112 dest = NULL;
113 else
114 {
115 dest = strstr(line, "=/");
116 if(!dest) dest = strstr(line, ",/");
117 if(!dest) dest = strstr(line, ", /");
118 }
119 if(enable_db && (strstr(line, "/dev_blind"))) {enable_dev_blind(NO_MSG); enable_db = false;}
120 }
121 parse_cmd:
122 if(dest)
123 {
124 *dest++ = NULL; while(*dest == ' ') dest++; //split parameters

Callers 4

mount_threadFunction · 0.85
script_threadFunction · 0.85
do_custom_comboFunction · 0.85
pad_combo_play.hFile · 0.85

Calls 15

sys_mem_allocateFunction · 0.85
replace_charFunction · 0.85
_islikeFunction · 0.85
check_path_tagsFunction · 0.85
handle_file_requestFunction · 0.85
ISFunction · 0.85
set_app_homeFunction · 0.85
scanFunction · 0.85
rename_fileFunction · 0.85
folder_copyFunction · 0.85
force_folder_copyFunction · 0.85
force_copyFunction · 0.85

Tested by

no test coverage detected