-#
-# AFL dictionary for SVG
-# ----------------------
-#
-# Several basic syntax elements and attributes, modeled on AFL XML dictionary
-#
-# Michal Zalewski <lcamtuf@google.com>
-# Vincent Sanders <vince@netsurf-browser.org>
-#
+# Keywords taken from
+# - https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Introduction
+# - https://css-tricks.com/svg-properties-and-css/
-# SVG element reference from MDN
-# https://developer.mozilla.org/en-US/docs/Web/SVG/Element
-#
-tag_a="<a"
-tag_open_close="<a />"
-tag_close="</a>"
-tag_altGlyph="<altGlyph"
-tag_altGlyphDef="<altGlyphDef"
-tag_altGlyphItem="<altGlyphItem"
-tag_animate="<animate"
-tag_animateColor="<animateColor"
-tag_animateMotion="<animateMotion"
-tag_animateTransform="<animateTransform"
-tag_circle="<circle"
-tag_clipPath="<clipPath"
-tag_close_clipPath="</clipPath>"
-tag_color_profile="<color-profile"
-tag_cursor="<cursor"
-tag_defs="<defs"
-tag_desc="<desc"
-tag_ellipse="<ellipse"
-tag_feBlend="<feBlend"
-tag_feColorMatrix="<feColorMatrix"
-tag_feComponentTransfer="<feComponentTransfer"
-tag_feComposite="<feComposite"
-tag_feConvolveMatrix="<feConvolveMatrix"
-tag_feDiffuseLighting="<feDiffuseLighting"
-tag_feDisplacementMap="<feDisplacementMap"
-tag_feDistantLight="<feDistantLight"
-tag_feFlood="<feFlood"
-tag_feFuncA="<feFuncA"
-tag_feFuncB="<feFuncB"
-tag_feFuncG="<feFuncG"
-tag_feFuncR="<feFuncR"
-tag_feGaussianBlur="<feGaussianBlur"
-tag_feImage="<feImage"
-tag_feMerge="<feMerge"
-tag_feMergeNode="<feMergeNode"
-tag_feMorphology="<feMorphology"
-tag_feOffset="<feOffset"
-tag_fePointLight="<fePointLight"
-tag_feSpecularLighting="<feSpecularLighting"
-tag_feSpotLight="<feSpotLight"
-tag_feTile="<feTile"
-tag_feTurbulence="<feTurbulence"
-tag_filter="<filter"
-tag_font="<font"
-tag_font_face="<font-face"
-tag_font_face_format="<font-face-format"
-tag_font_face_name="<font-face-name"
-tag_font_face_src="<font-face-src"
-tag_font_face_uri="<font-face-uri"
-tag_foreignObject="<foreignObject"
-tag_g="<g"
-tag_close_g="</g>"
-tag_glyph="<glyph"
-tag_glyphRef="<glyphRef"
-tag_hkern="<hkern"
-tag_image="<image"
-tag_line="<line"
-tag_linearGradient="<linearGradient"
-tag_marker="<marker"
-tag_mask="<mask"
-tag_metadata="<metadata"
-tag_missing_glyph="<missing-glyph"
-tag_mpath="<mpath"
-tag_path="<path"
-tag_pattern="<pattern"
-tag_polygon="<polygon"
-tag_polyline="<polyline"
-tag_radialGradient="<radialGradient"
-tag_rect="<rect"
-tag_script="<script"
-tag_set="<set"
-tag_stop="<stop"
-tag_style="<style"
-tag_svg="<svg"
-tag_switch="<switch"
-tag_symbol="<symbol"
-tag_text="<text"
-tag_textPath="<textPath"
-tag_title="<title"
-tag_tref="<tref"
-tag_tspan="<tspan"
-tag_use="<use"
-tag_view="<view"
-tag_vkern="<vkern"
+"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+"standalone="
+"version="
+"encoding="
+"<?xml"
+"?>"
+"/>"
+"<![CDATA["
-attrribute_id=" id"
-attrribute_transform=" transform"
-attrribute_target=" target"
-attrribute_d=" d"
-attrribute_style=" style"
-attrribute_width=" width"
-attrribute_height=" height"
-attrribute_x=" x"
-attrribute_y=" y"
-attrribute_anchor=" text-anchor"
+# tags
+"<svg"
+"xmlns=\"http://www.w3.org/2000/svg\""
+"<a"
+"<animate"
+"<animateMotion"
+"<animateTransform"
+"<circle"
+"<clipPath"
+"<color-profile"
+"<defs"
+"<desc"
+"<discard"
+"<ellipse"
+"<feBlend"
+"<feColorMatrix"
+"<feComponentTransfer"
+"<feComposite"
+"<feConvolveMatrix"
+"<feDiffuseLighting"
+"<feDisplacementMap"
+"<feDistantLight"
+"<feDropShadow"
+"<feFlood"
+"<feFuncA"
+"<feFuncB"
+"<feFuncG"
+"<feFuncR"
+"<feGaussianBlur"
+"<feImage"
+"<feMerge"
+"<feMergeNode"
+"<feMorphology"
+"<feOffset"
+"<fePointLight"
+"<feSpecularLighting"
+"<feSpotLight"
+"<feTile"
+"<feTurbulence"
+"<filter"
+"<foreignObject"
+"<g"
+"<hatch"
+"<hatchpath"
+"<image"
+"<line"
+"<linearGradient"
+"<marker"
+"<mask"
+"<mesh"
+"<meshgradient"
+"<meshpatch"
+"<meshrow"
+"<metadata"
+"<mpath"
+"<path"
+"<pattern"
+"<polygon"
+"<polyline"
+"<radialGradient"
+"<rect"
+"<rect"
+"<script"
+"<script>"
+"<set"
+"<solidcolor"
+"<stop"
+"<style"
+"<svg"
+"<switch"
+"<symbol"
+"<text"
+"<textArea"
+"<textPath"
+"<title"
+"<title>"
+"<tspan"
+"<unknown"
+"<use"
+"<view"
-attr_encoding=" encoding=\"1\""
-attr_generic=" a=\"1\""
-attr_href=" href=\"1\""
-attr_standalone=" standalone=\"no\""
-attr_version=" version=\"1\""
-attr_xml_base=" xml:base=\"1\""
-attr_xml_id=" xml:id=\"1\""
-attr_xml_lang=" xml:lang=\"1\""
-attr_xml_space=" xml:space=\"1\""
-attr_xmlns=" xmlns=\"1\""
-entity_builtin="<"
-entity_decimal=""
-entity_external="&a;"
-entity_hex=""
-
-string_any="ANY"
-string_brackets="[]"
-string_cdata="CDATA"
-string_col_fallback=":fallback"
-string_col_generic=":a"
-string_col_include=":include"
-string_dashes="--"
-string_empty="EMPTY"
-string_empty_dblquotes="\"\""
-string_empty_quotes="''"
-string_entities="ENTITIES"
-string_entity="ENTITY"
-string_fixed="#FIXED"
-string_id="ID"
-string_idref="IDREF"
-string_idrefs="IDREFS"
-string_implied="#IMPLIED"
-string_nmtoken="NMTOKEN"
-string_nmtokens="NMTOKENS"
-string_notation="NOTATION"
-string_parentheses="()"
-string_pcdata="#PCDATA"
-string_percent="%a"
-string_public="PUBLIC"
-string_required="#REQUIRED"
-string_schema=":schema"
-string_system="SYSTEM"
-string_ucs4="UCS-4"
-string_utf16="UTF-16"
-string_utf8="UTF-8"
-string_xmlns="xmlns:"
-
-tag_attlist="<!ATTLIST"
-tag_cdata="<![CDATA["
-tag_doctype="<!DOCTYPE"
-tag_element="<!ELEMENT"
-tag_entity="<!ENTITY"
-tag_ignore="<![IGNORE["
-tag_include="<![INCLUDE["
-tag_notation="<!NOTATION"
-tag_open_exclamation="<!"
-tag_open_q="<?"
-tag_sq2_close="]]>"
-tag_xml_q="<?xml?>"
+# attributes
+"alignment-baseline"
+"baseline-shift"
+"class"
+"color"
+"cursor"
+"cx"
+"cy"
+"direction"
+"display"
+"dominant-baseline"
+"editable"
+"fill"
+"fill-opacity"
+"font-family"
+"font-size"
+"font-size-adjust"
+"font-stretch"
+"font-style"
+"font-variant"
+"font-weight"
+"glyph-orientation-horizontal"
+"glyph-orientation-vertical"
+"gradientUnits"
+"height"
+"kerning""
+"letter-spacing"
+"offset"
+"overflow"
+"patternContentUnits"
+"pointer-events"
+"points"
+"rotate"
+"rx"
+"ry"
+"spreadMethod"
+"stop-color"
+"stop-opacity"
+"stroke"
+"stroke-dasharray"
+"stroke-linecap"
+"stroke-linejoin"
+"stroke-opacity"
+"stroke-width"
+"style"
+"text-anchor"
+"text-decoration"
+"textlength"
+"transform"
+"unicode-bidi"
+"visibility"
+"width"
+"word-spacing"
+"writing-mode"
+"x1"
+"x2"
+"y1"
+"y2"
+# attributes' values
+"bounding-Box"
+"repeat"
+"display"
+"transparent"
+"orange"
+"round"
+"butt"
+"userSpaceOnUse"
+"objectBoundingBox"
+"square"
+"miter"
+"bevel"
+"translate("
+"rotate("
+"matrix("
+"skewX("
+"skewY("
--- /dev/null
+/*
+ * This file is part of Libsvgtiny
+ * Licensed under the MIT License,
+ * http://opensource.org/licenses/mit-license.php
+ * Copyright 2008 James Bursa <james@semichrome.net>
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include "svgtiny.h"
+
+/* trivial test program that creates a svg diagram and parses it */
+int main(int argc, char *argv[])
+{
+ FILE *fd;
+ struct stat sb;
+ char *buffer;
+ size_t size;
+ size_t n;
+ struct svgtiny_diagram *diagram;
+ svgtiny_code code;
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s FILE\n", argv[0]);
+ return 1;
+ }
+
+ /* load file into memory buffer */
+ fd = fopen(argv[1], "rb");
+ if (!fd) {
+ perror(argv[1]);
+ return 1;
+ }
+
+ if (stat(argv[1], &sb)) {
+ perror(argv[1]);
+ return 1;
+ }
+ size = sb.st_size;
+
+ buffer = malloc(size);
+ if (!buffer) {
+ fprintf(stderr, "Unable to allocate %lld bytes\n",
+ (long long) size);
+ return 1;
+ }
+
+ n = fread(buffer, 1, size, fd);
+ if (n != size) {
+ perror(argv[1]);
+ return 1;
+ }
+
+ fclose(fd);
+
+ /* create svgtiny object */
+ diagram = svgtiny_create();
+ if (!diagram) {
+ fprintf(stderr, "svgtiny_create failed\n");
+ return 1;
+ }
+
+ /* parse */
+ code = svgtiny_parse(diagram, buffer, size, argv[1], 1000, 1000);
+ if (code != svgtiny_OK) {
+ fprintf(stderr, "svgtiny_parse failed: ");
+ switch (code) {
+ case svgtiny_OUT_OF_MEMORY:
+ fprintf(stderr, "svgtiny_OUT_OF_MEMORY");
+ break;
+ case svgtiny_LIBDOM_ERROR:
+ fprintf(stderr, "svgtiny_LIBDOM_ERROR");
+ break;
+ case svgtiny_NOT_SVG:
+ fprintf(stderr, "svgtiny_NOT_SVG");
+ break;
+ case svgtiny_SVG_ERROR:
+ fprintf(stderr, "svgtiny_SVG_ERROR: line %i: %s",
+ diagram->error_line,
+ diagram->error_message);
+ break;
+ default:
+ fprintf(stderr, "unknown svgtiny_code %i", code);
+ break;
+ }
+ fprintf(stderr, "\n");
+ }
+
+ free(buffer);
+
+ svgtiny_free(diagram);
+
+ return 0;
+}