summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--amiga/Makefile.target2
-rw-r--r--amiga/iff_dr2d.c33
-rw-r--r--amiga/iff_dr2d.h4
-rw-r--r--amiga/os3support.c39
-rw-r--r--amiga/os3support.h14
5 files changed, 82 insertions, 10 deletions
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index 21a482d95..5f7fe3f87 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -72,7 +72,7 @@ S_AMIGA := gui.c tree.c history.c hotlist.c schedule.c file.c \
sslcert.c gui_options.c print.c theme.c drag.c icon.c libs.c \
datatypes.c dt_picture.c dt_anim.c dt_sound.c plugin_hack.c \
stringview/stringview.c stringview/urlhistory.c \
- agclass/amigaguide_class.c fs_backing_store.c
+ agclass/amigaguide_class.c fs_backing_store.c os3support.c
S_AMIGA := $(addprefix amiga/,$(S_AMIGA))
# This is the final source build list
diff --git a/amiga/iff_dr2d.c b/amiga/iff_dr2d.c
index 54929da96..e8fd3e796 100644
--- a/amiga/iff_dr2d.c
+++ b/amiga/iff_dr2d.c
@@ -19,15 +19,18 @@
#ifdef WITH_NS_SVG
#include <stdio.h>
+#include <inttypes.h>
#include <svgtiny.h>
#include <proto/exec.h>
#include <string.h>
#include <proto/dos.h>
#ifndef AMIGA_DR2D_STANDALONE
+#include "amiga/os3support.h"
#include "amiga/iff_dr2d.h"
#include "content/hlcache.h"
#else
+#include "os3support.h"
#include "iff_dr2d.h"
#endif
@@ -68,7 +71,7 @@ static void addcolour(ULONG newcol)
}
bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
- uint32 size, const char *url)
+ uint32_t size, const char *url)
{
struct svgtiny_diagram *diagram;
svgtiny_code code;
@@ -334,17 +337,19 @@ bool ami_save_svg(struct hlcache_handle *c,char *filename)
/*
* This code can be compiled as a standalone program for testing etc.
* Use something like the following line:
- * gcc -o svg2dr2d iff_dr2d.c -lauto -lsvgtiny -lpthread -lz -use-dynld
- * -DWITH_NS_SVG -DAMIGA_DR2D_STANDALONE -D__USE_INLINE__
+ * gcc -o svg2dr2d iff_dr2d.c -lauto -lsvgtiny -lpthread -lsvgtiny
+ * -ldom -lwapcaplet -lexpat -lparserutils
+ * -DWITH_NS_SVG -DAMIGA_DR2D_STANDALONE -D__USE_INLINE__ -D__NOLIBBASE__
*/
-const char USED ver[] = "\0$VER: svg2dr2d 1.1 (18.05.2009)\0";
+
+const char __attribute__((used)) ver[] = "\0$VER: svg2dr2d 1.1 (18.05.2009)\0";
int main(int argc, char **argv)
{
BPTR fh = 0;
char *buffer;
struct IFFHandle *iffh = NULL;
- int64 size;
+ int64_t size;
LONG rarray[] = {0,0};
struct RDArgs *args;
STRPTR template = "SVG=INPUT/A,DR2D=OUTPUT/A";
@@ -354,6 +359,14 @@ int main(int argc, char **argv)
A_DR2D
};
+#ifndef __amigaos4__
+ DOSBase = OpenLibrary("dos.library", 37);
+ if(!DOSBase) return RETURN_FAIL;
+
+ IFFParseBase = OpenLibrary("iffparse.library", 37);
+ if(!IFFParseBase) return RETURN_FAIL;
+#endif
+
args = ReadArgs(template,rarray,NULL);
if(!args)
@@ -366,9 +379,9 @@ int main(int argc, char **argv)
{
size = GetFileSize(fh);
- buffer = AllocVecTagList((uint32)size, NULL);
+ buffer = AllocVecTagList((uint32_t)size, NULL);
- Read(fh,buffer,(uint32)size);
+ Read(fh,buffer,(uint32_t)size);
Close(fh);
}
else
@@ -395,7 +408,13 @@ int main(int argc, char **argv)
if(iffh->iff_Stream) Close((BPTR)iffh->iff_Stream);
if(iffh) FreeIFF(iffh);
FreeArgs(args);
+
+#ifndef __amigaos4__
+ if(DOSBase) CloseLibrary(DOSBase);
+ if(IFFParseBase) CloseLibrary(IFFParseBase);
+#endif
}
#endif // AMIGA_DR2D_STANDALONE
#endif // WITH_NS_SVG
+
diff --git a/amiga/iff_dr2d.h b/amiga/iff_dr2d.h
index 7ef562215..c9981d33a 100644
--- a/amiga/iff_dr2d.h
+++ b/amiga/iff_dr2d.h
@@ -66,7 +66,7 @@ struct stxt_struct {
float CharW, CharH, /* W/H of an individual char */
BaseX, BaseY, /* Start of baseline */
Rotation; /* Angle of text (in degrees) */
- uint16 NumChars;
+ uint16_t NumChars;
//char TextChars[NumChars];
};
@@ -99,7 +99,7 @@ struct dash_struct {
};
bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
- uint32 size, const char *url);
+ uint32_t size, const char *url);
#ifndef AMIGA_DR2D_STANDALONE
bool ami_save_svg(struct hlcache_handle *c, char *filename);
#endif
diff --git a/amiga/os3support.c b/amiga/os3support.c
new file mode 100644
index 000000000..b9134ac23
--- /dev/null
+++ b/amiga/os3support.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2014 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * 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
+ * Minimal compatibility header for AmigaOS 3
+ */
+
+#ifndef __amigaos4__
+#include "os3support.h"
+
+int64 GetFileSize(BPTR fh)
+{
+ int32 size = 0;
+ struct FileInfoBlock *fib = AllocVec(sizeof(struct FileInfoBlock), MEMF_ANY);
+ if(fib == NULL) return 0;
+
+ ExamineFH(fh, fib);
+ size = fib->fib_Size;
+
+ FreeVec(fib);
+ return (int64)size;
+}
+
+#endif
diff --git a/amiga/os3support.h b/amiga/os3support.h
index c93e09a06..61b6d06ad 100644
--- a/amiga/os3support.h
+++ b/amiga/os3support.h
@@ -26,6 +26,8 @@
#ifndef __amigaos4__
#include <stdint.h>
+#include <proto/exec.h>
+#include <proto/dos.h>
/* Include prototypes for amigalib */
#include <clib/alib_protos.h>
@@ -34,10 +36,18 @@
#include <exec/memory.h>
#endif
+/* Library bases */
+struct Library *SysBase;
+struct Library *DOSBase;
+struct Library *IFFParseBase;
+
/* Define extra memory type flags */
#define MEMF_PRIVATE MEMF_ANY
#define MEMF_SHARED MEMF_ANY
+/* Easy wrapper for AllocVecTagList with no tags */
+#define AllocVecTagList(SZ,TAG) AllocVec(SZ,MEMF_ANY);
+
/* Integral type definitions */
typedef int8_t int8;
typedef uint8_t uint8;
@@ -45,6 +55,8 @@ typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
+typedef int64_t int64;
+typedef uint64_t uint64;
/* TimeVal */
struct TimeVal {
@@ -79,6 +91,8 @@ struct TimeVal {
#define IDFMT_PALETTEMAPPED (1) /* Palette mapped icon (chunky, V44+) */
#define IDFMT_DIRECTMAPPED (2) /* Direct mapped icon (truecolor 0xAARRGGBB, V51+) */
+/* Functions */
+int64 GetFileSize(BPTR fh);
#endif
#endif