Back to index

courier  0.68.2
testhtml.c
Go to the documentation of this file.
00001 #include "html.h"
00002 
00003 #include <stdio.h>
00004 #include <string.h>
00005 
00006 static void write_stdout(const unicode_char *uc, size_t n, void *dummy)
00007 {
00008        while (n)
00009        {
00010               putchar(*uc++);
00011               --n;
00012        }
00013 }
00014 
00015 static char *cid_func(const char *cid, void *dummy)
00016 {
00017        return strdup(cid);
00018 }
00019 
00020 int main(int argc, char **argv)
00021 {
00022        struct htmlfilter_info *p;
00023        char buf[1024];
00024        unicode_char ubuf[1024];
00025        size_t n;
00026 
00027        p=htmlfilter_alloc(write_stdout, NULL);
00028 
00029        htmlfilter_set_http_prefix(p, "http://redirect?");
00030        htmlfilter_set_mailto_prefix(p, "http://mailto?");
00031        htmlfilter_set_convertcid(p, cid_func, NULL);
00032 
00033        while (fgets(buf, sizeof(buf), stdin) != NULL)
00034        {
00035               size_t i;
00036 
00037               n=strlen(buf);
00038 
00039               for (i=0; i<n; i++)
00040                      ubuf[i]=buf[i];
00041 
00042               htmlfilter(p, ubuf, i);
00043        }
00044        htmlfilter_free(p);
00045        return 0;
00046 }