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>
104 __RISCOSIFY_NO_REVERSE_SUFFIX;
112#define CHOICES_PREFIX "<Choices$Write>.WWW.NetSurf."
125 message_HELP_REQUEST,
128 message_DATA_SAVE_ACK,
130 message_DATA_LOAD_ACK,
133 message_SAVE_DESKTOP,
134 message_MENU_WARNING,
135 message_MENUS_DELETED,
137 message_CLAIM_ENTITY,
138 message_DATA_REQUEST,
142 message_PALETTE_CHANGE,
143 message_FONT_CHANGED,
145 message_URI_RETURN_RESULT,
146 message_INET_SUITE_OPEN_URL,
149 message_PRINT_TYPE_ODD,
177 static const char base_url[] =
"file:///NetSurf:/Resources/";
179 size_t path_len, length;
184 if (strcmp(
path,
"adblock.css") == 0) {
187 }
else if (strcmp(
path,
"default.css") == 0) {
190 }
else if (strcmp(
path,
"quirks.css") == 0) {
193 }
else if (strcmp(
path,
"favicon.ico") == 0) {
194 path =
"Icons/content.png";
196 }
else if (strcmp(
path,
"user.css") == 0) {
202 path_len = strlen(
path);
207 length =
SLEN(base_url) +
211 raw = malloc(length);
214 char *ptr = memcpy(raw, base_url,
SLEN(base_url));
215 ptr +=
SLEN(base_url);
219 if (path_len >
SLEN(
".html") &&
220 strncmp(
path + path_len -
SLEN(
".html"),
221 ".html",
SLEN(
".html")) == 0) {
222 ptr += sprintf(ptr,
"%s/", lang);
226 memcpy(ptr,
path, path_len);
256 os_PALETTE(20) palette;
258 error = xwimp_read_true_palette((os_palette *) &palette);
261 "xwimp_read_palette: 0x%x: %s",
266 def_colour = palette.entries[wimp] >> 8;
269 opts[option].
value.
c = def_colour;
295 NSLOG(netsurf, INFO,
"Failed initialising default options");
355 path = getenv(
"NetSurf$ChoicesSave");
357 die(
"Failed to find NetSurf Choices save path");
359 snprintf(buf,
sizeof(buf),
"%s",
path);
378 xosfile_create_dir(buf, 0);
390 xos_cli(
"FontRemove NetSurf:Resources.Fonts.");
399 static const os_error error = { 1,
"NetSurf has detected a serious "
400 "error and must exit. Please submit a bug report, "
401 "attaching the browser log file." };
402 os_colour old_sand, old_glass;
407 xhourglass_colours(0x0000ffff, 0x000000ff, &old_sand, &old_glass);
414 xos_read_var_val_size(
"NetSurf$CoreDump", 0, 0, &used, 0, 0);
417 xwimp_slot_size(-1, -1, &curr_slot, 0, 0);
418 NSLOG(netsurf, INFO,
"saving WimpSlot, size 0x%x", curr_slot);
419 xosfile_save(
"$.NetSurf_Slot", 0x8000, 0,
421 (
byte *) 0x8000 + curr_slot);
427 &base_address, 0, 0, 0, 0, 0);
429 "saving DA %i, base %p, size 0x%x",
433 xosfile_save(
"$.NetSurf_DA",
434 (bits) base_address, 0,
436 base_address + size);
442 const _kernel_oserror *err = __unixlib_write_coredump (NULL);
444 NSLOG(netsurf, INFO,
"Coredump failed: %s", err->errmess);
447 xhourglass_colours(old_sand, old_glass, 0, 0);
450 __write_backtrace(sig);
452 xwimp_report_error_by_category(&error,
453 wimp_ERROR_BOX_GIVEN_CATEGORY |
454 wimp_ERROR_BOX_CATEGORY_ERROR <<
455 wimp_ERROR_BOX_CATEGORY_SHIFT,
456 "NetSurf",
"!netsurf",
457 (osspriteop_area *) 1,
"Quit", 0);
458 xos_cli(
"Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.Log");
482 do { c = getc(fp); }
while (c != EOF && 32 <= c);
485 do { c = getc(fp); }
while (c != EOF && c < 32);
496 }
while (c != EOF && 32 <= c);
499 while (c != EOF && c < 32)
526 fp = fopen(file_name,
"rb");
528 NSLOG(netsurf, INFO,
"fopen(\"%s\", \"rb\"): %i: %s",
529 file_name, errno, strerror(errno));
536 goto uri_syntax_error;
540 strspn(
line,
"0123456789") != strlen(
line))
541 goto uri_syntax_error;
545 goto uri_syntax_error;
557 if (uri_title &&
line[0] && ((
line[0] !=
'*') ||
line[1])) {
558 *uri_title = strdup(
line);
588 fp = fopen(file_name,
"r");
590 NSLOG(netsurf, INFO,
"fopen(\"%s\", \"r\"): %i: %s",
591 file_name, errno, strerror(errno));
596 if (!fgets(
line,
sizeof line, fp)) {
598 NSLOG(netsurf, INFO,
"fgets: %i: %s", errno,
634 fp = fopen(file_name,
"r");
636 NSLOG(netsurf, INFO,
"fopen(\"%s\", \"r\"): %i: %s",
637 file_name, errno, strerror(errno));
642 while (fgets(
line,
sizeof line, fp)) {
643 if (strncmp(
line,
"URL=", 4) == 0) {
646 url = strdup(
line + 4);
656 NSLOG(netsurf, INFO,
"fgets: %i: %s", errno, strerror(errno));
678 int file_type = message->data.data_xfer.file_type;
699 data.data_xfer.file_name);
705 len = strlen(message->data.data_xfer.file_name);
706 if (len < 9 || strcmp(
".!NetSurf",
707 message->data.data_xfer.file_name + len - 9))
724 message->action = message_DATA_LOAD_ACK;
725 message->your_ref = message->my_ref;
726 oserror = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
728 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x: %s",
729 oserror->errnum, oserror->errmess);
757 int file_type = message->data.data_xfer.file_type;
803 case osfile_TYPE_DRAW:
806 case osfile_TYPE_SPRITE:
807 case osfile_TYPE_TEXT:
848 message->action = message_DATA_LOAD_ACK;
849 message->your_ref = message->my_ref;
850 oserror = xwimp_send_message(wimp_USER_MESSAGE, message,
853 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x: %s",
854 oserror->errnum, oserror->errmess);
870 const char *ep = (
char*)message + message->size;
871 char *p = message->file_name;
873 if ((
size_t)message->size >=
sizeof(*message))
874 ep = (
char*)message +
sizeof(*message) - 1;
876 while (p < ep && *p >=
' ') p++;
886 wimp_full_message_data_xfer *dataxfer = (wimp_full_message_data_xfer*)message;
896 switch (dataxfer->file_type) {
907 case osfile_TYPE_DRAW:
910 case osfile_TYPE_SPRITE:
911 case osfile_TYPE_TEXT:
917 dataxfer->your_ref = dataxfer->my_ref;
918 dataxfer->size = offsetof(wimp_full_message_data_xfer, file_name) + 16;
919 dataxfer->action = message_DATA_SAVE_ACK;
920 dataxfer->est_size = -1;
921 memcpy(dataxfer->file_name,
"<Wimp$Scrap>", 13);
923 error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)dataxfer, message->sender);
926 "xwimp_send_message: 0x%x: %s",
976 message->your_ref = message->my_ref;
977 error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE,
978 message, message->sender);
980 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x:%s",
981 error->errnum, error->errmess);
997 error = xosgbpb_writew(message->data.save_desktopw.file,
998 (
const byte*)
"Run ", 4, NULL);
1000 error = xosgbpb_writew(message->data.save_desktopw.file,
1003 error = xos_bputw(
'\n', message->data.save_desktopw.file);
1007 NSLOG(netsurf, INFO,
"xosgbpb_writew/xos_bputw: 0x%x:%s",
1008 error->errnum, error->errmess);
1012 message->your_ref = message->my_ref;
1013 error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE,
1014 message, message->sender);
1016 NSLOG(netsurf, INFO,
"xwimp_send_message: 0x%x:%s",
1017 error->errnum, error->errmess);
1031 wimp_full_message_window_info *wi;
1038 wi = (wimp_full_message_window_info*)message;
1055 os_MODEVAR_XWIND_LIMIT,
1057 os_MODEVAR_YWIND_LIMIT,
1058 os_MODEVAR_XEIG_FACTOR,
1059 os_MODEVAR_YEIG_FACTOR,
1068 NSLOG(netsurf, INFO,
"xos_read_vdu_variables: 0x%x: %s",
1069 error->errnum, error->errmess);
1084 resolvers = getenv(
"Inet$Resolvers");
1085 if (resolvers && resolvers[0]) {
1086 NSLOG(netsurf, INFO,
"Inet$Resolvers '%s'", resolvers);
1088 NSLOG(netsurf, INFO,
"Inet$Resolvers not set or empty");
1106 os_MODEVAR_MODE_FLAGS, &var_val, &psr);
1108 NSLOG(netsurf, ERROR,
"xos_read_mode_variable: 0x%x: %s",
1109 error->errnum, error->errmess);
1113 return (var_val == (1 << 15));
1125 void (*sigabrt)(int);
1126 void (*sigfpe)(int);
1127 void (*sigill)(int);
1128 void (*sigint)(int);
1129 void (*sigsegv)(int);
1130 void (*sigterm)(int);
1131 void (*sigoserror)(int);
1148 _FPU_SETCW(_FPU_IEEE & ~(_FPU_MASK_PM | _FPU_MASK_UM));
1150 xhourglass_start(1);
1155 xos_byte(osbyte_IN_KEY, 0, 0xff, &
os_version, NULL);
1158 NSLOG(netsurf, INFO,
"OS supports alpha sprites: %s",
1163 if (!xosmodule_lookup(
"VideoHWSMI", NULL, NULL, &
base, NULL, NULL)) {
1165 const char *help = (
char*)
base + ((
int*)
base)[5];
1166 while (*help > 9) help++;
1167 while (*help == 9) help++;
1168 if (!memcmp(help,
"0.55", 4))
1186 if (prev_sigs.sigabrt == SIG_ERR || prev_sigs.sigfpe == SIG_ERR ||
1187 prev_sigs.sigill == SIG_ERR ||
1188 prev_sigs.sigint == SIG_ERR ||
1189 prev_sigs.sigsegv == SIG_ERR ||
1190 prev_sigs.sigterm == SIG_ERR ||
1191 prev_sigs.sigoserror == SIG_ERR)
1192 die(
"Failed registering signal handlers");
1197 die(
"Unable to load Sprites.");
1200 nsdir_temp = getenv(
"NetSurf$Dir");
1202 die(
"Failed to locate NetSurf directory");
1205 die(
"Failed duplicating NetSurf directory string");
1218 error = xwimp_initialise(wimp_VERSION_RO38,
task_name,
1222 NSLOG(netsurf, INFO,
"xwimp_initialise: 0x%x: %s",
1223 error->errnum, error->errmess);
1224 die(error->errmess);
1260 if (getenv(
"NetSurf$Start_URI_Handler"))
1261 xwimp_start_task(
"Desktop", 0);
1264 if ((length = snprintf(
path,
sizeof(
path),
1265 "NetSurf:Resources.%s.Templates",
1267 die(
"Failed to locate Templates resource.");
1268 error = xwimp_open_template(
path);
1270 NSLOG(netsurf, INFO,
"xwimp_open_template failed: 0x%x: %s",
1271 error->errnum, error->errmess);
1272 die(error->errmess);
1300 wimp_close_template();
1312 NSLOG(netsurf, INFO,
"parameters: '%s'", argv[1]);
1314 if (strcasecmp(argv[1],
"-nowin") == 0) {
1319 else if (argc == 3) {
1320 NSLOG(netsurf, INFO,
"parameters: '%s' '%s'", argv[1],
1325 if (strcasecmp(argv[1],
"-html") == 0) {
1329 else if (strcasecmp(argv[1],
"-urlf") == 0) {
1332 NSLOG(netsurf, INFO,
"allocation failed");
1333 die(
"Insufficient memory for URL");
1339 else if (strcasecmp(argv[1],
"-url") == 0) {
1344 NSLOG(netsurf, INFO,
"Unknown parameters: '%s' '%s'",
1391 error = xosbyte_read(osbyte_VAR_COUNTRY_NUMBER, &country);
1393 NSLOG(netsurf, INFO,
"xosbyte_read failed: 0x%x: %s",
1394 error->errnum, error->errmess);
1414 sprintf(
path,
"NetSurf:Resources.%s", lang);
1434 char *canonical_path;
1443 error = xosfscontrol_canonicalise_path(
path, 0, 0, 0, 0, &spare);
1445 NSLOG(netsurf, INFO,
1446 "xosfscontrol_canonicalise_path failed: 0x%x: %s",
1453 canonical_path = malloc(1 - spare);
1454 if (canonical_path == NULL) {
1455 free(canonical_path);
1459 error = xosfscontrol_canonicalise_path(
path, canonical_path, 0, 0, 1 - spare, 0);
1461 NSLOG(netsurf, INFO,
1462 "xosfscontrol_canonicalise_path failed: 0x%x: %s",
1466 free(canonical_path);
1471 unix_path = __unixify(canonical_path, __RISCOSIFY_NO_REVERSE_SUFFIX, NULL, 0, 0);
1473 if (unix_path == NULL) {
1474 NSLOG(netsurf, INFO,
"__unixify failed: %s", canonical_path);
1475 free(canonical_path);
1478 free(canonical_path);
1481 ret =
url_escape(unix_path,
false,
"/", &escaped_path);
1490 url = malloc(urllen);
1492 NSLOG(netsurf, INFO,
"Unable to allocate url");
1497 if (*escaped_path ==
'/') {
1498 snprintf(url, urllen,
"%s%s",
1501 snprintf(url, urllen,
"%s%s",
1524 lwc_string *urlpath;
1533 if ((url == NULL) || (path_out == NULL)) {
1539 if (lwc_string_caseless_isequal(scheme, corestring_lwc_file,
1540 &match) != lwc_error_ok)
1544 lwc_string_unref(scheme);
1545 if (match ==
false) {
1550 if (urlpath == NULL) {
1555 lwc_string_length(urlpath),
1558 lwc_string_unref(urlpath);
1564 path = malloc(unpath_len + 100);
1570 r = __riscosify(unpath, 0, __RISCOSIFY_NO_SUFFIX,
1571 path, unpath_len + 100, 0);
1638 wimp_key *key = (wimp_key *) pw;
1641 os_error *error = xwimp_process_key(key->c);
1643 NSLOG(netsurf, INFO,
"xwimp_process_key: 0x%x: %s",
1644 error->errnum, error->errmess);
1658 if (key->c == wimp_KEY_ESCAPE &&
1668 }
else if (key->c == 22 ) {
1672 copy = malloc(
sizeof(wimp_key));
1675 memcpy(copy, key,
sizeof(wimp_key));
1679 os_error *error = xwimp_process_key(key->c);
1681 NSLOG(netsurf, INFO,
"xwimp_process_key: 0x%x: %s",
1682 error->errnum, error->errmess);
1698 switch (message->action) {
1699 case message_DATA_LOAD:
1702 if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
1706 (wimp_full_message_data_xfer *) message) ==
false) {
1711 case message_DATA_LOAD_ACK:
1716 case message_MENU_WARNING:
1721 case message_MENUS_DELETED:
1726 case message_CLAIM_ENTITY:
1730 case message_DATA_REQUEST:
1734 case message_MODE_CHANGE:
1736 rufl_invalidate_cache();
1739 case message_PALETTE_CHANGE:
1742 case message_FONT_CHANGED:
1746 case message_URI_PROCESS:
1747 if (event != wimp_USER_MESSAGE_ACKNOWLEDGE)
1750 case message_URI_RETURN_RESULT:
1753 case message_INET_SUITE_OPEN_URL:
1754 if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
1761 case message_PRINT_SAVE:
1762 if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
1765 case message_PRINT_ERROR:
1768 case message_PRINT_TYPE_ODD:
1790 case wimp_NULL_REASON_CODE:
1795 case wimp_REDRAW_WINDOW_REQUEST:
1799 case wimp_OPEN_WINDOW_REQUEST:
1803 case wimp_CLOSE_WINDOW_REQUEST:
1807 case wimp_POINTER_LEAVING_WINDOW:
1811 case wimp_POINTER_ENTERING_WINDOW:
1815 case wimp_MOUSE_CLICK:
1819 case wimp_USER_DRAG_BOX:
1823 case wimp_KEY_PRESSED:
1827 case wimp_MENU_SELECTION:
1835 case wimp_SCROLL_REQUEST:
1840 case wimp_USER_MESSAGE:
1841 case wimp_USER_MESSAGE_RECORDED:
1842 case wimp_USER_MESSAGE_ACKNOWLEDGE:
1854 wimp_event_no event;
1856 const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN | wimp_SAVE_FP;
1857 os_t track_poll_offset;
1863 os_t t = os_read_monotonic_time();
1865 if (track_poll_offset > 0) {
1866 t += track_poll_offset;
1875 event = wimp_poll_idle(mask, &block, t, 0);
1877 event = wimp_poll(wimp_MASK_NULL | mask, &block, 0);
1889 if (event == wimp_NULL_REASON_CODE) {
1907 error = xwimp_open_window(open);
1909 NSLOG(netsurf, INFO,
"xwimp_open_window: 0x%x: %s",
1910 error->errnum, error->errmess);
1927 filename = ((wimp_full_message_data_xfer *)message)->file_name;
1928 sprintf(command,
"@RunType_FFF %s", filename);
1929 error = xwimp_start_task(command, 0);
1931 NSLOG(netsurf, INFO,
"xwimp_start_task failed: 0x%x: %s",
1932 error->errnum, error->errmess);
1945 wimp_full_message_data_xfer message;
1949 const uint8_t *source_data;
1966 error = xosfile_read_no_path(temp_name, &objtype, 0, 0, 0, 0);
1967 if ((!error) && (objtype == osfile_IS_FILE)) {
1968 snprintf(message.file_name, 212,
"%s", temp_name);
1969 message.file_name[211] =
'\0';
1982 char full_name[256];
1991 full_name[255] =
'\0';
1992 r = __riscosify(full_name, 0, __RISCOSIFY_NO_SUFFIX,
1993 message.file_name, 212, 0);
1995 NSLOG(netsurf, INFO,
"__riscosify failed");
1998 message.file_name[211] =
'\0';
2000 error = xosfile_save_stamped(message.file_name,
2002 (
byte *) source_data,
2003 (
byte *) source_data + source_size);
2005 NSLOG(netsurf, INFO,
2006 "xosfile_save_stamped failed: 0x%x: %s",
2015 message.your_ref = 0;
2016 message.size = 44 + ((strlen(message.file_name) + 4) & (~3u));
2017 message.action = message_DATA_OPEN;
2022 message.est_size = 0;
2023 message.file_type = 0xfff;
2025 (wimp_message*)&message, 0,
2063 die(
"Out of memory");
2066 die(
"Out of memory");
2078 NSLOG(netsurf, INFO,
"%s %s", warning, detail);
2081 char warn_buffer[300];
2082 snprintf(warn_buffer,
sizeof warn_buffer,
"%s %s",
2084 detail ? detail :
"");
2085 warn_buffer[
sizeof warn_buffer - 1] = 0;
2089 wimp_ICON_DELETED, wimp_ICON_DELETED);
2096 snprintf(error.errmess,
sizeof error.errmess,
"%s %s",
2098 detail ? detail :
"");
2099 error.errmess[
sizeof error.errmess - 1] = 0;
2100 xwimp_report_error_by_category(&error,
2101 wimp_ERROR_BOX_OK_ICON |
2102 wimp_ERROR_BOX_GIVEN_CATEGORY |
2103 wimp_ERROR_BOX_CATEGORY_ERROR <<
2104 wimp_ERROR_BOX_CATEGORY_SHIFT,
2105 "NetSurf",
"!netsurf",
2106 (osspriteop_area *) 1, 0, 0);
2118void die(
const char *
const error)
2120 os_error warn_error;
2122 NSLOG(netsurf, INFO,
"%s", error);
2124 warn_error.errnum = 1;
2126 sizeof(warn_error.errmess)-1);
2127 warn_error.errmess[
sizeof(warn_error.errmess)-1] =
'\0';
2128 xwimp_report_error_by_category(&warn_error,
2129 wimp_ERROR_BOX_OK_ICON |
2130 wimp_ERROR_BOX_GIVEN_CATEGORY |
2131 wimp_ERROR_BOX_CATEGORY_ERROR <<
2132 wimp_ERROR_BOX_CATEGORY_SHIFT,
2133 "NetSurf",
"!netsurf",
2134 (osspriteop_area *) 1, 0, 0);
2171 const char *elm[16];
2175 size_t fname_len = 0;
2180 if ((nelm == 0) || (nelm > 16)) {
2183 if ((*str != NULL) && (size == NULL)) {
2193 for (elm_idx = 0; elm_idx < nelm; elm_idx++) {
2194 elm[elm_idx] = va_arg(ap,
const char *);
2196 if (elm[elm_idx] == NULL) {
2199 elm_len[elm_idx] = strlen(elm[elm_idx]);
2200 fname_len += elm_len[elm_idx];
2206 if (fname != NULL) {
2207 if (fname_len > *size) {
2211 fname = malloc(fname_len);
2212 if (fname == NULL) {
2221 memmove(curp, elm[0], elm_len[0]);
2232 for (elm_idx = 1; elm_idx < nelm; elm_idx++) {
2233 for (idx = 0; idx < elm_len[elm_idx]; idx++) {
2234 if (elm[elm_idx][idx] ==
DIR_SEP) {
2237 *curp = elm[elm_idx][idx];
2246 assert((curp - fname) <= (
int)fname_len);
2276 const char *leafname;
2291 fname = strdup(leafname);
2292 if (fname == NULL) {
2298 for (temp = fname; *temp != 0; temp++) {
2306 *size = strlen(fname);
2325 dname = strdup(fname);
2328 while ((cur = strchr(cur,
'.'))) {
2330 xosfile_create_dir(dname, 0);
2357 FILE *stream = fopen(
"<Wimp$ScrapDir>.WWW.NetSurf.dump",
"w");
2359 NSLOG(netsurf, INFO,
"fopen: errno %i", errno);
2369 error = xwimp_start_task(
"Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.dump",
2372 NSLOG(netsurf, INFO,
"xwimp_start_task failed: 0x%x: %s",
2373 error->errnum, error->errmess);
2406 char *cachepath = NULL;
2409 cachedir = getenv(
"Cache$Dir");
2410 if ((cachedir == NULL) || (cachedir[0] == 0)) {
2411 NSLOG(netsurf, INFO,
"cachedir was null");
2449 die(
"NetSurf operation table failed registration");
2454 error = xos_read_var_val_size(
"NetSurf$Logging", 0, os_VARTYPE_STRING,
2455 &used, NULL, &
type);
2456 if (error != NULL ||
type != os_VARTYPE_STRING || used != -2) {
2459 char logging_env[2];
2460 error = xos_read_var_val(
"NetSurf$Logging", logging_env,
2461 sizeof(logging_env), 0, os_VARTYPE_STRING,
2462 &used, NULL, &
type);
2463 if (error != NULL || logging_env[0] !=
'0') {
2478 die(
"Options failed to initialise");
2487 if (((length = snprintf(
path,
2489 "NetSurf:Resources.%s.Messages",
2491 (length >= (
int)
sizeof(
path))) {
2492 die(
"Failed to locate Messages resource.");
2505 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.
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.