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>
106 __RISCOSIFY_NO_REVERSE_SUFFIX;
114#define CHOICES_PREFIX "<Choices$Write>.WWW.NetSurf."
127 message_HELP_REQUEST,
130 message_DATA_SAVE_ACK,
132 message_DATA_LOAD_ACK,
135 message_SAVE_DESKTOP,
136 message_MENU_WARNING,
137 message_MENUS_DELETED,
139 message_CLAIM_ENTITY,
140 message_DATA_REQUEST,
144 message_PALETTE_CHANGE,
145 message_FONT_CHANGED,
147 message_URI_RETURN_RESULT,
148 message_INET_SUITE_OPEN_URL,
151 message_PRINT_TYPE_ODD,
179 static const char base_url[] =
"file:///NetSurf:/Resources/";
181 size_t path_len, length;
186 if (strcmp(
path,
"adblock.css") == 0) {
189 }
else if (strcmp(
path,
"default.css") == 0) {
192 }
else if (strcmp(
path,
"quirks.css") == 0) {
195 }
else if (strcmp(
path,
"favicon.ico") == 0) {
196 path =
"Icons/content.png";
198 }
else if (strcmp(
path,
"user.css") == 0) {
204 path_len = strlen(
path);
209 length =
SLEN(base_url) +
213 raw = malloc(length);
216 char *ptr = memcpy(raw, base_url,
SLEN(base_url));
217 ptr +=
SLEN(base_url);
221 if (path_len >
SLEN(
".html") &&
222 strncmp(
path + path_len -
SLEN(
".html"),
223 ".html",
SLEN(
".html")) == 0) {
224 ptr += sprintf(ptr,
"%s/", lang);
228 memcpy(ptr,
path, path_len);
258 os_PALETTE(20) palette;
260 error = xwimp_read_true_palette((os_palette *) &palette);
263 "xwimp_read_palette: 0x%x: %s",
268 def_colour = palette.entries[wimp] >> 8;
271 opts[option].
value.
c = def_colour;
297 NSLOG(netsurf, INFO,
"Failed initialising default options");
357 path = getenv(
"NetSurf$ChoicesSave");
359 die(
"Failed to find NetSurf Choices save path");
361 snprintf(buf,
sizeof(buf),
"%s",
path);
380 xosfile_create_dir(buf, 0);
392 xos_cli(
"FontRemove NetSurf:Resources.Fonts.");
401 static const os_error error = { 1,
"NetSurf has detected a serious "
402 "error and must exit. Please submit a bug report, "
403 "attaching the browser log file." };
404 os_colour old_sand, old_glass;
409 xhourglass_colours(0x0000ffff, 0x000000ff, &old_sand, &old_glass);
416 xos_read_var_val_size(
"NetSurf$CoreDump", 0, 0, &used, 0, 0);
419 xwimp_slot_size(-1, -1, &curr_slot, 0, 0);
420 NSLOG(netsurf, INFO,
"saving WimpSlot, size 0x%x", curr_slot);
421 xosfile_save(
"$.NetSurf_Slot", 0x8000, 0,
423 (
byte *) 0x8000 + curr_slot);
429 &base_address, 0, 0, 0, 0, 0);
431 "saving DA %i, base %p, size 0x%x",
435 xosfile_save(
"$.NetSurf_DA",
436 (bits) base_address, 0,
438 base_address + size);
444 const _kernel_oserror *err = __unixlib_write_coredump (NULL);
446 NSLOG(netsurf, INFO,
"Coredump failed: %s", err->errmess);
449 xhourglass_colours(old_sand, old_glass, 0, 0);
452 __write_backtrace(sig);
454 xwimp_report_error_by_category(&error,
455 wimp_ERROR_BOX_GIVEN_CATEGORY |
456 wimp_ERROR_BOX_CATEGORY_ERROR <<
457 wimp_ERROR_BOX_CATEGORY_SHIFT,
458 "NetSurf",
"!netsurf",
459 (osspriteop_area *) 1,
"Quit", 0);
460 xos_cli(
"Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.Log");
484 do { c = getc(fp); }
while (c != EOF && 32 <= c);
487 do { c = getc(fp); }
while (c != EOF && c < 32);
498 }
while (c != EOF && 32 <= c);
501 while (c != EOF && c < 32)
528 fp = fopen(file_name,
"rb");
530 NSLOG(netsurf, INFO,
"fopen(\"%s\", \"rb\"): %i: %s",
531 file_name, errno, strerror(errno));
538 goto uri_syntax_error;
542 strspn(
line,
"0123456789") != strlen(
line))
543 goto uri_syntax_error;
547 goto uri_syntax_error;
559 if (uri_title &&
line[0] && ((
line[0] !=
'*') ||
line[1])) {
560 *uri_title = strdup(
line);
590 fp = fopen(file_name,
"r");
592 NSLOG(netsurf, INFO,
"fopen(\"%s\", \"r\"): %i: %s",
593 file_name, errno, strerror(errno));
598 if (!fgets(
line,
sizeof line, fp)) {
600 NSLOG(netsurf, INFO,
"fgets: %i: %s", errno,
636 fp = fopen(file_name,
"r");
638 NSLOG(netsurf, INFO,
"fopen(\"%s\", \"r\"): %i: %s",
639 file_name, errno, strerror(errno));
644 while (fgets(
line,
sizeof line, fp)) {
645 if (strncmp(
line,
"URL=", 4) == 0) {
648 url = strdup(
line + 4);
658 NSLOG(netsurf, INFO,
"fgets: %i: %s", errno, strerror(errno));
680 int file_type = message->data.data_xfer.file_type;
701 data.data_xfer.file_name);
707 len = strlen(message->data.data_xfer.file_name);
708 if (len < 9 || strcmp(
".!NetSurf",
709 message->data.data_xfer.file_name + len - 9))
726 message->action = message_DATA_LOAD_ACK;
727 message->your_ref = message->my_ref;
728 oserror = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
730 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x: %s",
731 oserror->errnum, oserror->errmess);
759 int file_type = message->data.data_xfer.file_type;
805 case osfile_TYPE_DRAW:
808 case osfile_TYPE_SPRITE:
809 case osfile_TYPE_TEXT:
850 message->action = message_DATA_LOAD_ACK;
851 message->your_ref = message->my_ref;
852 oserror = xwimp_send_message(wimp_USER_MESSAGE, message,
855 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x: %s",
856 oserror->errnum, oserror->errmess);
872 const char *ep = (
char*)message + message->size;
873 char *p = message->file_name;
875 if ((
size_t)message->size >=
sizeof(*message))
876 ep = (
char*)message +
sizeof(*message) - 1;
878 while (p < ep && *p >=
' ') p++;
888 wimp_full_message_data_xfer *dataxfer = (wimp_full_message_data_xfer*)message;
898 switch (dataxfer->file_type) {
909 case osfile_TYPE_DRAW:
912 case osfile_TYPE_SPRITE:
913 case osfile_TYPE_TEXT:
919 dataxfer->your_ref = dataxfer->my_ref;
920 dataxfer->size = offsetof(wimp_full_message_data_xfer, file_name) + 16;
921 dataxfer->action = message_DATA_SAVE_ACK;
922 dataxfer->est_size = -1;
923 memcpy(dataxfer->file_name,
"<Wimp$Scrap>", 13);
925 error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)dataxfer, message->sender);
928 "xwimp_send_message: 0x%x: %s",
978 message->your_ref = message->my_ref;
979 error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE,
980 message, message->sender);
982 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x:%s",
983 error->errnum, error->errmess);
999 error = xosgbpb_writew(message->data.save_desktopw.file,
1000 (
const byte*)
"Run ", 4, NULL);
1002 error = xosgbpb_writew(message->data.save_desktopw.file,
1005 error = xos_bputw(
'\n', message->data.save_desktopw.file);
1009 NSLOG(netsurf, INFO,
"xosgbpb_writew/xos_bputw: 0x%x:%s",
1010 error->errnum, error->errmess);
1014 message->your_ref = message->my_ref;
1015 error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE,
1016 message, message->sender);
1018 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x:%s",
1019 error->errnum, error->errmess);
1033 wimp_full_message_window_info *wi;
1040 wi = (wimp_full_message_window_info*)message;
1057 os_MODEVAR_XWIND_LIMIT,
1059 os_MODEVAR_YWIND_LIMIT,
1060 os_MODEVAR_XEIG_FACTOR,
1061 os_MODEVAR_YEIG_FACTOR,
1070 NSLOG(netsurf, INFO,
"xos_read_vdu_variables: 0x%x: %s",
1071 error->errnum, error->errmess);
1086 resolvers = getenv(
"Inet$Resolvers");
1087 if (resolvers && resolvers[0]) {
1088 NSLOG(netsurf, INFO,
"Inet$Resolvers '%s'", resolvers);
1090 NSLOG(netsurf, INFO,
"Inet$Resolvers not set or empty");
1108 os_MODEVAR_MODE_FLAGS, &var_val, &psr);
1110 NSLOG(netsurf, ERROR,
"xos_read_mode_variable: 0x%x: %s",
1111 error->errnum, error->errmess);
1115 return (var_val == (1 << 15));
1127 void (*sigabrt)(int);
1128 void (*sigfpe)(int);
1129 void (*sigill)(int);
1130 void (*sigint)(int);
1131 void (*sigsegv)(int);
1132 void (*sigterm)(int);
1133 void (*sigoserror)(int);
1150 _FPU_SETCW(_FPU_IEEE & ~(_FPU_MASK_PM | _FPU_MASK_UM));
1152 xhourglass_start(1);
1157 xos_byte(osbyte_IN_KEY, 0, 0xff, &
os_version, NULL);
1160 NSLOG(netsurf, INFO,
"OS supports alpha sprites: %s",
1165 if (!xosmodule_lookup(
"VideoHWSMI", NULL, NULL, &
base, NULL, NULL)) {
1167 const char *help = (
char*)
base + ((
int*)
base)[5];
1168 while (*help > 9) help++;
1169 while (*help == 9) help++;
1170 if (!memcmp(help,
"0.55", 4))
1188 if (prev_sigs.sigabrt == SIG_ERR || prev_sigs.sigfpe == SIG_ERR ||
1189 prev_sigs.sigill == SIG_ERR ||
1190 prev_sigs.sigint == SIG_ERR ||
1191 prev_sigs.sigsegv == SIG_ERR ||
1192 prev_sigs.sigterm == SIG_ERR ||
1193 prev_sigs.sigoserror == SIG_ERR)
1194 die(
"Failed registering signal handlers");
1199 die(
"Unable to load Sprites.");
1202 nsdir_temp = getenv(
"NetSurf$Dir");
1204 die(
"Failed to locate NetSurf directory");
1207 die(
"Failed duplicating NetSurf directory string");
1224 error = xwimp_initialise(wimp_VERSION_RO38,
task_name,
1228 NSLOG(netsurf, INFO,
"xwimp_initialise: 0x%x: %s",
1229 error->errnum, error->errmess);
1230 die(error->errmess);
1266 if (getenv(
"NetSurf$Start_URI_Handler"))
1267 xwimp_start_task(
"Desktop", 0);
1270 if ((length = snprintf(
path,
sizeof(
path),
1271 "NetSurf:Resources.%s.Templates",
1273 die(
"Failed to locate Templates resource.");
1274 error = xwimp_open_template(
path);
1276 NSLOG(netsurf, INFO,
"xwimp_open_template failed: 0x%x: %s",
1277 error->errnum, error->errmess);
1278 die(error->errmess);
1306 wimp_close_template();
1318 NSLOG(netsurf, INFO,
"parameters: '%s'", argv[1]);
1320 if (strcasecmp(argv[1],
"-nowin") == 0) {
1325 else if (argc == 3) {
1326 NSLOG(netsurf, INFO,
"parameters: '%s' '%s'", argv[1],
1331 if (strcasecmp(argv[1],
"-html") == 0) {
1335 else if (strcasecmp(argv[1],
"-urlf") == 0) {
1338 NSLOG(netsurf, INFO,
"allocation failed");
1339 die(
"Insufficient memory for URL");
1345 else if (strcasecmp(argv[1],
"-url") == 0) {
1350 NSLOG(netsurf, INFO,
"Unknown parameters: '%s' '%s'",
1397 error = xosbyte_read(osbyte_VAR_COUNTRY_NUMBER, &country);
1399 NSLOG(netsurf, INFO,
"xosbyte_read failed: 0x%x: %s",
1400 error->errnum, error->errmess);
1420 sprintf(
path,
"NetSurf:Resources.%s", lang);
1440 char *canonical_path;
1449 error = xosfscontrol_canonicalise_path(
path, 0, 0, 0, 0, &spare);
1451 NSLOG(netsurf, INFO,
1452 "xosfscontrol_canonicalise_path failed: 0x%x: %s",
1459 canonical_path = malloc(1 - spare);
1460 if (canonical_path == NULL) {
1461 free(canonical_path);
1465 error = xosfscontrol_canonicalise_path(
path, canonical_path, 0, 0, 1 - spare, 0);
1467 NSLOG(netsurf, INFO,
1468 "xosfscontrol_canonicalise_path failed: 0x%x: %s",
1472 free(canonical_path);
1477 unix_path = __unixify(canonical_path, __RISCOSIFY_NO_REVERSE_SUFFIX, NULL, 0, 0);
1479 if (unix_path == NULL) {
1480 NSLOG(netsurf, INFO,
"__unixify failed: %s", canonical_path);
1481 free(canonical_path);
1484 free(canonical_path);
1487 ret =
url_escape(unix_path,
false,
"/", &escaped_path);
1496 url = malloc(urllen);
1498 NSLOG(netsurf, INFO,
"Unable to allocate url");
1503 if (*escaped_path ==
'/') {
1504 snprintf(url, urllen,
"%s%s",
1507 snprintf(url, urllen,
"%s%s",
1530 lwc_string *urlpath;
1539 if ((url == NULL) || (path_out == NULL)) {
1545 if (lwc_string_caseless_isequal(scheme, corestring_lwc_file,
1546 &match) != lwc_error_ok)
1550 lwc_string_unref(scheme);
1551 if (match ==
false) {
1556 if (urlpath == NULL) {
1561 lwc_string_length(urlpath),
1564 lwc_string_unref(urlpath);
1570 path = malloc(unpath_len + 100);
1576 r = __riscosify(unpath, 0, __RISCOSIFY_NO_SUFFIX,
1577 path, unpath_len + 100, 0);
1644 wimp_key *key = (wimp_key *) pw;
1647 os_error *error = xwimp_process_key(key->c);
1649 NSLOG(netsurf, INFO,
"xwimp_process_key: 0x%x: %s",
1650 error->errnum, error->errmess);
1664 if (key->c == wimp_KEY_ESCAPE &&
1674 }
else if (key->c == 22 ) {
1678 copy = malloc(
sizeof(wimp_key));
1681 memcpy(copy, key,
sizeof(wimp_key));
1685 os_error *error = xwimp_process_key(key->c);
1687 NSLOG(netsurf, INFO,
"xwimp_process_key: 0x%x: %s",
1688 error->errnum, error->errmess);
1704 switch (message->action) {
1705 case message_DATA_LOAD:
1708 if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
1712 (wimp_full_message_data_xfer *) message) ==
false) {
1717 case message_DATA_LOAD_ACK:
1722 case message_MENU_WARNING:
1727 case message_MENUS_DELETED:
1732 case message_CLAIM_ENTITY:
1736 case message_DATA_REQUEST:
1740 case message_MODE_CHANGE:
1742 rufl_invalidate_cache();
1745 case message_PALETTE_CHANGE:
1748 case message_FONT_CHANGED:
1752 case message_URI_PROCESS:
1753 if (event != wimp_USER_MESSAGE_ACKNOWLEDGE)
1756 case message_URI_RETURN_RESULT:
1759 case message_INET_SUITE_OPEN_URL:
1760 if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
1767 case message_PRINT_SAVE:
1768 if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
1771 case message_PRINT_ERROR:
1774 case message_PRINT_TYPE_ODD:
1796 case wimp_NULL_REASON_CODE:
1801 case wimp_REDRAW_WINDOW_REQUEST:
1805 case wimp_OPEN_WINDOW_REQUEST:
1809 case wimp_CLOSE_WINDOW_REQUEST:
1813 case wimp_POINTER_LEAVING_WINDOW:
1817 case wimp_POINTER_ENTERING_WINDOW:
1821 case wimp_MOUSE_CLICK:
1825 case wimp_USER_DRAG_BOX:
1829 case wimp_KEY_PRESSED:
1833 case wimp_MENU_SELECTION:
1841 case wimp_SCROLL_REQUEST:
1846 case wimp_USER_MESSAGE:
1847 case wimp_USER_MESSAGE_RECORDED:
1848 case wimp_USER_MESSAGE_ACKNOWLEDGE:
1860 wimp_event_no event;
1862 const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN | wimp_SAVE_FP;
1863 os_t track_poll_offset;
1869 os_t t = os_read_monotonic_time();
1871 if (track_poll_offset > 0) {
1872 t += track_poll_offset;
1881 event = wimp_poll_idle(mask, &block, t, 0);
1883 event = wimp_poll(wimp_MASK_NULL | mask, &block, 0);
1895 if (event == wimp_NULL_REASON_CODE) {
1913 error = xwimp_open_window(open);
1915 NSLOG(netsurf, INFO,
"xwimp_open_window: 0x%x: %s",
1916 error->errnum, error->errmess);
1933 filename = ((wimp_full_message_data_xfer *)message)->file_name;
1934 sprintf(command,
"@RunType_FFF %s", filename);
1935 error = xwimp_start_task(command, 0);
1937 NSLOG(netsurf, INFO,
"xwimp_start_task failed: 0x%x: %s",
1938 error->errnum, error->errmess);
1951 wimp_full_message_data_xfer message;
1955 const uint8_t *source_data;
1972 error = xosfile_read_no_path(temp_name, &objtype, 0, 0, 0, 0);
1973 if ((!error) && (objtype == osfile_IS_FILE)) {
1974 snprintf(message.file_name, 212,
"%s", temp_name);
1975 message.file_name[211] =
'\0';
1988 char full_name[256];
1997 full_name[255] =
'\0';
1998 r = __riscosify(full_name, 0, __RISCOSIFY_NO_SUFFIX,
1999 message.file_name, 212, 0);
2001 NSLOG(netsurf, INFO,
"__riscosify failed");
2004 message.file_name[211] =
'\0';
2006 error = xosfile_save_stamped(message.file_name,
2008 (
byte *) source_data,
2009 (
byte *) source_data + source_size);
2011 NSLOG(netsurf, INFO,
2012 "xosfile_save_stamped failed: 0x%x: %s",
2021 message.your_ref = 0;
2022 message.size = 44 + ((strlen(message.file_name) + 4) & (~3u));
2023 message.action = message_DATA_OPEN;
2028 message.est_size = 0;
2029 message.file_type = 0xfff;
2031 (wimp_message*)&message, 0,
2069 die(
"Out of memory");
2072 die(
"Out of memory");
2084 NSLOG(netsurf, INFO,
"%s %s", warning, detail);
2087 char warn_buffer[300];
2088 snprintf(warn_buffer,
sizeof warn_buffer,
"%s %s",
2090 detail ? detail :
"");
2091 warn_buffer[
sizeof warn_buffer - 1] = 0;
2095 wimp_ICON_DELETED, wimp_ICON_DELETED);
2102 snprintf(error.errmess,
sizeof error.errmess,
"%s %s",
2104 detail ? detail :
"");
2105 error.errmess[
sizeof error.errmess - 1] = 0;
2106 xwimp_report_error_by_category(&error,
2107 wimp_ERROR_BOX_OK_ICON |
2108 wimp_ERROR_BOX_GIVEN_CATEGORY |
2109 wimp_ERROR_BOX_CATEGORY_ERROR <<
2110 wimp_ERROR_BOX_CATEGORY_SHIFT,
2111 "NetSurf",
"!netsurf",
2112 (osspriteop_area *) 1, 0, 0);
2124void die(
const char *
const error)
2126 os_error warn_error;
2128 NSLOG(netsurf, INFO,
"%s", error);
2130 warn_error.errnum = 1;
2132 sizeof(warn_error.errmess)-1);
2133 warn_error.errmess[
sizeof(warn_error.errmess)-1] =
'\0';
2134 xwimp_report_error_by_category(&warn_error,
2135 wimp_ERROR_BOX_OK_ICON |
2136 wimp_ERROR_BOX_GIVEN_CATEGORY |
2137 wimp_ERROR_BOX_CATEGORY_ERROR <<
2138 wimp_ERROR_BOX_CATEGORY_SHIFT,
2139 "NetSurf",
"!netsurf",
2140 (osspriteop_area *) 1, 0, 0);
2177 const char *elm[16];
2181 size_t fname_len = 0;
2186 if ((nelm == 0) || (nelm > 16)) {
2189 if ((*str != NULL) && (size == NULL)) {
2199 for (elm_idx = 0; elm_idx < nelm; elm_idx++) {
2200 elm[elm_idx] = va_arg(ap,
const char *);
2202 if (elm[elm_idx] == NULL) {
2205 elm_len[elm_idx] = strlen(elm[elm_idx]);
2206 fname_len += elm_len[elm_idx];
2212 if (fname != NULL) {
2213 if (fname_len > *size) {
2217 fname = malloc(fname_len);
2218 if (fname == NULL) {
2227 memmove(curp, elm[0], elm_len[0]);
2238 for (elm_idx = 1; elm_idx < nelm; elm_idx++) {
2239 for (idx = 0; idx < elm_len[elm_idx]; idx++) {
2240 if (elm[elm_idx][idx] ==
DIR_SEP) {
2243 *curp = elm[elm_idx][idx];
2252 assert((curp - fname) <= (
int)fname_len);
2282 const char *leafname;
2297 fname = strdup(leafname);
2298 if (fname == NULL) {
2304 for (temp = fname; *temp != 0; temp++) {
2312 *size = strlen(fname);
2331 dname = strdup(fname);
2334 while ((cur = strchr(cur,
'.'))) {
2336 xosfile_create_dir(dname, 0);
2363 FILE *stream = fopen(
"<Wimp$ScrapDir>.WWW.NetSurf.dump",
"w");
2365 NSLOG(netsurf, INFO,
"fopen: errno %i", errno);
2375 error = xwimp_start_task(
"Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.dump",
2378 NSLOG(netsurf, INFO,
"xwimp_start_task failed: 0x%x: %s",
2379 error->errnum, error->errmess);
2412 char *cachepath = NULL;
2415 cachedir = getenv(
"Cache$Dir");
2416 if ((cachedir == NULL) || (cachedir[0] == 0)) {
2417 NSLOG(netsurf, INFO,
"cachedir was null");
2456 die(
"NetSurf operation table failed registration");
2461 error = xos_read_var_val_size(
"NetSurf$Logging", 0, os_VARTYPE_STRING,
2462 &used, NULL, &
type);
2463 if (error != NULL ||
type != os_VARTYPE_STRING || used != -2) {
2466 char logging_env[2];
2467 error = xos_read_var_val(
"NetSurf$Logging", logging_env,
2468 sizeof(logging_env), 0, os_VARTYPE_STRING,
2469 &used, NULL, &
type);
2470 if (error != NULL || logging_env[0] !=
'0') {
2485 die(
"Options failed to initialise");
2494 if (((length = snprintf(
path,
2496 "NetSurf:Resources.%s.Messages",
2498 (length >= (
int)
sizeof(
path))) {
2499 die(
"Failed to locate Messages resource.");
2512 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.
nserror search_web_init(const char *provider_fname)
Initialise the web search operations.
nserror search_web_select_provider(const char *selection)
Change the currently selected web search provider.
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).
core web search facilities 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.