Index: render/html.c =================================================================== --- render/html.c (révision 4457) +++ render/html.c (copie de travail) @@ -107,7 +107,7 @@ html->base_url = c->url; html->base_target = NULL; html->layout = 0; - html->background_colour = TRANSPARENT; + html->background_colour = CSS_COLOR_TRANSPARENT; html->stylesheet_count = 0; html->stylesheet_content = 0; html->style = 0; Index: render/html_redraw.c =================================================================== --- render/html_redraw.c (révision 4457) +++ render/html_redraw.c (copie de travail) @@ -122,7 +122,7 @@ /* clear to background colour */ plot.clip(clip_x0, clip_y0, clip_x1, clip_y1); - if (c->data.html.background_colour != TRANSPARENT) + if (c->data.html.background_colour != CSS_COLOR_TRANSPARENT) background_colour = c->data.html.background_colour; plot.clg(background_colour); @@ -292,17 +292,17 @@ if (!box->parent) { /* Root box */ if (box->style && - (box->style->background_color != TRANSPARENT || + (box->style->background_color != CSS_COLOR_TRANSPARENT || box->background)) { /* With its own background */ bg_box = box; } else if (!box->style || - (box->style->background_color == TRANSPARENT && + (box->style->background_color == CSS_COLOR_TRANSPARENT && !box->background)) { /* Without its own background */ if (box->children && box->children->style && (box->children->style->background_color != - TRANSPARENT || + CSS_COLOR_TRANSPARENT || box->children->background)) { /* But body has one, so use that */ bg_box = box->children; @@ -311,12 +311,12 @@ } else if (box->parent && !box->parent->parent) { /* Body box */ if (box->style && - (box->style->background_color != TRANSPARENT || + (box->style->background_color != CSS_COLOR_TRANSPARENT || box->background)) { /* With a background */ if (box->parent->style && (box->parent->style->background_color != - TRANSPARENT || + CSS_COLOR_TRANSPARENT || box->parent->background)) { /* Root has own background; process normally */ bg_box = box; @@ -334,7 +334,7 @@ if (bg_box && (bg_box->style && bg_box->type != BOX_BR && (bg_box->type != BOX_INLINE || bg_box->style != bg_box->parent->parent->style)) && - ((bg_box->style->background_color != TRANSPARENT) || + ((bg_box->style->background_color != CSS_COLOR_TRANSPARENT) || (bg_box->background))) { /* find intersection of clip box and border edge */ int px0 = x - border_left < x0 ? x0 : x - border_left; @@ -867,7 +867,7 @@ unsigned int light = i; colour c_lit; - if (c == TRANSPARENT) + if (c == CSS_COLOR_TRANSPARENT) return true; switch (style) { @@ -1306,7 +1306,7 @@ /* attributes override */ if ((clip_x0 >= clip_x1) || (clip_y0 >= clip_y1) || (clip_box->style->background_color != - TRANSPARENT) || + CSS_COLOR_TRANSPARENT) || (clip_box->background && clip_box->background->bitmap && bitmap_get_opaque( @@ -1315,7 +1315,7 @@ } /* plot the background colour */ - if (background->style->background_color != TRANSPARENT) { + if (background->style->background_color != CSS_COLOR_TRANSPARENT) { *background_colour = background->style->background_color; if (plot_colour) @@ -1483,10 +1483,10 @@ /** \todo We probably want to clamp to either end of the spectrum, * rather than simply taking the inverse colour. */ - if (vcolour == TRANSPARENT || vcolour == background_colour) + if (vcolour == CSS_COLOR_TRANSPARENT || vcolour == background_colour) vcolour = background_colour ^ 0xffffff; - if (hcolour == TRANSPARENT || hcolour == background_colour) + if (hcolour == CSS_COLOR_TRANSPARENT || hcolour == background_colour) hcolour = background_colour ^ 0xffffff; box_scrollbar_dimensions(box, padding_width, padding_height, w, Index: render/box_construct.c =================================================================== --- render/box_construct.c (révision 4457) +++ render/box_construct.c (copie de travail) @@ -2698,7 +2698,13 @@ n2 = n->children; buf = xmlBufferCreate(); while(n2) { +#ifndef win32 int ret = xmlNodeDump(buf, n2->doc, n2, 0, 0); +#else +#warning WIN32: FIXME + int ret = 0; + xmlNodeDump(buf, n2->doc, n2, 0, 0); +#endif if (ret == -1) { xmlBufferFree(buf); return false; Index: gtk/gtk_plotters.c =================================================================== --- gtk/gtk_plotters.c (révision 4457) +++ gtk/gtk_plotters.c (copie de travail) @@ -397,10 +397,10 @@ cairo_set_matrix(current_cr, &old_ctm); /* Now draw path */ - if (fill != TRANSPARENT) { + if (fill != CSS_COLOR_TRANSPARENT) { nsgtk_set_colour(fill); - if (c != TRANSPARENT) { + if (c != CSS_COLOR_TRANSPARENT) { /* Fill & Stroke */ cairo_fill_preserve(current_cr); nsgtk_set_colour(c); @@ -409,7 +409,7 @@ /* Fill only */ cairo_fill(current_cr); } - } else if (c != TRANSPARENT) { + } else if (c != CSS_COLOR_TRANSPARENT) { /* Stroke only */ nsgtk_set_colour(c); cairo_stroke(current_cr); Index: css/ruleset.c =================================================================== --- css/ruleset.c (révision 4457) +++ css/ruleset.c (copie de travail) @@ -462,7 +462,7 @@ { "teal", 0x808000 }, { "thistle", 0xd8bfd8 }, { "tomato", 0x4763ff }, - { "transparent", TRANSPARENT }, + { "transparent", CSS_COLOR_TRANSPARENT }, { "turquoise", 0xd0e040 }, { "violet", 0xee82ee }, { "violetred", 0x9020d0 }, /* not SVG-1.0*/ @@ -899,7 +899,7 @@ void parse_background(struct css_style * const s, const struct css_node * v) { - colour c = TRANSPARENT, c2; + colour c = CSS_COLOR_TRANSPARENT, c2; css_background_image_type bi = CSS_BACKGROUND_IMAGE_NONE, bi2; char *bi_uri = 0; css_background_repeat br = CSS_BACKGROUND_REPEAT_REPEAT, br2; Index: css/css.c =================================================================== --- css/css.c (révision 4457) +++ css/css.c (copie de travail) @@ -86,6 +86,7 @@ #define _GNU_SOURCE /* for strndup */ #include +#include #include #include #include @@ -312,7 +313,7 @@ * and the 'Initial value' otherwise. */ const struct css_style css_blank_style = { CSS_BACKGROUND_ATTACHMENT_SCROLL, - TRANSPARENT, + CSS_COLOR_TRANSPARENT, { CSS_BACKGROUND_IMAGE_NONE, 0 }, { { CSS_BACKGROUND_POSITION_PERCENT, { 0.0 } }, { CSS_BACKGROUND_POSITION_PERCENT, { 0.0 } } }, @@ -1581,7 +1582,7 @@ #define DUMP_COLOR(z, s) \ if (style->z != CSS_COLOR_NOT_SET) { \ - if (style->z == TRANSPARENT) \ + if (style->z == CSS_COLOR_TRANSPARENT) \ fprintf(stderr, s ": transparent; "); \ else if (style->z == CSS_COLOR_NONE) \ fprintf(stderr, s ": none; "); \ @@ -1735,7 +1736,7 @@ css_border_style_name[ style->border[i].style]); - if (style->border[i].color == TRANSPARENT) + if (style->border[i].color == CSS_COLOR_TRANSPARENT) fprintf(stderr, " transparent"); else if (style->border[i].color == CSS_COLOR_NONE) fprintf(stderr, " none"); @@ -2119,7 +2120,7 @@ fprintf(stderr, " invert"); break; case CSS_OUTLINE_COLOR_COLOR: - if (style->outline.color.value == TRANSPARENT) + if (style->outline.color.value == CSS_COLOR_TRANSPARENT) fprintf(stderr, " transparent"); else if (style->outline.color.value == CSS_COLOR_NONE) fprintf(stderr, " none"); Index: css/css.h =================================================================== --- css/css.h (révision 4457) +++ css/css.h (copie de travail) @@ -41,7 +41,7 @@ typedef unsigned long colour; /* 0xbbggrr */ -#define TRANSPARENT 0x1000000 +#define CSS_COLOR_TRANSPARENT 0x1000000 #define CSS_COLOR_INHERIT 0x2000000 #define CSS_COLOR_NONE 0x3000000 #define CSS_COLOR_NOT_SET 0x4000000 Index: Makefile.sources =================================================================== --- Makefile.sources (révision 4457) +++ Makefile.sources (copie de travail) @@ -61,6 +61,10 @@ gtk_history.c gtk_window.c gtk_filetype.c gtk_download.c S_GTK := $(addprefix gtk/,$(S_GTK)) +# S_WIN32 are sources purely for the win32 (mingw) build +S_WIN32 := +S_WIN32 := $(addprefix win32/,$(S_WIN32)) + # S_BEOS are sources purely for the BeOS build S_BEOS := beos_bitmap.cpp beos_fetch_rsrc.cpp beos_filetype.cpp beos_font.cpp \ beos_gui.cpp beos_history.cpp beos_login.cpp beos_options.cpp \ @@ -131,6 +135,11 @@ EXETARGET := nsgtk endif +ifeq ($(TARGET),mingw) +SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_WIN32) +EXETARGET := NetSurf +endif + ifeq ($(TARGET),beos) SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_BEOS) EXETARGET := NetSurf Index: utils/utils.h =================================================================== --- utils/utils.h (révision 4457) +++ utils/utils.h (copie de travail) @@ -24,7 +24,9 @@ #include #include #include +#ifndef win32 #include +#endif #include #ifndef NOF_ELEMENTS @@ -71,7 +73,9 @@ char * squash_whitespace(const char * s); char *cnv_space2nbsp(const char *s); bool is_dir(const char *path); +#ifndef win32 void regcomp_wrapper(regex_t *preg, const char *regex, int cflags); +#endif void unicode_transliterate(unsigned int c, char **r); char *human_friendly_bytesize(unsigned long bytesize); const char *rfc1123_date(time_t t); @@ -98,4 +102,8 @@ const query_callback *cb, void *pw, const char *yes, const char *no); void query_close(query_id); +#ifdef win32 +#define mkdir(p,m) _mkdir(p) #endif + +#endif Index: utils/config.h =================================================================== --- utils/config.h (révision 4457) +++ utils/config.h (copie de travail) @@ -24,7 +24,7 @@ /* Try to detect which features the target OS supports */ #define HAVE_STRNDUP -#if defined(__FreeBSD__) || (defined(__SRV4) && defined(__sun)) +#if defined(__FreeBSD__) || (defined(__SRV4) && defined(__sun)) || defined(win32) /* FreeBSD and Solaris do not have this function, so * we implement it ourselves in util.c */ @@ -42,7 +42,7 @@ #define WITH_AUTH /* SSL */ -#if !defined(small) +#if !defined(small) && !defined(win32) #define WITH_SSL #endif @@ -73,6 +73,9 @@ /* Theme auto-install */ #define WITH_THEME_INSTALL #else +#if defined(win32) +#undef WITH_MNG +#else /* We're likely to have a working mmap() */ #define WITH_MMAP #define WITH_NSSPRITE @@ -81,6 +84,7 @@ #define WITH_RSVG #endif #endif +#endif #if defined(WITH_NS_SVG) && defined(WITH_RSVG) #error Cannot build WITH_NS_SVG and WITH_RSVG both enabled Index: utils/useragent.c =================================================================== --- utils/useragent.c (révision 4457) +++ utils/useragent.c (copie de travail) @@ -17,7 +17,9 @@ * along with this program. If not, see . */ +#ifndef win32 #include +#endif #include #include @@ -36,16 +38,22 @@ static void user_agent_build_string(void) { +#ifndef win32 struct utsname un; +#endif const char *sysname = "Unknown"; const char *machine = "Unknown"; char *ua_string; int len; +#ifndef win32 if (uname(&un) >= 0) { sysname = un.sysname; machine = un.machine; } +#else + sysname = "Windows"; +#endif len = snprintf(NULL, 0, NETSURF_UA_FORMAT_STRING, netsurf_version_major, Index: utils/talloc.h =================================================================== --- utils/talloc.h (révision 4457) +++ utils/talloc.h (copie de travail) @@ -21,6 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include /* this is only needed for compatibility with the old talloc */ @@ -38,6 +39,10 @@ #define TALLOC_DEPRECATED 0 #endif +#ifndef __VALIST +#define __VALIST va_list +#endif + /* useful macros for creating type checked pointers */ #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) @@ -119,7 +124,7 @@ void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); char *talloc_strdup(const void *t, const char *p); char *talloc_strndup(const void *t, const char *p, size_t n); -char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +char *talloc_vasprintf(const void *t, const char *fmt, __VALIST ap) PRINTF_ATTRIBUTE(2,0); char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); Index: riscos/save_draw.c =================================================================== --- riscos/save_draw.c (révision 4457) +++ riscos/save_draw.c (copie de travail) @@ -304,8 +304,8 @@ } code = pencil_path(ro_save_draw_diagram, path, i + 1, - fill == TRANSPARENT ? pencil_TRANSPARENT : fill << 8, - c == TRANSPARENT ? pencil_TRANSPARENT : c << 8, + fill == CSS_COLOR_TRANSPARENT ? pencil_TRANSPARENT : fill << 8, + c == CSS_COLOR_TRANSPARENT ? pencil_TRANSPARENT : c << 8, width, pencil_JOIN_MITRED, pencil_CAP_BUTT, pencil_CAP_BUTT, 0, 0, false, pencil_SOLID); Index: riscos/plotters.c =================================================================== --- riscos/plotters.c (révision 4457) +++ riscos/plotters.c (copie de travail) @@ -283,7 +283,7 @@ trfm.entries[2][0] = (ro_plot_origin_x + transform[4] * 2) * 256; trfm.entries[2][1] = (ro_plot_origin_y - transform[5] * 2) * 256; - if (fill != TRANSPARENT) { + if (fill != CSS_COLOR_TRANSPARENT) { error = xcolourtrans_set_gcol(fill << 8, 0, os_ACTION_OVERWRITE, 0, 0); if (error) { @@ -300,7 +300,7 @@ } } - if (c != TRANSPARENT) { + if (c != CSS_COLOR_TRANSPARENT) { error = xcolourtrans_set_gcol(c << 8, 0, os_ACTION_OVERWRITE, 0, 0); if (error) { Index: desktop/browser.c =================================================================== --- desktop/browser.c (révision 4457) +++ desktop/browser.c (copie de travail) @@ -31,7 +31,9 @@ #include #include #include +#ifndef win32 #include +#endif #include "curl/curl.h" #include "utils/config.h" #include "content/fetch.h" Index: desktop/netsurf.c =================================================================== --- desktop/netsurf.c (révision 4457) +++ desktop/netsurf.c (copie de travail) @@ -22,7 +22,9 @@ #include #include #include +#ifndef win32 #include +#endif #include #include #include @@ -71,7 +73,9 @@ void netsurf_init(int argc, char** argv) { +#ifndef win32 struct utsname utsname; +#endif /* Ignore SIGPIPE - this is necessary as OpenSSL can generate these * and the default action is to terminate the app. There's no easy @@ -79,9 +83,11 @@ * sigaction() and some mechanism for getting the file descriptor * out of libcurl). However, we expect nothing else to generate a * SIGPIPE, anyway, so may as well just ignore them all. */ +#ifdef WIGPIPE signal(SIGPIPE, SIG_IGN); +#endif -#if !((defined(__SVR4) && defined(__sun)) || defined(__NetBSD__)) +#if !((defined(__SVR4) && defined(__sun)) || defined(__NetBSD__) || defined(win32)) stdout = stderr; #endif @@ -99,6 +105,7 @@ #endif LOG(("version '%s'", netsurf_version)); +#ifndef win32 if (uname(&utsname) < 0) LOG(("Failed to extract machine information")); else @@ -106,6 +113,7 @@ "machine <%s>", utsname.sysname, utsname.nodename, utsname.release, utsname.version, utsname.machine)); +#endif lib_init(); url_init(); Index: content/fetch.h =================================================================== --- content/fetch.h (révision 4457) +++ content/fetch.h (copie de travail) @@ -24,7 +24,11 @@ #define _NETSURF_DESKTOP_FETCH_H_ #include +#ifdef win32 +#include +#else #include +#endif #include "utils/config.h" typedef enum { Index: content/fetchers/fetch_curl.c =================================================================== --- content/fetchers/fetch_curl.c (révision 4457) +++ content/fetchers/fetch_curl.c (copie de travail) @@ -34,9 +34,11 @@ #include #include #include +#ifndef win32 #include +#include +#endif #include -#include #include "utils/config.h" #ifdef WITH_SSL #include Index: content/fetchers/fetch_data.c =================================================================== --- content/fetchers/fetch_data.c (révision 4457) +++ content/fetchers/fetch_data.c (copie de travail) @@ -26,9 +26,11 @@ #include #include #include +#ifndef win32 #include +#include +#endif #include -#include #include /* for URL unescaping functions */ #include "utils/config.h" #include "content/fetch.h" Index: content/urldb.c =================================================================== --- content/urldb.c (révision 4457) +++ content/urldb.c (copie de travail) @@ -91,7 +91,9 @@ #include #include +#ifndef win32 #include +#endif #include #include "image/bitmap.h" Index: content/fetch.c =================================================================== --- content/fetch.c (révision 4457) +++ content/fetch.c (copie de travail) @@ -33,7 +33,9 @@ #include #include #include +#ifndef win32 #include +#endif #include #include "utils/config.h" #ifdef WITH_SSL Index: Makefile =================================================================== --- Makefile (révision 4457) +++ Makefile (copie de travail) @@ -78,13 +78,15 @@ ifneq ($(TARGET),riscos) ifneq ($(TARGET),gtk) +ifneq ($(TARGET),mingw) ifneq ($(TARGET),beos) ifneq ($(TARGET),debug) -$(error Unknown TARGET "$(TARGET)", should either be "riscos", "gtk", "beos" or "debug") +$(error Unknown TARGET "$(TARGET)", should either be "riscos", "gtk", "mingw", "beos" or "debug") endif endif endif endif +endif Q=@ VQ=@ @@ -116,6 +118,12 @@ PKG_CONFIG := $(GCCSDK_INSTALL_ENV)/ro-pkg-config endif else +ifeq ($(TARGET),mingw) +GCCSDK_INSTALL_ENV ?= /usr/i586-mingw32msvc +CC := i586-mingw32msvc-gcc +EXEEXT := .exe +PKG_CONFIG := +else ifeq ($(TARGET),beos) # Building for BeOS/Haiku #ifeq ($(HOST),beos) @@ -131,6 +139,7 @@ PKG_CONFIG := pkg-config endif endif +endif OBJROOT := build-$(HOST)-$(TARGET)$(SUBTARGET) @@ -144,8 +153,10 @@ LDFLAGS += -lxml2 -lz -lcurl -lssl -lcrypto -ljpeg -liconv LDFLAGS += -lmng -ljpeg else +ifneq ($(TARGET),mingw) LDFLAGS := $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl openssl) LDFLAGS += -lz -lm -lmng -ljpeg +endif CCACHE := $(shell which ccache) @@ -207,6 +218,26 @@ endif endif +ifeq ($(TARGET),mingw) +# Building for MingW (win32) +MINGWCFLAGS := -std=c99 -Dnswin -Dwin32 -U__STRICT_ANSI__ +MINGWCFLAGS += -I. \ + -I$(GCCSDK_INSTALL_ENV)/include \ + -I$(GCCSDK_INSTALL_ENV)/include/libxml2 \ + -I$(GCCSDK_INSTALL_ENV)/include/libmng \ + -I../libxml2/include \ + -I../libs/include \ + -I../libs/include/curl \ + -I../libs/include/libxml2 \ + -I../libs/include/libpng12 +MINGWLDFLAGS := -mwindows -lmingw32 -L../libs -L../libs/lib -L../libxml2/lib -L../libxml2/bin +MINGWLDFLAGS += -lz -lm -ljpeg -lcurl -lxml2 -liconv -lregex +#debug +MINGWLDFLAGS += -mconsole +CFLAGS += $(MINGWCFLAGS) +LDFLAGS += $(MINGWLDFLAGS) +endif + ifeq ($(TARGET),beos) CFLAGS += -I. -O $(WARNFLAGS) -Dnsbeos \ -D_BSD_SOURCE -D_POSIX_C_SOURCE \