summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile29
-rw-r--r--examples/error.cpp20
-rw-r--r--examples/error.html1
-rw-r--r--examples/filter.cpp28
-rw-r--r--examples/message.html2
5 files changed, 80 insertions, 0 deletions
diff --git a/examples/Makefile b/examples/Makefile
new file mode 100644
index 0000000..3f40167
--- /dev/null
+++ b/examples/Makefile
@@ -0,0 +1,29 @@
+# Uncomment following to enable debug mode:
+# DEBUG = yes
+
+CC = g++
+EXAMPLES = filter error
+
+CPPFLAGS = -Wall -ansi -pedantic
+ifeq '$(DEBUG)' 'yes'
+CPPFLAGS += -g -O0
+else
+CPPFLAGS += -O3
+endif
+
+INCLUDE = -I../src
+LFLAGS = -L.. -lxenophage
+
+XENOPHAGE = ../libxenophage.a
+
+
+default: $(EXAMPLES)
+
+$(XENOPHAGE):
+ cd ..; $(MAKE)
+
+%: %.cpp $(XENOPHAGE)
+ $(CC) $(CPPFLAGS) $(INCLUDE) $< $(LFLAGS) -o $@
+
+clean:
+ rm -f $(EXAMPLES)
diff --git a/examples/error.cpp b/examples/error.cpp
new file mode 100644
index 0000000..54bb17d
--- /dev/null
+++ b/examples/error.cpp
@@ -0,0 +1,20 @@
+#include <file.hpp>
+#include <xift.hpp>
+
+
+int main()
+{
+ XiftFile exporter(stdout);
+ Xift xift(exporter);
+
+ xift.permitted.Tag("p").Attribute("class");
+
+ xift.PutFile("error.html");
+
+ if (!xift.End()) {
+ printf("Error on %d line, %d column:\n%s",
+ xift.ErrorLine(), xift.ErrorColumn(), xift.Error());
+ }
+
+ return 0;
+}
diff --git a/examples/error.html b/examples/error.html
new file mode 100644
index 0000000..b687c25
--- /dev/null
+++ b/examples/error.html
@@ -0,0 +1 @@
+<p class=ужас> text text text </p>
diff --git a/examples/filter.cpp b/examples/filter.cpp
new file mode 100644
index 0000000..6e786c9
--- /dev/null
+++ b/examples/filter.cpp
@@ -0,0 +1,28 @@
+#include <file.hpp>
+#include <xift.hpp>
+
+
+int main()
+{
+ XiftFile exporter(stdout);
+ Xift xift(exporter);
+
+ xift.Tag("a").Attribute("href");
+ XiftTags::Tag &p = xift.Tag("p");
+ p.Attribute("class");
+ p.Attribute("hidden");
+ p.Attribute("id");
+ xift.Tag("script");
+
+ xift.Remove("script");
+ p.Remove("id");
+
+ xift.PutFile("message.html");
+
+ if (!xift.End()) {
+ printf("Error on %d line, %d column:\n%s",
+ xift.ErrorLine(), xift.ErrorColumn(), xift.Error());
+ }
+
+ return 0;
+}
diff --git a/examples/message.html b/examples/message.html
new file mode 100644
index 0000000..7646366
--- /dev/null
+++ b/examples/message.html
@@ -0,0 +1,2 @@
+<script>SOME EVIL MAGIC!</script>
+<a href='#'>some link</a> <p class="some" hidden>parag</p>