summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2003-06-21 13:18:00 +0000
committerJames Bursa <james@netsurf-browser.org>2003-06-21 13:18:00 +0000
commit94073c9bf642727d41a50c278d03a2b2f4af60ee (patch)
tree18395e80cb5f3984844f88819354d9ed5064794c
parent0c0ff3c59631d0968c888279195ea40d4a7fd824 (diff)
downloadnetsurf-94073c9bf642727d41a50c278d03a2b2f4af60ee.tar.gz
netsurf-94073c9bf642727d41a50c278d03a2b2f4af60ee.tar.bz2
[project @ 2003-06-21 13:18:00 by bursa]
Add debug command line build. svn path=/import/netsurf/; revision=181
-rw-r--r--debug/filetyped.c21
-rw-r--r--debug/fontd.c147
-rw-r--r--debug/fontd.h45
-rw-r--r--debug/netsurfd.c63
-rw-r--r--debug/optionsd.c25
-rw-r--r--makefile40
-rw-r--r--render/layout.c4
7 files changed, 333 insertions, 12 deletions
diff --git a/debug/filetyped.c b/debug/filetyped.c
new file mode 100644
index 000000000..853e1e57e
--- /dev/null
+++ b/debug/filetyped.c
@@ -0,0 +1,21 @@
+/**
+ * $Id: filetyped.c,v 1.1 2003/06/21 13:18:00 bursa Exp $
+ */
+
+#include <stdlib.h>
+#include "netsurf/content/fetch.h"
+#include "netsurf/utils/log.h"
+#include "netsurf/utils/utils.h"
+
+/**
+ * filetype -- determine the MIME type of a local file
+ */
+
+const char *fetch_filetype(const char *unix_path)
+{
+ LOG(("unix path %s", unix_path));
+ if (strcasecmp(unix_path, "home/james/Projects/netsurf/CSS") == 0)
+ return "text/css";
+ return "text/html";
+}
+
diff --git a/debug/fontd.c b/debug/fontd.c
new file mode 100644
index 000000000..44440a930
--- /dev/null
+++ b/debug/fontd.c
@@ -0,0 +1,147 @@
+/**
+ * $Id: fontd.c,v 1.1 2003/06/21 13:18:00 bursa Exp $
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include "netsurf/css/css.h"
+#include "netsurf/debug/fontd.h"
+#include "netsurf/utils/utils.h"
+#include "netsurf/utils/log.h"
+
+/**
+ * font id = font family * 4 + bold * 2 + slanted
+ * font family: 0 = sans-serif, 1 = serif, ...
+ */
+
+const char * const font_table[FONT_FAMILIES * 4] = {
+ /* sans-serif */
+ "Homerton.Medium\\ELatin1",
+ "Homerton.Medium.Oblique\\ELatin1",
+ "Homerton.Bold\\ELatin1",
+ "Homerton.Bold.Oblique\\ELatin1",
+};
+
+static void font_close(struct font_data *data);
+
+/**
+ * functions
+ */
+
+unsigned long font_width(struct font_data *font, const char * text, unsigned int length)
+{
+ int width;
+
+ assert(font != 0 && text != 0);
+
+ if (length == 0)
+ return 0;
+
+ return length * 10;
+}
+
+void font_position_in_string(const char* text, struct font_data* font,
+ unsigned int length, unsigned long x, int* char_offset, int* pixel_offset)
+{
+ assert(font != 0 && text != 0);
+
+ *char_offset = x / 10;
+ *pixel_offset = x;
+
+ return;
+}
+
+
+struct font_set *font_new_set()
+{
+ struct font_set *set = xcalloc(1, sizeof(*set));
+ unsigned int i;
+
+ for (i = 0; i < FONT_FAMILIES * 4; i++)
+ set->font[i] = 0;
+
+ return set;
+}
+
+
+struct font_data *font_open(struct font_set *set, struct css_style *style)
+{
+ struct font_data *data;
+ unsigned int size = 16 * 11;
+ unsigned int f = 0;
+
+ assert(set != 0);
+
+ if (style->font_size.size == CSS_FONT_SIZE_LENGTH)
+ size = style->font_size.value.length.value * 16;
+
+ switch (style->font_weight) {
+ case CSS_FONT_WEIGHT_BOLD:
+ case CSS_FONT_WEIGHT_600:
+ case CSS_FONT_WEIGHT_700:
+ case CSS_FONT_WEIGHT_800:
+ case CSS_FONT_WEIGHT_900:
+ f += FONT_BOLD;
+ break;
+ default:
+ break;
+ }
+
+ switch (style->font_style) {
+ case CSS_FONT_STYLE_ITALIC:
+ case CSS_FONT_STYLE_OBLIQUE:
+ f += FONT_SLANTED;
+ break;
+ default:
+ break;
+ }
+
+ for (data = set->font[f]; data != 0; data = data->next)
+ if (data->size == size)
+ return data;
+
+ data = xcalloc(1, sizeof(*data));
+
+ data->size = size;
+ data->space_width = font_width(data, " ", 1);
+
+ data->next = set->font[f];
+ set->font[f] = data;
+
+ return data;
+}
+
+
+void font_free_set(struct font_set *set)
+{
+ unsigned int i;
+ struct font_data *data, *next;
+
+ assert(set != 0);
+
+ for (i = 0; i < FONT_FAMILIES * 4; i++) {
+ for (data = set->font[i]; data != 0; data = next) {
+ next = data->next;
+ font_close(data);
+ }
+ }
+
+ free(set);
+}
+
+
+void font_close(struct font_data *data)
+{
+
+ free(data);
+}
+
+
+char * font_split(struct font_data *data, const char * text, unsigned int length,
+ unsigned int width, unsigned int *used_width)
+{
+ *used_width = width;
+
+ return text + (width / 10);
+}
+
diff --git a/debug/fontd.h b/debug/fontd.h
new file mode 100644
index 000000000..e63af6de6
--- /dev/null
+++ b/debug/fontd.h
@@ -0,0 +1,45 @@
+/**
+ * $Id: fontd.h,v 1.1 2003/06/21 13:18:00 bursa Exp $
+ */
+
+#ifndef _NETSURF_RISCOS_FONT_H_
+#define _NETSURF_RISCOS_FONT_H_
+
+/**
+ * structures and typedefs
+ */
+
+#include "netsurf/css/css.h"
+
+typedef unsigned int font_id;
+
+#define FONT_FAMILIES 1
+#define FONT_BOLD 2
+#define FONT_SLANTED 1
+
+/* a font_set is just a linked list of font_data for each face for now */
+struct font_set {
+ struct font_data *font[FONT_FAMILIES * 4];
+};
+
+struct font_data {
+ unsigned int size;
+ unsigned int space_width;
+ struct font_data *next;
+};
+
+/**
+ * interface
+ */
+
+unsigned long font_width(struct font_data *font, const char * text, unsigned int length);
+void font_position_in_string(const char* text, struct font_data *font,
+ unsigned int length, unsigned long x, int* char_offset, int* pixel_offset);
+
+struct font_set *font_new_set(void);
+struct font_data *font_open(struct font_set *set, struct css_style *style);
+void font_free_set(struct font_set *set);
+char * font_split(struct font_data *data, const char * text, unsigned int length,
+ unsigned int width, unsigned int *used_width);
+
+#endif
diff --git a/debug/netsurfd.c b/debug/netsurfd.c
new file mode 100644
index 000000000..81a494ff0
--- /dev/null
+++ b/debug/netsurfd.c
@@ -0,0 +1,63 @@
+#include <string.h>
+#include "netsurf/content/fetch.h"
+#include "netsurf/content/cache.h"
+#include "netsurf/content/content.h"
+#include "netsurf/content/fetchcache.h"
+#include "netsurf/utils/log.h"
+
+int done;
+
+void callback(content_msg msg, struct content *c, void *p1,
+ void *p2, const char *error)
+{
+ LOG(("content %s, message %i", c->url, msg));
+ if (msg == CONTENT_MSG_DONE || msg == CONTENT_MSG_ERROR)
+ done = 1;
+ else if (msg == CONTENT_MSG_STATUS)
+ printf("=== STATUS: %s", c->status_message);
+}
+
+int main(int argc, char *argv[])
+{
+ char url[1000];
+ struct content *c;
+
+ fetch_init();
+ cache_init();
+
+ while (1) {
+ puts("=== URL:");
+ gets(url);
+ c = fetchcache(url, 0, callback, 0, 0, 100, 1000);
+ done = c->status == CONTENT_STATUS_DONE;
+ while (!done)
+ fetch_poll();
+ puts("=== SUCCESS, dumping cache");
+ cache_dump();
+ }
+
+ cache_quit();
+ fetch_quit();
+
+ return 0;
+}
+
+void gui_multitask(void)
+{
+ LOG(("-"));
+}
+
+int stricmp(char *s0, char *s1)
+{
+ return strcasecmp(s0, s1);
+}
+
+void gui_remove_gadget(void *p)
+{
+}
+
+void plugin_decode(void *a, void *b, void *c, void *d)
+{
+}
+
+
diff --git a/debug/optionsd.c b/debug/optionsd.c
new file mode 100644
index 000000000..493218cb6
--- /dev/null
+++ b/debug/optionsd.c
@@ -0,0 +1,25 @@
+/**
+ * $Id: optionsd.c,v 1.1 2003/06/21 13:18:00 bursa Exp $
+ */
+
+#include "netsurf/desktop/options.h"
+#include <stdio.h>
+#include <string.h>
+#include "netsurf/utils/log.h"
+#include "netsurf/utils/utils.h"
+
+struct options OPTIONS;
+
+void options_init(struct options* opt)
+{
+ opt->http = 0;
+ opt->http_proxy = strdup("");
+ opt->http_port = 8080;
+ opt->use_mouse_gestures = 0;
+ opt->allow_text_selection = 1;
+ opt->use_riscos_elements = 1;
+ opt->show_toolbar = 1;
+ opt->show_print_preview = 0;
+ opt->theme = strdup("Default");
+}
+
diff --git a/makefile b/makefile
index ccbaa3aa2..e6a15828f 100644
--- a/makefile
+++ b/makefile
@@ -1,20 +1,28 @@
-# $Id: makefile,v 1.34 2003/06/17 19:24:20 bursa Exp $
+# $Id: makefile,v 1.35 2003/06/21 13:18:00 bursa Exp $
CC = riscos-gcc
-OBJECTS = cache.o content.o fetch.o fetchcache.o other.o \
+CC_DEBUG = gcc
+OBJECTS_COMMON = cache.o content.o fetch.o fetchcache.o other.o \
css.o css_enum.o parser.o ruleset.o scanner.o \
- browser.o netsurf.o \
box.o html.o layout.o textplain.o \
- filetype.o font.o gif.o gui.o jpeg.o png.o theme.o \
- utils.o plugin.o options.o
+ utils.o
+OBJECTS = $(OBJECTS_COMMON) \
+ browser.o netsurf.o \
+ gif.o gui.o jpeg.o png.o theme.o plugin.o \
+ options.o filetype.o font.o
+OBJECTS_DEBUG = $(OBJECTS_COMMON) \
+ netsurfd.o \
+ optionsd.o filetyped.o fontd.o
DOCUMENTS = Themes.html
-VPATH = content:css:desktop:render:riscos:utils
+VPATH = content:css:desktop:render:riscos:utils:debug
WARNFLAGS = -W -Wall -Wundef -Wpointer-arith -Wbad-function-cast -Wcast-qual \
-Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \
-Wnested-externs -Winline -Wno-unused-parameter
CFLAGS = $(WARNFLAGS) -I.. -I/usr/local/riscoslibs/include \
-Dfd_set=long -mpoke-function-name
+CFLAGS_DEBUG = $(WARNFLAGS) -I.. -I/usr/include/libxml2 \
+ -Dfd_set=long -g
LDFLAGS = \
/usr/local/riscoslibs/libungif/libungif.ro \
/usr/local/riscoslibs/libxml2/libxml2.ro \
@@ -22,10 +30,14 @@ LDFLAGS = \
/usr/local/riscoslibs/curl/libcurl.ro \
/usr/local/riscoslibs/libpng/libpng.ro \
/usr/local/riscoslibs/zlib/libz.ro
+LDFLAGS_DEBUG = -L/usr/lib -lxml2 -lz -lm -lcurl -lssl -lcrypto -ldl
OBJDIR = $(shell $(CC) -dumpmachine)
SOURCES=$(OBJECTS:.o=.c)
OBJS=$(OBJECTS:%.o=$(OBJDIR)/%.o)
+OBJDIR_DEBUG = $(shell $(CC_DEBUG) -dumpmachine)
+SOURCES_DEBUG=$(OBJECTS_DEBUG:.o=.c)
+OBJS_DEBUG=$(OBJECTS_DEBUG:%.o=$(OBJDIR_DEBUG)/%.o)
DOCDIR = !NetSurf/Docs
DOCS=$(DOCUMENTS:%.html=$(DOCDIR)/%.html)
@@ -36,9 +48,16 @@ all: !NetSurf/!RunImage,ff8 $(DOCS)
netsurf.zip: !NetSurf/!RunImage,ff8 $(DOCS)
rm netsurf.zip; riscos-zip -9vr, netsurf.zip !NetSurf
+# debug targets
+debug: netsurf
+netsurf: $(OBJS_DEBUG)
+ $(CC_DEBUG) -o $@ $(LDFLAGS_DEBUG) $^
+
# pattern rule for c source
$(OBJDIR)/%.o : %.c
- $(CC) -o $@ -c $(CFLAGS) $(CFLAGS) $<
+ $(CC) -o $@ -c $(CFLAGS) $<
+$(OBJDIR_DEBUG)/%.o : %.c
+ $(CC_DEBUG) -o $@ -c $(CFLAGS_DEBUG) $<
# special cases
css/css_enum.c css/css_enum.h: css/css_enums css/makeenum
@@ -55,13 +74,14 @@ $(DOCDIR)/%.html: documentation/%.xml
xsltproc -o $@ http://www.movspclr.co.uk/dtd/100/prm-html.xsl $<
# generate dependencies
-depend : $(SOURCES)
- -mkdir $(OBJDIR)
+depend : $(SOURCES) $(SOURCES_DEBUG)
+ -mkdir $(OBJDIR) $(OBJDIR_DEBUG)
$(CC) -MM -MG $(CFLAGS) $^ | sed 's|.*\.o:|$(OBJDIR)/&|g' > $@
+ $(CC_DEBUG) -MM -MG $(CFLAGS_DEBUG) $^ | sed 's|.*\.o:|$(OBJDIR_DEBUG)/&|g' >> $@
# remove generated files
clean :
- -rm $(OBJDIR)/* depend css/css_enum.c css/css_enum.h \
+ -rm $(OBJDIR)/* $(OBJDIR_DEBUG)/* depend css/css_enum.c css/css_enum.h \
css/parser.c css/parser.h css/scanner.c css/scanner.h
include depend
diff --git a/render/layout.c b/render/layout.c
index 4b8b66cc6..ccfb0db76 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -1,5 +1,5 @@
/**
- * $Id: layout.c,v 1.41 2003/06/17 19:24:21 bursa Exp $
+ * $Id: layout.c,v 1.42 2003/06/21 13:18:00 bursa Exp $
*/
#include <assert.h>
@@ -18,7 +18,7 @@
#ifdef riscos
#include "netsurf/riscos/font.h"
#else
-#include "netsurf/debug/font.h"
+#include "netsurf/debug/fontd.h"
#endif
#include "netsurf/utils/utils.h"
#define NDEBUG