29#include <unixlib/local.h>
30#include <fpu_control.h>
31#include <oslib/help.h>
33#include <oslib/inetsuite.h>
34#include <oslib/pdriver.h>
35#include <oslib/osfile.h>
36#include <oslib/hourglass.h>
37#include <oslib/osgbpb.h>
38#include <oslib/osbyte.h>
39#include <oslib/osmodule.h>
40#include <oslib/osfscontrol.h>
105 __RISCOSIFY_NO_REVERSE_SUFFIX;
113#define CHOICES_PREFIX "<Choices$Write>.WWW.NetSurf."
126 message_HELP_REQUEST,
129 message_DATA_SAVE_ACK,
131 message_DATA_LOAD_ACK,
134 message_SAVE_DESKTOP,
135 message_MENU_WARNING,
136 message_MENUS_DELETED,
138 message_CLAIM_ENTITY,
139 message_DATA_REQUEST,
143 message_PALETTE_CHANGE,
144 message_FONT_CHANGED,
146 message_URI_RETURN_RESULT,
147 message_INET_SUITE_OPEN_URL,
150 message_PRINT_TYPE_ODD,
178 static const char base_url[] =
"file:///NetSurf:/Resources/";
180 size_t path_len, length;
185 if (strcmp(
path,
"adblock.css") == 0) {
188 }
else if (strcmp(
path,
"default.css") == 0) {
191 }
else if (strcmp(
path,
"quirks.css") == 0) {
194 }
else if (strcmp(
path,
"favicon.ico") == 0) {
195 path =
"Icons/content.png";
197 }
else if (strcmp(
path,
"user.css") == 0) {
203 path_len = strlen(
path);
208 length =
SLEN(base_url) +
212 raw = malloc(length);
215 char *ptr = memcpy(raw, base_url,
SLEN(base_url));
216 ptr +=
SLEN(base_url);
220 if (path_len >
SLEN(
".html") &&
221 strncmp(
path + path_len -
SLEN(
".html"),
222 ".html",
SLEN(
".html")) == 0) {
223 ptr += sprintf(ptr,
"%s/", lang);
227 memcpy(ptr,
path, path_len);
257 os_PALETTE(20) palette;
259 error = xwimp_read_true_palette((os_palette *) &palette);
262 "xwimp_read_palette: 0x%x: %s",
267 def_colour = palette.entries[wimp] >> 8;
270 opts[option].
value.
c = def_colour;
296 NSLOG(netsurf, INFO,
"Failed initialising default options");
356 path = getenv(
"NetSurf$ChoicesSave");
358 die(
"Failed to find NetSurf Choices save path");
360 snprintf(buf,
sizeof(buf),
"%s",
path);
379 xosfile_create_dir(buf, 0);
391 xos_cli(
"FontRemove NetSurf:Resources.Fonts.");
400 static const os_error error = { 1,
"NetSurf has detected a serious "
401 "error and must exit. Please submit a bug report, "
402 "attaching the browser log file." };
403 os_colour old_sand, old_glass;
408 xhourglass_colours(0x0000ffff, 0x000000ff, &old_sand, &old_glass);
415 xos_read_var_val_size(
"NetSurf$CoreDump", 0, 0, &used, 0, 0);
418 xwimp_slot_size(-1, -1, &curr_slot, 0, 0);
419 NSLOG(netsurf, INFO,
"saving WimpSlot, size 0x%x", curr_slot);
420 xosfile_save(
"$.NetSurf_Slot", 0x8000, 0,
422 (
byte *) 0x8000 + curr_slot);
428 &base_address, 0, 0, 0, 0, 0);
430 "saving DA %i, base %p, size 0x%x",
434 xosfile_save(
"$.NetSurf_DA",
435 (bits) base_address, 0,
437 base_address + size);
443 const _kernel_oserror *err = __unixlib_write_coredump (NULL);
445 NSLOG(netsurf, INFO,
"Coredump failed: %s", err->errmess);
448 xhourglass_colours(old_sand, old_glass, 0, 0);
451 __write_backtrace(sig);
453 xwimp_report_error_by_category(&error,
454 wimp_ERROR_BOX_GIVEN_CATEGORY |
455 wimp_ERROR_BOX_CATEGORY_ERROR <<
456 wimp_ERROR_BOX_CATEGORY_SHIFT,
457 "NetSurf",
"!netsurf",
458 (osspriteop_area *) 1,
"Quit", 0);
459 xos_cli(
"Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.Log");
483 do { c = getc(fp); }
while (c != EOF && 32 <= c);
486 do { c = getc(fp); }
while (c != EOF && c < 32);
497 }
while (c != EOF && 32 <= c);
500 while (c != EOF && c < 32)
527 fp = fopen(file_name,
"rb");
529 NSLOG(netsurf, INFO,
"fopen(\"%s\", \"rb\"): %i: %s",
530 file_name, errno, strerror(errno));
537 goto uri_syntax_error;
541 strspn(
line,
"0123456789") != strlen(
line))
542 goto uri_syntax_error;
546 goto uri_syntax_error;
558 if (uri_title &&
line[0] && ((
line[0] !=
'*') ||
line[1])) {
559 *uri_title = strdup(
line);
589 fp = fopen(file_name,
"r");
591 NSLOG(netsurf, INFO,
"fopen(\"%s\", \"r\"): %i: %s",
592 file_name, errno, strerror(errno));
597 if (!fgets(
line,
sizeof line, fp)) {
599 NSLOG(netsurf, INFO,
"fgets: %i: %s", errno,
635 fp = fopen(file_name,
"r");
637 NSLOG(netsurf, INFO,
"fopen(\"%s\", \"r\"): %i: %s",
638 file_name, errno, strerror(errno));
643 while (fgets(
line,
sizeof line, fp)) {
644 if (strncmp(
line,
"URL=", 4) == 0) {
647 url = strdup(
line + 4);
657 NSLOG(netsurf, INFO,
"fgets: %i: %s", errno, strerror(errno));
679 int file_type = message->data.data_xfer.file_type;
700 data.data_xfer.file_name);
706 len = strlen(message->data.data_xfer.file_name);
707 if (len < 9 || strcmp(
".!NetSurf",
708 message->data.data_xfer.file_name + len - 9))
725 message->action = message_DATA_LOAD_ACK;
726 message->your_ref = message->my_ref;
727 oserror = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
729 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x: %s",
730 oserror->errnum, oserror->errmess);
758 int file_type = message->data.data_xfer.file_type;
804 case osfile_TYPE_DRAW:
807 case osfile_TYPE_SPRITE:
808 case osfile_TYPE_TEXT:
849 message->action = message_DATA_LOAD_ACK;
850 message->your_ref = message->my_ref;
851 oserror = xwimp_send_message(wimp_USER_MESSAGE, message,
854 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x: %s",
855 oserror->errnum, oserror->errmess);
871 const char *ep = (
char*)message + message->size;
872 char *p = message->file_name;
874 if ((
size_t)message->size >=
sizeof(*message))
875 ep = (
char*)message +
sizeof(*message) - 1;
877 while (p < ep && *p >=
' ') p++;
887 wimp_full_message_data_xfer *dataxfer = (wimp_full_message_data_xfer*)message;
897 switch (dataxfer->file_type) {
908 case osfile_TYPE_DRAW:
911 case osfile_TYPE_SPRITE:
912 case osfile_TYPE_TEXT:
918 dataxfer->your_ref = dataxfer->my_ref;
919 dataxfer->size = offsetof(wimp_full_message_data_xfer, file_name) + 16;
920 dataxfer->action = message_DATA_SAVE_ACK;
921 dataxfer->est_size = -1;
922 memcpy(dataxfer->file_name,
"<Wimp$Scrap>", 13);
924 error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)dataxfer, message->sender);
927 "xwimp_send_message: 0x%x: %s",
977 message->your_ref = message->my_ref;
978 error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE,
979 message, message->sender);
981 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x:%s",
982 error->errnum, error->errmess);
998 error = xosgbpb_writew(message->data.save_desktopw.file,
999 (
const byte*)
"Run ", 4, NULL);
1001 error = xosgbpb_writew(message->data.save_desktopw.file,
1004 error = xos_bputw(
'\n', message->data.save_desktopw.file);
1008 NSLOG(netsurf, INFO,
"xosgbpb_writew/xos_bputw: 0x%x:%s",
1009 error->errnum, error->errmess);
1013 message->your_ref = message->my_ref;
1014 error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE,
1015 message, message->sender);
1017 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x:%s",
1018 error->errnum, error->errmess);
1032 wimp_full_message_window_info *wi;
1039 wi = (wimp_full_message_window_info*)message;
1056 os_MODEVAR_XWIND_LIMIT,
1058 os_MODEVAR_YWIND_LIMIT,
1059 os_MODEVAR_XEIG_FACTOR,
1060 os_MODEVAR_YEIG_FACTOR,
1069 NSLOG(netsurf, INFO,
"xos_read_vdu_variables: 0x%x: %s",
1070 error->errnum, error->errmess);
1085 resolvers = getenv(
"Inet$Resolvers");
1086 if (resolvers && resolvers[0]) {
1087 NSLOG(netsurf, INFO,
"Inet$Resolvers '%s'", resolvers);
1089 NSLOG(netsurf, INFO,
"Inet$Resolvers not set or empty");
1107 os_MODEVAR_MODE_FLAGS, &var_val, &psr);
1109 NSLOG(netsurf, ERROR,
"xos_read_mode_variable: 0x%x: %s",
1110 error->errnum, error->errmess);
1114 return (var_val == (1 << 15));
1126 void (*sigabrt)(int);
1127 void (*sigfpe)(int);
1128 void (*sigill)(int);
1129 void (*sigint)(int);
1130 void (*sigsegv)(int);
1131 void (*sigterm)(int);
1132 void (*sigoserror)(int);
1149 _FPU_SETCW(_FPU_IEEE & ~(_FPU_MASK_PM | _FPU_MASK_UM));
1151 xhourglass_start(1);
1156 xos_byte(osbyte_IN_KEY, 0, 0xff, &
os_version, NULL);
1159 NSLOG(netsurf, INFO,
"OS supports alpha sprites: %s",
1164 if (!xosmodule_lookup(
"VideoHWSMI", NULL, NULL, &
base, NULL, NULL)) {
1166 const char *help = (
char*)
base + ((
int*)
base)[5];
1167 while (*help > 9) help++;
1168 while (*help == 9) help++;
1169 if (!memcmp(help,
"0.55", 4))
1187 if (prev_sigs.sigabrt == SIG_ERR || prev_sigs.sigfpe == SIG_ERR ||
1188 prev_sigs.sigill == SIG_ERR ||
1189 prev_sigs.sigint == SIG_ERR ||
1190 prev_sigs.sigsegv == SIG_ERR ||
1191 prev_sigs.sigterm == SIG_ERR ||
1192 prev_sigs.sigoserror == SIG_ERR)
1193 die(
"Failed registering signal handlers");
1198 die(
"Unable to load Sprites.");
1201 nsdir_temp = getenv(
"NetSurf$Dir");
1203 die(
"Failed to locate NetSurf directory");
1206 die(
"Failed duplicating NetSurf directory string");
1219 error = xwimp_initialise(wimp_VERSION_RO38,
task_name,
1223 NSLOG(netsurf, INFO,
"xwimp_initialise: 0x%x: %s",
1224 error->errnum, error->errmess);
1225 die(error->errmess);
1261 if (getenv(
"NetSurf$Start_URI_Handler"))
1262 xwimp_start_task(
"Desktop", 0);
1265 if ((length = snprintf(
path,
sizeof(
path),
1266 "NetSurf:Resources.%s.Templates",
1268 die(
"Failed to locate Templates resource.");
1269 error = xwimp_open_template(
path);
1271 NSLOG(netsurf, INFO,
"xwimp_open_template failed: 0x%x: %s",
1272 error->errnum, error->errmess);
1273 die(error->errmess);
1301 wimp_close_template();
1313 NSLOG(netsurf, INFO,
"parameters: '%s'", argv[1]);
1315 if (strcasecmp(argv[1],
"-nowin") == 0) {
1320 else if (argc == 3) {
1321 NSLOG(netsurf, INFO,
"parameters: '%s' '%s'", argv[1],
1326 if (strcasecmp(argv[1],
"-html") == 0) {
1330 else if (strcasecmp(argv[1],
"-urlf") == 0) {
1333 NSLOG(netsurf, INFO,
"allocation failed");
1334 die(
"Insufficient memory for URL");
1340 else if (strcasecmp(argv[1],
"-url") == 0) {
1345 NSLOG(netsurf, INFO,
"Unknown parameters: '%s' '%s'",
1392 error = xosbyte_read(osbyte_VAR_COUNTRY_NUMBER, &country);
1394 NSLOG(netsurf, INFO,
"xosbyte_read failed: 0x%x: %s",
1395 error->errnum, error->errmess);
1415 sprintf(
path,
"NetSurf:Resources.%s", lang);
1435 char *canonical_path;
1444 error = xosfscontrol_canonicalise_path(
path, 0, 0, 0, 0, &spare);
1446 NSLOG(netsurf, INFO,
1447 "xosfscontrol_canonicalise_path failed: 0x%x: %s",
1454 canonical_path = malloc(1 - spare);
1455 if (canonical_path == NULL) {
1456 free(canonical_path);
1460 error = xosfscontrol_canonicalise_path(
path, canonical_path, 0, 0, 1 - spare, 0);
1462 NSLOG(netsurf, INFO,
1463 "xosfscontrol_canonicalise_path failed: 0x%x: %s",
1467 free(canonical_path);
1472 unix_path = __unixify(canonical_path, __RISCOSIFY_NO_REVERSE_SUFFIX, NULL, 0, 0);
1474 if (unix_path == NULL) {
1475 NSLOG(netsurf, INFO,
"__unixify failed: %s", canonical_path);
1476 free(canonical_path);
1479 free(canonical_path);
1482 ret =
url_escape(unix_path,
false,
"/", &escaped_path);
1491 url = malloc(urllen);
1493 NSLOG(netsurf, INFO,
"Unable to allocate url");
1498 if (*escaped_path ==
'/') {
1499 snprintf(url, urllen,
"%s%s",
1502 snprintf(url, urllen,
"%s%s",
1525 lwc_string *urlpath;
1534 if ((url == NULL) || (path_out == NULL)) {
1540 if (lwc_string_caseless_isequal(scheme, corestring_lwc_file,
1541 &match) != lwc_error_ok)
1545 lwc_string_unref(scheme);
1546 if (match ==
false) {
1551 if (urlpath == NULL) {
1556 lwc_string_length(urlpath),
1559 lwc_string_unref(urlpath);
1565 path = malloc(unpath_len + 100);
1571 r = __riscosify(unpath, 0, __RISCOSIFY_NO_SUFFIX,
1572 path, unpath_len + 100, 0);
1639 wimp_key *key = (wimp_key *) pw;
1642 os_error *error = xwimp_process_key(key->c);
1644 NSLOG(netsurf, INFO,
"xwimp_process_key: 0x%x: %s",
1645 error->errnum, error->errmess);
1659 if (key->c == wimp_KEY_ESCAPE &&
1669 }
else if (key->c == 22 ) {
1673 copy = malloc(
sizeof(wimp_key));
1676 memcpy(copy, key,
sizeof(wimp_key));
1680 os_error *error = xwimp_process_key(key->c);
1682 NSLOG(netsurf, INFO,
"xwimp_process_key: 0x%x: %s",
1683 error->errnum, error->errmess);
1699 switch (message->action) {
1700 case message_DATA_LOAD:
1703 if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
1707 (wimp_full_message_data_xfer *) message) ==
false) {
1712 case message_DATA_LOAD_ACK:
1717 case message_MENU_WARNING:
1722 case message_MENUS_DELETED:
1727 case message_CLAIM_ENTITY:
1731 case message_DATA_REQUEST:
1735 case message_MODE_CHANGE:
1737 rufl_invalidate_cache();
1740 case message_PALETTE_CHANGE:
1743 case message_FONT_CHANGED:
1747 case message_URI_PROCESS:
1748 if (event != wimp_USER_MESSAGE_ACKNOWLEDGE)
1751 case message_URI_RETURN_RESULT:
1754 case message_INET_SUITE_OPEN_URL:
1755 if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
1762 case message_PRINT_SAVE:
1763 if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
1766 case message_PRINT_ERROR:
1769 case message_PRINT_TYPE_ODD:
1791 case wimp_NULL_REASON_CODE:
1796 case wimp_REDRAW_WINDOW_REQUEST:
1800 case wimp_OPEN_WINDOW_REQUEST:
1804 case wimp_CLOSE_WINDOW_REQUEST:
1808 case wimp_POINTER_LEAVING_WINDOW:
1812 case wimp_POINTER_ENTERING_WINDOW:
1816 case wimp_MOUSE_CLICK:
1820 case wimp_USER_DRAG_BOX:
1824 case wimp_KEY_PRESSED:
1828 case wimp_MENU_SELECTION:
1836 case wimp_SCROLL_REQUEST:
1841 case wimp_USER_MESSAGE:
1842 case wimp_USER_MESSAGE_RECORDED:
1843 case wimp_USER_MESSAGE_ACKNOWLEDGE:
1855 wimp_event_no event;
1857 const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN | wimp_SAVE_FP;
1858 os_t track_poll_offset;
1864 os_t t = os_read_monotonic_time();
1866 if (track_poll_offset > 0) {
1867 t += track_poll_offset;
1876 event = wimp_poll_idle(mask, &block, t, 0);
1878 event = wimp_poll(wimp_MASK_NULL | mask, &block, 0);
1890 if (event == wimp_NULL_REASON_CODE) {
1908 error = xwimp_open_window(open);
1910 NSLOG(netsurf, INFO,
"xwimp_open_window: 0x%x: %s",
1911 error->errnum, error->errmess);
1928 filename = ((wimp_full_message_data_xfer *)message)->file_name;
1929 sprintf(command,
"@RunType_FFF %s", filename);
1930 error = xwimp_start_task(command, 0);
1932 NSLOG(netsurf, INFO,
"xwimp_start_task failed: 0x%x: %s",
1933 error->errnum, error->errmess);
1946 wimp_full_message_data_xfer message;
1950 const uint8_t *source_data;
1967 error = xosfile_read_no_path(temp_name, &objtype, 0, 0, 0, 0);
1968 if ((!error) && (objtype == osfile_IS_FILE)) {
1969 snprintf(message.file_name, 212,
"%s", temp_name);
1970 message.file_name[211] =
'\0';
1983 char full_name[256];
1992 full_name[255] =
'\0';
1993 r = __riscosify(full_name, 0, __RISCOSIFY_NO_SUFFIX,
1994 message.file_name, 212, 0);
1996 NSLOG(netsurf, INFO,
"__riscosify failed");
1999 message.file_name[211] =
'\0';
2001 error = xosfile_save_stamped(message.file_name,
2003 (
byte *) source_data,
2004 (
byte *) source_data + source_size);
2006 NSLOG(netsurf, INFO,
2007 "xosfile_save_stamped failed: 0x%x: %s",
2016 message.your_ref = 0;
2017 message.size = 44 + ((strlen(message.file_name) + 4) & (~3u));
2018 message.action = message_DATA_OPEN;
2023 message.est_size = 0;
2024 message.file_type = 0xfff;
2026 (wimp_message*)&message, 0,
2064 die(
"Out of memory");
2067 die(
"Out of memory");
2079 NSLOG(netsurf, INFO,
"%s %s", warning, detail);
2082 char warn_buffer[300];
2083 snprintf(warn_buffer,
sizeof warn_buffer,
"%s %s",
2085 detail ? detail :
"");
2086 warn_buffer[
sizeof warn_buffer - 1] = 0;
2090 wimp_ICON_DELETED, wimp_ICON_DELETED);
2097 snprintf(error.errmess,
sizeof error.errmess,
"%s %s",
2099 detail ? detail :
"");
2100 error.errmess[
sizeof error.errmess - 1] = 0;
2101 xwimp_report_error_by_category(&error,
2102 wimp_ERROR_BOX_OK_ICON |
2103 wimp_ERROR_BOX_GIVEN_CATEGORY |
2104 wimp_ERROR_BOX_CATEGORY_ERROR <<
2105 wimp_ERROR_BOX_CATEGORY_SHIFT,
2106 "NetSurf",
"!netsurf",
2107 (osspriteop_area *) 1, 0, 0);
2119void die(
const char *
const error)
2121 os_error warn_error;
2123 NSLOG(netsurf, INFO,
"%s", error);
2125 warn_error.errnum = 1;
2127 sizeof(warn_error.errmess)-1);
2128 warn_error.errmess[
sizeof(warn_error.errmess)-1] =
'\0';
2129 xwimp_report_error_by_category(&warn_error,
2130 wimp_ERROR_BOX_OK_ICON |
2131 wimp_ERROR_BOX_GIVEN_CATEGORY |
2132 wimp_ERROR_BOX_CATEGORY_ERROR <<
2133 wimp_ERROR_BOX_CATEGORY_SHIFT,
2134 "NetSurf",
"!netsurf",
2135 (osspriteop_area *) 1, 0, 0);
2172 const char *elm[16];
2176 size_t fname_len = 0;
2181 if ((nelm == 0) || (nelm > 16)) {
2184 if ((*str != NULL) && (size == NULL)) {
2194 for (elm_idx = 0; elm_idx < nelm; elm_idx++) {
2195 elm[elm_idx] = va_arg(ap,
const char *);
2197 if (elm[elm_idx] == NULL) {
2200 elm_len[elm_idx] = strlen(elm[elm_idx]);
2201 fname_len += elm_len[elm_idx];
2207 if (fname != NULL) {
2208 if (fname_len > *size) {
2212 fname = malloc(fname_len);
2213 if (fname == NULL) {
2222 memmove(curp, elm[0], elm_len[0]);
2233 for (elm_idx = 1; elm_idx < nelm; elm_idx++) {
2234 for (idx = 0; idx < elm_len[elm_idx]; idx++) {
2235 if (elm[elm_idx][idx] ==
DIR_SEP) {
2238 *curp = elm[elm_idx][idx];
2247 assert((curp - fname) <= (
int)fname_len);
2277 const char *leafname;
2292 fname = strdup(leafname);
2293 if (fname == NULL) {
2299 for (temp = fname; *temp != 0; temp++) {
2307 *size = strlen(fname);
2326 dname = strdup(fname);
2329 while ((cur = strchr(cur,
'.'))) {
2331 xosfile_create_dir(dname, 0);
2358 FILE *stream = fopen(
"<Wimp$ScrapDir>.WWW.NetSurf.dump",
"w");
2360 NSLOG(netsurf, INFO,
"fopen: errno %i", errno);
2370 error = xwimp_start_task(
"Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.dump",
2373 NSLOG(netsurf, INFO,
"xwimp_start_task failed: 0x%x: %s",
2374 error->errnum, error->errmess);
2407 char *cachepath = NULL;
2410 cachedir = getenv(
"Cache$Dir");
2411 if ((cachedir == NULL) || (cachedir[0] == 0)) {
2412 NSLOG(netsurf, INFO,
"cachedir was null");
2451 die(
"NetSurf operation table failed registration");
2456 error = xos_read_var_val_size(
"NetSurf$Logging", 0, os_VARTYPE_STRING,
2457 &used, NULL, &
type);
2458 if (error != NULL ||
type != os_VARTYPE_STRING || used != -2) {
2461 char logging_env[2];
2462 error = xos_read_var_val(
"NetSurf$Logging", logging_env,
2463 sizeof(logging_env), 0, os_VARTYPE_STRING,
2464 &used, NULL, &
type);
2465 if (error != NULL || logging_env[0] !=
'0') {
2480 die(
"Options failed to initialise");
2489 if (((length = snprintf(
path,
2491 "NetSurf:Resources.%s.Messages",
2493 (length >= (
int)
sizeof(
path))) {
2494 die(
"Failed to locate Messages resource.");
2507 die(
"NetSurf failed to initialise core");
const char * fetch_filetype(const char *unix_path)
Determine the MIME type of a local file.
int main(int argc, char **argv)
Normal entry point from OS.
Content for image/x-artworks (RISC OS interface).
static nserror artworks_init(void)
int schedule_run(void)
Process events up to current time.
Low-level source data cache backing store interface.
struct gui_llcache_table * filesystem_llcache_table
Browser window creation and manipulation interface.
nserror browser_window_navigate(struct browser_window *bw, struct nsurl *url, struct nsurl *referrer, enum browser_window_nav_flags flags, char *post_urlenc, struct fetch_multipart_data *post_multipart, struct hlcache_handle *parent)
Start fetching a page in a browser window.
nserror browser_window_create(enum browser_window_create_flags flags, struct nsurl *url, struct nsurl *referrer, struct browser_window *existing, struct browser_window **bw)
Create and open a new root browser window with the given page.
nserror browser_window_debug_dump(struct browser_window *bw, FILE *f, enum content_debug op)
Dump debug info concerning the browser window's contents to file.
@ BW_CREATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
@ BW_NAVIGATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
void ro_gui_buffer_close(void)
Closes any open buffer and flushes the contents to screen.
Screen buffering (interface).
@ CONTENT_DEBUG_RENDER
Debug the contents rendering.
Unified cookie database public interface.
void urldb_save_cookies(const char *filename)
Save persistent cookies to file.
void urldb_load_cookies(const char *filename)
Load a cookie file into the database.
Useful interned string pointers (interface).
#define FILE_SCHEME_PREFIX_LEN
File url prefix length.
#define FILE_SCHEME_PREFIX
File url prefix.
static nserror hotlist_save(const char *path)
nserror hotlist_init(const char *load_path, const char *save_path)
Initialise the hotlist.
void ro_gui_dialog_close_persistent(wimp_w parent)
Close persistent dialogs associated with a window.
void ro_gui_dialog_open(wimp_w w)
Open a dialog box, centred on the screen.
void ro_gui_dialog_init(void)
Load and create dialogs from template file.
void ro_gui_dialog_close(wimp_w close)
Close a dialog box.
Content for image/x-drawfile (RISC OS interface).
static nserror draw_init(void)
nserror
Enumeration of error codes.
@ NSERROR_NOSPACE
Insufficient space.
@ NSERROR_NOT_FOUND
Requested item not found.
@ NSERROR_BAD_PARAMETER
Bad Parameter.
@ NSERROR_NOMEM
Memory exhaustion.
const char * filename_request(void)
Request a new, unique, filename.
bool filename_initialise(void)
Initialise the filename provider.
#define TEMP_FILENAME_PREFIX
struct gui_bitmap_table * riscos_bitmap_table
bitmap operations table
void ro_gui_download_init(void)
Load the download window template.
bool ro_gui_download_prequit(void)
Respond to PreQuit message, displaying a prompt message if we need the user to confirm the shutdown.
struct gui_download_table * riscos_download_table
void ro_gui_download_datasave_ack(wimp_message *message)
Handle Message_DataSaveAck for a drag from a download window.
void nsfont_init(void)
Initialize font handling.
void ro_gui_wimp_get_desktop_font(void)
Retrieve the current desktop font family, size and style from the WindowManager in a form suitable fo...
struct gui_layout_table * riscos_layout_table
nserror ro_gui_global_history_finalise(void)
Free any resources allocated for the global history window.
RISc OS global history interface.
void ro_gui_hotlist_add_cleanup(void)
Clean up RMA storage used by the Message_HotlistAddURL protocol.
nserror ro_gui_hotlist_finalise(void)
Free any resources allocated for the cookie window.
#define message_HOTLIST_CHANGED
#define message_HOTLIST_ADD_URL
nserror ro_gui_local_history_finalise(void)
Free any resources allocated for the local history window.
RISC OS local history interface.
void ro_mouse_pointer_leaving_window(wimp_leaving *leaving)
Process Wimp_PointerLeaving events by terminating an active mouse track and passing the details on to...
os_t ro_mouse_poll_interval(void)
Return the desired polling interval to allow the mouse tracking to be carried out.
void ro_mouse_drag_end(wimp_dragged *dragged)
Process Wimp_DragEnd events by terminating an active drag track and passing the details on to any reg...
void ro_mouse_poll(void)
Process Null polls for any drags and mouse trackers that are currently active.
Mouse dragging and tracking support interface for RISC OS.
void ro_print_dataload_bounce(wimp_message *m)
Handle a bounced dataload message.
void ro_print_cleanup(void)
Cleanup after printing.
void ro_print_error(wimp_message *m)
Handle message_PRINT_ERROR.
bool ro_print_ack(wimp_message *m)
Handle message_DATASAVE_ACK for the printing protocol.
struct gui_window * ro_print_current_window
void ro_print_save_bounce(wimp_message *m)
Handle a bounced message_PRINT_SAVE.
void ro_print_type_odd(wimp_message *m)
Handle message_PRINT_TYPE_ODD.
void ro_gui_selection_data_request(wimp_full_message_data_request *req)
Responds to DATA_REQUEST message, returning information about the clipboard contents if we own the cl...
void ro_gui_selection_claim_entity(wimp_full_message_claim_entity *claim)
Responds to CLAIM_ENTITY message notifying us that the caret and selection or clipboard have been cla...
struct gui_clipboard_table * riscos_clipboard_table
bool ro_gui_selection_prepare_paste_datasave(wimp_full_message_data_xfer *dataxfer)
Prepare to paste data from another application (step 2)
void ro_gui_selection_prepare_paste(wimp_w w, ro_gui_selection_prepare_paste_cb cb, void *pw)
Prepare to paste data from another application.
void ro_gui_selection_dragging(wimp_message *message)
Handler for Message_Dragging, used to implement auto-scrolling and ghost caret when a drag is in prog...
bool ro_gui_selection_prepare_paste_dataload(wimp_full_message_data_xfer *dataxfer)
Prepare to paste data from another application (step 3)
void ro_gui_selection_drag_claim(wimp_message *message)
Text selection import/export (interface).
Browser window handling (interface).
#define ro_gui_window_close_all
Close all browser windows.
void ro_gui_iconbar_initialise(void)
Initialise the iconbar menus, create an icon and register the necessary handlers to look after them a...
Iconbar icon and menus (interface).
Public content interface.
struct nsurl * hlcache_handle_get_url(const struct hlcache_handle *handle)
Retrieve the URL associated with a high level cache handle.
const uint8_t * content_get_source_data(struct hlcache_handle *h, size_t *size)
Retrieve source of content.
Interface to platform-specific fetcher operations.
Interface to platform-specific miscellaneous browser operation table.
nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv)
Initialise the logging system.
bool verbose_log
flag to enable verbose logging
void nslog_finalise(void)
Shut down the logging system.
#define NSLOG(catname, level, logmsg, args...)
bool ro_message_handle_message(wimp_event_no event, wimp_message *message)
Attempts to route a message.
bool ro_message_send_message(wimp_event_no event, wimp_message *message, wimp_t task, void(*callback)(wimp_message *message))
Sends a message and registers a return route for a bounce.
bool ro_message_register_route(unsigned int message_code, void(*callback)(wimp_message *message))
Registers a route for a message code.
Automated RISC OS message routing (interface).
nserror messages_add_from_file(const char *path)
Read keys and values from messages file into the standard Messages hash.
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
NetSurf core interface registration, construction and destruction.
void netsurf_exit(void)
Finalise NetSurf core.
nserror netsurf_init(const char *store_path)
Initialise netsurf core.
nserror netsurf_register(struct netsurf_table *table)
Register operation table.
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
lwc_string * nsurl_get_component(const nsurl *url, nsurl_component part)
Get part of a URL as a lwc_string, from a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
void ro_gui_query_init(void)
nserror ro_gui_cookies_finalise(void)
Free any resources allocated for the cookie window.
nserror ro_gui_cookies_present(const char *search_term)
make the cookie window visible.
Interface to riscos cookie viewing using riscos core window.
struct core_window_table * riscos_core_window_table
RISC OS core window interface.
char * fetch_mimetype(const char *ro_path)
Find a MIME type for a local file.
int ro_content_filetype(struct hlcache_handle *c)
Determine the RISC OS filetype for a content.
RISC OS filetpe interface.
#define FILETYPE_ARTWORKS
#define FILETYPE_ACORN_URI
void ro_gui_screen_size(int *width, int *height)
Find screen size in OS units.
static void ro_gui_cleanup(void)
Ensures the gui exits cleanly.
static bool ro_gui_uri_file_parse_line(FILE *fp, char *b)
Read a "line" from an Acorn URI file.
const char *const __dynamic_da_name
For UnixLib.
static void ro_gui_check_resolvers(void)
Warn the user if Inet$Resolvers is not set.
ro_gui_drag_type gui_current_drag_type
static void riscos_poll(void)
Poll the RISC OS wimp for events.
static nsurl * gui_get_resource_url(const char *path)
Callback to translate resource to full url for RISC OS.
void ro_gui_view_source(struct hlcache_handle *c)
Send the source of a content to a text editor.
static struct gui_fetch_table riscos_fetch_table
static void ro_msg_datasave(wimp_message *message)
Handle Message_DataSave.
int __dynamic_da_max_size
For UnixLib.
static nserror gui_launch_url(struct nsurl *url)
Broadcast an URL that we can't handle.
osspriteop_area * gui_sprites
Sprite area containing pointer and hotlist sprites.
static nserror riscos_mkpath(char **str, size_t *size, size_t nelm, va_list ap)
Generate a riscos path from one or more component elemnts.
bool ro_gui_prequit(void)
Test whether it's okay to shutdown, prompting the user if not.
static void ro_gui_user_message(wimp_event_no event, wimp_message *message)
Handle the three User_Message events.
static nserror gui_init(int argc, char **argv)
Initialise the RISC OS specific GUI.
static nserror set_defaults(struct nsoption_s *defaults)
Set option defaults for riscos frontend.
static void ro_gui_get_screen_properties(void)
Get screen properties following a mode change.
wimp_t task_handle
RISC OS wimp task handle.
static bool nslog_stream_configure(FILE *fptr)
Ensures output logging stream is correctly configured.
nserror ro_warn_user(const char *warning, const char *detail)
Display a warning for a serious problem (eg memory exhaustion).
static void ro_msg_save_desktop(wimp_message *message)
Handle SaveDesktop message.
static void ro_gui_close_window_request(wimp_close *close)
Handle Close_Window_Request events.
static void gui_quit(void)
Close down the gui (RISC OS).
void ro_gui_dump_browser_window(struct browser_window *bw)
Send the debug dump of a content to a text editor.
static void ro_gui_keypress_cb(void *pw)
Handle key press paste callback.
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
Process a Wimp_Poll event.
static nserror set_colour_from_wimp(struct nsoption_s *opts, wimp_colour wimp, enum nsoption_e option, colour def_colour)
Set colour option from wimp.
static void ro_gui_signal(int sig)
Handles a signal.
bool ro_plot_patterned_lines
One version of the A9home OS is incapable of drawing patterned lines.
static char * ro_gui_url_file_parse(const char *file_name)
Parse an ANT URL file.
static void ro_msg_dataopen(wimp_message *message)
Handle Message_DataOpen (double-click on file in the Filer).
void die(const char *const error)
Display an error and exit.
static nserror ro_nsurl_to_path(struct nsurl *url, char **path_out)
Create a path from a nsurl using posix file handling.
static char * get_cachepath(void)
static void ro_gui_choose_language(void)
Choose the language to use.
static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out)
Create a nsurl from a RISC OS pathname.
static nserror riscos_mkdir_all(const char *fname)
Ensure that all directory elements needed to store a filename exist.
int __feature_imagefs_is_file
For UnixLib.
static void ro_msg_window_info(wimp_message *message)
Handle WindowInfo message (part of the iconising protocol)
static clock_t gui_last_poll
Time of last wimp_poll.
static void ro_msg_prequit(wimp_message *message)
Handle PreQuit message.
static nserror riscos_basename(const char *path, char **str, size_t *size)
Get the basename of a file using posix path handling.
void ro_gui_open_window_request(wimp_open *open)
Handle Open_Window_Request events.
static void ro_gui_keypress(wimp_key *key)
Handle gui keypress.
static void ro_msg_dataload(wimp_message *message)
Handle Message_DataLoad (file dragged in).
static void ro_gui_view_source_bounce(wimp_message *message)
source bounce callback.
static void ro_gui_create_dirs(void)
Create intermediate directories for Choices and User Data files.
bool os_alpha_sprite_supported
static struct gui_misc_table riscos_misc_table
static bool ro_gui__os_alpha_sprites_supported(void)
Determine whether the OS version supports alpha channels.
static ns_wimp_message_list task_messages
Accepted wimp user messages.
static void ro_msg_terminate_filename(wimp_full_message_data_xfer *message)
Ensure that the filename in a data transfer message is NULL terminated (some applications,...
static const char * task_name
static char * ro_gui_ieurl_file_parse(const char *file_name)
Parse an IEURL file.
static struct gui_file_table riscos_file_table
const char * ro_gui_default_language(void)
Determine the default language to use.
static char * ro_gui_uri_file_parse(const char *file_name, char **uri_title)
Parse an Acorn URI file.
static void ro_msg_datasave_ack(wimp_message *message)
Handle Message_DataSaveAck.
static struct @46 screen_info
os_t sched_time
Time of soonest scheduled event (valid only if sched_active is true).
nserror riscos_schedule(int t, void(*callback)(void *p), void *p)
Schedule a callback.
bool sched_active
Items have been scheduled.
#define ICON_WARNING_HELP
struct gui_search_table * riscos_search_table
#define ICON_WARNING_MESSAGE
void ro_gui_interactive_help_request(wimp_message *message)
Attempts to process an interactive help message request.
Interactive help (interface).
nserror ro_gui_pageinfo_finalise(void)
Free any resources allocated for the page info window.
Interface to page info core window for RISC OS.
File/object/selection saving (Interface).
void ro_gui_theme_initialise(void)
Initialise the theme handler.
void ro_gui_throb(void)
Animate the "throbbers" of all browser windows.
struct gui_window * ro_gui_toolbar_lookup(wimp_w window)
Convert a toolbar RISC OS window handle to a gui_window.
void ro_gui_window_update_boxes(void)
Redraw any pending update boxes.
bool ro_gui_toolbar_dataload(struct gui_window *g, wimp_message *message)
Handle Message_DataLoad (file dragged in) for a toolbar.
struct gui_window_table * riscos_window_table
bool ro_gui_alt_pressed(void)
Returns true iff one or more Alt keys is held down.
void ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi)
Window is being iconised.
struct gui_window * ro_gui_window_lookup(wimp_w window)
Convert a RISC OS window handle to a gui_window.
bool ro_gui_window_dataload(struct gui_window *g, wimp_message *message)
Handle Message_DataLoad (file dragged in) for a window.
void ro_gui_window_quit(void)
Destroy all browser windows.
void ro_gui_window_initialise(void)
Initialise the browser window module and its menus.
void ro_gui_drag_box_cancel(void)
void ro_gui_saveas_quit(void)
Clean-up function that releases our sprite area and memory.
void ro_gui_save_datasave_ack(wimp_message *message)
Handle Message_DataSaveAck for a drag from the save dialog or browser window, or Clipboard protocol.
void save_complete_init(void)
Initialise save complete module.
Save HTML document with dependencies (interface).
Content for image/x-riscos-sprite (RISC OS interface).
static nserror sprite_init(void)
Interface to utility string handling.
function table for fetcher operations.
const char *(* filetype)(const char *unix_path)
Determine the MIME type of a local file.
/brief function table for file and filename operations.
nserror(* mkpath)(char **str, size_t *size, size_t nemb, va_list ap)
Generate a path from one or more component elemnts.
Graphical user interface browser misc function table.
nserror(* schedule)(int t, void(*callback)(void *p), void *p)
Schedule a callback.
first entry in window list
struct browser_window * bw
The 'content' window that is rendered in the gui_window.
NetSurf operation function table.
struct gui_misc_table * misc
Browser table.
union nsoption_s::@149 value
#define alpha_SPRITE_MODE
uint32_t colour
Colour type: XBGR.
struct gui_utf8_table * riscos_utf8_table
UCS conversion tables (interface) This is only used if nothing claims Service_International,...
void ro_uri_message_received(wimp_message *msg)
void ro_uri_bounce(wimp_message *msg)
nserror url_escape(const char *unescaped, bool sptoplus, const char *escexceptions, char **result)
Escape a string suitable for inclusion in an URL.
nserror url_unescape(const char *str, size_t length, size_t *length_out, char **result_out)
Convert an escaped string to plain.
Interface to URL parsing and joining operations.
void ro_gui_url_bar_fini(void)
Finalise the url bar module.
bool ro_gui_url_bar_init(void)
Initialise the url bar module.
Unified URL information database public interface.
nserror urldb_save(const char *filename)
Export the current database to file.
nserror urldb_load(const char *filename)
Import an URL database from file, replacing any existing database.
void ro_url_broadcast(const char *url)
Broadcast an ANT URL message.
void ro_url_message_received(wimp_message *message)
Handle a Message_InetSuiteOpenURL.
void ro_url_bounce(wimp_message *message)
Handle a bounced Message_InetSuiteOpenURL.
ANT URL launching protocol (interface).
nserror netsurf_mkdir_all(const char *fname)
Ensure that all directory elements needed to store a filename exist.
nserror netsurf_nsurl_to_path(struct nsurl *url, char **path_out)
Create a path from a nsurl.
nserror netsurf_path_to_nsurl(const char *path, struct nsurl **url)
Create a nsurl from a path.
nserror netsurf_mkpath(char **str, size_t *size, size_t nelm,...)
Generate a path from one or more component elemnts.
Default operations table for files.
struct nsoption_s * nsoptions_default
global default option table.
static struct nsoption_s defaults[]
The table of compiled in default options.
nserror nsoption_dump(FILE *outf, struct nsoption_s *opts)
Write all options to a stream.
nserror nsoption_read(const char *path, struct nsoption_s *opts)
Read choices file and set them in the passed table.
struct nsoption_s * nsoptions
global active option table.
nserror nsoption_commandline(int *pargc, char **argv, struct nsoption_s *opts)
Process commandline and set options approriately.
nserror nsoption_init(nsoption_set_default_t *set_defaults, struct nsoption_s **popts, struct nsoption_s **pdefs)
Initialise option system.
nserror nsoption_finalise(struct nsoption_s *opts, struct nsoption_s *defs)
Finalise option system.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
#define nsoption_setnull_charp(OPTION, VALUE)
set string option in default table if currently unset
#define nsoption_set_int(OPTION, VALUE)
set an integer option in the default table
#define nsoption_set_charp(OPTION, VALUE)
set string option in default table
#define nsoption_bool(OPTION)
Get the value of a boolean option.
#define nsoption_set_uint(OPTION, VALUE)
set an unsigned integer option in the default table
Interface to a number of general purpose functionality.
#define SLEN(x)
Calculate length of constant C string.
bool is_dir(const char *path)
Check if a directory exists.
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8)
Set the contents of a text or sprite icon to a string.
osspriteop_area * ro_gui_load_sprite_file(const char *pathname)
Load a sprite file into memory.
void ro_gui_scroll(wimp_scroll *scroll)
Generic window scroll event handler.
General RISC OS WIMP/OS library functions (interface).
bool ro_gui_wimp_event_mouse_click(wimp_pointer *pointer)
Handles a mouse click event in a registered window.
bool ro_gui_wimp_event_redraw_window(wimp_draw *redraw)
Handle any redraw window requests.
bool ro_gui_wimp_event_scroll_window(wimp_scroll *scroll)
Handle any scroll window requests.
bool ro_gui_wimp_event_open_window(wimp_open *open)
Handle any open window requests.
bool ro_gui_wimp_event_close_window(wimp_w w)
Service any close window handlers.
bool ro_gui_wimp_event_pointer_entering_window(wimp_entering *entering)
Handle any pointer entering window requests.
bool ro_gui_wimp_event_keypress(wimp_key *key)
Handle any registered keypresses, and the standard RISC OS ones.
Automated RISC OS WIMP event handling (interface).
A collection of grubby utilities for working with OSLib's wimp API.
#define PTR_WIMP_MESSAGE_LIST(l)
#define PTR_OS_VDU_VAR_LIST(l)
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.