Merge remote-tracking branch 'upstream/master' into test/merge

gnustep
anthony 3 years ago
commit a82df31cd0

@ -12,8 +12,7 @@
#
# Look at Makefile.config for configuration options.
#
# Tested on unix platforms (building for GTK and cross-compiling for RO) and
# on RO (building for RO).
# Best results obtained building on unix platforms cross compiling for others
#
# To clean, invoke as above, with the 'clean' target
#
@ -26,63 +25,7 @@
all: all-program
# Determine host type
# NOTE: HOST determination on RISC OS could fail because of missing bug fixes
# in UnixLib which only got addressed in UnixLib 5 / GCCSDK 4.
# When you don't have 'uname' available, you will see:
# File 'uname' not found
# When you do and using a 'uname' compiled with a buggy UnixLib, you
# will see the following printed on screen:
# RISC OS
# In both cases HOST make variable is empty and we recover from that by
# assuming we're building on RISC OS.
# In case you don't see anything printed (including the warning), you
# have an up-to-date RISC OS build system. ;-)
HOST := $(shell uname -s)
# Sanitise host
# TODO: Ideally, we want the equivalent of s/[^A-Za-z0-9]/_/g here
HOST := $(subst .,_,$(subst -,_,$(subst /,_,$(HOST))))
ifeq ($(HOST),)
HOST := riscos
$(warning Build platform determination failed but that's a known problem for RISC OS so we're assuming a native RISC OS build.)
else
ifeq ($(HOST),RISC OS)
# Fixup uname -s returning "RISC OS"
HOST := riscos
endif
endif
ifeq ($(HOST),riscos)
# Build happening on RO platform, default target is RO backend
ifeq ($(TARGET),)
TARGET := riscos
endif
endif
ifeq ($(HOST),BeOS)
HOST := beos
endif
ifeq ($(HOST),Haiku)
# Haiku implements the BeOS API
HOST := beos
endif
ifeq ($(HOST),beos)
# Build happening on BeOS platform, default target is BeOS backend
ifeq ($(TARGET),)
TARGET := beos
endif
ifeq ($(TARGET),haiku)
override TARGET := beos
endif
endif
ifeq ($(HOST),AmigaOS)
HOST := amiga
ifeq ($(TARGET),)
TARGET := amiga
endif
endif
# default values for base variables
ifeq ($(HOST),FreeMiNT)
HOST := mint
@ -128,7 +71,7 @@ MESSAGES:=
# The filter applied to the fat (full) messages to generate split messages
MESSAGES_FILTER=any
# The languages in the fat messages to convert
MESSAGES_LANGUAGES=de en fr it nl
MESSAGES_LANGUAGES=de en fr it nl zh_CN
# The target directory for the split messages
MESSAGES_TARGET=resources
@ -138,7 +81,6 @@ MKDIR=mkdir
TOUCH=touch
STRIP?=strip
INSTALL?=install
SPLIT_MESSAGES=$(PERL) utils/split-messages.pl
# build verbosity
ifeq ($(V),1)
@ -150,170 +92,15 @@ VQ=@
# Override this only if the host compiler is called something different
BUILD_CC := cc
BUILD_CFLAGS = -g -W -Wall -Wundef -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wmissing-declarations -Wuninitialized \
-Wno-unused-parameter
ifeq ($(TARGET),riscos)
ifeq ($(HOST),riscos)
# Build for RO on RO
GCCSDK_INSTALL_ENV := <NSLibs$$Dir>
CCRES := ccres
TPLEXT :=
MAKERUN := makerun
SQUEEZE := squeeze
RUNEXT :=
CC := gcc
CXX := g++
EXEEXT :=
PKG_CONFIG :=
else
# Cross-build for RO (either using GCCSDK 3.4.6 - AOF,
# either using GCCSDK 4 - ELF)
ifeq ($(origin GCCSDK_INSTALL_ENV),undefined)
ifneq ($(realpath /opt/netsurf/arm-unknown-riscos/env),)
GCCSDK_INSTALL_ENV := /opt/netsurf/arm-unknown-riscos/env
else
GCCSDK_INSTALL_ENV := /home/riscos/env
endif
endif
ifeq ($(origin GCCSDK_INSTALL_CROSSBIN),undefined)
ifneq ($(realpath /opt/netsurf/arm-unknown-riscos/cross/bin),)
GCCSDK_INSTALL_CROSSBIN := /opt/netsurf/arm-unknown-riscos/cross/bin
else
GCCSDK_INSTALL_CROSSBIN := /home/riscos/cross/bin
endif
endif
CCRES := $(GCCSDK_INSTALL_CROSSBIN)/ccres
TPLEXT := ,fec
MAKERUN := $(GCCSDK_INSTALL_CROSSBIN)/makerun
SQUEEZE := $(GCCSDK_INSTALL_CROSSBIN)/squeeze
RUNEXT := ,feb
CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
ifneq (,$(findstring arm-unknown-riscos-gcc,$(CC)))
SUBTARGET := -elf
EXEEXT := ,e1f
ELF2AIF := $(GCCSDK_INSTALL_CROSSBIN)/elf2aif
else
SUBTARGET := -aof
EXEEXT := ,ff8
endif
CXX := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
PKG_CONFIG := $(GCCSDK_INSTALL_ENV)/ro-pkg-config
endif
else
ifeq ($(TARGET),beos)
# Building for BeOS/Haiku
#ifeq ($(HOST),beos)
# Build for BeOS on BeOS
GCCSDK_INSTALL_ENV := /boot/develop
CC := gcc
CXX := g++
EXEEXT :=
PKG_CONFIG := pkg-config
#endif
else
ifeq ($(TARGET),windows)
ifneq ($(HOST),windows)
# Set Mingw defaults
GCCSDK_INSTALL_ENV ?= /opt/netsurf/i686-w64-mingw32/env
GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/i686-w64-mingw32/cross/bin
CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
WINDRES := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*windres)
PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config
else
# Building on Windows
CC := gcc
PKG_CONFIG :=
endif
else
ifeq ($(findstring amiga,$(TARGET)),amiga)
ifeq ($(findstring amiga,$(HOST)),amiga)
PKG_CONFIG := pkg-config
else
ifeq ($(TARGET),amigaos3)
GCCSDK_INSTALL_ENV ?= /opt/netsurf/m68k-unknown-amigaos/env
GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/m68k-unknown-amigaos/cross/bin
SUBTARGET = os3
else
GCCSDK_INSTALL_ENV ?= /opt/netsurf/ppc-amigaos/env
GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/ppc-amigaos/cross/bin
endif
override TARGET := amiga
CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config
endif
else
ifeq ($(TARGET),atari)
ifeq ($(HOST),atari)
PKG_CONFIG := pkg-config
else
ifeq ($(HOST),mint)
PKG_CONFIG := pkg-config
else
GCCSDK_INSTALL_ENV ?= /opt/netsurf/m68k-atari-mint/env
GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/m68k-atari-mint/cross/bin
CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config
endif
endif
else
ifeq ($(TARGET),monkey)
ifeq ($(origin GCCSDK_INSTALL_ENV),undefined)
PKG_CONFIG := pkg-config
else
PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config
endif
ifneq ($(origin GCCSDK_INSTALL_CROSSBIN),undefined)
CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
CXX := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
endif
else
ifeq ($(TARGET),framebuffer)
ifeq ($(origin GCCSDK_INSTALL_ENV),undefined)
PKG_CONFIG := pkg-config
else
PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config
endif
ifneq ($(origin GCCSDK_INSTALL_CROSSBIN),undefined)
CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
CXX := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
endif
else
# All native targets
# use native package config
PKG_CONFIG := pkg-config
# gtk target processing
ifeq ($(TARGET),gtk3)
override TARGET := gtk
override NETSURF_GTK_MAJOR := 3
SUBTARGET = $(NETSURF_GTK_MAJOR)
else
ifeq ($(TARGET),gtk2)
override TARGET := gtk
override NETSURF_GTK_MAJOR := 2
SUBTARGET = $(NETSURF_GTK_MAJOR)
endif
endif
endif
endif
endif
endif
endif
endif
endif
# compute HOST, TARGET and SUBTARGET
include frontends/Makefile.hts
# target specific tool overrides
include frontends/$(TARGET)/Makefile.tools
# compiler versioning to adjust warning flags
CC_VERSION := $(shell $(CC) -dumpfullversion -dumpversion)
@ -338,138 +125,8 @@ TOOLROOT := $(OBJROOT)/tools
CFLAGS_ENV := $(CFLAGS)
CXXFLAGS_ENV := $(CXXFLAGS)
# A macro that conditionaly adds flags to the build when a feature is enabled.
#
# 1: Feature name (ie, NETSURF_USE_BMP -> BMP)
# 2: Parameters to add to CFLAGS
# 3: Parameters to add to LDFLAGS
# 4: Human-readable name for the feature
define feature_enabled
ifeq ($$(NETSURF_USE_$(1)),YES)
CFLAGS += $(2)
CXXFLAGS += $(2)
LDFLAGS += $(3)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(4) enabled (NETSURF_USE_$(1) := YES))
endif
else ifeq ($$(NETSURF_USE_$(1)),NO)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(4) disabled (NETSURF_USE_$(1) := NO))
endif
else
$$(info M.CONFIG: $(4) error (NETSURF_USE_$(1) := $$(NETSURF_USE_$(1))))
$$(error NETSURF_USE_$(1) must be YES or NO)
endif
endef
# A macro that conditionaly adds flags to the build with a uniform display.
#
# 1: Feature name (ie, NETSURF_USE_BMP -> BMP)
# 2: Human-readable name for the feature
# 3: Parameters to add to CFLAGS when enabled
# 4: Parameters to add to LDFLAGS when enabled
# 5: Parameters to add to CFLAGS when disabled
# 6: Parameters to add to LDFLAGS when disabled
define feature_switch
ifeq ($$(NETSURF_USE_$(1)),YES)
CFLAGS += $(3)
CXXFLAGS += $(3)
LDFLAGS += $(4)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(2) enabled (NETSURF_USE_$(1) := YES))
endif
else ifeq ($$(NETSURF_USE_$(1)),NO)
CFLAGS += $(5)
CXXFLAGS += $(5)
LDFLAGS += $(6)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(2) disabled (NETSURF_USE_$(1) := NO))
endif
else
$$(info M.CONFIG: $(4) error (NETSURF_USE_$(1) := $$(NETSURF_USE_$(1))))
$$(error NETSURF_USE_$(1) must be YES or NO)
endif
endef
# Extend flags with appropriate values from pkg-config for enabled features
#
# 1: pkg-config required modules for feature
# 2: Human-readable name for the feature
define pkg_config_find_and_add
ifeq ($$(PKG_CONFIG),)
$$(error pkg-config is required to auto-detect feature availability)
endif
PKG_CONFIG_$(1)_EXISTS := $$(shell $$(PKG_CONFIG) --exists $(1) && echo yes)
ifeq ($$(PKG_CONFIG_$(1)_EXISTS),yes)
CFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(1))
CXXFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(1))
LDFLAGS += $$(shell $$(PKG_CONFIG) --libs $(1))
ifneq ($(MAKECMDGOALS),clean)
$$(info PKG.CNFG: $(2) ($(1)) enabled)
endif
else
ifneq ($(MAKECMDGOALS),clean)
$$(info PKG.CNFG: $(2) ($(1)) failed)
$$(error Unable to find library for: $(2) ($(1)))
endif
endif
endef
# Extend flags with appropriate values from pkg-config for enabled features
#
# 1: Feature name (ie, NETSURF_USE_RSVG -> RSVG)
# 2: pkg-config required modules for feature
# 3: Human-readable name for the feature
define pkg_config_find_and_add_enabled
ifeq ($$(PKG_CONFIG),)
$$(error pkg-config is required to auto-detect feature availability)
endif
NETSURF_FEATURE_$(1)_AVAILABLE := $$(shell $$(PKG_CONFIG) --exists $(2) && echo yes)
NETSURF_FEATURE_$(1)_CFLAGS ?= -DWITH_$(1)
ifeq ($$(NETSURF_USE_$(1)),YES)
ifeq ($$(NETSURF_FEATURE_$(1)_AVAILABLE),yes)
CFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
CXXFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
LDFLAGS += $$(shell $$(PKG_CONFIG) --libs $(2)) $$(NETSURF_FEATURE_$(1)_LDFLAGS)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) enabled (NETSURF_USE_$(1) := YES))
endif
else
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) failed (NETSURF_USE_$(1) := YES))
$$(error Unable to find library for: $(3) ($(2)))
endif
endif
else ifeq ($$(NETSURF_USE_$(1)),AUTO)
ifeq ($$(NETSURF_FEATURE_$(1)_AVAILABLE),yes)
CFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
CXXFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
LDFLAGS += $$(shell $$(PKG_CONFIG) --libs $(2)) $$(NETSURF_FEATURE_$(1)_LDFLAGS)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) auto-enabled (NETSURF_USE_$(1) := AUTO))
NETSURF_USE_$(1) := YES
endif
else
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) auto-disabled (NETSURF_USE_$(1) := AUTO))
NETSURF_USE_$(1) := NO
endif
endif
else ifeq ($$(NETSURF_USE_$(1)),NO)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) disabled (NETSURF_USE_$(1) := NO))
endif
else
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) error (NETSURF_USE_$(1) := $$(NETSURF_USE_$(1))))
$$(error NETSURF_USE_$(1) must be YES, NO, or AUTO)
endif
endif
endef
# library and feature building macros
include Makefile.macros
# ----------------------------------------------------------------------------
# General flag setup
@ -607,6 +264,10 @@ CFLAGS += -DSTMTEXPR=1
CXXFLAGS += -DSTMTEXPR=1
endif
# We trace during link so that we can determine if a libary changes under us in
# order to re-link. This *may* be gcc specific, so may need tweaks in future.
LDFLAGS += -Wl,--trace
# ----------------------------------------------------------------------------
# General make rules
# ----------------------------------------------------------------------------
@ -635,6 +296,12 @@ POSTEXES :=
include frontends/Makefile
# ----------------------------------------------------------------------------
# Build tools setup
# ----------------------------------------------------------------------------
include tools/Makefile
# ----------------------------------------------------------------------------
# General source file setup
# ----------------------------------------------------------------------------
@ -669,20 +336,6 @@ S_COMMON := \
# Message targets
# ----------------------------------------------------------------------------
# Message splitting rule generation macro
# 1 = Language
define split_messages
$$(MESSAGES_TARGET)/$(1)/Messages: resources/FatMessages
$$(VQ)echo "MSGSPLIT: Language: $(1) Filter: $$(MESSAGES_FILTER)"
$$(Q)$$(MKDIR) -p $$(MESSAGES_TARGET)/$(1)
$$(Q)$$(RM) $$@
$$(Q)$$(SPLIT_MESSAGES) -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ -z $$<
CLEAN_MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
endef
# generate the message file rules
$(eval $(foreach LANG,$(MESSAGES_LANGUAGES), \
@ -710,15 +363,18 @@ OBJECTS := $(sort $(addprefix $(OBJROOT)/,$(subst /,_,$(patsubst %.c,%.o,$(patsu
# Include directory flags
IFLAGS = $(addprefix -I,$(INCLUDE_DIRS))
$(EXETARGET): $(OBJECTS) $(RESOURCES) $(MESSAGES)
$(EXETARGET): $(OBJECTS) $(RESOURCES) $(MESSAGES) tools/linktrace-to-depfile.pl
$(VQ)echo " LINK: $(EXETARGET)"
ifneq ($(TARGET)$(SUBTARGET),riscos-elf)
$(Q)$(CC) -o $(EXETARGET) $(OBJECTS) $(LDFLAGS)
$(Q)$(CC) -o $(EXETARGET) $(OBJECTS) $(LDFLAGS) > $(DEPROOT)/link-raw.d
else
$(Q)$(CXX) -o $(EXETARGET:,ff8=,e1f) $(OBJECTS) $(LDFLAGS)
$(Q)$(CXX) -o $(EXETARGET:,ff8=,e1f) $(OBJECTS) $(LDFLAGS) > $(DEPROOT)/link-raw.d
$(Q)$(ELF2AIF) $(EXETARGET:,ff8=,e1f) $(EXETARGET)
$(Q)$(RM) $(EXETARGET:,ff8=,e1f)
endif
$(VQ)echo "LINKDEPS: $(EXETARGET)"
$(Q)echo -n "$(EXETARGET) $(DEPROOT)/link.d: " > $(DEPROOT)/link.d
$(Q)$(PERL) tools/linktrace-to-depfile.pl < $(DEPROOT)/link-raw.d >> $(DEPROOT)/link.d
ifeq ($(NETSURF_STRIP_BINARY),YES)
$(VQ)echo " STRIP: $(EXETARGET)"
$(Q)$(STRIP) $(EXETARGET)
@ -730,21 +386,16 @@ ifeq ($(TARGET),beos)
$(Q)$(BEOS_SETVER) $(EXETARGET) \
-app $(VERSION_MAJ) $(VERSION_MIN) 0 d 0 \
-short "NetSurf $(VERSION_FULL)" \
-long "NetSurf $(VERSION_FULL) © 2003 - 2016 The NetSurf Developers"
-long "NetSurf $(VERSION_FULL) © 2003 - 2021 The NetSurf Developers"
$(VQ)echo " MIMESET: $(EXETARGET)"
$(Q)$(BEOS_MIMESET) $(EXETARGET)
endif
clean-target:
$(VQ)echo " CLEAN: $(EXETARGET)"
$(Q)$(RM) $(EXETARGET)
CLEANS += clean-target
clean-testament:
$(VQ)echo " CLEAN: testament.h"
$(Q)$(RM) $(OBJROOT)/testament.h
CLEANS += clean-testament
clean-builddir:
$(VQ)echo " CLEAN: $(OBJROOT)"
@ -752,89 +403,13 @@ clean-builddir:
CLEANS += clean-builddir
.PHONY: all-program testament
testament $(OBJROOT)/testament.h:
$(Q)$(PERL) utils/git-testament.pl $(CURDIR) $(OBJROOT)/testament.h
.PHONY: all-program
all-program: $(EXETARGET) $(POSTEXES)
.SUFFIXES:
DEPFILES :=
# Now some macros which build the make system
# 1 = Source file
# 2 = dep filename, no prefix
# 3 = obj filename, no prefix
define dependency_generate_c
DEPFILES += $(2)
endef
# 1 = Source file
# 2 = dep filename, no prefix
# 3 = obj filename, no prefix
define dependency_generate_s
DEPFILES += $(2)
endef
# 1 = Source file
# 2 = obj filename, no prefix
# 3 = dep filename, no prefix
ifeq ($(CC_MAJOR),2)
# simpler deps tracking for gcc2...
define compile_target_c
$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
$$(VQ)echo " DEP: $(1)"
$$(Q)$$(RM) $$(DEPROOT)/$(3)
$$(Q)$$(CC) $$(IFLAGS) $$(CFLAGS) -MM \
$(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
> $$(DEPROOT)/$(3)
$$(VQ)echo " COMPILE: $(1)"
$$(Q)$$(RM) $$(OBJROOT)/$(2)
$$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
endef
else
define compile_target_c
$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
$$(VQ)echo " COMPILE: $(1)"
$$(Q)$$(RM) $$(DEPROOT)/$(3)
$$(Q)$$(RM) $$(OBJROOT)/$(2)
$$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) \
-MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
-MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
endef
endif
define compile_target_cpp
$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
$$(VQ)echo " DEP: $(1)"
$$(Q)$$(RM) $$(DEPROOT)/$(3)
$$(Q)$$(CC) $$(IFLAGS) $$(CXXFLAGS) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) -MM \
$(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
> $$(DEPROOT)/$(3)
$$(VQ)echo " COMPILE: $(1)"
$$(Q)$$(RM) $$(OBJROOT)/$(2)
$$(Q)$$(CXX) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) $$(IFLAGS) $$(CXXFLAGS) $(CXXFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
endef
# 1 = Source file
# 2 = obj filename, no prefix
# 3 = dep filename, no prefix
define compile_target_s
$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
$$(VQ)echo "ASSEMBLE: $(1)"
$$(Q)$$(RM) $$(DEPROOT)/$(3)
$$(Q)$$(RM) $$(OBJROOT)/$(2)
$$(Q)$$(CC) $$(ASFLAGS) -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
-MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
endef
# Rules to construct dep lines for each object...
$(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \
@ -854,6 +429,7 @@ $(eval $(foreach SOURCE,$(filter %.m,$(SOURCES)), \
ifeq ($(filter $(MAKECMDGOALS),clean test coverage),)
-include $(sort $(addprefix $(DEPROOT)/,$(DEPFILES)))
-include $(DEPROOT)/link.d
endif
# And rules to build the objects themselves...

@ -0,0 +1,249 @@
# -*- mode: makefile-gmake -*-
##
## Netsurf library and feature macros
##
# A macro that conditionaly adds flags to the build when a feature is enabled.
#
# 1: Feature name (ie, NETSURF_USE_BMP -> BMP)
# 2: Parameters to add to CFLAGS
# 3: Parameters to add to LDFLAGS
# 4: Human-readable name for the feature
define feature_enabled
ifeq ($$(NETSURF_USE_$(1)),YES)
CFLAGS += $(2)
CXXFLAGS += $(2)
LDFLAGS += $(3)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(4) enabled (NETSURF_USE_$(1) := YES))
endif
else ifeq ($$(NETSURF_USE_$(1)),NO)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(4) disabled (NETSURF_USE_$(1) := NO))
endif
else
$$(info M.CONFIG: $(4) error (NETSURF_USE_$(1) := $$(NETSURF_USE_$(1))))
$$(error NETSURF_USE_$(1) must be YES or NO)
endif
endef
# A macro that conditionaly adds flags to the build with a uniform display.
#
# 1: Feature name (ie, NETSURF_USE_BMP -> BMP)
# 2: Human-readable name for the feature
# 3: Parameters to add to CFLAGS when enabled
# 4: Parameters to add to LDFLAGS when enabled
# 5: Parameters to add to CFLAGS when disabled
# 6: Parameters to add to LDFLAGS when disabled
define feature_switch
ifeq ($$(NETSURF_USE_$(1)),YES)
CFLAGS += $(3)
CXXFLAGS += $(3)
LDFLAGS += $(4)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(2) enabled (NETSURF_USE_$(1) := YES))
endif
else ifeq ($$(NETSURF_USE_$(1)),NO)
CFLAGS += $(5)
CXXFLAGS += $(5)
LDFLAGS += $(6)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(2) disabled (NETSURF_USE_$(1) := NO))
endif
else
$$(info M.CONFIG: $(4) error (NETSURF_USE_$(1) := $$(NETSURF_USE_$(1))))
$$(error NETSURF_USE_$(1) must be YES or NO)
endif
endef
# Extend flags with appropriate values from pkg-config for enabled features
#
# 1: pkg-config required modules for feature
# 2: Human-readable name for the feature
define pkg_config_find_and_add
ifeq ($$(PKG_CONFIG),)
$$(error pkg-config is required to auto-detect feature availability)
endif
PKG_CONFIG_$(1)_EXISTS := $$(shell $$(PKG_CONFIG) --exists $(1) && echo yes)
ifeq ($$(PKG_CONFIG_$(1)_EXISTS),yes)
CFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(1))
CXXFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(1))
LDFLAGS += $$(shell $$(PKG_CONFIG) --libs $(1))
ifneq ($(MAKECMDGOALS),clean)
$$(info PKG.CNFG: $(2) ($(1)) enabled)
endif
else
ifneq ($(MAKECMDGOALS),clean)
$$(info PKG.CNFG: $(2) ($(1)) failed)
$$(error Unable to find library for: $(2) ($(1)))
endif
endif
endef
# Extend flags with appropriate values from pkg-config for enabled features
#
# 1: Feature name (ie, NETSURF_USE_RSVG -> RSVG)
# 2: pkg-config required modules for feature
# 3: Human-readable name for the feature
define pkg_config_find_and_add_enabled
ifeq ($$(PKG_CONFIG),)
$$(error pkg-config is required to auto-detect feature availability)
endif
NETSURF_FEATURE_$(1)_AVAILABLE := $$(shell $$(PKG_CONFIG) --exists $(2) && echo yes)
NETSURF_FEATURE_$(1)_CFLAGS ?= -DWITH_$(1)
ifeq ($$(NETSURF_USE_$(1)),YES)
ifeq ($$(NETSURF_FEATURE_$(1)_AVAILABLE),yes)
CFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
CXXFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
LDFLAGS += $$(shell $$(PKG_CONFIG) --libs $(2)) $$(NETSURF_FEATURE_$(1)_LDFLAGS)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) enabled (NETSURF_USE_$(1) := YES))
endif
else
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) failed (NETSURF_USE_$(1) := YES))
$$(error Unable to find library for: $(3) ($(2)))
endif
endif
else ifeq ($$(NETSURF_USE_$(1)),AUTO)
ifeq ($$(NETSURF_FEATURE_$(1)_AVAILABLE),yes)
CFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
CXXFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
LDFLAGS += $$(shell $$(PKG_CONFIG) --libs $(2)) $$(NETSURF_FEATURE_$(1)_LDFLAGS)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) auto-enabled (NETSURF_USE_$(1) := AUTO))
NETSURF_USE_$(1) := YES
endif
else
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) auto-disabled (NETSURF_USE_$(1) := AUTO))
NETSURF_USE_$(1) := NO
endif
endif
else ifeq ($$(NETSURF_USE_$(1)),NO)
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) disabled (NETSURF_USE_$(1) := NO))
endif
else
ifneq ($(MAKECMDGOALS),clean)
$$(info M.CONFIG: $(3) ($(2)) error (NETSURF_USE_$(1) := $$(NETSURF_USE_$(1))))
$$(error NETSURF_USE_$(1) must be YES, NO, or AUTO)
endif
endif
endef
# Message splitting rule generation macro
#
# 1 = Language
define split_messages
$$(MESSAGES_TARGET)/$(1)/Messages: resources/FatMessages $$(TOOLROOT)/split-messages
$$(VQ)echo "MSGSPLIT: Language: $(1) Filter: $$(MESSAGES_FILTER)"
$$(Q)$$(MKDIR) -p $$(MESSAGES_TARGET)/$(1)
$$(Q)$$(RM) $$@
$$(Q)$$(TOOLROOT)/split-messages -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ -z $$<
CLEAN_MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
endef
# Now some macros which build the make system
# Extend dependancy files for c source files
#
# 1 = Source file
# 2 = dep filename, no prefix
# 3 = obj filename, no prefix
define dependency_generate_c
DEPFILES += $(2)
endef
# Extend dependancy files for s source files
#
# 1 = Source file
# 2 = dep filename, no prefix
# 3 = obj filename, no prefix
define dependency_generate_s
DEPFILES += $(2)
endef
# Rule generator to compile c files
#
# 1 = Source file
# 2 = obj filename, no prefix
# 3 = dep filename, no prefix
ifeq ($(CC_MAJOR),2)
# simpler deps tracking for gcc2...
define compile_target_c
$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
$$(VQ)echo " DEP: $(1)"
$$(Q)$$(RM) $$(DEPROOT)/$(3)
$$(Q)$$(CC) $$(IFLAGS) $$(CFLAGS) -MM \
$(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
> $$(DEPROOT)/$(3)
$$(VQ)echo " COMPILE: $(1)"
$$(Q)$$(RM) $$(OBJROOT)/$(2)
$$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
endef
else
define compile_target_c
$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
$$(VQ)echo " COMPILE: $(1)"
$$(Q)$$(RM) $$(DEPROOT)/$(3)
$$(Q)$$(RM) $$(OBJROOT)/$(2)
$$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) \
-MMD -MP -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
-MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
endef
endif
# Rule generator to compile cpp files
#
# 1 = Source file
# 2 = obj filename, no prefix
# 3 = dep filename, no prefix
define compile_target_cpp
$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
$$(VQ)echo " DEP: $(1)"
$$(Q)$$(RM) $$(DEPROOT)/$(3)
$$(Q)$$(CC) $$(IFLAGS) $$(CXXFLAGS) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) -MM \
$(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
> $$(DEPROOT)/$(3)
$$(VQ)echo " COMPILE: $(1)"
$$(Q)$$(RM) $$(OBJROOT)/$(2)
$$(Q)$$(CXX) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) $$(IFLAGS) $$(CXXFLAGS) $(CXXFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
endef
# Rule generator to compile s files
#
# 1 = Source file
# 2 = obj filename, no prefix
# 3 = dep filename, no prefix
define compile_target_s
$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
$$(VQ)echo "ASSEMBLE: $(1)"
$$(Q)$$(RM) $$(DEPROOT)/$(3)
$$(Q)$$(RM) $$(OBJROOT)/$(2)
$$(Q)$$(CC) $$(ASFLAGS) -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
-MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
endef

@ -3,7 +3,6 @@
S_CONTENT := \
content.c \
content_factory.c \
dirlist.c \
fetch.c \
hlcache.c \
llcache.c \
@ -18,10 +17,12 @@ ifeq ($(NETSURF_FS_BACKING_STORE),YES)
endif
# Content fetchers sources
# Content fetcher sources
include content/fetchers/Makefile
# Content handlers
S_FETCHERS := $(addprefix content/,$(S_FETCHERS))
# Content handler sources
include content/handlers/Makefile
S_CONTENT := $(addprefix content/,$(S_CONTENT))

@ -23,6 +23,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <nsutils/time.h>
#include "netsurf/inttypes.h"

@ -29,7 +29,6 @@
#include <libwapcaplet/libwapcaplet.h>
#include "desktop/search.h" /* search flags enum */
#include "netsurf/content_type.h"
#include "netsurf/mouse.h" /* mouse state enums */
#include "netsurf/console.h" /* console state and flags enums */
@ -421,24 +420,6 @@ bool content_scroll_at_point(struct hlcache_handle *h,
bool content_drop_file_at_point(struct hlcache_handle *h,
int x, int y, char *file);
/**
* Free text search a content
*
* \param[in] h Handle to content to search.
* \param[in] context The context passed to gui table search handlers
* \param[in] flags The flags that control the search
* \param[in] The string being searched for.
* \retun NSERROR_OK on success else error code on faliure
*/
nserror content_textsearch(struct hlcache_handle *h, void *context, search_flags_t flags, const char *string);
/**
* Clear a search
*
* \param[in] h Handle to content to clear search from.
*/
nserror content_textsearch_clear(struct hlcache_handle *h);
/**
* Control debug con a content.

@ -31,7 +31,6 @@
#include <libwapcaplet/libwapcaplet.h>
#include "netsurf/content_type.h"
#include "desktop/search.h" /* search flags enum */
#include "netsurf/mouse.h" /* mouse state enums */
struct nsurl;
@ -43,6 +42,7 @@ struct object_params;
struct content;
struct redraw_context;
struct rect;
struct browser_window;
struct browser_window_features;
struct textsearch_context;
struct box;

@ -53,10 +53,10 @@
#include "content/fetch.h"
#include "content/fetchers.h"
#include "content/fetchers/resource.h"
#include "content/fetchers/about.h"
#include "content/fetchers/about/about.h"
#include "content/fetchers/curl.h"
#include "content/fetchers/data.h"
#include "content/fetchers/file.h"
#include "content/fetchers/file/file.h"
#include "javascript/fetcher.h"
#include "content/urldb.h"
@ -90,7 +90,6 @@ struct fetch {
fetch_callback callback;/**< Callback function. */
nsurl *url; /**< URL. */
nsurl *referer; /**< Referer URL. */
bool send_referer; /**< Valid to send the referer */
bool verifiable; /**< Transaction is verifiable */
void *p; /**< Private data for callback. */
lwc_string *host; /**< Host part of URL, interned */
@ -461,7 +460,6 @@ fetch_start(nsurl *url,
{
struct fetch *fetch;
lwc_string *scheme;
bool match;
fetch = calloc(1, sizeof (*fetch));
if (fetch == NULL) {
@ -474,8 +472,8 @@ fetch_start(nsurl *url,
/* try and obtain a fetcher for this scheme */
fetch->fetcherd = get_fetcher_for_scheme(scheme);
lwc_string_unref(scheme);
if (fetch->fetcherd == -1) {
lwc_string_unref(scheme);
free(fetch);
return NSERROR_NO_FETCH_HANDLER;
}
@ -490,48 +488,9 @@ fetch_start(nsurl *url,
fetch->host = nsurl_get_component(url, NSURL_HOST);
if (referer != NULL) {
lwc_string *ref_scheme;
fetch->referer = nsurl_ref(referer);
ref_scheme = nsurl_get_component(referer, NSURL_SCHEME);
/* Not a problem if referer has no scheme */
/* Determine whether to send the Referer header */
if (nsoption_bool(send_referer) && ref_scheme != NULL) {
/* User permits us to send the header
* Only send it if:
* 1) The fetch and referer schemes match
* or 2) The fetch is https and the referer is http
*
* This ensures that referer information is only sent
* across schemes in the special case of an https
* request from a page served over http. The inverse
* (https -> http) should not send the referer (15.1.3)
*/
bool match1;
bool match2;
if (lwc_string_isequal(scheme, ref_scheme,
&match) != lwc_error_ok) {
match = false;
}
if (lwc_string_isequal(scheme, corestring_lwc_https,
&match1) != lwc_error_ok) {
match1 = false;
}
if (lwc_string_isequal(ref_scheme, corestring_lwc_http,
&match2) != lwc_error_ok) {
match2= false;
}
if (match == true || (match1 == true && match2 == true))
fetch->send_referer = true;
}
if (ref_scheme != NULL)
lwc_string_unref(ref_scheme);
}
/* these aren't needed past here */
lwc_string_unref(scheme);
/* try and set up the fetch */
fetch->fetcher_handle = fetchers[fetch->fetcherd].ops.setup(fetch, url,
only_2xx, downgrade_tls,
@ -839,13 +798,6 @@ void fetch_set_http_code(struct fetch *fetch, long http_code)
fetch->http_code = http_code;
}
/* exported interface documented in content/fetch.h */
const char *fetch_get_referer_to_send(struct fetch *fetch)
{
if (fetch->send_referer)
return nsurl_access(fetch->referer);
return NULL;
}
/* exported interface documented in content/fetch.h */
void fetch_set_cookie(struct fetch *fetch, const char *data)

@ -229,11 +229,6 @@ void fetch_free(struct fetch *f);
*/
void fetch_set_http_code(struct fetch *fetch, long http_code);
/**
* get the referer from the fetch
*/
const char *fetch_get_referer_to_send(struct fetch *fetch);
/**
* set cookie data on a fetch
*/

@ -1,10 +1,15 @@
# Content fetchers sources
S_FETCHERS_YES := data.c file.c about.c resource.c
S_FETCHERS_YES := data.c resource.c
S_FETCHERS_NO :=
S_FETCHERS_$(NETSURF_USE_CURL) += curl.c
S_FETCHERS := $(addprefix content/fetchers/,$(S_FETCHERS_YES))
S_FETCHERS := $(addprefix fetchers/,$(S_FETCHERS_YES))
# The following files depend on the testament
content/fetchers/about.c: testament $(OBJROOT)/testament.h
# about fetcher
include content/fetchers/about/Makefile
S_FETCHERS += $(addprefix fetchers/about/,$(S_FETCHER_ABOUT))
# file fetcher
include content/fetchers/file/Makefile
S_FETCHERS += $(addprefix fetchers/file/,$(S_FETCHER_FILE))

File diff suppressed because it is too large Load Diff

@ -0,0 +1,20 @@
# about fetcher sources
S_FETCHER_ABOUT := \
about.c \
blank.c \
certificate.c \
chart.c \
choices.c \
config.c \
imagecache.c \
nscolours.c \
query.c \
query_auth.c \
query_fetcherror.c \
query_privacy.c \
query_timeout.c \
testament.c
# The following files depend on the testament
content/fetchers/about/testament.c: testament $(OBJROOT)/testament.h

@ -0,0 +1,758 @@
/*
* Copyright 2011 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf.
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file
*
* URL handling for the "about" scheme.
*
* Based on the data fetcher by Rob Kendrick
* This fetcher provides a simple scheme for the user to access
* information from the browser from a known, fixed URL.
*/
#include <stdbool.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "netsurf/inttypes.h"
#include "utils/errors.h"
#include "utils/nsurl.h"
#include "utils/corestrings.h"
#include "utils/utils.h"
#include "utils/ring.h"
#include "content/fetch.h"
#include "content/fetchers.h"
#include "private.h"
#include "about.h"
#include "blank.h"
#include "certificate.h"
#include "config.h"
#include "chart.h"
#include "choices.h"
#include "imagecache.h"
#include "nscolours.h"
#include "query.h"
#include "query_auth.h"
#include "query_fetcherror.h"
#include "query_privacy.h"
#include "query_timeout.h"
#include "atestament.h"
typedef bool (*fetch_about_handler)(struct fetch_about_context *);
/**
* Context for an about fetch
*/
struct fetch_about_context {
struct fetch_about_context *r_next, *r_prev;
struct fetch *fetchh; /**< Handle for this fetch */
bool aborted; /**< Flag indicating fetch has been aborted */
bool locked; /**< Flag indicating entry is already entered */
nsurl *url; /**< The full url the fetch refers to */
const struct fetch_multipart_data *multipart; /**< post data */
fetch_about_handler handler;
};
static struct fetch_about_context *ring = NULL;
/**
* handler info for about scheme
*/
struct about_handlers {
const char *name; /**< name to match in url */
int name_len;
lwc_string *lname; /**< Interned name */
fetch_about_handler handler; /**< handler for the url */
bool hidden; /**< If entry should be hidden in listing */
};
/**
* issue fetch callbacks with locking
*/
static bool
fetch_about_send_callback(const fetch_msg *msg, struct fetch_about_context *ctx)
{
ctx->locked = true;
fetch_send_callback(msg, ctx->fetchh);
ctx->locked = false;
return ctx->aborted;
}
/* exported interface documented in about/private.h */
bool
fetch_about_send_finished(struct fetch_about_context *ctx)
{
fetch_msg msg;
msg.type = FETCH_FINISHED;
return fetch_about_send_callback(&msg, ctx);
}
/* exported interface documented in about/private.h */
bool fetch_about_set_http_code(struct fetch_about_context *ctx, long code)
{
fetch_set_http_code(ctx->fetchh, code);
return ctx->aborted;
}
/* exported interface documented in about/private.h */
bool
fetch_about_send_header(struct fetch_about_context *ctx, const char *fmt, ...)
{
char header[64];
fetch_msg msg;
va_list ap;
va_start(ap, fmt);
vsnprintf(header, sizeof header, fmt, ap);
va_end(ap);
msg.type = FETCH_HEADER;
msg.data.header_or_data.buf = (const uint8_t *) header;
msg.data.header_or_data.len = strlen(header);
return fetch_about_send_callback(&msg, ctx);
}
/* exported interface documented in about/private.h */
nserror
fetch_about_senddata(struct fetch_about_context *ctx, const uint8_t *data, size_t data_len)
{
fetch_msg msg;
msg.type = FETCH_DATA;
msg.data.header_or_data.buf = data;
msg.data.header_or_data.len = data_len;
if (fetch_about_send_callback(&msg, ctx)) {
return NSERROR_INVALID;
}
return NSERROR_OK;
}
/* exported interface documented in about/private.h */
nserror
fetch_about_ssenddataf(struct fetch_about_context *ctx, const char *fmt, ...)
{
char buffer[1024];
char *dbuff;
fetch_msg msg;
va_list ap;
int slen;
va_start(ap, fmt);
slen = vsnprintf(buffer, sizeof(buffer), fmt, ap);
va_end(ap);
if (slen < (int)sizeof(buffer)) {
msg.type = FETCH_DATA;
msg.data.header_or_data.buf = (const uint8_t *) buffer;
msg.data.header_or_data.len = slen;
if (fetch_about_send_callback(&msg, ctx)) {
return NSERROR_INVALID;
}
return NSERROR_OK;
}
dbuff = malloc(slen + 1);
if (dbuff == NULL) {
return NSERROR_NOSPACE;
}
va_start(ap, fmt);
slen = vsnprintf(dbuff, slen + 1, fmt, ap);
va_end(ap);
msg.type = FETCH_DATA;
msg.data.header_or_data.buf = (const uint8_t *)dbuff;
msg.data.header_or_data.len = slen;
if (fetch_about_send_callback(&msg, ctx)) {
free(dbuff);
return NSERROR_INVALID;
}
free(dbuff);
return NSERROR_OK;
}
/* exported interface documented in about/private.h */
nsurl *fetch_about_get_url(struct fetch_about_context *ctx)
{
return ctx->url;
}
/* exported interface documented in about/private.h */
const struct fetch_multipart_data *
fetch_about_get_multipart(struct fetch_about_context *ctx)
{
return ctx->multipart;
}
/* exported interface documented in about/private.h */
bool fetch_about_srverror(struct fetch_about_context *ctx)
{
nserror res;
fetch_set_http_code(ctx->fetchh, 500);
/* content type */
if (fetch_about_send_header(ctx, "Content-Type: text/plain"))
return false;
res = fetch_about_ssenddataf(ctx, "Server error 500");
if (res != NSERROR_OK) {
return false;
}
fetch_about_send_finished(ctx);
return true;
}
/**
* Handler to generate about scheme credits page.
*
* \param ctx The fetcher context.
* \return true if handled false if aborted.
*/
static bool fetch_about_credits_handler(struct fetch_about_context *ctx)
{
fetch_msg msg;
/* content is going to return redirect */
fetch_set_http_code(ctx->fetchh, 302);
msg.type = FETCH_REDIRECT;
msg.data.redirect = "resource:credits.html";
fetch_about_send_callback(&msg, ctx);
return true;
}
/**
* Handler to generate about scheme licence page.
*
* \param ctx The fetcher context.
* \return true if handled false if aborted.
*/
static bool fetch_about_licence_handler(struct fetch_about_context *ctx)
{
fetch_msg msg;
/* content is going to return redirect */
fetch_set_http_code(ctx->fetchh, 302);
msg.type = FETCH_REDIRECT;
msg.data.redirect = "resource:licence.html";
fetch_about_send_callback(&msg, ctx);
return true;
}
/**
* Handler to generate about scheme logo page
*
* \param ctx The fetcher context.
* \return true if handled false if aborted.
*/
static bool fetch_about_logo_handler(struct fetch_about_context *ctx)
{
fetch_msg msg;
/* content is going to return redirect */
fetch_set_http_code(ctx->fetchh, 302);
msg.type = FETCH_REDIRECT;
msg.data.redirect = "resource:netsurf.png";
fetch_about_send_callback(&msg, ctx);
return true;
}
/**
* Handler to generate about scheme welcome page
*
* \param ctx The fetcher context.
* \return true if handled false if aborted.
*/
static bool fetch_about_welcome_handler(struct fetch_about_context *ctx)
{
fetch_msg msg;
/* content is going to return redirect */
fetch_set_http_code(ctx->fetchh, 302);
msg.type = FETCH_REDIRECT;
msg.data.redirect = "resource:welcome.html";
fetch_about_send_callback(&msg, ctx);
return true;
}