diff --git a/www-client/links/links-2.14.recipe b/www-client/links/links-2.14.recipe new file mode 100644 index 000000000..1117f2aa5 --- /dev/null +++ b/www-client/links/links-2.14.recipe @@ -0,0 +1,76 @@ +SUMMARY="A graphics and text mode web browser" +DESCRIPTION="Links is a multi-platform web browser you can run in Terminal." +HOMEPAGE="http://links.twibright.com/" +COPYRIGHT="1999-2013 Mikulas Patocka + 2000-2011 Petr Kulhavy, Karel Kulhavy, Martin Pergel" +LICENSE="GNU GPL v2" +REVISION="1" +SOURCE_URI="http://links.twibright.com/download/links-$portVersion.tar.gz" +CHECKSUM_SHA256="22fa8dcb5a60b8ffd611de31ebd4c79edce472637a3554bab401795da91d4387" +PATCHES="links-$portVersion.patchset" + +ARCHITECTURES="?x86_gcc2 ?x86 x86_64" + +PROVIDES=" + links = $portVersion + cmd:links = $portVersion + " +REQUIRES=" + haiku + lib:libcrypto + lib:libgomp + lib:libjpeg + lib:libpng16 + lib:libssl +# lib:libtiff + lib:libz + " + +BUILD_REQUIRES=" + haiku_devel + devel:libcrypto +# devel:libGL + devel:libglu + devel:libpng16 + devel:libjpeg + devel:libssl +# devel:libtiff + devel:libz >= 1.2.8 + " +BUILD_PREREQUIRES=" + cmd:autoconf + cmd:libtool + cmd:aclocal + cmd:make + cmd:gcc + cmd:ld + cmd:pkg_config + " + +BUILD() +{ + STDCPPLIBS=-lstdc++ + if [ "$effectiveTargetArchitecture" = x86_gcc2 ]; then + STDCPPLIBS=-lstdc++.r4 + fi + aclocal + automake --add-missing + autoheader + automake + autoconf + runConfigure ./configure \ + --without-x \ + --enable-graphics + make STDCPPLIBS=$STDCPPLIBS +} + +INSTALL() +{ + make install + addAppDeskbarSymlink $binDir/links Links +} + +TEST() +{ + make check +} diff --git a/www-client/links/patches/links-2.14.patchset b/www-client/links/patches/links-2.14.patchset new file mode 100644 index 000000000..c4b1904d0 --- /dev/null +++ b/www-client/links/patches/links-2.14.patchset @@ -0,0 +1,1479 @@ +From 9b313c4abd8ae832743f9ce70aa728a67e69656e Mon Sep 17 00:00:00 2001 +From: Jerome Duval +Date: Sat, 15 Jul 2017 14:22:23 +0200 +Subject: apply patch from 2.8 + + +diff --git a/Makefile.am b/Makefile.am +index 373f783..594ecb8 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -4,7 +4,7 @@ + + man_MANS=links.1 + +-EXTRA_DIST=$(man_MANS) atheos.cpp BRAILLE_HOWTO KEYS SITES descrip.mms *.opt PATCH-gpm-1.20.0-smooth-cursor PATCH-libpng-1.2.18 mailcap.pl rebuild Links_logo.png Unicode/*.cp Unicode/[!C]* intl/[!C]* suffix/[!C]* graphics/*.c graphics/arrow.png graphics/gen graphics/system_font/*.png graphics/font/century_extensions-medium-roman-serif-vari/*.png graphics/font/century_school-bold-roman-serif-vari/*.png graphics/font/century_school-medium-roman-serif-vari/*.png graphics/font/courier-medium-roman-serif-mono/*.png graphics/font/japanese-medium-roman-sans-mono/*.png graphics/font/symbol-medium-roman-sans-vari/*.png graphics/font/century_school-bold-roman-serif-vari/aliases graphics/font/century_school-medium-roman-serif-vari/aliases graphics/font/japanese-medium-roman-sans-mono/aliases graphics/font/symbol-medium-roman-sans-vari/aliases doc/links_cal/*.png doc/links_cal/*.html graphics/Makefile graphics/Fontmap graphics/clip.c graphics/links.xpm graphics/makefont graphics/pdf2html graphics/spacer.png pkg-config.m4 *.xpm *.ico *.rc mk-release-os2 mk-release-win mk-dos mk-dos83.cmd links.wis *.nsi links.crt ++EXTRA_DIST=$(man_MANS) atheos.cpp haiku.cpp BRAILLE_HOWTO KEYS SITES descrip.mms *.opt PATCH-gpm-1.20.0-smooth-cursor PATCH-libpng-1.2.18 mailcap.pl rebuild Links_logo.png Unicode/*.cp Unicode/[!C]* intl/[!C]* suffix/[!C]* graphics/*.c graphics/arrow.png graphics/gen graphics/system_font/*.png graphics/font/century_extensions-medium-roman-serif-vari/*.png graphics/font/century_school-bold-roman-serif-vari/*.png graphics/font/century_school-medium-roman-serif-vari/*.png graphics/font/courier-medium-roman-serif-mono/*.png graphics/font/japanese-medium-roman-sans-mono/*.png graphics/font/symbol-medium-roman-sans-vari/*.png graphics/font/century_school-bold-roman-serif-vari/aliases graphics/font/century_school-medium-roman-serif-vari/aliases graphics/font/japanese-medium-roman-sans-mono/aliases graphics/font/symbol-medium-roman-sans-vari/aliases doc/links_cal/*.png doc/links_cal/*.html graphics/Makefile graphics/Fontmap graphics/clip.c graphics/links.xpm graphics/makefont graphics/pdf2html graphics/spacer.png pkg-config.m4 *.xpm *.ico *.rc mk-release-os2 mk-release-win mk-dos mk-dos83.cmd links.wis *.nsi links.crt links-haiku.rdef + + bin_PROGRAMS=links + +@@ -13,6 +13,17 @@ links_LDADD=atheos.o + else + endif + ++if HAIKU_GR ++links_LDADD=haiku.o -lbe $(STDCPPLIBS) ++EXTRA_links_DEPENDENCIES=links-haiku.rsrc ++# automake will not let us touch the binary after link ++# and install will not copy the attributes anyway... so do it after install ++install-exec-hook: ++ xres -o $(DESTDIR)$(bindir)/links$(EXEEXT) links-haiku.rsrc ++ mimeset $(DESTDIR)$(bindir)/links$(EXEEXT) ++else ++endif ++ + links_SOURCES=af_unix.c auth.c beos.c bfu.c block.c bookmark.c cache.c charsets.c compress.c connect.c cookies.c data.c default.c dip.c directfb.c dither.c dns.c dos.c drivers.c error.c file.c finger.c fn_impl.c font_inc.c framebuf.c ftp.c gif.c grx.c hpux.c html.c html_gr.c html_r.c html_tbl.c http.c https.c img.c imgcache.c jpeg.c jsint.c kbd.c language.c listedit.c lru.c mailto.c main.c memory.c menu.c objreq.c os_dep.c pmshell.c png.c sched.c select.c session.c smb.c string.c suffix.c svg.c svgalib.c terminal.c tiff.c types.c url.c view.c view_gr.c vms.c x.c xbm.c beos.h bits.h cfg.h codepage.h com-defs.h config-vms.h dfb_cur.h hpux.h language.h links.h os_dep.h os_depx.h setup.h arrow.inc codepage.inc entity.inc fbcommon.inc language.inc links_ic.inc suffix.inc suffix_x.inc uni_7b.inc upcase.inc vpipe.inc + + dist-hook: +@@ -28,6 +39,12 @@ CXXFLAGS=@CXXFLAGS@ + atheos.o: $(srcdir)/atheos.cpp + $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c $(srcdir)/atheos.cpp + ++haiku.o: haiku.cpp ++ $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -o $@ -c $< ++ ++links-haiku.rsrc: links-haiku.rdef ++ rc -o $@ $< ++ + datadir = $(prefix)/@DATADIRNAME@ + LIBS = @LIBS@ + +diff --git a/acconfig.h b/acconfig.h +index dcd6db7..b878c80 100644 +--- a/acconfig.h ++++ b/acconfig.h +@@ -197,6 +197,9 @@ + #undef GRDRV_ATHEOS + + /* */ ++#undef GRDRV_HAIKU ++ ++/* */ + #undef GRDRV_GRX + + /* */ +diff --git a/beos.c b/beos.c +index dedc9a0..c39d144 100644 +--- a/beos.c ++++ b/beos.c +@@ -3,7 +3,7 @@ + * This file is a part of the Links program, released under GPL + */ + +-#if defined(__BEOS__) || defined(__HAIKU__) ++#if defined(__BEOS__) + + #include "com-defs.h" + +diff --git a/configure.in b/configure.in +index d020c41..eb559fa 100644 +--- a/configure.in ++++ b/configure.in +@@ -18,7 +18,7 @@ export CFLAGS + export LDFLAGS + export LIBS + +-AM_CONFIG_HEADER(config.h) ++AC_CONFIG_HEADER(config.h) + + dnl Checks for programs. + AC_PROG_CC +@@ -549,10 +549,10 @@ fi + + AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no) + if test "$cf_result" = no; then +- AC_CHECK_LIB(socket, socket) +- if test "$ac_cv_lib_socket_socket" = no; then +- AC_CHECK_LIB(network, socket) +- if test "$ac_cv_lib_network_socket" = no; then ++ AC_CHECK_LIB(network, socket) ++ if test "$ac_cv_lib_network_socket" = no; then ++ AC_CHECK_LIB(socket, socket) ++ if test "$ac_cv_lib_socket_socket" = no; then + AC_CHECK_LIB(watt, socket) + if test "$ac_cv_lib_watt_socket" = no; then + AC_ERROR([socket function not present]) +@@ -712,6 +712,7 @@ if test "$ac_cv_have_beginthread" = yes; then + AC_DEFINE(HAVE_BEGINTHREAD) + fi + AC_CHECK_HEADERS(atheos/threads.h) ++AC_CHECK_HEADERS(kernel/OS.h) + AC_HAVE_FUNCS(spawn_thread resume_thread) + + AC_HAVE_FUNCS(MouOpen _read_kbd) +@@ -867,6 +868,7 @@ fi + + + cf_have_atheos=no ++cf_have_haiku=no + + if test "$cf_use_graphics" != no; then + AC_DEFINE(G) +@@ -913,6 +915,7 @@ dnl AC_ARG_WITH(sdl, [ --without-sdl compile without SDL graphics dri + AC_ARG_WITH(pmshell, [ --without-pmshell compile without PMShell graphics driver],[if test "$withval" = no; then disable_pmshell=yes; else disable_pmshell=no; fi]) + AC_ARG_WITH(windows, [ --without-windows compile without Windows graphics driver],[if test "$withval" = no; then disable_windows=yes; else disable_windows=no; fi]) + AC_ARG_WITH(atheos, [ --without-atheos compile without Atheos graphics driver],[if test "$withval" = no; then disable_atheos=yes; else disable_atheos; fi]) ++AC_ARG_WITH(haiku, [ --without-haiku compile without Haiku/BeOS graphics driver],[if test "$withval" = no; then disable_haiku=yes; else disable_haiku=no; fi]) + AC_ARG_WITH(grx, [ --without-grx compile without DOS GRX graphics driver],[if test "$withval" = no; then disable_grx=yes; else disable_grx; fi]) + + drivers="" +@@ -1138,6 +1141,31 @@ if test "$disable_atheos" != yes; then + fi + fi + ++if test "$disable_haiku" != yes ; then ++ old_ext="$ac_ext" ++ ac_ext=cpp ++ AC_CHECK_HEADERS(interface/View.h) ++ AC_CHECK_HEADERS(interface/Window.h) ++ AC_CHECK_HEADERS(interface/Screen.h) ++ AC_CHECK_HEADERS(interface/Bitmap.h) ++ AC_CHECK_HEADERS(support/Locker.h) ++ AC_CHECK_HEADERS(app/Application.h) ++ ac_ext="$old_ext" ++ ++ if test "$ac_cv_header_kernel_OS_h" = yes && ++ test "$ac_cv_header_interface_View_h" = yes && ++ test "$ac_cv_header_interface_Window_h" = yes && ++ test "$ac_cv_header_interface_Screen_h" = yes && ++ test "$ac_cv_header_interface_Bitmap_h" = yes && ++ test "$ac_cv_header_support_Locker_h" = yes && ++ test "$ac_cv_header_app_Application_h" = yes; then ++ AC_PROG_CXX ++ AC_DEFINE(GRDRV_HAIKU) ++ drivers="$drivers HAIKU" ++ cf_have_haiku=yes ++ fi ++fi ++ + if test "$disable_grx" != yes -a "$ac_cv_have_djgpp" = yes; then + LIBS_X="$LIBS" + AC_CHECK_HEADERS(grx20.h) +@@ -1275,6 +1303,7 @@ fi + + + AM_CONDITIONAL(ATHEOS_GR, test "$cf_have_atheos" = yes) ++AM_CONDITIONAL(HAIKU_GR, test "$cf_have_haiku" = yes) + + test "$ac_cv_have_emx" = yes && LDFLAGS="$LDFLAGS -Zexe" + +diff --git a/drivers.c b/drivers.c +index 71c5854..0a9bedb 100644 +--- a/drivers.c ++++ b/drivers.c +@@ -31,6 +31,9 @@ extern struct graphics_driver pmshell_driver; + #ifdef GRDRV_ATHEOS + extern struct graphics_driver atheos_driver; + #endif ++#ifdef GRDRV_HAIKU ++extern struct graphics_driver haiku_driver; ++#endif + #ifdef GRDRV_GRX + extern struct graphics_driver grx_driver; + #endif +@@ -51,6 +54,9 @@ static struct graphics_driver *graphics_drivers[] = { + #ifdef GRDRV_ATHEOS + &atheos_driver, + #endif ++#ifdef GRDRV_HAIKU ++ &haiku_driver, ++#endif + #ifndef SPAD + #ifdef GRDRV_X + &x_driver, +diff --git a/haiku.cpp b/haiku.cpp +new file mode 100644 +index 0000000..707a12e +--- /dev/null ++++ b/haiku.cpp +@@ -0,0 +1,890 @@ ++/* haiku.cpp ++ * (c) 2007 François Revol ++ * This file is a part of the Links program, released under GPL ++ */ ++ ++#if defined __BEOS__ || defined __HAIKU__ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* ++ * GUI code ++ */ ++ ++/* ++ * TODO: ++ * - BeOS doesn't handle BView::DrawBitmap() with RGB24, and links doesn't seem to handle RGB32, ++ * so the colorspace is forced into 16bpp for now. ++ * - more paste handling ? ++ * - more DnD (maybe check if in menu or not and prepend "g" ?) ++ * - handle DnD of Net+ bookmarks ++ */ ++ ++extern "C" { ++#include "cfg.h" ++} ++ ++#ifdef GRDRV_HAIKU ++ ++extern "C" { ++#include "links.h" ++} ++#undef B_ENTER ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++//#define DBG(l...) fprintf(stderr, l); ++#define DBG(l...) {} ++ ++/* ++#ifdef debug ++#undef debug ++#endif ++#define debug(x) ++#define fprintf(x, y) ++*/ ++ ++extern "C" struct graphics_driver haiku_driver; ++ ++class LinksApplication : public BApplication { ++ public: ++ LinksApplication():BApplication("application/x-vnd.links"){} ++ virtual void RefsReceived(BMessage *message); ++ virtual bool QuitRequested(); ++}; ++ ++class LinksView; ++ ++class LinksWindow : public BWindow { ++ public: ++ LinksWindow(BRect r); ++ ~LinksWindow(); ++ virtual void FrameResized(float width, float height); ++ virtual bool QuitRequested(); ++ int resized; ++ LinksView *view; ++}; ++ ++class LinksView : public BView { ++ public: ++ LinksView(LinksWindow *w); ++ ~LinksView(); ++ virtual void Draw(BRect r); ++ virtual void MouseDown(BPoint p); ++ virtual void MouseUp(BPoint p); ++ virtual void MouseMoved(BPoint p, uint32 transit, const BMessage *dragmsg); ++ virtual void KeyDown(const char *s, int32 numBytes); ++ virtual void MessageReceived(BMessage *msg); ++ LinksWindow *win; ++ struct graphics_device *dev; ++ void d_flush(); ++ int flushing; ++ int last_x, last_y; ++}; ++ ++#define lv(dev) ((LinksView *)(dev)->driver_data) ++ ++#define lock_dev(dev) do { if (!lv(dev)->win->Lock()) return; } while (0) ++#define lock_dev0(dev) do { if (!lv(dev)->win->Lock()) return 0; } while (0) ++#define unlock_dev(dev) do { lv(dev)->win->Unlock(); } while (0) ++ ++void be_get_size(struct graphics_device *dev); ++ ++#define detach_message(dev) \ ++ BMessage *current = Looper()->DetachCurrentMessage(); \ ++ if (current) { \ ++ current->AddPointer("linksdev", dev); \ ++ } ++ ++#define pipe_message(dev) \ ++ if (current) { \ ++ write(wpipe, ¤t, sizeof(current)); \ ++ } ++ ++#define detach_and_pipe_message(dev) do { \ ++ BMessage *current = Looper()->DetachCurrentMessage(); \ ++ if (current) { \ ++ current->AddPointer("linksdev", dev); \ ++ write(wpipe, ¤t, sizeof(current)); \ ++ } \ ++} while (0) ++ ++LinksApplication *be_links_app; ++BLocker *be_lock = NULL; ++ ++int msg_pipe[2]; ++ ++thread_id be_app_thread_id; ++ ++#define rpipe (msg_pipe[0]) ++#define wpipe (msg_pipe[1]) ++ ++#define small_color (sizeof(rgb_color) <= sizeof(long)) ++#define get_color32(c, rgb) rgb_color c((rgb_color){(rgb >> 16) & 255, (rgb >> 8) & 255, rgb & 255, 255}) ++ ++color_space be_cs_desktop, be_cs_bmp; ++ ++int be_x_size, be_y_size; ++ ++int be_win_x_size, be_win_y_size; ++int be_win_x_pos, be_win_y_pos; ++ ++static BMessage *initial_refs_msg; ++ ++void LinksApplication::RefsReceived(BMessage *message) ++{ ++ entry_ref ref; ++ //if (!IsLaunching()) ++ // return; ++ BMessenger msgr(WindowAt(0)); ++ BMessage *m = new BMessage(*message); ++ m->AddSpecifier("View", (int32)0); ++ //m->what = B_SIMPLE_DATA; ++ if (msgr.IsValid()) { ++ msgr.SendMessage(m); ++ } else ++ initial_refs_msg = m; ++} ++ ++bool LinksApplication::QuitRequested() ++{ ++ BApplication::QuitRequested(); ++ //printf("qc: %ld\n", CountWindows()); ++ return true; ++} ++ ++LinksWindow::LinksWindow(BRect r):BWindow(r, "Links", B_DOCUMENT_WINDOW, 0) ++{ ++ DBG("LINKSWINDOW\n"); ++ resized = 0; ++ view = NULL; ++} ++ ++LinksWindow::~LinksWindow() ++{ ++ view = NULL; ++ DBG("~LINKSWINDOW\n"); ++} ++ ++void LinksWindow::FrameResized(float width, float height) ++{ ++ resized = 1; ++} ++ ++bool LinksWindow::QuitRequested() ++{ ++ detach_and_pipe_message(view->dev); ++ return false; ++} ++ ++void do_flush(void *p_dev) ++{ ++ struct graphics_device *dev = (struct graphics_device *)p_dev; ++ LinksView *v = lv(dev); ++ v->win->Lock(); ++ v->win->Flush(); ++ v->win->Unlock(); ++ v->flushing = 0; ++} ++ ++LinksView::LinksView(LinksWindow *w):BView(w->Bounds(), "Links", B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE) ++{ ++ DBG("LINKSVIEW\n"); ++ (win = w)->AddChild(this); ++ SetViewColor(B_TRANSPARENT_32_BIT); ++ MakeFocus(); ++ w->view = this; ++ flushing = 0; ++ last_x = last_y = 0; ++} ++ ++LinksView::~LinksView() ++{ ++ win->view = NULL; ++ DBG("~LINKSVIEW\n"); ++} ++ ++void LinksView::d_flush() ++{ ++ if (flushing) return; ++ register_bottom_half(do_flush, this->dev); ++ flushing = 1; ++} ++ ++#undef select ++ ++int be_loop_select(int n, fd_set *r, fd_set *w, fd_set *e, struct timeval *t) ++{ ++ int v; ++ v = select(n, r, w, e, t); ++ check_bottom_halves(); ++ return v; ++} ++ ++void be_paste_string(struct graphics_device *dev, const char *str) ++{ ++ unsigned char *s = (unsigned char *)str; ++ int c, i; ++ while (s && *s) { ++ GET_UTF_8(s, c); ++ if (dev) dev->keyboard_handler(dev, c, 0); ++ } ++} ++ ++void be_get_event(void *dummy) ++{ ++ BMessage *msg; ++ LinksView *view = NULL; ++ LinksWindow *win = NULL; ++ struct graphics_device *dev; ++ read(rpipe, &msg, sizeof(msg)); ++ DBG("GETE\n"); ++ if (!msg) ++ return; ++ if (msg->FindPointer("linksdev", (void **)&dev) < B_OK) ++ return; ++ if (dev) { ++ view = lv(dev); ++ if (view) ++ win = dynamic_cast(view->Window()); ++ } ++ switch (msg->what) { ++ case B_QUIT_REQUESTED: ++ if (dev) ++ dev->keyboard_handler(dev, KBD_CTRL_C, 0); ++ break; ++ case _UPDATE_: ++ { ++ BRect r; ++ if (msg->FindRect("updateRect", &r) < B_OK) ++ return; ++ struct rect rr; ++ rr.x1 = (int)r.left; ++ rr.x2 = (int)r.right + 1; ++ rr.y1 = (int)r.top; ++ rr.y2 = (int)r.bottom + 1; ++ /*DBG("paint: %d %d %d %d\n", rr.x1, rr.x2, rr.y1, rr.y2);*/ ++ if (dev) { ++ if (!win->resized) dev->redraw_handler(dev, &rr); ++ else { ++ be_get_size(dev); ++ win->resized = 0; ++ dev->resize_handler(dev); ++ } ++ } ++ check_bottom_halves(); ++ } ++ break; ++ case B_MOUSE_DOWN: ++ { ++ BPoint where; ++ int32 buttons; ++ int btn = B_LEFT; ++ if (msg->FindInt32("buttons", &buttons) != B_OK) ++ return; ++ if (msg->FindPoint("where", &where) != B_OK) ++ return; ++ if (buttons & B_PRIMARY_MOUSE_BUTTON) ++ btn = B_LEFT; ++ else if (buttons & B_SECONDARY_MOUSE_BUTTON) ++ btn = B_RIGHT; ++ else if (buttons & B_TERTIARY_MOUSE_BUTTON) ++ btn = B_MIDDLE; ++ else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 1)) ++ btn = B_FOURTH; ++ else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 2)) ++ btn = B_FIFTH; ++ else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 3)) ++ btn = B_SIXTH; ++ if (dev) dev->mouse_handler(dev, view->last_x = (int)where.x, view->last_y = (int)where.y, B_DOWN | btn); ++ } ++ break; ++ case B_MOUSE_UP: ++ { ++ BPoint where; ++ int32 buttons; ++ int btn = B_LEFT; ++ if (msg->FindInt32("buttons", &buttons) != B_OK) ++ return; ++ if (msg->FindPoint("where", &where) != B_OK) ++ return; ++ if (buttons & ~B_PRIMARY_MOUSE_BUTTON == 0) ++ btn = B_LEFT; ++ else if (buttons & ~B_SECONDARY_MOUSE_BUTTON == 0) ++ btn = B_RIGHT; ++ else if (buttons & ~B_TERTIARY_MOUSE_BUTTON == 0) ++ btn = B_MIDDLE; ++ else if (buttons & ~(B_TERTIARY_MOUSE_BUTTON << 1) == 0) ++ btn = B_FOURTH; ++ else if (buttons & ~(B_TERTIARY_MOUSE_BUTTON << 2) == 0) ++ btn = B_FIFTH; ++ else if (buttons & ~(B_TERTIARY_MOUSE_BUTTON << 3) == 0) ++ btn = B_SIXTH; ++ if (dev) dev->mouse_handler(dev, view->last_x = (int)where.x, view->last_y = (int)where.y, B_UP | btn); ++ } ++ break; ++ case B_MOUSE_MOVED: ++ { ++ BPoint where; ++ int32 buttons; ++ int btn = B_LEFT; ++ if (msg->FindInt32("buttons", &buttons) != B_OK) ++ return; ++ if (msg->FindPoint("where", &where) != B_OK) ++ return; ++ if (buttons & B_PRIMARY_MOUSE_BUTTON) ++ btn = B_LEFT; ++ else if (buttons & B_SECONDARY_MOUSE_BUTTON) ++ btn = B_RIGHT; ++ else if (buttons & B_TERTIARY_MOUSE_BUTTON) ++ btn = B_MIDDLE; ++ else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 1)) ++ btn = B_FOURTH; ++ else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 2)) ++ btn = B_FIFTH; ++ else if (buttons & (B_TERTIARY_MOUSE_BUTTON << 3)) ++ btn = B_SIXTH; ++ if (dev) dev->mouse_handler(dev, view->last_x = (int)where.x, view->last_y = (int)where.y, !buttons ? B_MOVE : B_DRAG | btn); ++ } ++ break; ++ case B_KEY_DOWN: ++ { ++ int32 modifiers; ++ int32 numBytes; ++ const char *bytes; ++ int c; ++ int mods = 0; ++ if (msg->FindInt32("modifiers", &modifiers) != B_OK) ++ return; ++ if (msg->FindString("bytes", &bytes) != B_OK) ++ return; ++ unsigned char buf[4] = { 0, 0, 0, 0 }; ++ unsigned char *ss; ++ if (modifiers & (B_LEFT_CONTROL_KEY | B_RIGHT_CONTROL_KEY | B_LEFT_COMMAND_KEY | B_RIGHT_COMMAND_KEY)) { ++ int32 raw; ++ if (msg->FindInt32("raw_char", &raw) != B_OK) ++ return; ++ buf[0] = (unsigned char)raw; ++ ss = buf; ++ } else ++ ss = (unsigned char *)bytes; ++ ++ GET_UTF_8(ss, c); ++ switch (c) { ++ case B_BACKSPACE: c = KBD_BS; break; ++ case B_ENTER: c = KBD_ENTER; break; ++ case B_SPACE: c = ' '; break; ++ case B_TAB: c = KBD_TAB; break; ++ case B_ESCAPE: c = KBD_ESC; break; ++ case B_LEFT_ARROW: c = KBD_LEFT; break; ++ case B_RIGHT_ARROW: c = KBD_RIGHT; break; ++ case B_UP_ARROW: c = KBD_UP; break; ++ case B_DOWN_ARROW: c = KBD_DOWN; break; ++ case B_INSERT: c = KBD_INS; break; ++ case B_DELETE: c = KBD_DEL; break; ++ case B_HOME: c = KBD_HOME; break; ++ case B_END: c = KBD_END; break; ++ case B_PAGE_UP: c = KBD_PAGE_UP; break; ++ case B_PAGE_DOWN: c = KBD_PAGE_DOWN; break; ++ default: if (c < 32) c = 0; ++ else modifiers &= ~(B_LEFT_SHIFT_KEY|B_RIGHT_SHIFT_KEY); ++ break; ++ } ++ if (modifiers & (B_LEFT_SHIFT_KEY|B_RIGHT_SHIFT_KEY)) ++ mods |= KBD_SHIFT; ++ if (modifiers & (B_LEFT_CONTROL_KEY|B_RIGHT_CONTROL_KEY)) ++ mods |= KBD_CTRL; ++ if (modifiers & (B_LEFT_COMMAND_KEY|B_RIGHT_COMMAND_KEY)) ++ mods |= KBD_ALT; ++ if (c) if (dev) dev->keyboard_handler(dev, c, mods); ++ } ++ break; ++ case B_MOUSE_WHEEL_CHANGED: ++ { ++ float delta_x, delta_y; ++ if (msg->FindFloat("be:wheel_delta_x", &delta_x) != B_OK) ++ delta_x = 0; ++ if (msg->FindFloat("be:wheel_delta_y", &delta_y) != B_OK) ++ delta_y = 0; ++ if (delta_y) if (dev) dev->mouse_handler(dev, view->last_x, view->last_y, B_MOVE | (delta_y > 0 ? B_WHEELDOWN : B_WHEELUP)); ++ if (delta_x) if (dev) dev->mouse_handler(dev, view->last_x, view->last_y, B_MOVE | (delta_x < 0 ? B_WHEELLEFT : B_WHEELRIGHT)); ++ } ++ break; ++ case B_PASTE: ++ if (be_clipboard->Lock()) { ++ BMessage *data = be_clipboard->Data(); ++ if (data) { ++ const char *text_plain; ++ ssize_t len; ++ //data->PrintToStream(); ++ if (data->FindData("text/plain", B_MIME_TYPE, (const void **)&text_plain, &len) == B_OK) { ++ be_paste_string(dev, text_plain); ++ } ++ } ++ be_clipboard->Unlock(); ++ } ++ break; ++ case B_REFS_RECEIVED: ++ if (dev) ++ be_paste_string(dev, "\033\ng"); ++ /* FALLTHROUGH */ ++ case B_SIMPLE_DATA: ++ { ++ /* something got dropped */ ++ entry_ref ref; ++ const char *text_plain; ++ ssize_t len; ++ //msg->PrintToStream(); ++ /* try find a file path to paste */ ++ if (msg->FindRef("refs", &ref) == B_OK) { ++ BPath path(&ref); ++ if (path.InitCheck() == B_OK) { ++ BFile f(path.Path(), B_READ_ONLY); ++ BString url; ++ if (f.InitCheck() == B_OK && f.ReadAttrString("META:url", &url) >= B_OK) { ++ be_paste_string(dev, url.String()); ++ } else ++ be_paste_string(dev, path.Path()); ++ } ++ } else if (msg->FindData("text/plain", B_MIME_TYPE, (const void **)&text_plain, &len) == B_OK) { ++ be_paste_string(dev, text_plain); ++ } ++ } ++ break; ++ default: ++ msg->PrintToStream(); ++ break; ++ } ++ delete msg; ++} ++ ++void be_get_size(struct graphics_device *dev) ++{ ++ BRect r; ++ lock_dev(dev); ++ r = lv(dev)->Bounds(); ++ unlock_dev(dev); ++ dev->size.x1 = dev->size.y1 = 0; ++ dev->size.x2 = (int)r.Width() + 1; ++ dev->size.y2 = (int)r.Height() + 1; ++} ++ ++void LinksView::Draw(BRect r) ++{ ++ detach_message(dev); ++ current->AddRect("updateRect", r); ++ pipe_message(dev); ++} ++ ++ ++void LinksView::MouseDown(BPoint p) ++{ ++ detach_and_pipe_message(dev); ++} ++ ++void LinksView::MouseUp(BPoint p) ++{ ++ detach_and_pipe_message(dev); ++} ++ ++void LinksView::MouseMoved(BPoint p, uint32 transit, const BMessage *dragmsg) ++{ ++ detach_and_pipe_message(dev); ++} ++ ++void LinksView::MessageReceived(BMessage *msg) ++{ ++ switch (msg->what) { ++ case B_REFS_RECEIVED: ++ case B_MOUSE_WHEEL_CHANGED: ++ case B_PASTE: ++ case B_SIMPLE_DATA: ++ detach_and_pipe_message(dev); ++ break; ++ default: ++ BView::MessageReceived(msg); ++ } ++} ++ ++void LinksView::KeyDown(const char *s, int32 numBytes) ++{ ++ detach_and_pipe_message(dev); ++} ++ ++unsigned char *be_get_driver_param(void) ++{ ++ return NULL; ++} ++ ++int32 be_app_thread(void *p) ++{ ++ be_links_app->Lock(); ++ be_links_app->Run(); ++ delete be_links_app; ++ return 0; ++} ++ ++unsigned char *be_init_driver(unsigned char *param, unsigned char *display) ++{ ++ be_links_app = new LinksApplication(); ++ if (!be_links_app) { ++ return stracpy((unsigned char *)"Unable to allocate Application object.\n"); ++ } ++ if (c_pipe(msg_pipe)) { ++ delete be_links_app; ++ return stracpy((unsigned char *)"Could not create pipe.\n"); ++ } ++ fcntl(rpipe, F_SETFL, O_NONBLOCK); ++ fcntl(wpipe, F_SETFL, O_NONBLOCK); ++ set_handlers(rpipe, be_get_event, NULL, NULL, NULL); ++ be_app_thread_id = spawn_thread(be_app_thread, "links_app", B_NORMAL_PRIORITY, NULL); ++ resume_thread(be_app_thread_id); ++ be_links_app->Unlock(); ++ be_cs_desktop = B_NO_COLOR_SPACE; ++ be_x_size = 640; ++ be_y_size = 480; ++ BScreen d; ++ if (d.IsValid()) { ++ be_cs_desktop = d.ColorSpace(); ++ be_x_size = (int)d.Frame().Width() + 1; ++ be_y_size = (int)d.Frame().Height() + 1; ++ } ++ be_win_y_size = be_y_size * 9 / 10; ++ be_win_x_size = be_win_y_size; ++ /* ++ DBG("%d %d\n", be_x_size, be_y_size); ++ DBG("%d %d\n", be_win_x_size, be_win_y_size); ++ */ ++ be_win_y_pos = (be_y_size - be_win_y_size) / 2; ++ be_win_x_pos = be_x_size - be_win_x_size - be_win_y_pos; ++ if (/*be_cs_desktop == B_RGB32 ||*/ be_cs_desktop == B_RGB24 || be_cs_desktop == B_RGB16 || be_cs_desktop == B_RGB15) ++ be_cs_bmp = be_cs_desktop; ++ else if (be_cs_desktop == B_RGB32 || be_cs_desktop == B_RGBA32) be_cs_bmp = B_RGB24; ++ else be_cs_bmp = B_RGB15; ++ be_cs_bmp = B_RGB16; // XXX: DEBUG ++ switch (be_cs_bmp) { ++ case B_RGB24: ++ haiku_driver.depth = 0xc3; ++ break; ++ case B_RGB16: ++ haiku_driver.depth = 0x82; ++ break; ++ case B_RGB15: ++ haiku_driver.depth = 0x7a; ++ break; ++ default: ++ internal("unknown depth"); ++ } ++ return NULL; ++} ++ ++void be_shutdown_driver() ++{ ++ status_t ret; ++ //debug((unsigned char *)"D"); ++ close(rpipe); ++ close(wpipe); ++ set_handlers(rpipe, NULL, NULL, NULL, NULL); ++ //debug((unsigned char *)"DD"); ++ be_links_app->PostMessage(B_QUIT_REQUESTED); ++ //debug((unsigned char *)"E"); ++ wait_for_thread(be_app_thread_id, &ret); ++ //debug((unsigned char *)"F"); ++} ++ ++struct graphics_device *be_init_device() ++{ ++ LinksView *view; ++ LinksWindow *win; ++ struct graphics_device *dev = (struct graphics_device *)mem_calloc(sizeof(struct graphics_device)); ++ if (!dev) return NULL; ++ //dev->drv = &haiku_driver; ++ //debug((unsigned char *)"1"); ++ win = new LinksWindow(BRect(be_win_x_pos, be_win_y_pos, be_win_x_pos + be_win_x_size, be_win_y_pos + be_win_y_size)); ++ //debug((unsigned char *)"2"); ++ if (!win) { ++ mem_free(dev); ++ return NULL; ++ } ++ //debug((unsigned char *)"3"); ++ view = new LinksView(win); ++ if (!view) { ++ delete win; ++ mem_free(dev); ++ return NULL; ++ } ++ view->dev = dev; ++ dev->driver_data = view; ++ be_get_size(dev); ++ memcpy(&dev->clip, &dev->size, sizeof(struct rect)); ++ //debug((unsigned char *)"4"); ++ win->Show(); ++ win->Lock(); ++ view->MakeFocus(); ++ win->Unlock(); ++ //debug((unsigned char *)"5"); ++ if (initial_refs_msg) { ++ BMessenger msgr(win); ++ if (msgr.IsValid()) { ++ msgr.SendMessage(initial_refs_msg); ++ initial_refs_msg = NULL; ++ } ++ } ++ return dev; ++} ++ ++void be_shutdown_device(struct graphics_device *dev) ++{ ++ LinksWindow *win = lv(dev)->win; ++ unregister_bottom_half(do_flush, dev); ++ lv(dev)->dev = NULL; ++ win->PostMessage(B_QUIT_REQUESTED); ++ mem_free(dev); ++} ++ ++void be_set_title(struct graphics_device *dev, unsigned char *title) ++{ ++ LinksWindow *win = lv(dev)->win; ++ lock_dev(dev); ++ win->SetTitle((const char *)title); ++ lv(dev)->d_flush(); ++ unlock_dev(dev); ++} ++ ++/* ++int be_get_filled_bitmap(struct bitmap *bmp, long color) ++{ ++ internal((unsigned char *)"nedopsano"); ++ return 0; ++} ++*/ ++ ++int be_get_empty_bitmap(struct bitmap *bmp) ++{ ++ DBG("bmp\n"); ++//DBG("bmp (%d, %d) cs %08x\n", bmp->x, bmp->y, be_cs_bmp); ++ BRect r(0, 0, bmp->x - 1, bmp->y - 1); ++ BBitmap *b = new BBitmap(r, /*B_RGB32*/be_cs_bmp); ++ if (!b) { ++ bmp->data = NULL; ++DBG("%s: error 1\n", __FUNCTION__); ++ return 0; ++ } ++ if (!b->IsValid()) { ++ bmp->data = NULL; ++ delete b; ++DBG("%s: error 2\n", __FUNCTION__); ++ return 0; ++ } ++ if (b->LockBits() < B_OK) { ++ bmp->data = NULL; ++ delete b; ++DBG("%s: error 3\n", __FUNCTION__); ++ return 0; ++ } ++ bmp->data = b->Bits(); ++ bmp->skip = b->BytesPerRow(); ++ bmp->flags = b; ++//DBG("bmp: data %p, skip %d, flags %p\n", bmp->data, bmp->skip, bmp->flags); ++ return 0; ++} ++ ++void be_register_bitmap(struct bitmap *bmp) ++{ ++ BBitmap *b = (BBitmap *)bmp->flags; ++ b->UnlockBits(); ++} ++ ++void *be_prepare_strip(struct bitmap *bmp, int top, int lines) ++{ ++ DBG("preps\n"); ++ BBitmap *b = (BBitmap *)bmp->flags; ++ if (b->LockBits() < B_OK) ++ return NULL; ++ bmp->data = b->Bits(); ++ bmp->skip = b->BytesPerRow(); ++ return ((char *)bmp->data) + bmp->skip * top; ++} ++ ++void be_commit_strip(struct bitmap *bmp, int top, int lines) ++{ ++ BBitmap *b = (BBitmap *)bmp->flags; ++ b->UnlockBits(); ++} ++ ++void be_unregister_bitmap(struct bitmap *bmp) ++{ ++ DBG("unb\n"); ++ BBitmap *b = (BBitmap *)bmp->flags; ++ delete b; ++} ++ ++void be_draw_bitmap(struct graphics_device *dev, struct bitmap *bmp, int x, int y) ++{ ++ DBG("drawb\n"); ++ BBitmap *b = (BBitmap *)bmp->flags; ++ lock_dev(dev); ++ lv(dev)->DrawBitmap(b, b->Bounds(), BRect(x, y, x + bmp->x - 1, y + bmp->y - 1)); ++ lv(dev)->d_flush(); ++ unlock_dev(dev); ++} ++ ++/* ++void be_draw_bitmaps(struct graphics_device *dev, struct bitmap **bmp, int n, int x, int y) ++{ ++ LinksView *lvv = lv(dev); ++ lock_dev(dev); ++ while (n--) { ++ BBitmap *b = (BBitmap *)(*bmp)->flags; ++ lvv->DrawBitmap(b, b->Bounds(), BRect(x, y, x + (*bmp)->x, y + (*bmp)->y)); ++ x += (*bmp)->x; ++ bmp++; ++ } ++ lv(dev)->d_flush(); ++ unlock_dev(dev); ++} ++*/ ++ ++long be_get_color(int rgb) ++{ ++ if (small_color) { ++ get_color32(c, rgb); ++ return *(long *)(void *)&c; ++ } else return rgb & 0xffffff; ++} ++ ++void be_fill_area(struct graphics_device *dev, int x1, int y1, int x2, int y2, long color) ++{ ++ DBG("fill\n"); ++ if (x1 >= x2 || y1 >= y2) return; ++ lock_dev(dev); ++ if (small_color) ++ lv(dev)->SetHighColor(*(rgb_color *)(void *)&color); ++ else ++ lv(dev)->SetHighColor(get_color32(, color)); ++ lv(dev)->FillRect(BRect(x1, y1, x2 - 1, y2 - 1)); ++ lv(dev)->d_flush(); ++ unlock_dev(dev); ++} ++ ++void be_draw_hline(struct graphics_device *dev, int x1, int y, int x2, long color) ++{ ++ DBG("hline\n"); ++ if (x1 >= x2) return; ++ lock_dev(dev); ++ if (small_color) ++ lv(dev)->SetHighColor(*(rgb_color *)(void *)&color); ++ else ++ lv(dev)->SetHighColor(get_color32(, color)); ++ lv(dev)->StrokeLine(BPoint(x1, y), BPoint(x2 - 1, y)); ++ lv(dev)->d_flush(); ++ unlock_dev(dev); ++} ++ ++void be_draw_vline(struct graphics_device *dev, int x, int y1, int y2, long color) ++{ ++ DBG("vline\n"); ++ if (y1 >= y2) return; ++ lock_dev(dev); ++ if (small_color) ++ lv(dev)->SetHighColor(*(rgb_color *)(void *)&color); ++ else ++ lv(dev)->SetHighColor(get_color32(, color)); ++ lv(dev)->StrokeLine(BPoint(x, y1), BPoint(x, y2 - 1)); ++ lv(dev)->d_flush(); ++ unlock_dev(dev); ++} ++ ++int be_hscroll(struct graphics_device *dev, struct rect_set **ignore, int sc) ++{ ++ DBG("hscroll\n"); ++ if (dev->clip.x1 >= dev->clip.x2 || dev->clip.y1 >= dev->clip.y2) return 0; ++ if (sc <= dev->clip.x1 - dev->clip.x2) return 1; ++ if (sc >= dev->clip.x2 - dev->clip.x1) return 1; ++ lock_dev0(dev); ++ if (sc > 0) lv(dev)->CopyBits(BRect(dev->clip.x1, dev->clip.y1, dev->clip.x2 - sc - 1, dev->clip.y2 - 1), BRect(dev->clip.x1 + sc, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 - 1)); ++ else lv(dev)->CopyBits(BRect(dev->clip.x1 - sc, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 - 1), BRect(dev->clip.x1, dev->clip.y1, dev->clip.x2 + sc - 1, dev->clip.y2 - 1)); ++ lv(dev)->d_flush(); ++ unlock_dev(dev); ++ return 1; ++} ++ ++int be_vscroll(struct graphics_device *dev, struct rect_set **ignore, int sc) ++{ ++ DBG("vscroll\n"); ++ if (!sc || dev->clip.x1 >= dev->clip.x2 || dev->clip.y1 >= dev->clip.y2) return 0; ++ if (sc <= dev->clip.y1 - dev->clip.y2) return 1; ++ if (sc >= dev->clip.y2 - dev->clip.y1) return 1; ++ lock_dev0(dev); ++ if (sc > 0) lv(dev)->CopyBits(BRect(dev->clip.x1, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 - sc - 1), BRect(dev->clip.x1, dev->clip.y1 + sc, dev->clip.x2 - 1, dev->clip.y2 - 1)); ++ else lv(dev)->CopyBits(BRect(dev->clip.x1, dev->clip.y1 - sc, dev->clip.x2 - 1, dev->clip.y2 - 1), BRect(dev->clip.x1, dev->clip.y1, dev->clip.x2 - 1, dev->clip.y2 + sc - 1)); ++ lv(dev)->d_flush(); ++ unlock_dev(dev); ++ return 1; ++} ++ ++void be_set_clip_area(struct graphics_device *dev, struct rect *r) ++{ ++ DBG("setc\n"); ++ memcpy(&dev->clip, r, sizeof(struct rect)); ++ lock_dev(dev); ++ BRegion clip(BRect(r->x1, r->y1, r->x2 - 1, r->y2 - 1)); ++ lv(dev)->ConstrainClippingRegion(&clip); ++ unlock_dev(dev); ++} ++ ++struct graphics_driver haiku_driver = { ++ (unsigned char *)"haiku", ++ be_init_driver, ++ be_init_device, ++ be_shutdown_device, ++ be_shutdown_driver, ++ dummy_emergency_shutdown, ++ be_get_driver_param, ++ be_get_empty_bitmap, ++ be_register_bitmap, ++ be_prepare_strip, ++ be_commit_strip, ++ be_unregister_bitmap, ++ be_draw_bitmap, ++ be_get_color, ++ be_fill_area, ++ be_draw_hline, ++ be_draw_vline, ++ be_hscroll, ++ be_vscroll, ++ be_set_clip_area, ++ dummy_block, ++ dummy_unblock, ++ be_set_title, ++ NULL, /* exec */ ++ NULL, /* set_clipboard_text */ ++ NULL, /* get_clipboard_text */ ++ 0, /* depth */ ++ 0, 0, /* size */ ++ 0, /* flags */ ++ 0, /* codepage */ ++ NULL, /* shell */ ++}; ++ ++#endif /* GRDRV_HAIKU */ ++ ++#endif +diff --git a/links-haiku.rdef b/links-haiku.rdef +new file mode 100644 +index 0000000..b18b11c +--- /dev/null ++++ b/links-haiku.rdef +@@ -0,0 +1,125 @@ ++/* ++** links-haiku.rdef ++** ++** Automatically generated by BResourceParser on ++** Thursday, December 13, 2007 at 23:46:45. ++** ++*/ ++ ++resource(1, "BEOS:APP_FLAGS") (#'APPF') $"01000000"; ++ ++resource(1, "BEOS:APP_VERSION") #'APPV' array { ++ $"02000000010000000000000000000000210000006C696E6B7320322E31707265" ++ $"3333000000000000000000000000000000000000000000000000000000000000" ++ $"00000000000000000000000000000000000000004C696E6B732062726F777365" ++ $"7220322E31707265333300000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000" ++}; ++ ++resource(101, "BEOS:L:STD_ICON") #'ICON' array { ++ $"2A2A2A2A2A2A2A2A2A2A2A2A2A2A2C0000363434343434343434343434343434" ++ $"2A2A2A2A2A2A2A2A2A2A2A2A2A2A2C0000363434343434343434343434343434" ++ $"2A2A2A2B2B2B2B2B2B2B2B2B2B2B2C0000363434343434343434343434343434" ++ $"2A2A2A3200000000000000000000000000363434343434343434343434343434" ++ $"2A2A2A2FF1313200000000000131310000363434343434343434343434343434" ++ $"2A2A2A2A2A2A2A30000000002B2A2C0000363434343434343434343434343434" ++ $"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434" ++ $"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434" ++ $"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434" ++ $"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434" ++ $"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434" ++ $"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434" ++ $"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434" ++ $"2A2A2A2A2A2A2A2F000000002A2A2C0000363434343434343434343434343434" ++ $"2C2C2C2C2C2C2C30000000002C2C2D0000373636363636363636363636363636" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"0000000000000000000000000000000000000000000000000000000000000000" ++ $"2222222222222226000000002222230000151A1A1A1A1A1A1A1A1A1A1A1A1A1A" ++ $"20202020202020250000000020202200001A3F3F3F3F3F3F3F3F3F3F3F3F3F3F" ++ $"20202020202020250000000020202200001A3F3F3F3F3F3F3F1501113F3F3F3F" ++ $"20202020202020250000000020202200001A3F3F3F3F3F3F3F0E00133F3F3F3F" ++ $"20202020202020250000000020202200001A3F3F3F3F3F3F3F0500163F3F3F3F" ++ $"20202020202020250000000020202200001A3F3F3F3F3F3F1A0000193F3F3F3F" ++ $"20202020202020250000000020202200001A3F3F3F3F3F3F0C00001B3F3F3F3F" ++ $"20202020202020250000000020202200001A3F3F3F3F3F190000001E3F3F3F3F" ++ $"20202020202020250000000020202200001A3F3F3F3F1A030000013F3F3F3F3F" ++ $"20202020202020270000000023202200001A3F1E170C00000000043F3F3F3F3F" ++ $"2020202628292900000000000029290000040300000000000000063F3F3F3F3F" ++ $"20202027292929292929292929292900000203030303030303030B3F3F3F3F3F" ++ $"20202020202020202020202020202200001A3F3F3F3F3F3F3F3F3F3F3F3F3F3F" ++ $"20202020202020202020202020202200001A3F3F3F3F3F3F3F3F3F3F3F3F3F3F" ++ $"20202020202020202020202020202200001A3F3F3F3F3F3F3F3F3F3F3F3F3F3F" ++}; ++ ++resource(101, "BEOS:M:STD_ICON") #'MICN' array { ++ $"2A2A2A2A2A2A2A303A34343434343434" ++ $"2A2C3030303030F73A34343434343434" ++ $"2A2B2D300000EB323A34343434343434" ++ $"2A2A2A2C00002A303A34343434343434" ++ $"2A2A2A2C00002A303A34343434343434" ++ $"2A2A2A2C00002A303A34343434343434" ++ $"2A2A2A2C00002A303A34343434343434" ++ $"303030310000F1333D3A3A3A3A3A3A3A" ++ $"2626262700002629050D0D0D0D0D0D0D" ++ $"20202022000020260D3F3F3F1D143F3F" ++ $"20202022000020260D3F3F3F140A3F3F" ++ $"20202022000020260D3F3F3F090D3F3F" ++ $"20202022000020260D3F3F16000F3F3F" ++ $"20222427000026280710090000123F3F" ++ $"202225252525252807111111111A3F3F" ++ $"20202020202020260D3F3F3F3F3F3F3F" ++}; ++ ++resource(101, "BEOS:ICON") #'VICN' array { ++ $"6E6369661305000200060237E670B8880E39469D39AE144A52234B0D2500C6D7" ++ $"F5FF6B94DD03EC6666020006023B2B47BB18653D0FA53D225148297046CA1900" ++ $"00FF00FFA9FF00020016023B2B47BB18653D0FA53D225148297046CA1900FFFF" ++ $"8A020006023B3049396B0ABA90833C646E4A101543299500FFFFFFFF52FF5202" ++ $"0016023B3049396B0ABA90833C646E4A101543299500FFFFC9020006023C71E3" ++ $"3A0C78BA15E43C7D2149055549455700E3EDFFFF9EC2FF020006023CD8653068" ++ $"26B065D13CD5A34A6E4A46E21900FFDCDCFFDA5858020006023A1DA6393F04BB" ++ $"B5BC3C6B074AEA364809110087CA05FF026802020016023C00913B1266BB9E06" ++ $"3C5B934A01F04914EC00FFFF4E03003CB00200060230B31E3A09B9BB024238A1" ++ $"2F4BAB534AFF0B00A3043CFFFFDCE603CD4D4D030D296402000602BD498B3E11" ++ $"59BF219BBE7D2F4BE71F4AB31300C13E3EFFE27A7A040174020016023F2938BB" ++ $"F60A3BA9823EEC25C40E6348C15D0099FF00020016023E8FA33A7B71BA9D783E" ++ $"B2C049F7BAC28CE500C8FF00130A06322E323E42464C3C4C2C3D260A04322E32" ++ $"3E424642350A04322E42354C2C3D260A04423542464C3C4C2C0A0338423C4D3C" ++ $"440A08335C395C41544F5C555C6051594D3E510A0422422252325A32490A0422" ++ $"4232493C402D3A0A043249325A3C503C400A043E424E495840493A0A043E524E" ++ $"5A4E493E420A1243C97243C375BF66C2A93F503C5133C4F03330342F3830382D" ++ $"2927292A2C2C2D2E2DC2F2B7B1C3BEB5E1C358B5E1C4AA0A042C252927382D3B" ++ $"2B0A04364B334D3E5241500A0442463F48434A46480A042A4727492B4B2E490A" ++ $"04382D38303B2E3B2B0A04434A4358465646480A04332F334D364B362D160A10" ++ $"01052020230A1001052022120A00010030103701178400040A0101012010370A" ++ $"0B01032010370A0E0104201D250A0101072020230A00010030101C0117840004" ++ $"0A02010A2004080A0C010320101C0A0801092004080A00010030283901178400" ++ $"040A0401012028390A0601022028390A0A01032028390A000100302A20011784" ++ $"00040A030101202A200A050102202A200A090103202A200A12040C0D0E0F000A" ++ $"0003101211000A11010B00" ++}; ++ ++resource(1, "BEOS:APP_SIG") (#'MIMS') "application/x-vnd.links"; ++ ++resource(1, "BEOS:FILE_TYPES") message { ++ "types" = "text/html", ++ "types" = "application/x-vnd.Be-bookmark", ++ "types" = "application/x-vnd.Be.URL.http" ++}; +diff --git a/os_dep.c b/os_dep.c +index 2691467..79bf675 100644 +--- a/os_dep.c ++++ b/os_dep.c +@@ -439,7 +439,7 @@ static void terminal_resize_poll(void) + + #endif + +-#if defined(UNIX) || defined(WIN) || defined(INTERIX) || defined(BEOS) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(OPENVMS) ++#if defined(UNIX) || defined(WIN) || defined(INTERIX) || defined(BEOS) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(OPENVMS) || defined(HAIKU) + + #ifdef SIGWINCH + static void sigwinch(void *s) +@@ -858,7 +858,7 @@ int is_xterm(void) + return xt; + } + +-#elif defined(BEOS) || defined(ATHEOS) || defined(DOS) ++#elif defined(BEOS) || defined(ATHEOS) || defined(DOS) || defined(HAIKU) + + int is_xterm(void) + { +@@ -1029,6 +1029,12 @@ void init_os_terminal(void) + } + } + #endif ++#ifdef HAIKU ++ if (getenv("TERM") == NULL) { ++ /* probably launched from Tracker or Deskbar, force graphics mode */ ++ force_g = 1; ++ } ++#endif + } + + #ifdef INTERIX +@@ -1230,7 +1236,7 @@ unsigned char *os_fixup_external_program(unsigned char *prog) + #endif + + +-#if defined(UNIX) || defined(INTERIX) || defined(BEOS) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(OPENVMS) || defined(DOS) ++#if defined(UNIX) || defined(INTERIX) || defined(BEOS) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(OPENVMS) || defined(DOS) || defined(HAIKU) + + #if defined(BEOS) && defined(HAVE_SETPGID) + +@@ -1975,7 +1981,7 @@ static uint32 bgat(void *t) + + #endif + +-#if defined(UNIX) || defined(OS2) || defined(WIN) || defined(INTERIX) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) ++#if defined(UNIX) || defined(OS2) || defined(WIN) || defined(INTERIX) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(HAIKU) + + void terminate_osdep(void) + { +@@ -1992,7 +1998,7 @@ void unblock_stdin(void) {} + + #if defined(BEOS) + +-#include ++#include + + static int thr_sem_init = 0; + static sem_id thr_sem; +@@ -2765,6 +2771,13 @@ int get_system_env(void) + return 0; + } + ++#elif defined(HAIKU) ++ ++int get_system_env(void) ++{ ++ return ENV_BE; ++} ++ + #elif defined(WIN) + + int get_system_env(void) +@@ -2887,6 +2900,14 @@ static int open_in_new_be(struct terminal *term, unsigned char *exe, unsigned ch + } + #endif + ++#ifdef HAIKU ++static int open_in_new_haiku(struct terminal *term, unsigned char *exe, unsigned char *param) ++{ ++ exec_new_links(term, cast_uchar "Terminal", exe, param); ++ return 0; ++} ++#endif ++ + #ifdef G + static int open_in_new_g(struct terminal *term, unsigned char *exe, unsigned char *param) + { +@@ -2935,6 +2956,9 @@ static struct { + #ifdef BEOS + {ENV_BE, open_in_new_be, TEXT_(T_BEOS_TERMINAL), TEXT_(T_HK_BEOS_TERMINAL)}, + #endif ++#ifdef HAIKU ++ {ENV_BE, open_in_new_haiku, TEXT_(T_BEOS_TERMINAL), TEXT_(T_HK_BEOS_TERMINAL)}, ++#endif + #ifdef G + {ENV_G, open_in_new_g, TEXT_(T_WINDOW), TEXT_(T_HK_WINDOW)}, + #endif +@@ -2983,6 +3007,9 @@ int can_open_os_shell(int environment) + #ifdef BEOS + if (!(environment & ENV_BE)) return 0; + #endif ++#ifdef HAIKU ++ if (!(environment & ENV_BE)) return 0; ++#endif + #ifdef G + if (F && drv->flags & GD_NO_OS_SHELL) return 0; + #endif +diff --git a/os_dep.h b/os_dep.h +index ffc0e13..6d46b6c 100644 +--- a/os_dep.h ++++ b/os_dep.h +@@ -29,7 +29,7 @@ + #define WIN + #elif defined(__INTERIX) + #define INTERIX +-#elif defined(__BEOS__) || defined(__HAIKU__) ++#elif defined(__BEOS__) + #define BEOS + #elif defined(__riscos__) + #define RISCOS +@@ -41,6 +41,8 @@ + #define OPENVMS + #elif defined(__DJGPP) + #define DOS ++#elif defined(__HAIKU__) ++#define HAIKU + #else + #define UNIX + #endif +@@ -170,6 +172,25 @@ static inline int dir_sep(unsigned char x) { return x == '/'; } + + #include "beos.h" + ++#elif defined(HAIKU) ++ ++static inline int dir_sep(unsigned char x) { return x == '/'; } ++#define NEWLINE "\n" ++#define NO_ASYNC_LOOKUP /* async lookup works on BeOS but crashes the Haiku kernel */ ++#define FS_UNIX_RIGHTS ++#define FS_UNIX_SOFTLINKS ++#define FS_UNIX_USERS ++/* TODO: allocate new SYS_* or replace SYS_BEOS */ ++#define SYSTEM_ID SYS_BEOS ++#define SYSTEM_NAME "Haiku" ++#define DEFAULT_SHELL "/bin/sh" ++#define GETSHELL getenv("SHELL") ++#define NO_CTRL_Z ++#define SET_WINDOW_TITLE_UTF_8 ++#define SHARED_CONFIG_DIR "/etc/" ++#define NO_FORK_ON_EXIT ++#define ASSOC_BLOCK ++ + #elif defined(RISCOS) + + static inline int dir_sep(unsigned char x) { return x == '/' || x == '\\'; } +diff --git a/os_depx.h b/os_depx.h +index cd71bbc..3a35740 100644 +--- a/os_depx.h ++++ b/os_depx.h +@@ -176,6 +176,10 @@ int bounced_write(int fd, const void *buf, size_t size); + #endif + #endif + ++#ifdef HAIKU ++/* nothing so far */ ++#endif ++ + #ifdef OPENVMS + #if defined(__INITIAL_POINTER_SIZE) + #if __INITIAL_POINTER_SIZE == 64 +@@ -352,6 +356,9 @@ int vga_select(int n, fd_set *r, fd_set *w, fd_set *e, struct timeval *t); + #elif defined(GRDRV_ATHEOS) + #define loop_select ath_select + int ath_select(int n, fd_set *r, fd_set *w, fd_set *e, struct timeval *t); ++#elif defined(GRDRV_HAIKU) ++#define loop_select be_loop_select ++int be_loop_select(int n, fd_set *r, fd_set *w, fd_set *e, struct timeval *t); + #else + #define loop_select select + #endif +-- +2.12.2 + + +From d282e95dd072b3428fa87f38c325e5734c5785ce Mon Sep 17 00:00:00 2001 +From: Jerome Duval +Date: Sat, 15 Jul 2017 14:41:58 +0200 +Subject: fix build with 2.14 + + +diff --git a/cfg.h b/cfg.h +index 9822cd0..74aaac2 100644 +--- a/cfg.h ++++ b/cfg.h +@@ -67,9 +67,9 @@ + #define volatile + #endif + +-#if defined(HAVE_RESTRICT) ++#if defined(HAVE_RESTRICT) && !defined(__cplusplus) + #define my_restrict restrict +-#elif defined(HAVE___RESTRICT) ++#elif defined(HAVE___RESTRICT) && !defined(__cplusplus) + #define my_restrict __restrict + #else + #define my_restrict +diff --git a/haiku.cpp b/haiku.cpp +index 707a12e..744797f 100644 +--- a/haiku.cpp ++++ b/haiku.cpp +@@ -27,9 +27,7 @@ + * - handle DnD of Net+ bookmarks + */ + +-extern "C" { + #include "cfg.h" +-} + + #ifdef GRDRV_HAIKU + +@@ -554,7 +552,7 @@ unsigned char *be_init_driver(unsigned char *param, unsigned char *display) + } + fcntl(rpipe, F_SETFL, O_NONBLOCK); + fcntl(wpipe, F_SETFL, O_NONBLOCK); +- set_handlers(rpipe, be_get_event, NULL, NULL, NULL); ++ set_handlers(rpipe, be_get_event, NULL, NULL); + be_app_thread_id = spawn_thread(be_app_thread, "links_app", B_NORMAL_PRIORITY, NULL); + resume_thread(be_app_thread_id); + be_links_app->Unlock(); +@@ -602,7 +600,7 @@ void be_shutdown_driver() + //debug((unsigned char *)"D"); + close(rpipe); + close(wpipe); +- set_handlers(rpipe, NULL, NULL, NULL, NULL); ++ set_handlers(rpipe, NULL, NULL, NULL); + //debug((unsigned char *)"DD"); + be_links_app->PostMessage(B_QUIT_REQUESTED); + //debug((unsigned char *)"E"); +@@ -857,8 +855,12 @@ struct graphics_driver haiku_driver = { + be_init_device, + be_shutdown_device, + be_shutdown_driver, +- dummy_emergency_shutdown, ++ NULL, ++ NULL, + be_get_driver_param, ++ NULL, ++ NULL, ++ NULL, + be_get_empty_bitmap, + be_register_bitmap, + be_prepare_strip, +-- +2.12.2 +