summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nohtml/common.cpp1
-rw-r--r--nohtml/common.h57
-rw-r--r--nohtml/conv.cpp802
-rw-r--r--nohtml/conv.h33
-rw-r--r--nohtml/filter.cpp126
-rw-r--r--nohtml/filter.h9
-rw-r--r--nohtml/nohtml.cpp104
-rw-r--r--nohtml/nohtml.rc76
-rw-r--r--nohtml/nohtml.sln26
-rw-r--r--nohtml/nohtml.vcproj295
-rw-r--r--nohtml/options.cpp68
-rw-r--r--nohtml/options.h13
-rw-r--r--nohtml/readme.txt47
-rw-r--r--nohtml/resource.h17
-rw-r--r--nohtml/resource.rc2
-rw-r--r--nohtml/strl.cpp104
-rw-r--r--nohtml/strl.h10
-rw-r--r--nohtml/version.h26
-rw-r--r--nohtml/version.rc33
19 files changed, 1849 insertions, 0 deletions
diff --git a/nohtml/common.cpp b/nohtml/common.cpp
new file mode 100644
index 0000000..3324856
--- /dev/null
+++ b/nohtml/common.cpp
@@ -0,0 +1 @@
+#include "common.h"
diff --git a/nohtml/common.h b/nohtml/common.h
new file mode 100644
index 0000000..a2f77aa
--- /dev/null
+++ b/nohtml/common.h
@@ -0,0 +1,57 @@
+#ifndef _COMMON_INC
+#define _COMMON_INC
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef WINVER // Allow use of features specific to Windows XP or later.
+#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
+#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
+#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
+#endif
+
+#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
+#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
+#endif
+
+#if defined( UNICODE ) && !defined( _UNICODE )
+#define _UNICODE
+#endif
+
+#include <tchar.h>
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+
+#include <windows.h>
+#include <commctrl.h>
+#include <richedit.h>
+#include <malloc.h>
+#include <stdlib.h>
+
+#define MIRANDA_VER 0x0600
+#include <newpluginapi.h>
+#include <m_system.h>
+#include <m_database.h>
+#include <m_langpack.h>
+#include <m_options.h>
+#include <m_protomod.h>
+#include <m_protosvc.h>
+#include <stdio.h>
+#include <m_utils.h>
+#include <m_updater.h>
+
+#define MODULE "nohtml"
+
+extern HINSTANCE hInst;
+extern PLUGINLINK *pluginLink;
+
+#ifndef MIID_NOHTML
+#define MIID_NOHTML { 0x9544122C, 0x46DD, 0x4BFA, { 0x8A, 0x5A, 0x5D, 0xDC, 0x3, 0x14, 0x28, 0x93 } }
+#endif
+
+#endif
diff --git a/nohtml/conv.cpp b/nohtml/conv.cpp
new file mode 100644
index 0000000..accf524
--- /dev/null
+++ b/nohtml/conv.cpp
@@ -0,0 +1,802 @@
+#include "common.h"
+#include "conv.h"
+#include "strl.h"
+#if _MSC_VER
+#pragma warning( disable: 4706 )
+#endif
+char* strip_html(char *src)
+{
+ wchar_t* buf=new wchar_t[strlen(src)+1];
+ MultiByteToWideChar(CP_ACP, 0, src, -1,buf,(strlen(src)+1)*2);
+ wchar_t* stripped_buf=strip_html(buf);
+ delete[] buf;
+ char* dest=new char[wcslen(stripped_buf)+1];
+ WideCharToMultiByte( CP_ACP, 0, stripped_buf, -1,dest,wcslen(stripped_buf)+1, NULL, NULL );
+ delete[] stripped_buf;
+ return dest;
+}
+wchar_t* strip_html(wchar_t *src)
+{
+ wchar_t *ptr;
+ wchar_t *ptrl;
+ wchar_t *rptr;
+ wchar_t* dest=wcsldup(src,wcslen(src));
+ while ((ptr = wcsstr(dest,L"<P>")) != NULL || (ptr = wcsstr(dest, L"<p>")) != NULL) {
+ memmove(ptr + 4, ptr + 3, wcslen(ptr + 3)*2 + 2);
+ *ptr = '\r';
+ *(ptr + 1) = '\n';
+ *(ptr + 2) = '\r';
+ *(ptr + 3) = '\n';
+ }
+ while ((ptr = wcsstr(dest,L"</P>")) != NULL || (ptr = wcsstr(dest, L"</p>")) != NULL) {
+ *ptr = L'\r';
+ *(ptr + 1) = L'\n';
+ *(ptr + 2) = L'\r';
+ *(ptr + 3) = L'\n';
+ }
+ while ((ptr = wcsstr(dest, L"<BR>")) != NULL || (ptr = wcsstr(dest, L"<br>")) != NULL) {
+ *ptr = L'\r';
+ *(ptr + 1) = L'\n';
+ memmove(ptr + 2, ptr + 4, wcslen(ptr + 4)*2 + 2);
+ }
+ while ((ptr = wcsstr(dest, L"<HR>")) != NULL || (ptr = wcsstr(dest, L"<hr>")) != NULL) {
+ *ptr = L'\r';
+ *(ptr + 1) = L'\n';
+ memmove(ptr + 2, ptr + 4, wcslen(ptr + 4)*2 + 2);
+ }
+ rptr = dest;
+ /*while (ptr = wcsstr(rptr, L"<A HREF=\""))
+ {
+ int addr=ptr-rptr;
+ dest=renew(dest,wcslen(dest)*2+2,7);
+ rptr=dest;
+ ptr=rptr+addr;
+ memcpy(ptr,L"[link: ",7*2);
+ ptrl=ptr+7;
+ memmove(ptrl, ptrl + 2, wcslen(ptrl + 2)*2 + 2);
+ if ((ptrl = wcsstr(ptr, L"\">")))
+ {
+ memmove(ptrl+7,ptrl+1,wcslen(ptrl+1)*2+2);
+ memcpy(ptrl,L" title: ",8*2);
+
+ wchar_t* s1 = wcsstr(ptrl,L"</A");
+ wchar_t* s2 = wcsstr(rptr,L"<A HREF");
+ if (s1&&s1<s2||s1&&!s2)
+ {
+ ptr=s1;
+ *ptr=L' ';
+ ptr[1]=L']';
+ memmove(ptr+2, ptr + 4, wcslen(ptr + 4)*2 + 2);
+ }
+ else if(s2&&s2<s1||s2&&!s1)
+ {
+ ptr=s2;
+ memmove(ptr+2, ptr, wcslen(ptr)*2 + 2);
+ *ptr=L' ';
+ ptr[1]=L']';
+ }
+ else
+ {
+ ptr=dest;
+ memcpy(&ptr[wcslen(ptr)],L" ]",3*2);
+ }
+ }
+ else
+ rptr++;
+ }
+ rptr = dest;
+ while (ptr = wcsstr(rptr, L"<a href=\""))
+ {
+ int addr=ptr-rptr;
+ dest=renew(dest,wcslen(dest)*2+2,7*2);
+ rptr=dest;
+ ptr=rptr+addr;
+ memcpy(ptr,L"[link: ",7*2);
+ ptrl=ptr+7;
+ memmove(ptrl, ptrl + 2, wcslen(ptrl + 2)*2 + 2);
+ if ((ptrl = wcsstr(ptr, L"\">")))
+ {
+ memmove(ptrl+7,ptrl+1,wcslen(ptrl+1)*2+2);
+ memcpy(ptrl,L" title: ",8*2);
+
+ wchar_t* s1 = wcsstr(ptrl,L"</a href");
+ wchar_t* s2 = wcsstr(rptr,L"<a href");
+ if (s1&&s1<s2||s1&&!s2)
+ {
+ ptr=s1;
+ *ptr=L' ';
+ ptr[1]=L']';
+ memmove(ptr+2, ptr + 4, wcslen(ptr + 4)*2 + 2);
+ }
+ else if(s2&&s2<s1||s2&&!s1)
+ {
+ ptr=s2;
+ memmove(ptr+2, ptr, wcslen(ptr)*2 + 2);
+ *ptr=L' ';
+ ptr[1]=L']';
+ }
+ else
+ {
+ ptr=dest;
+ memcpy(&ptr[wcslen(ptr)],L" ]",3*2);
+ }
+ }
+ else
+ rptr++;
+ }*/
+ rptr = dest;
+ while ((ptr = wcsstr(rptr, L"<"))) {
+ ptrl = ptr + 1;
+ if ((ptrl = wcsstr(ptrl, L">"))) {
+ memmove(ptr, ptrl + 1, wcslen(ptrl + 1)*2 + 2);
+ }
+ else
+ break;
+ }
+ ptrl = NULL;
+ while ((ptr = wcsstr(dest, L"&quot;")) != NULL && (ptrl == NULL || ptr > ptrl)) {
+ *ptr = L'"';
+ memmove(ptr + 1, ptr + 6, wcslen(ptr + 6)*2 + 2);
+ ptrl = ptr;
+ }
+ ptrl = NULL;
+ while ((ptr = wcsstr(dest, L"&lt;")) != NULL && (ptrl == NULL || ptr > ptrl)) {
+ *ptr = L'<';
+ memmove(ptr + 1, ptr + 4, wcslen(ptr + 4)*2 + 2);
+ ptrl = ptr;
+ }
+ ptrl = NULL;
+ while ((ptr = wcsstr(dest, L"&gt;")) != NULL && (ptrl == NULL || ptr > ptrl)) {
+ *ptr = L'>';
+ memmove(ptr + 1, ptr + 4, wcslen(ptr + 4)*2 + 2);
+ ptrl = ptr;
+ }
+ ptrl = NULL;
+ while ((ptr = wcsstr(dest, L"&amp;")) != NULL && (ptrl == NULL || ptr > ptrl)) {
+ *ptr = L'&';
+ memmove(ptr + 1, ptr + 5, wcslen(ptr + 5)*2 + 2);
+ ptrl = ptr;
+ }
+ return dest;
+}
+char* strip_carrots(char *src)// EAT!!!!!!!!!!!!!
+{
+ wchar_t* buf=new wchar_t[strlen(src)+1];
+ MultiByteToWideChar(CP_ACP, 0, src, -1,buf,(strlen(src)+1)*2);
+ wchar_t* stripped_buf=strip_carrots(buf);
+ delete[] buf;
+ char* dest=new char[wcslen(stripped_buf)+1];
+ WideCharToMultiByte( CP_ACP, 0, stripped_buf, -1,dest,wcslen(stripped_buf)+1, NULL, NULL );
+ delete[] stripped_buf;
+ return dest;
+}
+wchar_t* strip_carrots(wchar_t *src)// EAT!!!!!!!!!!!!!
+{
+ wchar_t *ptr;
+ wchar_t* dest=wcsldup(src,wcslen(src));
+ while ((ptr = wcsstr(dest, L"<")) != NULL)
+ {
+ int addr=ptr-dest;
+ dest=renew(dest,wcslen(dest)+2,7);
+ ptr=dest+addr;
+ memmove(ptr + 4, ptr + 1, wcslen(ptr + 1)*2 + 8);
+ memcpy(ptr,L"&lt;",8);
+ }
+ while ((ptr = wcsstr(dest, L">")) != NULL)
+ {
+ int addr=ptr-dest;
+ dest=renew(dest,wcslen(dest)+2,7);
+ ptr=dest+addr;
+ memmove(ptr + 4, ptr + 1, wcslen(ptr + 1)*2 + 8);
+ memcpy(ptr,L"&gt;",8);
+ }
+ dest[wcslen(dest)]='\0';
+ return dest;
+}
+char* strip_linebreaks(char *src)
+{
+ char* dest=strldup(src,lstrlen(src));
+ char *ptr;
+ while ((ptr = strstr(dest, "\r")) != NULL)
+ {
+ memmove(ptr, ptr + 1, lstrlen(ptr + 1)+1);
+ }
+ while ((ptr = strstr(dest, "\n")) != NULL)
+ {
+ int addr=ptr-dest;
+ dest=renew(dest,lstrlen(dest)+1,7);
+ ptr=dest+addr;
+ memmove(ptr + 4, ptr + 1, lstrlen(ptr + 1) + 4);
+ memcpy(ptr,"<br>",4);
+ }
+ dest[lstrlen(dest)]='\0';
+ return dest;
+}
+char* html_to_bbcodes(char *src)
+{
+ wchar_t* buf=new wchar_t[strlen(src)+1];
+ MultiByteToWideChar(CP_ACP, 0, src, -1,buf,(strlen(src)+1)*2);
+ wchar_t* stripped_buf=html_to_bbcodes(buf);
+ delete[] buf;
+ char* dest=new char[wcslen(stripped_buf)+1];
+ WideCharToMultiByte( CP_ACP, 0, stripped_buf, -1,dest,wcslen(stripped_buf)+1, NULL, NULL );
+ delete[] stripped_buf;
+ return dest;
+}
+wchar_t* html_to_bbcodes(wchar_t *src)
+{
+ wchar_t *ptr;
+ wchar_t *ptrl;
+ wchar_t *rptr;
+ wchar_t* dest=wcsldup(src,wcslen(src));
+ while ((ptr = wcsstr(dest, L"<B>")) != NULL || (ptr = wcsstr(dest, L"<b>")) != NULL)
+ {
+ *ptr = L'[';
+ *(ptr+1) = L'b';
+ *(ptr+2) = L']';
+ if((ptr = wcsstr(dest, L"</B>")) != NULL || (ptr = wcsstr(dest, L"</b>")) != NULL)
+ {
+ *ptr = L'[';
+ *(ptr+2) = L'b';
+ *(ptr+3) = L']';
+ }
+ else
+ {
+ dest=renew(dest,wcslen(dest)*2+2,5*2);
+ memcpy(&dest[wcslen(dest)],L"[/b]",5*2);
+ }
+ }
+ while ((ptr = wcsstr(dest, L"<I>")) != NULL || (ptr = wcsstr(dest, L"<i>")) != NULL)
+ {
+ *ptr = L'[';
+ *(ptr+1) = L'i';
+ *(ptr+2) = L']';
+ if((ptr = wcsstr(dest, L"</I>")) != NULL || (ptr = wcsstr(dest, L"</i>")) != NULL)
+ {
+ *ptr = L'[';
+ *(ptr+2) = L'i';
+ *(ptr+3) = L']';
+ }
+ else
+ {
+ dest=renew(dest,wcslen(dest)*2+2,5*2);
+ memcpy(&dest[wcslen(dest)],L"[/i]",5*2);
+ }
+ }
+ while ((ptr = wcsstr(dest, L"<U>")) != NULL || (ptr = wcsstr(dest, L"<u>")) != NULL)
+ {
+ *ptr = L'[';
+ *(ptr+1) = L'u';
+ *(ptr+2) = L']';
+ if((ptr = wcsstr(dest, L"</U>")) != NULL || (ptr = wcsstr(dest, L"</u>")) != NULL)
+ {
+ *ptr = L'[';
+ *(ptr+2) = L'u';
+ *(ptr+3) = L']';
+ }
+ else
+ {
+ dest=renew(dest,wcslen(dest)*2+2,5*2);
+ memcpy(&dest[wcslen(dest)],L"[/u]",5*2);
+ }
+ }
+ rptr = dest;
+ while (ptr = wcsstr(rptr,L"<A HREF"))
+ {
+ wchar_t* begin=ptr;
+ ptrl = ptr + 4;
+ memcpy(ptrl,L"[url=",5*2);
+ memmove(ptr, ptrl, wcslen(ptrl)*2 + 2);
+ if ((ptr = wcsstr(ptrl,L">")))
+ {
+ ptr-=1;
+ memmove(ptr, ptr+1, wcslen(ptr+1)*2 + 2);
+ *(ptr)=L']';
+ ptrl-=1;
+ wchar_t* s1 = wcsstr(ptrl,L"</A");
+ wchar_t* s2 = wcsstr(rptr,L"<A HREF");
+ if (s1&&s1<s2||s1&&!s2)
+ {
+ ptr=s1;
+ ptr=strip_tag_within(begin,ptr);
+ memmove(ptr+2, ptr, wcslen(ptr)*2 + 2);
+ memcpy(ptr,L"[/url]",6*2);
+ }
+ else if(s2&&s2<s1||s2&&!s1)
+ {
+ ptr=s2;
+ ptr=strip_tag_within(begin,ptr);
+ int addr=ptr-rptr;
+ dest=renew(dest,wcslen(dest)*2+2,7*2);
+ rptr=dest;
+ ptr=rptr+addr;
+ memmove(ptr+6, ptr, wcslen(ptr)*2 + 2);
+ memcpy(ptr,L"[/url]",6*2);
+ }
+ else
+ {
+ strip_tag_within(begin,&dest[wcslen(dest)]);
+ //int addr=ptr-rptr;
+ dest=renew(dest,wcslen(dest)*2+2,7*2);
+ rptr=dest;
+ ptr=dest;
+ memcpy(&ptr[wcslen(ptr)],L"[/url]",7*2);
+ }
+ }
+ else
+ rptr++;
+ }
+ rptr = dest;
+ while (ptr = wcsstr(rptr,L"<a href"))
+ {
+ wchar_t* begin=ptr;
+ ptrl = ptr + 4;
+ memcpy(ptrl,L"[url=",5*2);
+ memmove(ptr, ptrl, wcslen(ptrl)*2 + 2);
+ if ((ptr = wcsstr(ptrl,L">")))
+ {
+ ptr-=1;
+ memmove(ptr, ptr+1, wcslen(ptr+1)*2 + 2);
+ *(ptr)=L']';
+ ptrl-=1;
+ wchar_t* s1 = wcsstr(ptrl,L"</a");
+ wchar_t* s2 = wcsstr(ptrl,L"<a href");
+ if (s1&&s1<s2||s1&&!s2)
+ {
+ ptr=s1;
+ ptr=strip_tag_within(begin,ptr);
+ memmove(ptr+2, ptr, wcslen(ptr)*2 + 2);
+ memcpy(ptr,L"[/url]",6*2);
+ }
+ else if(s2&&s2<s1||s2&&!s1)
+ {
+ ptr=s2;
+ ptr=strip_tag_within(begin,ptr);
+ int addr=ptr-rptr;
+ dest=renew(dest,wcslen(dest)*2+2,7*2);
+ rptr=dest;
+ ptr=rptr+addr;
+ memmove(ptr+6, ptr, wcslen(ptr)*2 + 2);
+ memcpy(ptr,L"[/url]",6*2);
+ }
+ else
+ {
+ strip_tag_within(begin,&dest[wcslen(dest)]);
+ //int addr=ptr-rptr;
+ dest=renew(dest,wcslen(dest)*2+2,7*2);
+ rptr=dest;
+ ptr=dest;
+ memcpy(&ptr[wcslen(ptr)],L"[/url]",7*2);
+ }
+ }
+ else
+ rptr++;
+ }
+ rptr = dest;
+ while (ptr = wcsstr(rptr, L"<FONT COLOR=\""))
+ {
+ int addr=ptr-rptr;
+ dest=renew(dest,wcslen(dest)*2+2,7*2);
+ rptr=dest;
+ ptr=rptr+addr;
+ ptrl = ptr + 6;
+ memcpy(ptrl,L"[color=",7*2);
+ memmove(ptr, ptrl, wcslen(ptrl)*2 + 2);
+ if ((ptr = wcsstr(ptrl, L">")))
+ {
+ memmove(ptrl+7,ptr,wcslen(ptr)*2+2);
+ *(ptrl+7)=L']';
+ ptr=ptrl+7;
+ wchar_t* s1 = wcsstr(ptr,L"</FONT");
+ wchar_t* s2 = wcsstr(ptr,L"<FONT COLOR=\"");
+ if (s1&&s1<s2||s1&&!s2)
+ {
+ ptr=s1;
+ memmove(ptr+1, ptr, wcslen(ptr)*2 + 2);
+ memcpy(ptr,L"[/color]",8*2);
+ }
+ else if(s2&&s2<s1||s2&&!s1)
+ {
+ ptr=s2;
+ memmove(ptr+8, ptr, wcslen(ptr)*2 + 2);
+ memcpy(ptr,L"[/color]",8*2);
+ }
+ else
+ {
+ ptr=dest;
+ memcpy(&ptr[wcslen(ptr)],L"[/color]",9*2);
+ }
+ }
+ else
+ rptr++;
+ }
+ rptr = dest;
+ while (ptr = wcsstr(rptr, L"<font color=\""))
+ {
+ int addr=ptr-rptr;
+ dest=renew(dest,wcslen(dest)*2+2,7*2);
+ rptr=dest;
+ ptr=rptr+addr;
+ ptrl = ptr + 6;
+ memcpy(ptrl,L"[color=",7*2);
+ memmove(ptr, ptrl, wcslen(ptrl)*2 + 2);
+ if ((ptr = wcsstr(ptrl, L">")))
+ {
+ memmove(ptrl+7,ptr,wcslen(ptr)*2+2);
+ *(ptrl+7)=L']';
+ ptr=ptrl+7;
+ wchar_t* s1 = wcsstr(ptr,L"</font");
+ wchar_t* s2 = wcsstr(ptr,L"<font color=\"");
+ if (s1&&s1<s2||s1&&!s2)
+ {
+ ptr=s1;
+ memmove(ptr+1, ptr, wcslen(ptr)*2 + 2);
+ memcpy(ptr,L"[/color]",8*2);
+ }
+ else if(s2&&s2<s1||s2&&!s1)
+ {
+ ptr=s2;
+ memmove(ptr+8, ptr, wcslen(ptr)*2 + 2);
+ memcpy(ptr,L"[/color]",8*2);
+ }
+ else
+ {
+ ptr=dest;
+ memcpy(&ptr[wcslen(ptr)],L"[/color]",9*2);
+ }
+ }
+ else
+ rptr++;
+ }
+ rptr = dest;
+ while ((ptr = wcsstr(rptr, L"<FONT COLOR=")) || (ptr = wcsstr(rptr, L"<font color=")))
+ {
+ int addr=ptr-rptr;
+ dest=renew(dest,wcslen(dest)*2+2,7*2);
+ rptr=dest;
+ ptr=rptr+addr;
+ ptrl = ptr + 5;
+ memcpy(ptrl,L"[color=",7*2);
+ memmove(ptr, ptrl, wcslen(ptrl)*2 + 2);
+ if ((ptr = wcsstr(ptrl, L">")))
+ {
+ *(ptr)=L']';
+ if ((ptrl = wcsstr(ptr, L"</FONT")) || (ptrl = wcsstr(ptr, L"</font")))
+ {
+ memmove(ptrl+1, ptrl, wcslen(ptrl)*2 + 2);
+ memcpy(ptrl,L"[/color]",8*2);
+ }
+ else
+ {
+ memcpy(&dest[wcslen(dest)],L"[/color]",9*2);
+ }
+ }
+ else
+ rptr++;
+ }
+ return dest;
+}
+char* bbcodes_to_html(const char *src)
+{
+ wchar_t* buf=new wchar_t[strlen(src)+1];
+ MultiByteToWideChar(CP_ACP, 0, src, -1,buf,(strlen(src)+1)*2);
+ wchar_t* stripped_buf=bbcodes_to_html(buf);
+ delete[] buf;
+ char* dest=new char[wcslen(stripped_buf)+1];
+ WideCharToMultiByte( CP_ACP, 0, stripped_buf, -1,dest,wcslen(stripped_buf)+1, NULL, NULL );
+ delete[] stripped_buf;
+ return dest;
+}
+wchar_t* bbcodes_to_html(const wchar_t *src)
+{
+ wchar_t *ptr;
+ wchar_t *rptr;
+ wchar_t* dest=wcsldup(src,wcslen(src));
+ while ((ptr = wcsstr(dest, L"[b]")) != NULL) {
+ *ptr = L'<';
+ *(ptr+1) = L'b';
+ *(ptr+2) = L'>';
+ }
+ while ((ptr = wcsstr(dest, L"[/b]")) != NULL) {
+ *ptr = L'<';
+ *(ptr+2) = L'b';
+ *(ptr+3) = L'>';
+ }
+ while ((ptr = wcsstr(dest, L"[i]")) != NULL) {
+ *ptr = L'<';
+ *(ptr+1) = L'i';
+ *(ptr+2) = L'>';
+ }
+ while ((ptr = wcsstr(dest, L"[/i]")) != NULL) {
+ *ptr = L'<';
+ *(ptr+2) = L'i';
+ *(ptr+3) = L'>';
+ }
+ while ((ptr = wcsstr(dest, L"[u]")) != NULL) {
+ *ptr = L'<';
+ *(ptr+1) = L'u';
+ *(ptr+2) = L'>';
+ }
+ while ((ptr = wcsstr(dest, L"[/u]")) != NULL) {
+ *ptr = L'<';
+ *(ptr+2) = L'u';
+ *(ptr+3) = L'>';
+ }
+ rptr = dest;
+ while ((ptr = wcsstr(rptr, L"[color=")))
+ {
+ int addr=ptr-rptr;
+ dest=renew(dest,wcslen(dest)+2,7);
+ rptr=dest;
+ ptr=rptr+addr;
+ memmove(ptr+5, ptr, wcslen(ptr)*sizeof(wchar_t) + 2);
+ memcpy(ptr,L"<font ",6*sizeof(wchar_t));
+ if ((ptr = wcsstr(ptr,L"]")))
+ {
+ *(ptr)=L'>';
+ if ((ptr = wcsstr(ptr,L"[/color]")))
+ {
+ memcpy(ptr,L"</font>",7*sizeof(wchar_t));
+ memmove(ptr+7,ptr+8,wcslen(ptr+8)*sizeof(wchar_t)+2);
+ }
+ }
+ else
+ rptr++;
+ }
+ while ((ptr = wcsstr(rptr, L"[url=")))
+ {
+ int addr=ptr-rptr;
+ dest=renew(dest,wcslen(dest)+2,7);
+ rptr=dest;
+ ptr=rptr+addr;
+ memmove(ptr+3, ptr, wcslen(ptr)+2);
+ memcpy(ptr,L"<a href",7);
+ if ((ptr = wcsstr(ptr, L"]")))
+ {
+ *(ptr)=L'>';
+ if ((ptr = wcsstr(ptr, L"[/url]")))
+ {
+ memcpy(ptr,L"</a>",4*sizeof(wchar_t));
+ memmove(ptr+4,ptr+6,wcslen(ptr+6)*sizeof(wchar_t)+2);
+ }
+ }
+ else
+ rptr++;
+ }
+ return dest;
+}
+void strip_tag(char* begin, char* end)
+{
+ memmove(begin,end+1,lstrlen(end+1)+1);
+}
+void strip_tag(wchar_t* begin, wchar_t* end)
+{
+ memmove(begin,end+1,wcslen(end+1)+2);
+}
+//strip a tag within a string
+char* strip_tag_within(char* begin, char* end)
+{
+ while(char* sub_begin=strstr(begin,"<"))
+ {
+ if(sub_begin<end)//less than the original ending
+ {
+ char* sub_end=strstr(begin,">");
+ strip_tag(sub_begin,sub_end);
+ end=end-(sub_end-sub_begin)-1;
+ }
+ else
+ break;
+ }
+ return end;
+}
+//strip a tag within a string
+wchar_t* strip_tag_within(wchar_t* begin, wchar_t* end)
+{
+ while(wchar_t* sub_begin=wcsstr(begin,L"<"))
+ {
+ if(sub_begin<end)//less than the original ending
+ {
+ wchar_t* sub_end=wcsstr(begin,L">");
+ strip_tag(sub_begin,sub_end);
+ end=end-(sub_end-sub_begin)-1;
+ }
+ else
+ break;
+ }
+ return end;
+}
+char* rtf_to_html(HWND hwndDlg,int DlgItem)
+{
+ char* buf=new char[4024];
+ int pos=0;
+ int start=0;
+ int end=1;
+ BOOL Bold=false;
+ BOOL Italic=false;
+ BOOL Underline=false;
+ char Face[32]="\0";
+ COLORREF Color;
+ COLORREF BackColor;
+ int Size=0;
+ GETTEXTLENGTHEX tl;
+ tl.flags=GTL_DEFAULT;
+ tl.codepage=CP_ACP;
+ int length=SendDlgItemMessage(hwndDlg, DlgItem, EM_GETTEXTLENGTHEX,(WPARAM)&tl,0);
+ while(start<length)
+ {
+ SendDlgItemMessage(hwndDlg, DlgItem, EM_SETSEL, start, end);
+ CHARFORMAT2 cfOld;
+ cfOld.cbSize = sizeof(CHARFORMAT2);
+ cfOld.dwMask = CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_SIZE|CFM_COLOR|CFM_BACKCOLOR|CFM_FACE;
+ SendDlgItemMessage(hwndDlg, DlgItem, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cfOld);
+ BOOL isBold = (cfOld.dwEffects & CFE_BOLD) && (cfOld.dwMask & CFM_BOLD);
+ BOOL isItalic = (cfOld.dwEffects & CFE_ITALIC) && (cfOld.dwMask & CFM_ITALIC);
+ BOOL isUnderline = (cfOld.dwEffects & CFE_UNDERLINE) && (cfOld.dwMask & CFM_UNDERLINE);
+ COLORREF isColor=cfOld.crTextColor;
+ COLORREF isBackColor=cfOld.crBackColor;
+ int isSize;
+ if(cfOld.yHeight==38*20)
+ isSize=7;
+ else if(cfOld.yHeight==24*20)
+ isSize=6;
+ else if(cfOld.yHeight==18*20)
+ isSize=5;
+ else if(cfOld.yHeight==14*20)
+ isSize=4;
+ else if(cfOld.yHeight==12*20)
+ isSize=3;
+ else if(cfOld.yHeight==10*20)
+ isSize=2;
+ else if(cfOld.yHeight==8*20)
+ isSize=1;
+ else
+ isSize=3;
+ char text[2];
+ SendDlgItemMessage(hwndDlg, DlgItem, EM_GETSELTEXT, 0, (LPARAM)&text);
+ if(Bold!=isBold)
+ {
+ Bold=isBold;
+ if(isBold)
+ {
+ strlcpy(&buf[pos],"<b>",4);
+ pos+=3;
+ }
+ else
+ {
+ if(start!=0)
+ {
+ strlcpy(&buf[pos],"</b>",5);
+ pos+=4;
+ }
+ }
+ }
+ if(Italic!=isItalic)
+ {
+ Italic=isItalic;
+ if(isItalic)
+ {
+ strlcpy(&buf[pos],"<i>",4);
+ pos+=3;
+ }
+ else
+ {
+ if(start!=0)
+ {
+ strlcpy(&buf[pos],"</i>",5);
+ pos+=4;
+ }
+ }
+ }
+ if(Underline!=isUnderline)
+ {
+ Underline=isUnderline;
+ if(isUnderline)
+ {
+ strlcpy(&buf[pos],"<u>",4);
+ pos+=3;
+ }
+ else
+ {
+ if(start!=0)
+ {
+ strlcpy(&buf[pos],"</u>",5);
+ pos+=4;
+ }
+ }
+ }
+ if(Size!=isSize||Color!=isColor||BackColor!=isBackColor||strcmp(Face,cfOld.szFaceName))
+ {
+ Size=isSize;
+ Color=isColor;
+ BackColor=isBackColor;
+ strlcpy(Face,cfOld.szFaceName,strlen(cfOld.szFaceName)+1);
+ if(start!=0)
+ {
+ strlcpy(&buf[pos],"</font>",8);
+ pos+=7;
+ }
+ strlcpy(&buf[pos],"<font",6);
+ pos+=5;
+ strlcpy(&buf[pos]," face=\"",8);
+ pos+=7;
+ strlcpy(&buf[pos],Face,strlen(Face)+1);
+ pos+=strlen(Face);
+ strlcpy(&buf[pos],"\"",2);
+ pos++;
+ if(!(cfOld.dwEffects & CFE_AUTOBACKCOLOR))
+ {
+ strlcpy(&buf[pos]," back=#",7);
+ pos+=6;
+ char chBackColor[7];
+ _itoa((_htonl(BackColor)>>8),chBackColor,16);
+ int len=strlen(chBackColor);
+ if(len<6)
+ {
+ memmove(chBackColor+(6-len),chBackColor,len+1);
+ for(int i=0;i<6;i++)
+ chBackColor[i]='0';
+ }
+ strlcpy(&buf[pos],chBackColor,7);
+ pos+=6;
+ }
+ if(!(cfOld.dwEffects & CFE_AUTOCOLOR))
+ {
+ strlcpy(&buf[pos]," color=#",9);
+ pos+=8;
+ char chColor[7];
+ _itoa((_htonl(Color)>>8),chColor,16);
+ int len=strlen(chColor);
+ if(len<6)
+ {
+ memmove(chColor+(6-len),chColor,len+1);
+ for(int i=0;i<6;i++)
+ chColor[i]='0';
+ }
+ strlcpy(&buf[pos],chColor,7);
+ pos+=6;
+ }
+ strlcpy(&buf[pos]," size=",7);
+ pos+=6;
+ char chSize[2];
+ _itoa(Size,chSize,10);
+ strlcpy(&buf[pos],chSize,2);
+ pos++;
+
+ strlcpy(&buf[pos],">",2);
+ pos++;
+ }
+ if(text[0]=='\r')
+ {
+ strlcpy(&buf[pos],"<br>",5);
+ pos+=4;
+ }
+ else
+ {
+ strlcpy(&buf[pos],text,2);
+ pos++;
+ }
+ start++;
+ end++;
+ }
+ if(Bold)
+ {
+ strlcpy(&buf[pos],"</b>",5);
+ pos+=4;
+ }
+ if(Italic)
+ {
+ strlcpy(&buf[pos],"</i>",5);
+ pos+=4;
+ }
+ if(Underline)
+ {
+ strlcpy(&buf[pos],"</u>",5);
+ pos+=4;
+ }
+ strlcpy(&buf[pos],"</font>",8);
+ pos+=7;
+ return buf;
+}
+#if _MSC_VER
+#pragma warning( default: 4706 )
+#endif
diff --git a/nohtml/conv.h b/nohtml/conv.h
new file mode 100644
index 0000000..4040de3
--- /dev/null
+++ b/nohtml/conv.h
@@ -0,0 +1,33 @@
+#ifndef CONV_H
+#define CONV_H
+char* strip_html(char *src);
+wchar_t* strip_html(wchar_t *src);//wide char version
+char* strip_carrots(char *src);
+wchar_t* strip_carrots(wchar_t *src);//wide char version
+char* strip_linebreaks(char *src);
+void wcs_htons(wchar_t * ch);
+char* html_to_bbcodes(char *src);
+wchar_t* html_to_bbcodes(wchar_t *src);//wchar_t version
+char* bbcodes_to_html(const char *src);
+wchar_t* bbcodes_to_html(const wchar_t *src);//wchar_t version
+void strip_tag(char* begin, char* end);
+char* strip_tag_within(char* begin, char* end);
+void strip_tag(wchar_t* begin, wchar_t* end);
+wchar_t* strip_tag_within(wchar_t* begin, wchar_t* end);
+char* rtf_to_html(HWND hwndDlg,int DlgItem);
+
+template <class T>
+T* renew(T* src, int size, int size_chg)
+{
+ T* dest=new T[size+size_chg];
+ memcpy(dest,src,size*sizeof(T));
+ delete[] src;
+ return dest;
+}
+
+inline unsigned long _htonl(unsigned long s)
+{
+ return (s&0x000000ff)<<24|(s&0x0000ff00)<<8|(s&0x00ff0000)>>8|(s&0xff000000)>>24;
+}
+
+#endif
diff --git a/nohtml/filter.cpp b/nohtml/filter.cpp
new file mode 100644
index 0000000..4d3ed77
--- /dev/null
+++ b/nohtml/filter.cpp
@@ -0,0 +1,126 @@
+#include "common.h"
+#include "filter.h"
+#include "options.h"
+#include "conv.h"
+
+int FilterSendMessage(WPARAM wParam, LPARAM lParam) {
+ CCSDATA *ccs = (CCSDATA *) lParam;
+ char *message = (char *)ccs->lParam;
+
+ // TODO: process 'message' and/or 'messagew' below
+ if(ccs->wParam & PREF_UNICODE) {
+ wchar_t *messagew = (wchar_t *)&message[strlen(message)+1];
+ } else {
+ }
+
+ return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
+}
+
+int FilterSendMessageW(WPARAM wParam, LPARAM lParam) {
+ CCSDATA *ccs = (CCSDATA *) lParam;
+ ccs->wParam |= PREF_UNICODE;
+
+ return FilterSendMessage(wParam, lParam);
+}
+
+int FilterRecvMessage(WPARAM wParam, LPARAM lParam) {
+ CCSDATA *ccs = (CCSDATA *) lParam;
+ PROTORECVEVENT *pre = (PROTORECVEVENT *) ccs->lParam;
+
+ char *old_message = pre->szMessage;
+
+ char* buf = 0;
+ if(ccs->wParam & PREF_UNICODE) {
+ wchar_t *messagew = (wchar_t *)&old_message[strlen(old_message)+1];
+ //LOG("Recieved a unicode message.");
+ wchar_t* wbuf=(wchar_t*)&pre->szMessage[lstrlen(pre->szMessage)+1];
+ wchar_t* st_wbuf;
+ if(options.bbcodes)
+ {
+ //LOG("Converting from html to bbcodes then stripping leftover html.(U)");
+ wchar_t* bbuf=html_to_bbcodes(wbuf);
+ st_wbuf=strip_html(bbuf);
+ delete[] bbuf;
+ }
+ else
+ {
+ //LOG("Stripping html.(U)");
+ st_wbuf=strip_html(wbuf);
+ }
+ //delete[] pre->szMessage; not necessary - done in server.cpp
+ buf=(char *)malloc(wcslen(st_wbuf)*3+3);
+ WideCharToMultiByte( CP_ACP, 0,st_wbuf, -1,buf,wcslen(st_wbuf)+1, NULL, NULL);
+ memcpy(&buf[strlen(buf)+1],st_wbuf,lstrlen(buf)*2+2);
+ delete[] st_wbuf;
+ pre->szMessage = buf;
+ } else {
+ //LOG("Recieved a non-unicode message.");
+ if(options.bbcodes)
+ {
+ //LOG("Converting from html to bbcodes then stripping leftover html.");
+ char* bbuf=html_to_bbcodes(pre->szMessage);
+ buf=strip_html(bbuf);
+ delete[] bbuf;
+ }
+ else
+ {
+ //LOG("Stripping html.");
+ buf=strip_html(pre->szMessage);
+ }
+ pre->szMessage = buf;
+ }
+
+ int ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam);
+ pre->szMessage = old_message;
+ return ret;
+}
+
+int NewContact(WPARAM wParam, LPARAM lParam) {
+ // add filter
+ HANDLE hContact = (HANDLE)wParam;
+ CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM )hContact, ( LPARAM )MODULE );
+
+ return 0;
+}
+
+void RegisterFilter() {
+ PROTOCOLDESCRIPTOR pd = {0};
+ pd.cbSize = sizeof(pd);
+ pd.szName = MODULE "Filter";
+ // TODO: modify this to reflect the purpose of your plugin
+ pd.type = PROTOTYPE_FILTER;
+ CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
+}
+
+HANDLE hEventNewContact;
+#define NUM_FILTER_SERVICES 3
+HANDLE hServices[NUM_FILTER_SERVICES];
+
+void AddFilterToContacts() {
+ // this adds us as a filter to all existing and new contacts
+ // TODO: modify this (and the NewContact function above) to include only the contacts required
+ HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 );
+ while ( hContact != NULL ) {
+ CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM )hContact, ( LPARAM )(MODULE "Filter"));
+ hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 );
+ }
+
+ hEventNewContact = HookEvent(ME_DB_CONTACT_ADDED, NewContact);
+}
+
+void CreateFilterServices() {
+ // create our services
+ int i = 0;
+ hServices[i++] = CreateProtoServiceFunction(MODULE "Filter", PSS_MESSAGE, FilterSendMessage);
+ hServices[i++] = CreateProtoServiceFunction(MODULE "Filter", PSS_MESSAGE"W", FilterSendMessageW);
+ hServices[i++] = CreateProtoServiceFunction(MODULE "Filter", PSR_MESSAGE, FilterRecvMessage);
+
+ // remember to modify the NUM_FILTER_SERVICES #define above if you add more services!
+}
+
+void DeinitFilter() {
+ UnhookEvent(hEventNewContact);
+
+ for(int i = 0; i < NUM_FILTER_SERVICES; i++)
+ DestroyServiceFunction(hServices[i]);
+} \ No newline at end of file
diff --git a/nohtml/filter.h b/nohtml/filter.h
new file mode 100644
index 0000000..0a42110
--- /dev/null
+++ b/nohtml/filter.h
@@ -0,0 +1,9 @@
+#ifndef _FILTER_INC
+#define _FILTER_INC
+
+void RegisterFilter();
+void AddFilterToContacts();
+void CreateFilterServices();
+void DeinitFilter();
+
+#endif
diff --git a/nohtml/nohtml.cpp b/nohtml/nohtml.cpp
new file mode 100644
index 0000000..8cf58c6
--- /dev/null
+++ b/nohtml/nohtml.cpp
@@ -0,0 +1,104 @@
+/* Replace "dll.h" with the name of your header */
+#include "common.h"
+#include "version.h"
+#include "resource.h"
+#include "options.h"
+#include "filter.h"
+
+///////////////////////////////////////////////
+// Common Plugin Stuff
+///////////////////////////////////////////////
+HINSTANCE hInst;
+PLUGINLINK *pluginLink;
+
+PLUGININFOEX pluginInfo={
+ sizeof(PLUGININFOEX),
+ //META_PROTO,
+ __PLUGIN_NAME, // altered here and on file listing, so as not to match original
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESC,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ 0,
+ 0,
+ // TODO: generate your own GUID!!
+ { 0xD78C8249, 0xE8DB, 0x46B1, { 0x92, 0xF3, 0x88, 0xE6, 0xDC, 0x96, 0x4E, 0x8D } }
+};
+
+
+extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) {
+ hInst=hinstDLL;
+ return TRUE;
+}
+
+extern "C" __declspec (dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) {
+ return &pluginInfo;
+}
+
+extern "C" __declspec (dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion) {
+ pluginInfo.cbSize = sizeof(PLUGININFO);
+ return (PLUGININFO*)&pluginInfo;
+}
+
+static const MUUID interfaces[] = {MIID_NOHTML, MIID_LAST};
+extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
+{
+ return interfaces;
+}
+
+int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
+ if(ServiceExists(MS_UPDATE_REGISTER)) {
+ // register with updater
+ Update update = {0};
+ char szVersion[16];
+
+ update.cbSize = sizeof(Update);
+
+ update.szComponentName = pluginInfo.shortName;
+ update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion);
+ update.cpbVersion = strlen((char *)update.pbVersion);
+
+ update.szUpdateURL = UPDATER_AUTOREGISTER;
+
+ // these are the three lines that matter - the archive, the page containing the version string, and the text (or data)
+ // before the version that we use to locate it on the page
+ // (note that if the update URL and the version URL point to standard file listing entries, the backend xml
+ // data will be used to check for updates rather than the actual web page - this is not true for beta urls)
+ update.szBetaUpdateURL = "http://www.scottellis.com.au/miranda_plugins/nohtml.zip";
+ update.szBetaVersionURL = "http://www.scottellis.com.au/miranda_plugins/ver_nohtml.html";
+ update.pbBetaVersionPrefix = (BYTE *)"No HTML version ";
+
+ update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix);
+
+ CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
+ }
+
+
+ return 0;
+}
+
+HANDLE hModulesLoaded;
+extern "C" __declspec (dllexport) int Load(PLUGINLINK *link) {
+ pluginLink=link;
+
+ InitOptions();
+
+ /////////////
+ ////// init filter
+ RegisterFilter();
+ AddFilterToContacts();
+
+ // hook modules loaded
+ hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ return 0;
+}
+
+extern "C" __declspec (dllexport) int Unload(void) {
+ UnhookEvent(hModulesLoaded);
+ DeinitFilter();
+ DeinitOptions();
+
+ return 0;
+}
diff --git a/nohtml/nohtml.rc b/nohtml/nohtml.rc
new file mode 100644
index 0000000..1389299
--- /dev/null
+++ b/nohtml/nohtml.rc
@@ -0,0 +1,76 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral (Default) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPT1 DIALOGEX 0, 0, 246, 179
+STYLE DS_SETFONT | WS_POPUP
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+ CONTROL "Replace HTML with BBCodes",IDC_CHK_BBCODES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,65,74,111,10
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // Neutral (Default) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/nohtml/nohtml.sln b/nohtml/nohtml.sln
new file mode 100644
index 0000000..dfd1856
--- /dev/null
+++ b/nohtml/nohtml.sln
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nohtml", "nohtml.vcproj", "{35961A10-6297-47AA-A6D9-1713389AC5F9}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug (Unicode)|Win32 = Debug (Unicode)|Win32
+ Debug|Win32 = Debug|Win32
+ Release (Unicode)|Win32 = Release (Unicode)|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {35961A10-6297-47AA-A6D9-1713389AC5F9}.Debug (Unicode)|Win32.ActiveCfg = Release|Win32
+ {35961A10-6297-47AA-A6D9-1713389AC5F9}.Debug (Unicode)|Win32.Build.0 = Release|Win32
+ {35961A10-6297-47AA-A6D9-1713389AC5F9}.Debug|Win32.ActiveCfg = Debug|Win32
+ {35961A10-6297-47AA-A6D9-1713389AC5F9}.Debug|Win32.Build.0 = Debug|Win32
+ {35961A10-6297-47AA-A6D9-1713389AC5F9}.Release (Unicode)|Win32.ActiveCfg = Release|Win32
+ {35961A10-6297-47AA-A6D9-1713389AC5F9}.Release (Unicode)|Win32.Build.0 = Release|Win32
+ {35961A10-6297-47AA-A6D9-1713389AC5F9}.Release|Win32.ActiveCfg = Release|Win32
+ {35961A10-6297-47AA-A6D9-1713389AC5F9}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/nohtml/nohtml.vcproj b/nohtml/nohtml.vcproj
new file mode 100644
index 0000000..fcd5a30
--- /dev/null
+++ b/nohtml/nohtml.vcproj
@@ -0,0 +1,295 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="nohtml"
+ ProjectGUID="{35961A10-6297-47AA-A6D9-1713389AC5F9}"
+ RootNamespace="nohtml"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="_DEBUG;_WINDOWS;_USERDLL"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="common.h"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="NDEBUG;_WINDOWS;_USERDLL"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="common.h"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\common.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\conv.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\filter.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\nohtml.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\options.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\strl.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\common.h"
+ >
+ </File>
+ <File
+ RelativePath=".\conv.h"
+ >
+ </File>
+ <File
+ RelativePath=".\filter.h"
+ >
+ </File>
+ <File
+ RelativePath=".\options.h"
+ >
+ </File>
+ <File
+ RelativePath=".\resource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\strl.h"
+ >
+ </File>
+ <File
+ RelativePath=".\version.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath=".\nohtml.rc"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\resource.rc"
+ >
+ </File>
+ <File
+ RelativePath=".\version.rc"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\readme.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/nohtml/options.cpp b/nohtml/options.cpp
new file mode 100644
index 0000000..3eb06ca
--- /dev/null
+++ b/nohtml/options.cpp
@@ -0,0 +1,68 @@
+#include "common.h"
+#include "options.h"
+#include "resource.h"
+
+Options options;
+
+void LoadOptions() {
+ DBWriteContactSettingDword(0, MODULE, "BBCodes", options.bbcodes ? 1 : 0);
+}
+
+void SaveOptions() {
+ options.bbcodes = (DBGetContactSettingDword(0, MODULE, "BBCodes", 0) != 0);
+}
+
+BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+ static HANDLE hItemAll;
+
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault( hwndDlg );
+ return FALSE;
+ case WM_COMMAND:
+ break;
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ options.bbcodes = IsDlgButtonChecked(hwndDlg, IDC_CHK_BBCODES);
+ SaveOptions();
+ break;
+ }
+ break;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+int OptInit(WPARAM wParam, LPARAM lParam) {
+ OPTIONSDIALOGPAGE odp = { 0 };
+ odp.cbSize = sizeof(odp);
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.flags |= ODPF_TCHAR;
+ odp.position = -790000000;
+ odp.hInstance = hInst;
+
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT1);
+ odp.ptszTitle = TranslateT(MODULE);
+ odp.ptszGroup = TranslateT("Plugins");
+ odp.nIDBottomSimpleControl = 0;
+ odp.pfnDlgProc = DlgProcOpts;
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+
+ return 0;
+}
+
+HANDLE hEventOptInit;
+void InitOptions() {
+ hEventOptInit = HookEvent(ME_OPT_INITIALISE, OptInit);
+ LoadOptions();
+}
+
+void DeinitOptions() {
+ UnhookEvent(hEventOptInit);
+}
diff --git a/nohtml/options.h b/nohtml/options.h
new file mode 100644
index 0000000..f679ad6
--- /dev/null
+++ b/nohtml/options.h
@@ -0,0 +1,13 @@
+#ifndef _OPTIONS_INC
+#define _OPTIONS_INC
+
+typedef struct {
+ bool bbcodes;
+} Options;
+
+extern Options options;
+
+void InitOptions();
+void DeinitOptions();
+
+#endif
diff --git a/nohtml/readme.txt b/nohtml/readme.txt
new file mode 100644
index 0000000..b1f1008
--- /dev/null
+++ b/nohtml/readme.txt
@@ -0,0 +1,47 @@
+========================================================================
+ Miranda Plugin : nohtml Project Overview
+========================================================================
+
+Miranda Plugin has created this nohtml project for you as a starting point.
+
+This file contains a summary of what you will find in each of the files that make up your project.
+
+nohtml.vcproj
+ This is the main project file for projects generated using an Application Wizard.
+ It contains information about the version of the product that generated the file, and
+ information about the platforms, configurations, and project features selected with the
+ Application Wizard.
+
+nohtml.cpp
+ Main plugin file. Contains the functions necessary for the plugin to load.
+
+nohtml.rc
+ Project resources - this is the the only resource file that should require editing on your part!
+ This file contains for example the options dialog page.
+
+version.h
+ Version information
+
+version.rc
+ Version resource - do not edit!
+
+common.h
+ Common includes - also acts as the procompiled header file for the project.
+
+common.cpp
+ Just includes the common.h header file.
+
+resource.h
+ Resource defines
+
+resource.rc
+ Binds together the version and plugin resources - do not edit!
+
+options.cpp
+options.h
+ These files contain the dialog procedure for the options page, and placeholders for options including save and load routines.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/nohtml/resource.h b/nohtml/resource.h
new file mode 100644
index 0000000..ebcf9c7
--- /dev/null
+++ b/nohtml/resource.h
@@ -0,0 +1,17 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by nohtml.rc
+//
+#define IDD_OPT1 109
+#define IDC_CHK_BBCODES 1001
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 120
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1002
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/nohtml/resource.rc b/nohtml/resource.rc
new file mode 100644
index 0000000..09c6086
--- /dev/null
+++ b/nohtml/resource.rc
@@ -0,0 +1,2 @@
+#include "version.rc"
+#include "nohtml.rc"
diff --git a/nohtml/strl.cpp b/nohtml/strl.cpp
new file mode 100644
index 0000000..e4e5e26
--- /dev/null
+++ b/nohtml/strl.cpp
@@ -0,0 +1,104 @@
+/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */
+
+/*-
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "common.h"
+#include "strl.h"
+
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns lstrlen(src); if retval >= siz, truncation occurred.
+ */
+size_t strlcpy(char* dst,const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0) {
+ do {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
+size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
+{
+ wchar_t *d = dst;
+ const wchar_t *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0) {
+ do {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
+char* strldup(const char* src,size_t siz)
+{
+ char* dst=new char[siz+1];
+ memcpy(dst,src,siz+1);
+ return dst;
+}
+wchar_t* wcsldup(const wchar_t* src,size_t siz)
+{
+ wchar_t* dst=new wchar_t[siz+1];
+ memcpy(dst,src,siz*2+2);
+ return dst;
+}
+char* strlcat(const char* dst,const char *src)
+{
+ char* nstr=new char[lstrlen(dst)+lstrlen(src)+1];
+ memcpy(nstr,dst,lstrlen(dst));
+ memcpy(&nstr[lstrlen(dst)],src,lstrlen(src)+1);
+ return nstr;
+}
diff --git a/nohtml/strl.h b/nohtml/strl.h
new file mode 100644
index 0000000..e64b3d1
--- /dev/null
+++ b/nohtml/strl.h
@@ -0,0 +1,10 @@
+#ifndef STRL_H
+#define STRL_H
+#include <stdio.h>
+#include <windows.h>
+size_t strlcpy(char* dst,const char *src, size_t siz);
+size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz);
+char* strldup(const char* src,size_t siz);
+wchar_t* wcsldup(const wchar_t* src,size_t siz);
+char* strlcat(const char* dst,const char *src);
+#endif
diff --git a/nohtml/version.h b/nohtml/version.h
new file mode 100644
index 0000000..494e474
--- /dev/null
+++ b/nohtml/version.h
@@ -0,0 +1,26 @@
+// Set the version number here - it will affect the version resource and the version field of the pluginInfo structure
+// (Be careful that you don't have the resource file open when you change this and rebuild, otherwise the changes may not
+// take effect within the version resource)
+
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 0
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 1
+
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
+#define __STRINGIFY(x) #x
+#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS)
+
+#ifdef _UNICODE
+#define __PLUGIN_NAME "nohtml (Unicode)"
+#else
+#define __PLUGIN_NAME "nohtml"
+#endif
+#define __FILENAME "nohtml.dll"
+
+#define __DESC "Removes HTML from incomming messages, optinally replacing them with bbcodes"
+#define __AUTHOR "Scott Ellis"
+#define __AUTHOREMAIL "mail@scottellis.com.au"
+#define __AUTHORWEB "http://www.scottellis.com.au"
+#define __COPYRIGHT "© 2007 Scott Ellis"
diff --git a/nohtml/version.rc b/nohtml/version.rc
new file mode 100644
index 0000000..0bb7a49
--- /dev/null
+++ b/nohtml/version.rc
@@ -0,0 +1,33 @@
+
+#include <windows.h>
+#include "version.h"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "Author", __AUTHOR
+ VALUE "FileDescription", __DESC
+ VALUE "InternalName", __PLUGIN_NAME
+ VALUE "LegalCopyright", __COPYRIGHT
+ VALUE "OriginalFilename", __FILENAME
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END