2023-07-12 09:00:08 +02:00
|
|
|
MODULE Fetcher;
|
|
|
|
IMPORT OS, Browser, Desktop;
|
|
|
|
|
|
|
|
EXTERN terminalStreamPtr: POINTER TO CHAR;
|
|
|
|
EXTERN arg0Ptr: POINTER TO CHAR;
|
2023-07-12 19:41:11 +02:00
|
|
|
EXTERN arg1Ptr: POINTER TO CHAR;
|
|
|
|
EXTERN arg2Ptr: POINTER TO CHAR;
|
|
|
|
EXTERN arg3Ptr: POINTER TO CHAR;
|
2023-07-12 09:00:08 +02:00
|
|
|
|
2023-10-13 01:20:12 +02:00
|
|
|
VAR iconsResFile: ARRAY FILE_STRUCT_SIZE OF CHAR;
|
|
|
|
iconsRes: POINTER TO CHAR;
|
|
|
|
iconsResSize: INT;
|
|
|
|
hasIcons: CHAR;
|
|
|
|
|
2023-07-12 09:00:08 +02:00
|
|
|
PROCEDURE Main();
|
|
|
|
BEGIN
|
2023-10-13 01:20:12 +02:00
|
|
|
(* open icons.res from the boot disk and read its contents into `iconsRes` *)
|
|
|
|
hasIcons := 0;
|
|
|
|
IF open("icons.res", get_boot_disk_id(), PTROF(iconsResFile)) THEN
|
|
|
|
iconsResSize := get_size(PTROF(iconsResFile));
|
|
|
|
iconsRes := allocate_memory(iconsResSize);
|
|
|
|
read(iconsResSize, PTROF(iconsResFile), iconsRes);
|
|
|
|
hasIcons := 1;
|
|
|
|
END;
|
|
|
|
|
2023-07-12 09:00:08 +02:00
|
|
|
IF (terminalStreamPtr = 0) & (arg0Ptr = 0) THEN
|
|
|
|
(* probably launched from startup.cfg *)
|
2023-10-13 01:20:12 +02:00
|
|
|
DesktopMain(hasIcons, iconsRes);
|
2023-07-12 09:00:08 +02:00
|
|
|
ELSIF arg0Ptr <|= 5 THEN
|
|
|
|
(* launched from an existing instance of fetcher *)
|
2023-10-13 01:20:12 +02:00
|
|
|
BrowserMain(arg0Ptr, arg1Ptr, arg2Ptr, arg3Ptr, hasIcons, iconsRes);
|
2023-07-12 09:00:08 +02:00
|
|
|
ELSE
|
|
|
|
(* probably launched from the terminal *)
|
2023-10-13 01:20:12 +02:00
|
|
|
BrowserMain(string_to_int(arg0Ptr, 10), 0, 0, 0, hasIcons, iconsRes);
|
|
|
|
END;
|
|
|
|
|
|
|
|
IF hasIcons THEN
|
|
|
|
free_memory(iconsRes);
|
2023-07-12 09:00:08 +02:00
|
|
|
END;
|
|
|
|
END;
|
|
|
|
END.
|