diff -u -r --new-file src.orig/dkimbase.cpp src/dkimbase.cpp
--- src.orig/dkimbase.cpp	2007-02-22 13:40:00.000000000 +0100
+++ src/dkimbase.cpp	2008-06-05 15:45:15.000000000 +0200
@@ -27,7 +27,6 @@
 
 #include <algorithm>
 
-
 CDKIMBase::CDKIMBase()
 {
 	m_From = NULL;
@@ -122,7 +121,7 @@
 
 	while( p < e )
 	{
-		if( *p != '\n' || m_LinePos == 0 || m_Line[m_LinePos-1] != '\r' )
+		if(*p != '\n' && *p != '\r' )
 		{
 			// add char to line
 			if (m_LinePos >= m_LineSize)
@@ -135,13 +134,13 @@
 		}
 		else
 		{
-			// back up past the CR
-			m_LinePos--;
-
-			if( m_LinePos == 0 )
+			if(*p == '\r' && p+1<e && *(p+1)=='\n') p++;
+			if( m_LinePos==0 )
 			{
 				// empty line found.  count it but do not process it
 				m_EmptyLineCount++;
+				m_LinePos=0;
+
 			}
 			else
 			{
diff -u -r --new-file src.orig/dkim.h src/dkim.h
--- src.orig/dkim.h	2007-09-04 14:38:00.000000000 +0200
+++ src/dkim.h	2008-06-05 15:45:15.000000000 +0200
@@ -159,6 +159,10 @@
 
 char *DKIM_CALL DKIMGetErrorString( int ErrorCode );
 
+#ifndef _WIN32
+#include "macros.h"
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff -u -r --new-file src.orig/libdkimtest.cpp src/libdkimtest.cpp
--- src.orig/libdkimtest.cpp	2007-02-22 17:05:00.000000000 +0100
+++ src/libdkimtest.cpp	2008-06-05 15:58:35.000000000 +0200
@@ -35,8 +35,24 @@
 	return 0;
 }
 
+void usage()
+{
 
-
+	printf( "\nAlt-N Technologies DKIM Project 1.0.17 <http://libdkim.sourceforge.net/>\n\n");
+	printf( "usage: libdkimtest [-b<1|2|3>] [-c<r|s|t|u>] [-d<domain tag>] [-l] [-h] [-i<user@domain.TLD>] [-q] [-s] [-t] [-v] [-x<expire time>] [-z<hash>] <msgfile> <privkeyfile> <outfile>\n\n");
+	printf( "-b<standard>         1=allman, 2=ietf, 3=both [DEFAULT]\n");
+	printf( "-c<canonicalization> r=relaxed [DEFAULT], s=simple, t=relaxed/simple, u=simple/relaxed\n");
+	printf( "-d<domain tag>       if not provided it will be determined from the sender/from header\n");
+	printf( "-l                   include body length tag\n");
+	printf( "-h                   this help\n");
+	printf( "-i<identity>         if not provided it will not be included\n");
+	printf( "-s                   sign message\n");
+	printf( "-t                   include timestamp tag\n");
+	printf( "-v                   verify message\n");
+	printf( "-x<expire_time>      expire time in seconds since epoch (DEFAULT=current time+604800). If not set, then it will not be included\n");
+	printf( "-z<hash>             1=sha1, 2=sha256, 3=both [DEFAULT]\n");
+	printf( "-y<selector>         selector tag [DEFAULT=default]\n\n");
+}
 int main(int argc, char* argv[])
 {
 	int n;
@@ -57,13 +73,11 @@
 	time(&t);
 
 	opts.nCanon = DKIM_SIGN_RELAXED;
-	opts.nIncludeBodyLengthTag = 1;
+	opts.nIncludeBodyLengthTag = 0;
 	opts.nIncludeQueryMethod = 0;
 	opts.nIncludeTimeStamp = 0;
 	opts.expireTime = t + 604800;		// expires in 1 week
-	strcpy( opts.szSelector, "MDaemon" );
-	strcpy( opts.szDomain, "bardenhagen.com" );
-	strcpy( opts.szIdentity, "dkimtest@bardenhagen.com" );
+	strcpy( opts.szSelector, "default" );
 	opts.pfnHeaderCallback = SignThisHeader;
 	strcpy( opts.szRequiredHeaders, "NonExistant" );
 	opts.nIncludeCopiedHeaders = 0;
@@ -72,6 +86,11 @@
 	int nArgParseState = 0;
 	bool bSign = true;
 
+	if(argc<2){
+		usage();
+		exit(1);
+	}
+
 	for( n = 1; n < argc; n++ )
 	{
 		if( argv[n][0] == '-' && strlen(argv[n]) > 1 )
@@ -101,14 +120,16 @@
 				}
 				break;
 
-
+			case 'd': 
+				strncpy(opts.szDomain,(const char*)(argv[n]+2),sizeof(opts.szDomain)-1);
+				break;
 			case 'l':		// body length tag
 				opts.nIncludeBodyLengthTag = 1;
 				break;
 
 
 			case 'h':
-				printf( "usage: \n" );
+				usage();	
 				return 0;
 
 			case 'i':		// identity 
@@ -118,7 +139,7 @@
 				}
 				else
 				{
-					strcpy( opts.szIdentity, argv[n] + 2 );
+					strncpy( opts.szIdentity, argv[n] + 2,sizeof(opts.szIdentity)-1 );
 				}
 				break;
 
@@ -149,6 +170,9 @@
 				}
 				break;
 
+			case 'y':
+				strncpy( opts.szSelector, argv[n]+2, sizeof(opts.szSelector)-1);
+				break;
 
 			case 'z':		// sign w/ sha1, sha256 or both 
 				opts.nHash = atoi( &argv[n][2] );
@@ -256,7 +280,7 @@
 
 		DKIMVerifyOptions vopts;
 		vopts.pfnSelectorCallback = NULL; //SelectorCallback;
-		vopts.pfnPolicyCallback = NULL; //PolicyCallback;
+		vopts.pfnPracticesCallback = NULL; //PolicyCallback;
 
 		n = DKIMVerifyInit( &ctxt, &vopts );
 
diff -u -r --new-file src.orig/macros.h src/macros.h
--- src.orig/macros.h	1970-01-01 01:00:00.000000000 +0100
+++ src/macros.h	2008-06-05 15:45:15.000000000 +0200
@@ -0,0 +1,24 @@
+/*
+ * macros.h:  Useful macros
+ *
+ * Author:
+ *	Dick Porter (dick@ximian.com)
+ *
+ * (C) 2002 Ximian, Inc.
+ */
+
+#ifndef _WAPI_MACROS_H_
+#define _WAPI_MACROS_H_
+
+#include <sys/types.h>
+
+#define MAKEWORD(low, high) ((__uint16_t)(((__uint8_t)(low)) | \
+				       ((__uint16_t)((__uint8_t)(high))) << 8))
+#define MAKELONG(low, high) ((__uint32_t)(((__uint16_t)(low)) | \
+				       ((__uint32_t)((__uint16_t)(high))) << 16))
+#define LOWORD(i32) ((__uint16_t)((i32) & 0xFFFF))
+#define HIWORD(i32) ((__uint16_t)(((__uint32_t)(i32) >> 16) & 0xFFFF))
+#define LOBYTE(i16) ((__uint8_t)((i16) & 0xFF))
+#define HIBYTE(i16) ((__uint8_t)(((__uint16_t)(i16) >> 8) & 0xFF))
+
+#endif /* _WAPI_MACROS_H_ */
diff -u -r --new-file src.orig/Makefile src/Makefile
--- src.orig/Makefile	2007-02-22 13:40:00.000000000 +0100
+++ src/Makefile	2008-06-05 15:45:15.000000000 +0200
@@ -1,15 +1,15 @@
 # libdkim makefile for UNIX
 #
 
-#ifdef LINUX
+ifdef LINUX
 CFLAGS  = -c
 LFLAGS  = 
 LIBS    = -lcrypto -lresolv
-#else
+else
 CFLAGS  = -c
 LFLAGS  = 
 LIBS    = -lcrypto 
-#endif
+endif
 
 INCL	=  -I /usr/include/openssl/
 
