summaryrefslogtreecommitdiffstats
path: root/sqwebmail/testhtml.c
diff options
context:
space:
mode:
authorSam Varshavchik2013-08-19 16:39:41 -0400
committerSam Varshavchik2013-08-25 14:43:51 -0400
commit9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch)
tree7a81a04cb51efb078ee350859a64be2ebc6b8813 /sqwebmail/testhtml.c
parenta9520698b770168d1f33d6301463bb70a19655ec (diff)
downloadcourier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2
Initial checkin
Imported from subversion report, converted to git. Updated all paths in scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'sqwebmail/testhtml.c')
-rw-r--r--sqwebmail/testhtml.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/sqwebmail/testhtml.c b/sqwebmail/testhtml.c
new file mode 100644
index 0000000..aa7572f
--- /dev/null
+++ b/sqwebmail/testhtml.c
@@ -0,0 +1,46 @@
+#include "html.h"
+
+#include <stdio.h>
+#include <string.h>
+
+static void write_stdout(const unicode_char *uc, size_t n, void *dummy)
+{
+ while (n)
+ {
+ putchar(*uc++);
+ --n;
+ }
+}
+
+static char *cid_func(const char *cid, void *dummy)
+{
+ return strdup(cid);
+}
+
+int main(int argc, char **argv)
+{
+ struct htmlfilter_info *p;
+ char buf[1024];
+ unicode_char ubuf[1024];
+ size_t n;
+
+ p=htmlfilter_alloc(write_stdout, NULL);
+
+ htmlfilter_set_http_prefix(p, "http://redirect?");
+ htmlfilter_set_mailto_prefix(p, "http://mailto?");
+ htmlfilter_set_convertcid(p, cid_func, NULL);
+
+ while (fgets(buf, sizeof(buf), stdin) != NULL)
+ {
+ size_t i;
+
+ n=strlen(buf);
+
+ for (i=0; i<n; i++)
+ ubuf[i]=buf[i];
+
+ htmlfilter(p, ubuf, i);
+ }
+ htmlfilter_free(p);
+ return 0;
+}