$OpenBSD: patch-ECtools_zarafa-search_ECIndexImporterAttachments_cpp,v 1.3 2014/07/03 06:14:40 robert Exp $

OpenBSD does not have RLIMIT_AS.

ECIndexImporterAttachments.cpp:249:34: error: 'max' was not declared in this scope
ECIndexImporterAttachments.cpp:440:3: error: 'string' was not declared in this scope
ECIndexImporterAttachments.cpp:443:4: error: 'set' was not declared in this scope
ECIndexImporterAttachments.cpp:602:46: error: 'min' was not declared in this scope

--- ECtools/zarafa-search/ECIndexImporterAttachments.cpp.orig	Fri May 23 15:56:37 2014
+++ ECtools/zarafa-search/ECIndexImporterAttachments.cpp	Wed Jul  2 17:28:25 2014
@@ -47,6 +47,10 @@
  * 
  */
 
+#include <algorithm>
+#include <set>
+#include <string>
+
 #include <platform.h>
 
 #include <mapi.h>
@@ -78,6 +82,10 @@
 
 using namespace std;
 
+#if defined(__OpenBSD__) && !defined(RLIMIT_AS)
+#define RLIMIT_AS	RLIMIT_DATA
+#endif
+
 ECIndexImporterAttachment::ECIndexImporterAttachment(ECThreadData *lpThreadData, ECIndexImporter *lpIndexer)
 {
 	m_lpThreadData = lpThreadData;
@@ -248,7 +256,7 @@ HRESULT ECIndexImporterAttachment::CopyStreamToParser(
 	ULONG ulWriteData;
 	fd_set rset, wset;
 	int res;
-	int fd = max(ulFpWrite, ulFpRead);
+	int fd = std::max(ulFpWrite, ulFpRead);
 	struct timeval timeout;
 
 
@@ -269,7 +277,7 @@ HRESULT ECIndexImporterAttachment::CopyStreamToParser(
 		FD_ZERO(&wset);
 		if (ulTotalWriteData) {
 			FD_SET(ulFpWrite, &wset);
-			fd = max(ulFpWrite, ulFpRead);
+			fd = std::max(ulFpWrite, ulFpRead);
 		} else {
 			fd = ulFpRead;
 		}
@@ -439,10 +447,10 @@ HRESULT ECIndexImporterAttachment::ParseValueAttachmen
 	command.assign(m_strCommand + " ");
 
 	if (!strMimeTag.empty() && strMimeTag.compare(_T("application/octet-stream")) != 0) {
-		string tmp = trim(convert_to<string>(strMimeTag), "\r\n ");
+		std::string tmp = trim(convert_to<std::string>(strMimeTag), "\r\n ");
 		size_t pos = tmp.find_first_of('/');
 		if (pos != std::string::npos) {
-			set<string, stricmp_comparison>::iterator i = m_lpThreadData->m_setMimeFilter.find(string(tmp,0,pos));
+			std::set<std::string, stricmp_comparison>::iterator i = m_lpThreadData->m_setMimeFilter.find(std::string(tmp,0,pos));
 			if (i != m_lpThreadData->m_setMimeFilter.end()) {
 				m_lpThreadData->lpLogger->Log(EC_LOGLEVEL_DEBUG, "Skipping filtered attachment mimetype: %s for %ls", tmp.c_str(), strFilename.c_str());
 				hr = MAPI_E_INVALID_OBJECT;
@@ -454,8 +462,8 @@ HRESULT ECIndexImporterAttachment::ParseValueAttachmen
 		command.append("'");
 	} else if (!strExtension.empty()) {
 		// this string mostly does not exist
-		string tmp = trim(convert_to<string>(strExtension), "\r\n ");
-		set<string, stricmp_comparison>::iterator i = m_lpThreadData->m_setExtFilter.find(string(tmp,1)); // skip dot in extension find
+		std::string tmp = trim(convert_to<std::string>(strExtension), "\r\n ");
+		std::set<std::string, stricmp_comparison>::iterator i = m_lpThreadData->m_setExtFilter.find(std::string(tmp,1)); // skip dot in extension find
 		if (i != m_lpThreadData->m_setExtFilter.end()) {
 			m_lpThreadData->lpLogger->Log(EC_LOGLEVEL_DEBUG, "Skipping filtered attachment extension: %s for %ls", tmp.c_str(), strFilename.c_str());
 			hr = MAPI_E_INVALID_OBJECT;
@@ -465,14 +473,14 @@ HRESULT ECIndexImporterAttachment::ParseValueAttachmen
 		command.append(forcealnum(tmp, "."));
 		command.append("'");
 	} else if (!strFilename.empty()) {
-		std::string tmp = trim(convert_to<string>(strFilename), "\r\n ");
+		std::string tmp = trim(convert_to<std::string>(strFilename), "\r\n ");
 		size_t pos = tmp.find_last_of('.');
 		if (pos == std::string::npos)
 			goto exit;
 
 		
 		// skip dot in find
-		set<string, stricmp_comparison>::iterator i = m_lpThreadData->m_setExtFilter.find(string(tmp, pos+1));
+		std::set<std::string, stricmp_comparison>::iterator i = m_lpThreadData->m_setExtFilter.find(std::string(tmp, pos+1));
 		if (i != m_lpThreadData->m_setExtFilter.end()) {
 			m_lpThreadData->lpLogger->Log(EC_LOGLEVEL_DEBUG, "Skipping filtered attachment extension: %ls", strFilename.c_str());
 			hr = MAPI_E_INVALID_OBJECT;
@@ -480,7 +488,7 @@ HRESULT ECIndexImporterAttachment::ParseValueAttachmen
 		}
 
 		command.append("ext '");
-		command.append(forcealnum(string(tmp, pos), "."));
+		command.append(forcealnum(std::string(tmp, pos), "."));
 		command.append("'");
 	} else {
 		m_lpThreadData->lpLogger->Log(EC_LOGLEVEL_DEBUG, "Invalid attachment, no mimetag, extension or filename");
@@ -601,7 +609,7 @@ HRESULT ECIndexImporterAttachment::ParseAttachment(fol
 	if (ulAttachSize) {
 		/* Copy attachment data into stream */
 		while (TRUE) {
-			ULONG ulRead = min(m_ulCache, ulAttachSize);
+			ULONG ulRead = std::min(m_ulCache, ulAttachSize);
 			ULONG ulCopy = ulRead;
 			ULONG ulWritten = 0;
 
