summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xamiga_lib/Makefile.lib66
-rwxr-xr-xamiga_lib/hubbub.library_rev.h6
-rwxr-xr-xamiga_lib/hubbub.library_rev.i18
-rwxr-xr-xamiga_lib/hubbub.library_rev.rev1
-rwxr-xr-xamiga_lib/hubbub.library_rev.s21
-rwxr-xr-xamiga_lib/include/interfaces/hubbub.h72
-rwxr-xr-xamiga_lib/include/interfaces/parserutils.h193
-rwxr-xr-xamiga_lib/include/proto/hubbub.h58
-rwxr-xr-xamiga_lib/include/proto/parserutils.h58
-rwxr-xr-xamiga_lib/init.c305
-rwxr-xr-xamiga_lib/stubs/auto.c39
-rwxr-xr-xamiga_lib/stubs/funcs.c62
-rwxr-xr-xamiga_lib/vectors.c42
-rw-r--r--include/hubbub/tree.h2
14 files changed, 942 insertions, 1 deletions
diff --git a/amiga_lib/Makefile.lib b/amiga_lib/Makefile.lib
new file mode 100755
index 0000000..a507c9e
--- /dev/null
+++ b/amiga_lib/Makefile.lib
@@ -0,0 +1,66 @@
+# Makefile for project "parserutils"
+# Automatically generated by idltool
+#
+# $Id$
+#
+
+# Uncomment the next line if you are cross compiling
+# CROSS_COMPILE = ppc-amigaos-
+
+CC = $(CROSS_COMPILE)gcc
+CXX = $(CROSS_COMPILE)c++
+AS = $(CROSS_COMPILE)as
+LD = $(CROSS_COMPILE)ld
+RANLIB = $(CROSS_COMPILE)ranlib
+RM = delete
+# RM = rm
+
+# Change these as required
+OPTIMIZE = -O3
+DEBUG = # -gstabs -DDEBUG
+CFLAGS = -Wall $(OPTIMIZE) $(DEBUG) -Iinclude -I../include
+
+# Flags passed to gcc during linking
+LINK =
+
+# Name of the "thing" to build
+TARGET = hubbub.library
+
+# Additional linker libraries
+LIBS = ../build-Amiga-Amiga-release-lib-static/libhubbub.a -lparserutils
+
+# Version of the library to build
+VERSION = 2
+
+STUBS = stubs/auto.c stubs/funcs.c
+
+# -------------------------------------------------------------
+# Nothing should need changing below this line
+
+SRCS = init.c
+
+OBJS = $(SRCS:.c=.o)
+# Rules for building
+$(TARGET): $(OBJS)
+ $(CC) $(LINK) -nostartfiles -o $(TARGET) $(OBJS) $(LIBS)
+ strip $(TARGET)
+ copy $(TARGET) libs:
+
+libhubbub.so: $(STUBS:.c=.o)
+ $(CC) -N -fPIC -shared -Wl,-soname,libhubbub.so.0 -o $@ $^
+
+libhubbub.a: libhubbub.a.debug
+ strip -S -R.comment $< -o $@
+
+libhubbub.a.debug: $(STUBS:.c=.o)
+ rm -f $@
+ ar cru $@ $^
+
+.PHONY: clean
+clean:
+ $(RM) $(TARGET) $(OBJS)
+
+.PHONY: revision
+revision:
+ bumprev $(VERSION) $(TARGET)
+
diff --git a/amiga_lib/hubbub.library_rev.h b/amiga_lib/hubbub.library_rev.h
new file mode 100755
index 0000000..c997046
--- /dev/null
+++ b/amiga_lib/hubbub.library_rev.h
@@ -0,0 +1,6 @@
+#define VERSION 2
+#define REVISION 1
+#define DATE "3.7.2012"
+#define VERS "hubbub.library 2.1"
+#define VSTRING "hubbub.library 2.1 (3.7.2012)\r\n"
+#define VERSTAG "\0$VER: hubbub.library 2.1 (3.7.2012)"
diff --git a/amiga_lib/hubbub.library_rev.i b/amiga_lib/hubbub.library_rev.i
new file mode 100755
index 0000000..86d023f
--- /dev/null
+++ b/amiga_lib/hubbub.library_rev.i
@@ -0,0 +1,18 @@
+VERSION EQU 2
+REVISION EQU 1
+
+DATE MACRO
+ dc.b '3.7.2012'
+ ENDM
+
+VERS MACRO
+ dc.b 'hubbub.library 2.1'
+ ENDM
+
+VSTRING MACRO
+ dc.b 'hubbub.library 2.1 (3.7.2012)',13,10,0
+ ENDM
+
+VERSTAG MACRO
+ dc.b 0,'$VER: hubbub.library 2.1 (3.7.2012)',0
+ ENDM
diff --git a/amiga_lib/hubbub.library_rev.rev b/amiga_lib/hubbub.library_rev.rev
new file mode 100755
index 0000000..d00491f
--- /dev/null
+++ b/amiga_lib/hubbub.library_rev.rev
@@ -0,0 +1 @@
+1
diff --git a/amiga_lib/hubbub.library_rev.s b/amiga_lib/hubbub.library_rev.s
new file mode 100755
index 0000000..5f42e96
--- /dev/null
+++ b/amiga_lib/hubbub.library_rev.s
@@ -0,0 +1,21 @@
+VERSION = 2
+REVISION = 1
+
+.macro DATE
+.ascii "3.7.2012"
+.endm
+
+.macro VERS
+.ascii "hubbub.library 2.1"
+.endm
+
+.macro VSTRING
+.ascii "hubbub.library 2.1 (3.7.2012)"
+.byte 13,10,0
+.endm
+
+.macro VERSTAG
+.byte 0
+.ascii "$VER: hubbub.library 2.1 (3.7.2012)"
+.byte 0
+.endm
diff --git a/amiga_lib/include/interfaces/hubbub.h b/amiga_lib/include/interfaces/hubbub.h
new file mode 100755
index 0000000..efd4227
--- /dev/null
+++ b/amiga_lib/include/interfaces/hubbub.h
@@ -0,0 +1,72 @@
+#ifndef HUBBUB_INTERFACE_DEF_H
+#define HUBBUB_INTERFACE_DEF_H
+
+/*
+** This file was machine generated by idltool 53.1.
+** Do not edit
+*/
+
+#ifndef EXEC_TYPES_H
+#include <exec/types.h>
+#endif
+#ifndef EXEC_EXEC_H
+#include <exec/exec.h>
+#endif
+#ifndef EXEC_INTERFACES_H
+#include <exec/interfaces.h>
+#endif
+
+#include "hubbub/parser.h"
+
+#ifdef __cplusplus
+#ifdef __USE_AMIGAOS_NAMESPACE__
+namespace AmigaOS {
+#endif
+extern "C" {
+#endif
+
+struct HubbubIFace
+{
+ struct InterfaceData Data;
+
+ uint32 APICALL (*HubbubObtain)(struct HubbubIFace *Self);
+ uint32 APICALL (*HubbubRelease)(struct HubbubIFace *Self);
+ void APICALL (*HubbubExpunge)(struct HubbubIFace *Self);
+ struct Interface * APICALL (*HubbubClone)(struct HubbubIFace *Self);
+
+ /* hubbub/errors.h */
+ const char *(*hubbub_error_to_string)(hubbub_error error);
+
+ /* hubbub/hubbub.h */
+ /* lib private
+ hubbub_error (*hubbub_initialise)(const char *aliases_file,
+ hubbub_allocator_fn alloc, void *pw);
+
+ hubbub_error (*hubbub_finalise)(hubbub_allocator_fn alloc, void *pw);
+ */
+
+ /* hubbub/parser.h */
+ hubbub_error (*hubbub_parser_create)(const char *enc, bool fix_enc,
+ hubbub_allocator_fn alloc, void *pw, hubbub_parser **parser);
+ hubbub_error (*hubbub_parser_destroy)(hubbub_parser *parser);
+ hubbub_error (*hubbub_parser_setopt)(hubbub_parser *parser,
+ hubbub_parser_opttype type, hubbub_parser_optparams *params);
+ hubbub_error (*hubbub_parser_parse_chunk)(hubbub_parser *parser,
+ const uint8_t *data, size_t len);
+ hubbub_error (*hubbub_parser_completed)(hubbub_parser *parser);
+ const char *(*hubbub_parser_read_charset)(hubbub_parser *parser,
+ hubbub_charset_source *source);
+
+ /* v2 */
+ hubbub_error (*hubbub_parser_insert_chunk)(hubbub_parser *parser,
+ const uint8_t *data, size_t len);
+};
+
+#ifdef __cplusplus
+}
+#ifdef __USE_AMIGAOS_NAMESPACE__
+}
+#endif
+#endif
+
+#endif /* HUBBUB_INTERFACE_DEF_H */
diff --git a/amiga_lib/include/interfaces/parserutils.h b/amiga_lib/include/interfaces/parserutils.h
new file mode 100755
index 0000000..96fa814
--- /dev/null
+++ b/amiga_lib/include/interfaces/parserutils.h
@@ -0,0 +1,193 @@
+#ifndef PARSERUTILS_INTERFACE_DEF_H
+#define PARSERUTILS_INTERFACE_DEF_H
+
+/*
+** This file was machine generated by idltool 53.1.
+** Do not edit
+*/
+
+#ifndef EXEC_TYPES_H
+#include <exec/types.h>
+#endif
+#ifndef EXEC_EXEC_H
+#include <exec/exec.h>
+#endif
+#ifndef EXEC_INTERFACES_H
+#include <exec/interfaces.h>
+#endif
+
+#include "parserutils/parserutils.h"
+#include "parserutils/charset/codec.h"
+#include "parserutils/charset/mibenum.h"
+#include "parserutils/charset/utf16.h"
+#include "parserutils/charset/utf8.h"
+#include "parserutils/input/inputstream.h"
+#include "parserutils/utils/buffer.h"
+#include "parserutils/utils/stack.h"
+#include "parserutils/utils/vector.h"
+
+
+
+#ifdef __cplusplus
+#ifdef __USE_AMIGAOS_NAMESPACE__
+namespace AmigaOS {
+#endif
+extern "C" {
+#endif
+
+struct ParserUtilsIFace
+{
+ struct InterfaceData Data;
+
+ uint32 APICALL (*ParserUtilsObtain)(struct ParserUtilsIFace *Self);
+ uint32 APICALL (*ParserUtilsRelease)(struct ParserUtilsIFace *Self);
+ void APICALL (*ParserUtilsExpunge)(struct ParserUtilsIFace *Self);
+ struct Interface * APICALL (*ParserUtilsClone)(struct ParserUtilsIFace *Self);
+
+ /* parserutils/errors.h */
+ const char * (*parserutils_error_to_string)(parserutils_error error);
+ parserutils_error (*parserutils_error_from_string)(const char *str, size_t len);
+
+ /* parserutils/parserutils.h */
+ /* NB: These two need to be dummy functions in the stubs
+ * lib open/close should call these itself with an Aliases file
+ * stored somewhere central (l:charsets?) */
+ /* commented out as they need to be library private
+ parserutils_error (*parserutils_initialise)(const char *aliases_file,
+ parserutils_alloc alloc, void *pw);
+ parserutils_error (*parserutils_finalise)(parserutils_alloc alloc, void *pw);
+ */
+
+ /* parserutils/charset/codec.h */
+ parserutils_error (*parserutils_charset_codec_create)(const char *charset,
+ parserutils_alloc alloc, void *pw,
+ parserutils_charset_codec **codec);
+ parserutils_error (*parserutils_charset_codec_destroy)(
+ parserutils_charset_codec *codec);
+ parserutils_error (*parserutils_charset_codec_setopt)(
+ parserutils_charset_codec *codec,
+ parserutils_charset_codec_opttype type,
+ parserutils_charset_codec_optparams *params);
+ parserutils_error (*parserutils_charset_codec_encode)(
+ parserutils_charset_codec *codec,
+ const uint8_t **source, size_t *sourcelen,
+ uint8_t **dest, size_t *destlen);
+ parserutils_error (*parserutils_charset_codec_decode)(
+ parserutils_charset_codec *codec,
+ const uint8_t **source, size_t *sourcelen,
+ uint8_t **dest, size_t *destlen);
+ parserutils_error (*parserutils_charset_codec_reset)(
+ parserutils_charset_codec *codec);
+
+ /* parserutils/charset/mibenum.h */
+ uint16_t (*parserutils_charset_mibenum_from_name)(const char *alias, size_t len);
+ const char * (*parserutils_charset_mibenum_to_name)(uint16_t mibenum);
+ bool (*parserutils_charset_mibenum_is_unicode)(uint16_t mibenum);
+
+ /* parserutils/charset/utf16.h */
+ parserutils_error (*parserutils_charset_utf16_to_ucs4)(const uint8_t *s,
+ size_t len, uint32_t *ucs4, size_t *clen);
+ parserutils_error (*parserutils_charset_utf16_from_ucs4)(uint32_t ucs4,
+ uint8_t *s, size_t *len);
+ parserutils_error (*parserutils_charset_utf16_length)(const uint8_t *s,
+ size_t max, size_t *len);
+ parserutils_error (*parserutils_charset_utf16_char_byte_length)(const uint8_t *s,
+ size_t *len);
+ parserutils_error (*parserutils_charset_utf16_prev)(const uint8_t *s,
+ uint32_t off, uint32_t *prevoff);
+ parserutils_error (*parserutils_charset_utf16_next)(const uint8_t *s,
+ uint32_t len, uint32_t off, uint32_t *nextoff);
+ parserutils_error (*parserutils_charset_utf16_next_paranoid)(const uint8_t *s,
+ uint32_t len, uint32_t off, uint32_t *nextoff);
+
+ /* parserutils/charset/utf8.h */
+ parserutils_error (*parserutils_charset_utf8_to_ucs4)(const uint8_t *s, size_t len,
+ uint32_t *ucs4, size_t *clen);
+ parserutils_error (*parserutils_charset_utf8_from_ucs4)(uint32_t ucs4, uint8_t **s,
+ size_t *len);
+ parserutils_error (*parserutils_charset_utf8_length)(const uint8_t *s, size_t max,
+ size_t *len);
+ parserutils_error (*parserutils_charset_utf8_char_byte_length)(const uint8_t *s,
+ size_t *len);
+ parserutils_error (*parserutils_charset_utf8_prev)(const uint8_t *s, uint32_t off,
+ uint32_t *prevoff);
+ parserutils_error (*parserutils_charset_utf8_next)(const uint8_t *s, uint32_t len,
+ uint32_t off, uint32_t *nextoff);
+ parserutils_error (*parserutils_charset_utf8_next_paranoid)(const uint8_t *s,
+ uint32_t len, uint32_t off, uint32_t *nextoff);
+
+ /* parserutils/input/inputstream.h */
+ parserutils_error (*parserutils_inputstream_create)(const char *enc,
+ uint32_t encsrc, parserutils_charset_detect_func csdetect,
+ parserutils_alloc alloc, void *pw,
+ parserutils_inputstream **stream);
+ parserutils_error (*parserutils_inputstream_destroy)(
+ parserutils_inputstream *stream);
+ parserutils_error (*parserutils_inputstream_append)(
+ parserutils_inputstream *stream,
+ const uint8_t *data, size_t len);
+ parserutils_error (*parserutils_inputstream_insert)(
+ parserutils_inputstream *stream,
+ const uint8_t *data, size_t len);
+ parserutils_error (*parserutils_inputstream_peek_slow)(
+ parserutils_inputstream *stream,
+ size_t offset, const uint8_t **ptr, size_t *length);
+ /* inlined, don't think we need them here
+ parserutils_error (*parserutils_inputstream_peek)(
+ parserutils_inputstream *stream, size_t offset,
+ const uint8_t **ptr, size_t *length);
+ void (*parserutils_inputstream_advance)(
+ parserutils_inputstream *stream, size_t bytes);
+ */
+ const char * (*parserutils_inputstream_read_charset)(
+ parserutils_inputstream *stream, uint32_t *source);
+ parserutils_error (*parserutils_inputstream_change_charset)(
+ parserutils_inputstream *stream,
+ const char *enc, uint32_t source);
+
+ /* parserutils/utils/buffer.h */
+ parserutils_error (*parserutils_buffer_create)(parserutils_alloc alloc,
+ void *pw, parserutils_buffer **buffer);
+ parserutils_error (*parserutils_buffer_destroy)(parserutils_buffer *buffer);
+ parserutils_error (*parserutils_buffer_append)(parserutils_buffer *buffer,
+ const uint8_t *data, size_t len);
+ parserutils_error (*parserutils_buffer_insert)(parserutils_buffer *buffer,
+ size_t offset, const uint8_t *data, size_t len);
+ parserutils_error (*parserutils_buffer_discard)(parserutils_buffer *buffer,
+ size_t offset, size_t len);
+ parserutils_error (*parserutils_buffer_grow)(parserutils_buffer *buffer);
+ parserutils_error (*parserutils_buffer_randomise)(parserutils_buffer *buffer);
+
+ /* parserutils/utils/stack.h */
+ parserutils_error (*parserutils_stack_create)(size_t item_size, size_t chunk_size,
+ parserutils_alloc alloc, void *pw, parserutils_stack **stack);
+ parserutils_error (*parserutils_stack_destroy)(parserutils_stack *stack);
+ parserutils_error (*parserutils_stack_push)(parserutils_stack *stack,
+ const void *item);
+ parserutils_error (*parserutils_stack_pop)(parserutils_stack *stack, void *item);
+ void * (*parserutils_stack_get_current)(parserutils_stack *stack);
+
+ /* parserutils/utils/vector.h */
+ parserutils_error (*parserutils_vector_create)(size_t item_size,
+ size_t chunk_size, parserutils_alloc alloc, void *pw,
+ parserutils_vector **vector);
+ parserutils_error (*parserutils_vector_destroy)(parserutils_vector *vector);
+ parserutils_error (*parserutils_vector_append)(parserutils_vector *vector,
+ void *item);
+ parserutils_error (*parserutils_vector_clear)(parserutils_vector *vector);
+ parserutils_error (*parserutils_vector_remove_last)(parserutils_vector *vector);
+ parserutils_error (*parserutils_vector_get_length)(parserutils_vector *vector, size_t *length);
+ const void * (*parserutils_vector_iterate)(const parserutils_vector *vector,
+ int32_t *ctx);
+ const void * (*parserutils_vector_peek)(const parserutils_vector *vector,
+ int32_t ctx);
+};
+
+#ifdef __cplusplus
+}
+#ifdef __USE_AMIGAOS_NAMESPACE__
+}
+#endif
+#endif
+
+#endif /* PARSERUTILS_INTERFACE_DEF_H */
diff --git a/amiga_lib/include/proto/hubbub.h b/amiga_lib/include/proto/hubbub.h
new file mode 100755
index 0000000..3ce70b1
--- /dev/null
+++ b/amiga_lib/include/proto/hubbub.h
@@ -0,0 +1,58 @@
+#ifndef PROTO_HUBBUB_H
+#define PROTO_HUBBUB_H
+
+/*
+** $Id$
+** Includes Release 50.1
+**
+** Prototype/inline/pragma header file combo
+**
+** Copyright (c) 2010 Hyperion Entertainment CVBA.
+** All Rights Reserved.
+*/
+
+/****************************************************************************/
+
+#ifndef __NOLIBBASE__
+ #ifndef __USE_BASETYPE__
+ extern struct Library * hubbub;
+ #else
+ extern struct Library * hubbub;
+ #endif /* __USE_BASETYPE__ */
+#endif /* __NOLIBBASE__ */
+
+/****************************************************************************/
+
+#ifdef __amigaos4__
+ #include <interfaces/hubbub.h>
+ #ifdef __USE_INLINE__
+ #include <inline4/hubbub.h>
+ #endif /* __USE_INLINE__ */
+ #ifndef CLIB_HUBBUB_PROTOS_H
+ #define CLIB_HUBBUB_PROTOS_H 1
+ #endif /* CLIB_HUBBUB_PROTOS_H */
+ #ifndef __NOGLOBALIFACE__
+ extern struct HubbubIFace *IHubbub;
+ #endif /* __NOGLOBALIFACE__ */
+#else /* __amigaos4__ */
+ #ifndef CLIB_HUBBUB_PROTOS_H
+ #include <clib/hubbub_protos.h>
+ #endif /* CLIB_HUBBUB_PROTOS_H */
+ #if defined(__GNUC__)
+ #ifndef __PPC__
+ #include <inline/hubbub.h>
+ #else
+ #include <ppcinline/hubbub.h>
+ #endif /* __PPC__ */
+ #elif defined(__VBCC__)
+ #ifndef __PPC__
+ #include <inline/hubbub_protos.h>
+ #endif /* __PPC__ */
+ #else
+ #include <pragmas/hubbub_pragmas.h>
+ #endif /* __GNUC__ */
+#endif /* __amigaos4__ */
+
+/****************************************************************************/
+
+#endif /* PROTO_HUBBUB_H */
diff --git a/amiga_lib/include/proto/parserutils.h b/amiga_lib/include/proto/parserutils.h
new file mode 100755
index 0000000..a71ac6e
--- /dev/null
+++ b/amiga_lib/include/proto/parserutils.h
@@ -0,0 +1,58 @@
+#ifndef PROTO_PARSERUTILS_H
+#define PROTO_PARSERUTILS_H
+
+/*
+** $Id$
+** Includes Release 50.1
+**
+** Prototype/inline/pragma header file combo
+**
+** Copyright (c) 2010 Hyperion Entertainment CVBA.
+** All Rights Reserved.
+*/
+
+/****************************************************************************/
+
+#ifndef __NOLIBBASE__
+ #ifndef __USE_BASETYPE__
+ extern struct Library * parserutils;
+ #else
+ extern struct Library * parserutils;
+ #endif /* __USE_BASETYPE__ */
+#endif /* __NOLIBBASE__ */
+
+/****************************************************************************/
+
+#ifdef __amigaos4__
+ #include <interfaces/parserutils.h>
+ #ifdef __USE_INLINE__
+ #include <inline4/parserutils.h>
+ #endif /* __USE_INLINE__ */
+ #ifndef CLIB_PARSERUTILS_PROTOS_H
+ #define CLIB_PARSERUTILS_PROTOS_H 1
+ #endif /* CLIB_PARSERUTILS_PROTOS_H */
+ #ifndef __NOGLOBALIFACE__
+ extern struct ParserUtilsIFace *IParserUtils;
+ #endif /* __NOGLOBALIFACE__ */
+#else /* __amigaos4__ */
+ #ifndef CLIB_PARSERUTILS_PROTOS_H
+ #include <clib/parserutils_protos.h>
+ #endif /* CLIB_PARSERUTILS_PROTOS_H */
+ #if defined(__GNUC__)
+ #ifndef __PPC__
+ #include <inline/parserutils.h>
+ #else
+ #include <ppcinline/parserutils.h>
+ #endif /* __PPC__ */
+ #elif defined(__VBCC__)
+ #ifndef __PPC__
+ #include <inline/parserutils_protos.h>
+ #endif /* __PPC__ */
+ #else
+ #include <pragmas/parserutils_pragmas.h>
+ #endif /* __GNUC__ */
+#endif /* __amigaos4__ */
+
+/****************************************************************************/
+
+#endif /* PROTO_PARSERUTILS_H */
diff --git a/amiga_lib/init.c b/amiga_lib/init.c
new file mode 100755
index 0000000..b58d3a2
--- /dev/null
+++ b/amiga_lib/init.c
@@ -0,0 +1,305 @@
+/* :ts=4
+ * $VER: init.c $Revision$ (19-Nov-2010)
+ *
+ * This file is part of parserutils.
+ *
+ * Copyright (c) 2010 Hyperion Entertainment CVBA.
+ * All Rights Reserved.
+ *
+ * $Id$
+ *
+ * $Log$
+ *
+ *
+ */
+
+#include <exec/exec.h>
+#include <proto/exec.h>
+#include <dos/dos.h>
+#include <stddef.h>
+#include "hubbub/parser.h"
+#include <proto/parserutils.h>
+#include <stdarg.h>
+#include <proto/hubbub.h>
+
+/* Version Tag */
+#include "hubbub.library_rev.h"
+STATIC CONST UBYTE USED verstag[] = VERSTAG;
+
+struct Interface *INewlib __attribute__((force_no_baserel)) = NULL;
+struct ParserUtilsIFace *IParserUtils __attribute__((force_no_baserel)) = NULL;
+
+struct CLibrary
+{
+ struct Library libNode;
+ BPTR segList;
+ /* If you need more data fields, add them here */
+};
+
+/*
+ * The system (and compiler) rely on a symbol named _start which marks
+ * the beginning of execution of an ELF file. To prevent others from
+ * executing this library, and to keep the compiler/linker happy, we
+ * define an empty _start symbol here.
+ *
+ * On the classic system (pre-AmigaOS 4.x) this was usually done by
+ * moveq #0,d0
+ * rts
+ *
+ */
+int32 _start(void);
+
+int32 _start(void)
+{
+ /* If you feel like it, open DOS and print something to the user */
+ return RETURN_FAIL;
+}
+
+/*
+void *hubbub_realloc(void *ptr, size_t size, void *pw)
+{
+ (void)pw;
+ if (ptr == NULL)
+ return size > 0 ? malloc(size) : NULL;
+ if (size == 0) {
+ free(ptr);
+ return NULL;
+ }
+ return realloc(ptr, size);
+}
+*/
+
+/* Open the library */
+STATIC struct Library *libOpen(struct LibraryManagerInterface *Self, ULONG version)
+{
+ struct CLibrary *libBase = (struct CLibrary *)Self->Data.LibBase;
+
+ if (version > VERSION)
+ {
+ return NULL;
+ }
+
+ /* Add any specific open code here
+ Return 0 before incrementing OpenCnt to fail opening */
+
+
+ /* Add up the open count */
+ libBase->libNode.lib_OpenCnt++;
+ return (struct Library *)libBase;
+
+}
+
+
+/* Close the library */
+STATIC APTR libClose(struct LibraryManagerInterface *Self)
+{
+ struct Library *libBase = (struct Library *)Self->Data.LibBase;
+ /* Make sure to undo what open did */
+
+
+ /* Make the close count */
+ ((struct Library *)libBase)->lib_OpenCnt--;
+
+ return 0;
+}
+
+
+/* Expunge the library */
+STATIC APTR libExpunge(struct LibraryManagerInterface *Self)
+{
+ /* If your library cannot be expunged, return 0 */
+ struct ExecIFace *IExec
+ = (struct ExecIFace *)(*(struct ExecBase **)4)->MainInterface;
+ APTR result = (APTR)0;
+ struct CLibrary *libBase = (struct CLibrary *)Self->Data.LibBase;
+ if (libBase->libNode.lib_OpenCnt == 0)
+ {
+ result = (APTR)libBase->segList;
+
+ /* Undo what the init code did */
+
+ // hubbub_finalise(hubbub_realloc, NULL);
+
+ struct Library *ParserUtilsBase = IParserUtils->Data.LibBase;
+ IExec->DropInterface(IParserUtils);
+ IExec->CloseLibrary(ParserUtilsBase);
+
+ struct Library *newlibbase = INewlib->Data.LibBase;
+ IExec->DropInterface(INewlib);
+ IExec->CloseLibrary(newlibbase);
+
+ IExec->Remove((struct Node *)libBase);
+ IExec->DeleteLibrary((struct Library *)libBase);
+ }
+ else
+ {
+ result = (APTR)0;
+ libBase->libNode.lib_Flags |= LIBF_DELEXP;
+ }
+ return result;
+}
+
+/* The ROMTAG Init Function */
+STATIC struct Library *libInit(struct Library *LibraryBase, APTR seglist, struct Interface *exec)
+{
+ struct CLibrary *libBase = (struct CLibrary *)LibraryBase;
+ struct ExecIFace *IExec UNUSED = (struct ExecIFace *)exec;
+ struct Library *newlibbase;
+ struct Library *ParserUtilsBase;
+
+ libBase->libNode.lib_Node.ln_Type = NT_LIBRARY;
+ libBase->libNode.lib_Node.ln_Pri = 0;
+ libBase->libNode.lib_Node.ln_Name = "hubbub.library";
+ libBase->libNode.lib_Flags = LIBF_SUMUSED|LIBF_CHANGED;
+ libBase->libNode.lib_Version = VERSION;
+ libBase->libNode.lib_Revision = REVISION;
+ libBase->libNode.lib_IdString = VSTRING;
+
+ libBase->segList = (BPTR)seglist;
+
+ newlibbase = IExec->OpenLibrary("newlib.library", 3);
+ if (newlibbase)
+ {
+ INewlib = IExec->GetInterface(newlibbase, "main", 1, NULL);
+ if(!INewlib) return NULL;
+ }
+
+ ParserUtilsBase = IExec->OpenLibrary("parserutils.library", 1);
+ if (ParserUtilsBase)
+ {
+ IParserUtils = IExec->GetInterface(ParserUtilsBase, "main", 1, NULL);
+ if(!IParserUtils) return NULL;
+ }
+
+/*
+ if(hubbub_initialise("L:CharSets/Aliases", hubbub_realloc, NULL) != HUBBUB_OK)
+ return NULL;
+*/
+
+ /* Add additional init code here if you need it. For example, to open additional
+ Libraries:
+ libBase->UtilityBase = IExec->OpenLibrary("utility.library", 50L);
+ if (libBase->UtilityBase)
+ {
+ libBase->IUtility = (struct UtilityIFace *)IExec->GetInterface(ElfBase->UtilityBase,
+ "main", 1, NULL);
+ if (!libBase->IUtility)
+ return NULL;
+ } else return NULL; */
+
+ return (struct Library *)libBase;
+}
+
+STATIC uint32 HubbubObtain(struct HubbubIFace *Self)
+{
+ return Self->Data.RefCount++;
+}
+
+STATIC uint32 HubbubRelease(struct HubbubIFace *Self)
+{
+ return Self->Data.RefCount--;
+}
+
+/* ------------------- Manager Interface ------------------------ */
+/* These are generic. Replace if you need more fancy stuff */
+STATIC uint32 _manager_Obtain(struct LibraryManagerInterface *Self)
+{
+ uint32 res;
+ __asm__ __volatile__(
+ "1: lwarx %0,0,%1\n"
+ "addic %0,%0,1\n"
+ "stwcx. %0,0,%1\n"
+ "bne- 1b"
+ : "=&r" (res)
+ : "r" (&Self->Data.RefCount)
+ : "cc", "memory");
+
+ return res;
+}
+
+STATIC uint32 _manager_Release(struct LibraryManagerInterface *Self)
+{
+ uint32 res;
+ __asm__ __volatile__(
+ "1: lwarx %0,0,%1\n"
+ "addic %0,%0,-1\n"
+ "stwcx. %0,0,%1\n"
+ "bne- 1b"
+ : "=&r" (res)
+ : "r" (&Self->Data.RefCount)
+ : "cc", "memory");
+
+ return res;
+}
+
+/* Manager interface vectors */
+STATIC CONST APTR lib_manager_vectors[] =
+{
+ _manager_Obtain,
+ _manager_Release,
+ NULL,
+ NULL,
+ libOpen,
+ libClose,
+ libExpunge,
+ NULL,
+ (APTR)-1
+};
+
+/* "__library" interface tag list */
+STATIC CONST struct TagItem lib_managerTags[] =
+{
+ { MIT_Name, (Tag)"__library" },
+ { MIT_VectorTable, (Tag)lib_manager_vectors},
+ { MIT_Version, 1 },
+ { TAG_DONE, 0 }
+};
+
+/* ------------------- Library Interface(s) ------------------------ */
+
+#include "vectors.c"
+
+/* Uncomment this line (and see below) if your library has a 68k jump table */
+/* extern APTR VecTable68K[]; */
+
+STATIC CONST struct TagItem mainTags[] =
+{
+ { MIT_Name, (Tag)"main" },
+ { MIT_VectorTable, (Tag)main_vectors },
+ { MIT_Version, 1 },
+ { TAG_DONE, 0 }
+};
+
+STATIC CONST CONST_APTR libInterfaces[] =
+{
+ lib_managerTags,
+ mainTags,
+ NULL
+};
+
+STATIC CONST struct TagItem libCreateTags[] =
+{
+ { CLT_DataSize, sizeof(struct CLibrary) },
+ { CLT_InitFunc, (Tag)libInit },
+ { CLT_Interfaces, (Tag)libInterfaces },
+ /* Uncomment the following line if you have a 68k jump table */
+ /* { CLT_Vector68K, (Tag)VecTable68K }, */
+ {TAG_DONE, 0 }
+};
+
+
+/* ------------------- ROM Tag ------------------------ */
+STATIC CONST struct Resident lib_res USED =
+{
+ RTC_MATCHWORD,
+ (struct Resident *)&lib_res,
+ (APTR)(&lib_res + 1),
+ RTF_NATIVE|RTF_AUTOINIT, /* Add RTF_COLDSTART if you want to be resident */
+ VERSION,
+ NT_LIBRARY, /* Make this NT_DEVICE if needed */
+ 0, /* PRI, usually not needed unless you're resident */
+ "hubbub.library",
+ VSTRING,
+ (APTR)libCreateTags
+};
+
diff --git a/amiga_lib/stubs/auto.c b/amiga_lib/stubs/auto.c
new file mode 100755
index 0000000..bbe61d6
--- /dev/null
+++ b/amiga_lib/stubs/auto.c
@@ -0,0 +1,39 @@
+#include <proto/exec.h>
+#include <proto/dos.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+struct Interface *IHubbub = NULL;
+
+void __init_hubbub_IHubbub(void) __attribute__((constructor));
+void __exit_hubbub_IHubbub(void) __attribute__((destructor));
+
+void __init_hubbub_IHubbub(void)
+{
+ struct Library * LibBase = IExec->OpenLibrary("hubbub.library", 2L);
+
+ if (LibBase)
+ {
+ IHubbub = IExec->GetInterface(LibBase, "main", 1, NULL);
+ }
+
+ if (!IHubbub)
+ {
+ fprintf(stderr, "Could not open hubbub.library v2\n");
+
+ IExec->CloseLibrary(LibBase);
+ exit(EXIT_FAILURE);
+ }
+}
+
+void __exit_hubbub_IHubbub(void)
+{
+ if (IHubbub)
+ {
+ struct Library * LibBase = IHubbub->Data.LibBase;
+
+ IExec->DropInterface(IHubbub);
+ IExec->CloseLibrary(LibBase);
+ IHubbub = NULL;
+ }
+}
diff --git a/amiga_lib/stubs/funcs.c b/amiga_lib/stubs/funcs.c
new file mode 100755
index 0000000..542d7fd
--- /dev/null
+++ b/amiga_lib/stubs/funcs.c
@@ -0,0 +1,62 @@
+#include <stddef.h>
+#include "hubbub/parser.h"
+#include <proto/hubbub.h>
+
+ /* hubbub/errors.h */
+ const char *hubbub_error_to_string(hubbub_error error)
+ {
+ return IHubbub->hubbub_error_to_string(error);
+ }
+
+ /* hubbub/hubbub.h */
+ hubbub_error hubbub_initialise(const char *aliases_file,
+ hubbub_allocator_fn alloc, void *pw)
+ {
+ return HUBBUB_OK;
+ }
+
+ hubbub_error hubbub_finalise(hubbub_allocator_fn alloc, void *pw)
+ {
+ return HUBBUB_OK;
+ }
+
+ /* hubbub/parser.h */
+ hubbub_error hubbub_parser_create(const char *enc, bool fix_enc,
+ hubbub_allocator_fn alloc, void *pw, hubbub_parser **parser)
+ {
+ return IHubbub->hubbub_parser_create(enc, fix_enc, alloc, pw, parser);
+ }
+
+ hubbub_error hubbub_parser_destroy(hubbub_parser *parser)
+ {
+ return IHubbub->hubbub_parser_destroy(parser);
+ }
+
+ hubbub_error hubbub_parser_setopt(hubbub_parser *parser,
+ hubbub_parser_opttype type, hubbub_parser_optparams *params)
+ {
+ return IHubbub->hubbub_parser_setopt(parser, type, params);
+ }
+
+ hubbub_error hubbub_parser_parse_chunk(hubbub_parser *parser,
+ const uint8_t *data, size_t len)
+ {
+ return IHubbub->hubbub_parser_parse_chunk(parser, data, len);
+ }
+
+ hubbub_error hubbub_parser_completed(hubbub_parser *parser)
+ {
+ return IHubbub->hubbub_parser_completed(parser);
+ }
+
+ const char *hubbub_parser_read_charset(hubbub_parser *parser,
+ hubbub_charset_source *source)
+ {
+ return IHubbub->hubbub_parser_read_charset(parser, source);
+ }
+
+ hubbub_error hubbub_parser_insert_chunk(hubbub_parser *parser,
+ const uint8_t *data, size_t len)
+ {
+ return IHubbub->hubbub_parser_insert_chunk(parser, data, len);
+ }
diff --git a/amiga_lib/vectors.c b/amiga_lib/vectors.c
new file mode 100755
index 0000000..6b189da
--- /dev/null
+++ b/amiga_lib/vectors.c
@@ -0,0 +1,42 @@
+
+/* This file was generated by idltool 53.1. Do not edit */
+
+#ifndef EXEC_TYPES_H
+#include <exec/types.h>
+
+#endif
+#ifndef EXEC_EXEC_H
+#include <exec/exec.h>
+#endif
+#ifndef EXEC_INTERFACES_H
+#include <exec/interfaces.h>
+#endif
+
+STATIC CONST APTR main_vectors[] =
+{
+ HubbubObtain,
+ HubbubRelease,
+ NULL,
+ NULL,
+ /* hubbub/errors.h */
+ hubbub_error_to_string,
+
+ /* hubbub/hubbub.h */
+ /* lib private
+ hubbub_initialise,
+ hubbub_finalise,
+ */
+
+ /* hubbub/parser.h */
+ hubbub_parser_create,
+ hubbub_parser_destroy,
+ hubbub_parser_setopt,
+ hubbub_parser_parse_chunk,
+ hubbub_parser_completed,
+ hubbub_parser_read_charset,
+
+ /* added in v2 */
+ hubbub_parser_insert_chunk,
+ (APTR)-1
+};
+
diff --git a/include/hubbub/tree.h b/include/hubbub/tree.h
index 48f6b5a..29950f6 100644
--- a/include/hubbub/tree.h
+++ b/include/hubbub/tree.h
@@ -288,8 +288,8 @@ typedef struct hubbub_tree_handler {
hubbub_tree_add_attributes add_attributes; /**< Add attributes */
hubbub_tree_set_quirks_mode set_quirks_mode; /**< Set quirks mode */
hubbub_tree_encoding_change encoding_change; /**< Change encoding */
- hubbub_tree_complete_script complete_script; /**< Script Complete */
void *ctx; /**< Context pointer */
+ hubbub_tree_complete_script complete_script; /**< Script Complete */
} hubbub_tree_handler;
#ifdef __cplusplus