Compare commits
4 Commits
BOBS_MPI_E
...
MAPI_TRUNK
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
112cd3f592 | ||
|
|
0e43f0be3f | ||
|
|
2eb83bc94e | ||
|
|
eabbdbd75c |
28
mozilla/mailnews/mapi/makefile.win
Normal file
28
mozilla/mailnews/mapi/makefile.win
Normal file
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Srilatha Moturi <srilatha@netscape.com>
|
||||
# Krishna Mohan Khandrika <kkhandrika@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
DIRS=mapihook resources mapiDll
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
54
mozilla/mailnews/mapi/mapiDll/Mapi32.DEF
Normal file
54
mozilla/mailnews/mapi/mapiDll/Mapi32.DEF
Normal file
@@ -0,0 +1,54 @@
|
||||
; ***** BEGIN LICENSE BLOCK *****
|
||||
; Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
;
|
||||
; The contents of this file are subject to the Mozilla Public License Version
|
||||
; 1.1 (the "License"); you may not use this file except in compliance with
|
||||
; the License. You may obtain a copy of the License at
|
||||
; http://www.mozilla.org/MPL/
|
||||
;
|
||||
; Software distributed under the License is distributed on an "AS IS" basis,
|
||||
; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
; for the specific language governing rights and limitations under the
|
||||
; License.
|
||||
;
|
||||
; The Original Code is Mozilla.
|
||||
;
|
||||
; The Initial Developer of the Original Code is
|
||||
; Netscape Communications Corp.
|
||||
; Portions created by the Initial Developer are Copyright (C) 2001
|
||||
; the Initial Developer. All Rights Reserved.
|
||||
;
|
||||
; Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
;
|
||||
; Alternatively, the contents of this file may be used under the terms of
|
||||
; either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
; the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
; in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
; of those above. If you wish to allow use of your version of this file only
|
||||
; under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
; use your version of this file under the terms of the MPL, indicate your
|
||||
; decision by deleting the provisions above and replace them with the notice
|
||||
; and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
; the provisions above, a recipient may use your version of this file under
|
||||
; the terms of any one of the MPL, the GPL or the LGPL.
|
||||
;
|
||||
; ***** END LICENSE BLOCK *****
|
||||
|
||||
LIBRARY mozMapi32.dll
|
||||
DESCRIPTION 'Mozilla Simple MAPI Support'
|
||||
|
||||
EXPORTS
|
||||
MAPILogon
|
||||
MAPILogoff
|
||||
MAPISendMail
|
||||
MAPISendDocuments
|
||||
MAPIFindNext
|
||||
MAPIReadMail
|
||||
MAPISaveMail
|
||||
MAPIDeleteMail
|
||||
MAPIAddress
|
||||
MAPIDetails
|
||||
MAPIResolveName
|
||||
MAPIFreeBuffer
|
||||
GetMapiDllVersion
|
||||
|
||||
335
mozilla/mailnews/mapi/mapiDll/MapiDll.cpp
Normal file
335
mozilla/mailnews/mapi/mapiDll/MapiDll.cpp
Normal file
@@ -0,0 +1,335 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
* Contributor(s): Rajiv Dayal (rdayal@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <assert.h>
|
||||
#include <mapidefs.h>
|
||||
#include <mapi.h>
|
||||
#include "msgMapi.h"
|
||||
#include "msgMapiMain.h"
|
||||
|
||||
#define MAX_RECIPS 100
|
||||
#define MAX_FILES 100
|
||||
|
||||
const CLSID CLSID_nsMapiImp = {0x29f458be, 0x8866, 0x11d5,
|
||||
{0xa3, 0xdd, 0x0, 0xb0, 0xd0, 0xf3, 0xba, 0xa7}};
|
||||
const IID IID_nsIMapi = {0x6EDCD38E,0x8861,0x11d5,
|
||||
{0xA3,0xDD,0x00,0xB0,0xD0,0xF3,0xBA,0xA7}};
|
||||
|
||||
DWORD tId = 0;
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE aInstance, DWORD aReason, LPVOID aReserved)
|
||||
{
|
||||
switch (aReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH : tId = TlsAlloc();
|
||||
if (tId == 0xFFFFFFFF)
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH : TlsFree(tId);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL InitMozillaReference(nsIMapi **aRetValue)
|
||||
{
|
||||
// Check wehther this thread has a valid Interface
|
||||
// by looking into thread-specific-data variable
|
||||
|
||||
*aRetValue = (nsIMapi *)TlsGetValue(tId);
|
||||
|
||||
// Check whether the pointer actually resolves to
|
||||
// a valid method call; otherwise mozilla is not running
|
||||
|
||||
if ((*aRetValue) && (*aRetValue)->IsValid() == S_OK)
|
||||
return TRUE;
|
||||
|
||||
HRESULT hRes = CoInitialize(NULL);
|
||||
|
||||
hRes = ::CoCreateInstance(CLSID_nsMapiImp, NULL, CLSCTX_LOCAL_SERVER,
|
||||
IID_nsIMapi, (LPVOID *)aRetValue);
|
||||
|
||||
if (hRes == S_OK && (*aRetValue)->Initialize() == S_OK)
|
||||
if (TlsSetValue(tId, (LPVOID)(*aRetValue)))
|
||||
return TRUE;
|
||||
|
||||
// Either CoCreate or TlsSetValue failed; so return FALSE
|
||||
|
||||
if ((*aRetValue))
|
||||
(*aRetValue)->Release();
|
||||
|
||||
::CoUninitialize();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// The MAPILogon function begins a Simple MAPI session, loading the default message ////
|
||||
// store and address book providers ////
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ULONG FAR PASCAL MAPILogon(ULONG aUIParam, LPTSTR aProfileName,
|
||||
LPTSTR aPassword, FLAGS aFlags,
|
||||
ULONG aReserved, LPLHANDLE aSession)
|
||||
{
|
||||
HRESULT hr = 0;
|
||||
ULONG nSessionId = 0;
|
||||
nsIMapi *pNsMapi = NULL;
|
||||
|
||||
if (!InitMozillaReference(&pNsMapi))
|
||||
return MAPI_E_FAILURE;
|
||||
|
||||
if (!(aFlags & MAPI_UNICODE))
|
||||
{
|
||||
// Need to convert the parameters to Unicode.
|
||||
|
||||
char *pUserName = (char *) aProfileName;
|
||||
char *pPassWord = (char *) aPassword;
|
||||
|
||||
TCHAR ProfileName[MAX_NAME_LEN] = {0};
|
||||
TCHAR PassWord[MAX_PW_LEN] = {0};
|
||||
|
||||
if (pUserName != NULL)
|
||||
{
|
||||
if (!MultiByteToWideChar(CP_ACP, 0, pUserName, -1, ProfileName,
|
||||
MAX_NAME_LEN))
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
if (pPassWord != NULL)
|
||||
{
|
||||
if (!MultiByteToWideChar(CP_ACP, 0, pPassWord, -1, PassWord,
|
||||
MAX_NAME_LEN))
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
hr = pNsMapi->Login(aUIParam, ProfileName, PassWord, aFlags,
|
||||
&nSessionId);
|
||||
}
|
||||
else
|
||||
hr = pNsMapi->Login(aUIParam, aProfileName, aPassword,
|
||||
aFlags, &nSessionId);
|
||||
if (hr == S_OK)
|
||||
(*aSession) = (LHANDLE) nSessionId;
|
||||
else
|
||||
return nSessionId;
|
||||
|
||||
return SUCCESS_SUCCESS;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPILogoff (LHANDLE aSession, ULONG aUIParam,
|
||||
FLAGS aFlags, ULONG aReserved)
|
||||
{
|
||||
nsIMapi *pNsMapi = (nsIMapi *)TlsGetValue(tId);
|
||||
if (pNsMapi != NULL)
|
||||
{
|
||||
if (pNsMapi->Logoff((ULONG) aSession) == S_OK)
|
||||
pNsMapi->Release();
|
||||
pNsMapi = NULL;
|
||||
}
|
||||
|
||||
TlsSetValue(tId, NULL);
|
||||
|
||||
::CoUninitialize();
|
||||
|
||||
return SUCCESS_SUCCESS;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPISendMail (LHANDLE lhSession, ULONG ulUIParam, lpnsMapiMessage lpMessage,
|
||||
FLAGS flFlags, ULONG ulReserved )
|
||||
{
|
||||
HRESULT hr = 0;
|
||||
BOOL bTempSession = FALSE ;
|
||||
nsIMapi *pNsMapi = NULL;
|
||||
|
||||
if (!InitMozillaReference(&pNsMapi))
|
||||
return MAPI_E_FAILURE;
|
||||
|
||||
if (lpMessage->nRecipCount > MAX_RECIPS)
|
||||
return MAPI_E_TOO_MANY_RECIPIENTS ;
|
||||
|
||||
if (lpMessage->nFileCount > MAX_FILES)
|
||||
return MAPI_E_TOO_MANY_FILES ;
|
||||
|
||||
if ( (!(flFlags & MAPI_DIALOG)) && (lpMessage->lpRecips == NULL) )
|
||||
return MAPI_E_UNKNOWN_RECIPIENT ;
|
||||
|
||||
if (!lhSession || pNsMapi->IsValidSession(lhSession) != S_OK)
|
||||
{
|
||||
FLAGS LoginFlag ;
|
||||
if ( (flFlags & MAPI_LOGON_UI) && (flFlags & MAPI_NEW_SESSION) )
|
||||
LoginFlag = MAPI_LOGON_UI | MAPI_NEW_SESSION ;
|
||||
else if (flFlags & MAPI_LOGON_UI)
|
||||
LoginFlag = MAPI_LOGON_UI ;
|
||||
|
||||
hr = MAPILogon (ulUIParam, (LPTSTR) NULL, (LPTSTR) NULL, LoginFlag, 0, &lhSession) ;
|
||||
if (hr != SUCCESS_SUCCESS)
|
||||
return MAPI_E_LOGIN_FAILURE ;
|
||||
bTempSession = TRUE ;
|
||||
}
|
||||
|
||||
// we need to deal with null data passed in by MAPI clients, specially when MAPI_DIALOG is set.
|
||||
// The MS COM type lib code generated by MIDL for the MS COM interfaces checks for these parameters
|
||||
// to be non null, although null is a valid value for them here.
|
||||
nsMapiRecipDesc * lpRecips ;
|
||||
nsMapiFileDesc * lpFiles ;
|
||||
|
||||
nsMapiMessage Message ;
|
||||
memset (&Message, 0, sizeof (nsMapiMessage) ) ;
|
||||
nsMapiRecipDesc Recipient ;
|
||||
memset (&Recipient, 0, sizeof (nsMapiRecipDesc) );
|
||||
nsMapiFileDesc Files ;
|
||||
memset (&Files, 0, sizeof (nsMapiFileDesc) ) ;
|
||||
|
||||
if(!lpMessage)
|
||||
{
|
||||
lpMessage = &Message ;
|
||||
}
|
||||
if(!lpMessage->lpRecips)
|
||||
{
|
||||
lpRecips = &Recipient ;
|
||||
}
|
||||
else
|
||||
lpRecips = lpMessage->lpRecips ;
|
||||
if(!lpMessage->lpFiles)
|
||||
{
|
||||
lpFiles = &Files ;
|
||||
}
|
||||
else
|
||||
lpFiles = lpMessage->lpFiles ;
|
||||
|
||||
hr = pNsMapi->SendMail (lhSession, lpMessage,
|
||||
(short) lpMessage->nRecipCount, lpRecips,
|
||||
(short) lpMessage->nFileCount, lpFiles,
|
||||
flFlags, ulReserved);
|
||||
|
||||
if (bTempSession)
|
||||
MAPILogoff (lhSession, ulUIParam, 0,0) ;
|
||||
|
||||
// we are seeing a problem when using Word, although we return success from the MAPI support
|
||||
// MS COM interface in mozilla, we are getting this error here. This is a temporary hack !!
|
||||
if (hr == 0x800703e6)
|
||||
return SUCCESS_SUCCESS;
|
||||
|
||||
return hr ;
|
||||
}
|
||||
|
||||
|
||||
ULONG FAR PASCAL MAPISendDocuments(ULONG ulUIParam, LPTSTR lpszDelimChar, LPTSTR lpszFilePaths,
|
||||
LPTSTR lpszFileNames, ULONG ulReserved)
|
||||
{
|
||||
LHANDLE lhSession ;
|
||||
nsIMapi *pNsMapi = NULL;
|
||||
|
||||
if (!InitMozillaReference(&pNsMapi))
|
||||
return MAPI_E_FAILURE;
|
||||
|
||||
unsigned long result = MAPILogon (ulUIParam, (LPTSTR) NULL, (LPTSTR) NULL, MAPI_LOGON_UI, 0, &lhSession) ;
|
||||
if (result != SUCCESS_SUCCESS)
|
||||
return MAPI_E_LOGIN_FAILURE ;
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
hr = pNsMapi->SendDocuments(lhSession, (LPTSTR) lpszDelimChar, (LPTSTR) lpszFilePaths,
|
||||
(LPTSTR) lpszFileNames, ulReserved) ;
|
||||
|
||||
MAPILogoff (lhSession, ulUIParam, 0,0) ;
|
||||
|
||||
return hr ;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIFindNext(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszMessageType,
|
||||
LPTSTR lpszSeedMessageID, FLAGS flFlags, ULONG ulReserved,
|
||||
LPTSTR lpszMessageID)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIReadMail(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszMessageID,
|
||||
FLAGS flFlags, ULONG ulReserved, lpMapiMessage FAR *lppMessage)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPISaveMail(LHANDLE lhSession, ULONG ulUIParam, lpMapiMessage lpMessage,
|
||||
FLAGS flFlags, ULONG ulReserved, LPTSTR lpszMessageID)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIDeleteMail(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszMessageID,
|
||||
FLAGS flFlags, ULONG ulReserved)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIAddress(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszCaption,
|
||||
ULONG nEditFields, LPTSTR lpszLabels, ULONG nRecips,
|
||||
lpMapiRecipDesc lpRecips, FLAGS flFlags,
|
||||
ULONG ulReserved, LPULONG lpnNewRecips,
|
||||
lpMapiRecipDesc FAR *lppNewRecips)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIDetails(LHANDLE lhSession, ULONG ulUIParam, lpMapiRecipDesc lpRecip,
|
||||
FLAGS flFlags, ULONG ulReserved)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIResolveName(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszName,
|
||||
FLAGS flFlags, ULONG ulReserved, lpMapiRecipDesc FAR *lppRecip)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIFreeBuffer(LPVOID pv)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL GetMapiDllVersion()
|
||||
{
|
||||
return 94;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#/bin/sh
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
@@ -13,15 +11,14 @@
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is script to change the system id in an object file from PA-RISC 2.0 to 1.1.
|
||||
# The Original Code is Mozilla.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Hewlett-Packard Company.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1999
|
||||
# Netscape Communications Corp.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# wrapped by Dennis Handly on Tue Mar 23 15:23:43 1999
|
||||
# Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@@ -35,20 +32,30 @@
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# script to change the system id in an object file from PA-RISC 2.0 to 1.1
|
||||
DEPTH=..\..\..
|
||||
|
||||
adb -w $1 << EOF
|
||||
?m 0 -1 0
|
||||
0x0?X
|
||||
0x0?W (@0x0&~0x40000)|(~@0x0&0x40000)
|
||||
MODULE = mozMapi32
|
||||
EXPORT_LIBRARY = $(MODULE)
|
||||
LIBRARY_NAME = $(MODULE)
|
||||
DEFFILE = Mapi32.def
|
||||
|
||||
0?"change checksum"
|
||||
0x7c?X
|
||||
0x7c?W (@0x7c&~0x40000)|(~@0x7c&0x40000)
|
||||
$q
|
||||
EOF
|
||||
REQUIRES = MapiProxy \
|
||||
msgMapi \
|
||||
xpcom \
|
||||
string \
|
||||
$(NULL)
|
||||
|
||||
exit 0
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
###############################################################
|
||||
|
||||
LCFLAGS=-DUNICODE -D_UNICODE
|
||||
|
||||
|
||||
OBJS= .\$(OBJDIR)\MapiDll.obj
|
||||
|
||||
WIN_LIBS= ole32.lib
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
26
mozilla/mailnews/mapi/mapihook/makefile.win
Normal file
26
mozilla/mailnews/mapi/mapihook/makefile.win
Normal file
@@ -0,0 +1,26 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): kkhandrika@netscape.com
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS= build public src
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -11,15 +11,15 @@
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Solaris software cryptographic token.
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Sun Microsystems, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sun Microsystems, Inc.
|
||||
* Krishna Mohan Khandrika <kkhandrika@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@@ -35,31 +35,30 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MPI_AMD64
|
||||
#error This file only works on AMD64 platforms.
|
||||
#endif
|
||||
#include "nsISupports.idl"
|
||||
|
||||
#include <mpi-priv.h>
|
||||
|
||||
/*
|
||||
* MPI glue
|
||||
*
|
||||
/**
|
||||
* This interface provides support for registering Mozilla as a COM component
|
||||
* for extending the use of Mail/News through Simple MAPI.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Presently, this is only used by the Montgomery arithmetic code. */
|
||||
/* c += a * b */
|
||||
void MPI_ASM_DECL s_mpv_mul_d_add_prop(const mp_digit *a, mp_size a_len,
|
||||
mp_digit b, mp_digit *c)
|
||||
{
|
||||
mp_digit w;
|
||||
mp_digit d;
|
||||
[noscript, uuid(8967fed2-c8bb-11d5-a3e9-00b0d0f3baa7)]
|
||||
interface nsIMapiSupport : nsISupports {
|
||||
|
||||
d = s_mpv_mul_add_vec64(c, a, a_len, b);
|
||||
c += a_len;
|
||||
while (d) {
|
||||
w = c[0] + d;
|
||||
d = (w < c[0] || w < d);
|
||||
*c++ = w;
|
||||
}
|
||||
}
|
||||
/** Initiates MAPI support
|
||||
*/
|
||||
|
||||
void initializeMAPISupport();
|
||||
|
||||
/** Shuts down the MAPI support
|
||||
*/
|
||||
|
||||
void shutdownMAPISupport();
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_IMAPISUPPORT_CONTRACTID "@mozilla.org/mapisupport;1"
|
||||
#define NS_IMAPISUPPORT_CLASSNAME "Mozilla MAPI Support"
|
||||
%}
|
||||
|
||||
174
mozilla/mailnews/mapi/mapihook/src/nsMapiSupport.cpp
Normal file
174
mozilla/mailnews/mapi/mapihook/src/nsMapiSupport.cpp
Normal file
@@ -0,0 +1,174 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsComPtr.h"
|
||||
#include "nsMapiSupport.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsMapiRegistry.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIAppStartupNotifier.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
||||
const CLSID CLSID_nsMapiImp = {0x29f458be, 0x8866, 0x11d5, \
|
||||
{0xa3, 0xdd, 0x0, 0xb0, 0xd0, 0xf3, 0xba, 0xa7}};
|
||||
|
||||
/** Implementation of the nsIMapiSupport interface.
|
||||
* Use standard implementation of nsISupports stuff.
|
||||
*/
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsMapiSupport, nsIMapiSupport, nsIObserver);
|
||||
|
||||
static NS_METHOD nsMapiRegistrationProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath, const char *registryLocation, const char *componentType,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICategoryManager> categoryManager(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = categoryManager->AddCategoryEntry(APPSTARTUP_CATEGORY, "Mapi Support",
|
||||
"service," NS_IMAPISUPPORT_CONTRACTID, PR_TRUE, PR_TRUE, nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMapiSupport::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
|
||||
{
|
||||
if (!nsCRT::strcmp(aTopic, "profile-after-change"))
|
||||
return InitializeMAPISupport();
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
||||
return ShutdownMAPISupport();
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService(do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = observerService->AddObserver(this,"profile-after-change", PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsMapiSupport::nsMapiSupport()
|
||||
: m_dwRegister(0),
|
||||
m_nsMapiFactory(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsMapiSupport::~nsMapiSupport()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMapiSupport::InitializeMAPISupport()
|
||||
{
|
||||
::CoInitialize(nsnull);
|
||||
if (m_nsMapiFactory == nsnull) // No Registering if already done. Sanity Check!!
|
||||
{
|
||||
m_nsMapiFactory = new nsMapiFactory();
|
||||
|
||||
if (m_nsMapiFactory != nsnull)
|
||||
{
|
||||
HRESULT hr = ::CoRegisterClassObject(CLSID_nsMapiImp, \
|
||||
m_nsMapiFactory, \
|
||||
CLSCTX_LOCAL_SERVER, \
|
||||
REGCLS_MULTIPLEUSE, \
|
||||
&m_dwRegister);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
m_nsMapiFactory->Release() ;
|
||||
m_nsMapiFactory = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMapiSupport::ShutdownMAPISupport()
|
||||
{
|
||||
if (m_dwRegister != 0)
|
||||
::CoRevokeClassObject(m_dwRegister);
|
||||
|
||||
if (m_nsMapiFactory != nsnull)
|
||||
{
|
||||
m_nsMapiFactory->Release();
|
||||
m_nsMapiFactory = nsnull;
|
||||
}
|
||||
|
||||
::CoUninitialize();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMapiRegistry);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMapiSupport);
|
||||
|
||||
// The list of components we register
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
NS_IMAPIREGISTRY_CLASSNAME,
|
||||
NS_IMAPIREGISTRY_CID,
|
||||
NS_IMAPIREGISTRY_CONTRACTID,
|
||||
nsMapiRegistryConstructor
|
||||
},
|
||||
|
||||
{
|
||||
NS_IMAPISUPPORT_CLASSNAME,
|
||||
NS_IMAPISUPPORT_CID,
|
||||
NS_IMAPISUPPORT_CONTRACTID,
|
||||
nsMapiSupportConstructor,
|
||||
nsMapiRegistrationProc,
|
||||
nsnull
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(msgMapiModule, components);
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
/*
|
||||
* dec2hex.c
|
||||
*
|
||||
* Convert decimal integers into hexadecimal
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
@@ -16,14 +11,14 @@
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Michael J. Fromberger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@@ -38,34 +33,35 @@
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/* $Id: dec2hex.c,v 1.3 2004-04-27 23:04:37 gerv%gerv.net Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifndef NS_MAPI_SUPPORT_H_
|
||||
#define NS_MAPI_SUPPORT_H_
|
||||
|
||||
#include "mpi.h"
|
||||
#include <nsIObserver.h>
|
||||
#include <nsIMapiSupport.h>
|
||||
#include "msgMapiFactory.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
#define NS_IMAPISUPPORT_CID \
|
||||
{0x8967fed2, 0xc8bb, 0x11d5, \
|
||||
{ 0xa3, 0xe9, 0x00, 0xb0, 0xd0, 0xf3, 0xba, 0xa7 }}
|
||||
|
||||
class nsMapiSupport : public nsIMapiSupport, public nsIObserver
|
||||
{
|
||||
mp_int a;
|
||||
char *buf;
|
||||
int len;
|
||||
public :
|
||||
|
||||
if(argc < 2) {
|
||||
fprintf(stderr, "Usage: %s <a>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
nsMapiSupport();
|
||||
~nsMapiSupport();
|
||||
|
||||
mp_init(&a); mp_read_radix(&a, argv[1], 10);
|
||||
len = mp_radix_size(&a, 16);
|
||||
buf = malloc(len);
|
||||
mp_toradix(&a, buf, 16);
|
||||
// Declare all interface methods we must implement.
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIMAPISUPPORT
|
||||
|
||||
printf("%s\n", buf);
|
||||
private :
|
||||
|
||||
free(buf);
|
||||
mp_clear(&a);
|
||||
DWORD m_dwRegister;
|
||||
nsMapiFactory *m_nsMapiFactory;
|
||||
};
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // NS_MAPI_SUPPORT_H_
|
||||
64
mozilla/mailnews/mapi/old/hook/makefile.win
Normal file
64
mozilla/mailnews/mapi/old/hook/makefile.win
Normal file
@@ -0,0 +1,64 @@
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE=mapiguts
|
||||
|
||||
################################################################################
|
||||
## exports
|
||||
|
||||
#EXPORTS =
|
||||
|
||||
|
||||
################################################################################
|
||||
## library
|
||||
|
||||
LIBNAME = .\$(OBJDIR)\mapiguts
|
||||
|
||||
!ifdef MOZ_STATIC_COMPONENT_LIBS
|
||||
LIB = $(LIBNAME).lib
|
||||
!else
|
||||
DLL = $(LIBNAME).dll
|
||||
!endif
|
||||
|
||||
DEFINES= -NS_DEBUG
|
||||
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\mapihook.obj \
|
||||
.\$(OBJDIR)\mapimail.obj \
|
||||
$(NULL)
|
||||
|
||||
LLIBS= \
|
||||
$(LLIBS) \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\xppref32.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\mapiutils_s.lib \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
!ifdef MOZ_STATIC_COMPONENT_LIBS
|
||||
install:: $(LIb)
|
||||
$(MAKE_INSTALL) $(LIBNAME).$(LIB_SUFFIX) $(DIST)\bin\components
|
||||
!else
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) $(LIBNAME).$(DLL_SUFFIX) $(DIST)\bin\components
|
||||
!endif
|
||||
1579
mozilla/mailnews/mapi/old/hook/mapihook.cpp
Normal file
1579
mozilla/mailnews/mapi/old/hook/mapihook.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,57 +1,48 @@
|
||||
/*
|
||||
* bbs_rand.h
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* Blum, Blum & Shub PRNG using the MPI library
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Michael J. Fromberger.
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/* $Id: bbs_rand.h,v 1.3 2004-04-27 23:04:37 gerv%gerv.net Exp $ */
|
||||
#ifndef _MAPI_HOOK_H_
|
||||
#define _MAPI_HOOK_H_
|
||||
|
||||
#ifndef _H_BBSRAND_
|
||||
#define _H_BBSRAND_
|
||||
#include <structs.h> // for MWContext
|
||||
|
||||
#include <limits.h>
|
||||
#include "mpi.h"
|
||||
//
|
||||
// This is the entry point to the MAPI session manager that lives
|
||||
// inside of Communicator.
|
||||
//
|
||||
LONG ProcessNetscapeMAPIHook(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#define BBS_RAND_MAX UINT_MAX
|
||||
|
||||
/* Suggested length of seed data */
|
||||
extern int bbs_seed_size;
|
||||
|
||||
void bbs_srand(unsigned char *data, int len);
|
||||
unsigned int bbs_rand(void);
|
||||
|
||||
#endif /* end _H_BBSRAND_ */
|
||||
#endif // _MAPI_HOOK_H_
|
||||
853
mozilla/mailnews/mapi/old/hook/mapimail.cpp
Normal file
853
mozilla/mailnews/mapi/old/hook/mapimail.cpp
Normal file
@@ -0,0 +1,853 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
// More MAPI Hooks for Communicator
|
||||
// Written by: Rich Pizzarro (rhp@netscape.com)
|
||||
// November 1997
|
||||
//
|
||||
#include "windows.h"
|
||||
#include "template.h"
|
||||
#include "msgcom.h"
|
||||
#include "wfemsg.h"
|
||||
#include "compstd.h"
|
||||
#include "compbar.h"
|
||||
#include "compmisc.h"
|
||||
#include "compfrm.h"
|
||||
#include "prefapi.h"
|
||||
#include "intl_csi.h"
|
||||
#include "dlghtmrp.h"
|
||||
#include "dlghtmmq.h"
|
||||
|
||||
// rhp - was breaking the optimized build!
|
||||
//#include "edt.h"
|
||||
//#include "edview.h"
|
||||
//#include "postal.h"
|
||||
//#include "apiaddr.h"
|
||||
//#include "mailmisc.h"
|
||||
|
||||
extern "C" {
|
||||
#include "xpgetstr.h"
|
||||
extern int MK_MSG_MSG_COMPOSITION;
|
||||
};
|
||||
|
||||
#include "mapimail.h"
|
||||
#include "nscpmapi.h"
|
||||
#include "mailpriv.h"
|
||||
#include "nsstrseq.h"
|
||||
|
||||
MWContext
|
||||
*GetUsableContext(void)
|
||||
{
|
||||
CGenericFrame *pFrame = (CGenericFrame * )FEU_GetLastActiveFrame();
|
||||
|
||||
ASSERT(pFrame != NULL);
|
||||
if (pFrame == NULL)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
// Now return the context...
|
||||
return((MWContext *) pFrame->GetMainContext());
|
||||
}
|
||||
|
||||
//
|
||||
// This function will create a composition window and either do
|
||||
// a blind send or pop up the compose window for the user to
|
||||
// complete the operation
|
||||
//
|
||||
// Return: appropriate MAPI return code...
|
||||
//
|
||||
//
|
||||
extern "C" LONG
|
||||
DoFullMAPIMailOperation(MAPISendMailType *sendMailPtr,
|
||||
const char *pInitialText,
|
||||
BOOL winShowFlag)
|
||||
{
|
||||
CGenericDoc *pDocument;
|
||||
LPSTR subject;
|
||||
NSstringSeq mailInfoSeq;
|
||||
DWORD stringCount = 6;
|
||||
DWORD i;
|
||||
CString csDefault;
|
||||
|
||||
// Get a context to use for this call...
|
||||
MWContext *pOldContext = GetUsableContext();
|
||||
if (!pOldContext)
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
// Don't allow a compose window to be created if the user hasn't
|
||||
// specified an email address
|
||||
const char *real_addr = FE_UsersMailAddress();
|
||||
if (MISC_ValidateReturnAddress(pOldContext, real_addr) < 0)
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
//
|
||||
// Now, we must build the fields object...
|
||||
//
|
||||
mailInfoSeq = (NSstringSeq) &(sendMailPtr->dataBuf[0]);
|
||||
subject = NSStrSeqGet(mailInfoSeq, 0);
|
||||
|
||||
// We should give it a subject to preven the prompt from coming
|
||||
// up...
|
||||
if ((!subject) || !(*subject))
|
||||
{
|
||||
csDefault.LoadString(IDS_COMPOSE_DEFAULTNOSUBJECT);
|
||||
subject = csDefault.GetBuffer(2);
|
||||
}
|
||||
|
||||
TRACE("MAPI: ProcessMAPISendMail() Subject = [%s]\n", subject);
|
||||
TRACE("MAPI: ProcessMAPISendMail() Text Size = [%d]\n", strlen((const char *)pInitialText));
|
||||
TRACE("MAPI: ProcessMAPISendMail() # of Recipients = [%d]\n", sendMailPtr->MSG_nRecipCount);
|
||||
|
||||
|
||||
char toString[1024] = "";
|
||||
char ccString[1024] = "";
|
||||
char bccString[1024] = "";
|
||||
|
||||
for (i=0; i<sendMailPtr->MSG_nRecipCount; i++)
|
||||
{
|
||||
LPSTR ptr;
|
||||
UCHAR tempString[256];
|
||||
|
||||
ULONG addrType = atoi(NSStrSeqGet(mailInfoSeq, stringCount++));
|
||||
|
||||
// figure which type of address this is?
|
||||
if (addrType == MAPI_CC)
|
||||
ptr = ccString;
|
||||
else if (addrType == MAPI_BCC)
|
||||
ptr = bccString;
|
||||
else
|
||||
ptr = toString;
|
||||
|
||||
LPSTR namePtr = (LPSTR) NSStrSeqGet(mailInfoSeq, stringCount++);
|
||||
LPSTR emailPtr = (LPSTR) NSStrSeqGet(mailInfoSeq, stringCount++);
|
||||
if ( (lstrlen(emailPtr) > 5) && (*(emailPtr + 4) == ':') )
|
||||
{
|
||||
emailPtr += 5;
|
||||
}
|
||||
|
||||
// Now build the temp string to tack on in the format
|
||||
// "Rich Pizzarro" <rhp@netscape.com>
|
||||
wsprintf((LPSTR) tempString, "\"%s\" <%s>", namePtr, emailPtr);
|
||||
|
||||
// add a comma if not the first one
|
||||
if (ptr[0] != '\0')
|
||||
lstrcat(ptr, ",");
|
||||
|
||||
// tack on string!
|
||||
lstrcat(ptr, (LPSTR) tempString);
|
||||
}
|
||||
|
||||
BOOL bEncrypt = FALSE;
|
||||
BOOL bSign = FALSE;
|
||||
|
||||
PREF_GetBoolPref("mail.crypto_sign_outgoing_mail", &bSign);
|
||||
PREF_GetBoolPref("mail.encrypt_outgoing_mail", &bEncrypt);
|
||||
MSG_CompositionFields *fields =
|
||||
MSG_CreateCompositionFields(real_addr, real_addr,
|
||||
toString,
|
||||
ccString,
|
||||
bccString,
|
||||
"", "", "",
|
||||
"", subject, "",
|
||||
"", "", "",
|
||||
"",
|
||||
bEncrypt,
|
||||
bSign);
|
||||
if (!fields)
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
// RICHIE
|
||||
// INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(pOldContext);
|
||||
// int16 win_csid = INTL_GetCSIWinCSID(csi);
|
||||
|
||||
pDocument = (CGenericDoc*)theApp.m_TextComposeTemplate->OpenDocumentFile(NULL, NULL, /*win_csid RICHIE*/ winShowFlag);
|
||||
if ( !pDocument )
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
CWinCX * pContext = (CWinCX*) pDocument->GetContext();
|
||||
if ( !pContext )
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
MSG_CompositionPaneCallbacks Callbacks;
|
||||
Callbacks.CreateRecipientsDialog = CreateRecipientsDialog;
|
||||
Callbacks.CreateAskHTMLDialog = CreateAskHTMLDialog;
|
||||
|
||||
int16 doccsid;
|
||||
MWContext *context = pContext->GetContext();
|
||||
CComposeFrame *pCompose = (CComposeFrame *) pContext->GetFrame()->GetFrameWnd();
|
||||
|
||||
pCompose->SetComposeStuff(context, fields); // squirl away stuff for post-create
|
||||
|
||||
// This needs to be set TRUE if using the old non-HTML text frame
|
||||
// to prevent dropping dragged URLs
|
||||
pContext->m_bDragging = !pCompose->UseHtml();
|
||||
if (!pCompose->UseHtml())
|
||||
{
|
||||
pCompose->SetMsgPane(
|
||||
MSG_CreateCompositionPane(pContext->GetContext(),
|
||||
context,
|
||||
g_MsgPrefs.m_pMsgPrefs,
|
||||
fields,
|
||||
WFE_MSGGetMaster())
|
||||
);
|
||||
}
|
||||
|
||||
ASSERT(pCompose->GetMsgPane());
|
||||
MSG_SetFEData(pCompose->GetMsgPane(),(void *)pCompose);
|
||||
pCompose->UpdateAttachmentInfo();
|
||||
|
||||
// Pass doccsid info to new context for MailToWin conversion
|
||||
doccsid = INTL_GetCSIDocCSID(LO_GetDocumentCharacterSetInfo(context));
|
||||
INTL_SetCSIDocCSID(LO_GetDocumentCharacterSetInfo(context),
|
||||
(doccsid ? doccsid : INTL_DefaultDocCharSetID(context)));
|
||||
|
||||
pCompose->DisplayHeaders(NULL);
|
||||
|
||||
CComposeBar * pBar = pCompose->GetComposeBar();
|
||||
ASSERT(pBar);
|
||||
LPADDRESSCONTROL pIAddressList = pBar->GetAddressWidgetInterface();
|
||||
|
||||
if (!pIAddressList->IsCreated())
|
||||
{
|
||||
pBar->CreateAddressingBlock();
|
||||
}
|
||||
|
||||
// rhp - Deal with addressing the brute force way! This is a
|
||||
// "fix" for bad behavior when creating these windows and not
|
||||
// showing them on the desktop.
|
||||
if (!winShowFlag) // Hack to fix the window not being mapped
|
||||
{
|
||||
pCompose->AppendAddress(MSG_TO_HEADER_MASK, "");
|
||||
pCompose->AppendAddress(MSG_CC_HEADER_MASK, "");
|
||||
pCompose->AppendAddress(MSG_BCC_HEADER_MASK, "");
|
||||
}
|
||||
|
||||
// Always do plain text composition!
|
||||
pCompose->CompleteComposeInitialization();
|
||||
|
||||
// Do this so we don't get popups on "empty" messages
|
||||
if ( (!pInitialText) || (!(*pInitialText)) )
|
||||
pInitialText = " ";
|
||||
|
||||
const char * pBody = pInitialText ? pInitialText : MSG_GetCompBody(pCompose->GetMsgPane());
|
||||
if (pBody)
|
||||
{
|
||||
FE_InsertMessageCompositionText(context,pBody,TRUE);
|
||||
}
|
||||
|
||||
//
|
||||
// Now set the message as being edited!
|
||||
//
|
||||
pCompose->SetModified(TRUE);
|
||||
|
||||
//
|
||||
// Finally deal with the attachments...
|
||||
//
|
||||
if (sendMailPtr->MSG_nFileCount > 0)
|
||||
{
|
||||
// Send this puppy when done with the attachments...
|
||||
if (!winShowFlag)
|
||||
{
|
||||
pCompose->SetMAPISendMode(MAPI_SEND);
|
||||
}
|
||||
|
||||
MSG_AttachmentData *pAttach = (MSG_AttachmentData *)
|
||||
XP_CALLOC((sendMailPtr->MSG_nFileCount + 1),
|
||||
sizeof(MSG_AttachmentData));
|
||||
if (!pAttach)
|
||||
{
|
||||
return(MAPI_E_INSUFFICIENT_MEMORY);
|
||||
}
|
||||
|
||||
memset(pAttach, 0, (sendMailPtr->MSG_nFileCount + 1) *
|
||||
sizeof(MSG_AttachmentData));
|
||||
for (i=0; i<sendMailPtr->MSG_nFileCount; i++)
|
||||
{
|
||||
CString cs;
|
||||
// Create URL from filename...
|
||||
WFE_ConvertFile2Url(cs,
|
||||
(const char *)NSStrSeqGet(mailInfoSeq, stringCount++));
|
||||
pAttach[i].url = XP_STRDUP(cs);
|
||||
|
||||
// Now also include the "display" name...
|
||||
StrAllocCopy(pAttach[i].real_name, NSStrSeqGet(mailInfoSeq, stringCount++));
|
||||
}
|
||||
|
||||
// Set the list!
|
||||
MSG_SetAttachmentList(pCompose->GetMsgPane(), pAttach);
|
||||
|
||||
// Now free everything...
|
||||
for (i=0; i<sendMailPtr->MSG_nFileCount; i++)
|
||||
{
|
||||
if (pAttach[i].url)
|
||||
XP_FREE(pAttach[i].url);
|
||||
|
||||
if (pAttach[i].real_name)
|
||||
XP_FREE(pAttach[i].real_name);
|
||||
}
|
||||
|
||||
XP_FREE(pAttach);
|
||||
}
|
||||
|
||||
//
|
||||
// Now, if we were supposed to do the blind send...do it, otherwise,
|
||||
// just popup the window...
|
||||
//
|
||||
if (winShowFlag)
|
||||
{
|
||||
// Post message to compose window to set the initial focus.
|
||||
pCompose->PostMessage(WM_COMP_SET_INITIAL_FOCUS);
|
||||
}
|
||||
else if (sendMailPtr->MSG_nFileCount <= 0) // Send NOW if no attachments!
|
||||
{
|
||||
pCompose->PostMessage(WM_COMMAND, IDM_SEND);
|
||||
}
|
||||
|
||||
return(SUCCESS_SUCCESS);
|
||||
}
|
||||
|
||||
//
|
||||
// This function will create a composition window and just attach
|
||||
// the attachments of interest and pop up the window...
|
||||
//
|
||||
// Return: appropriate MAPI return code...
|
||||
//
|
||||
//
|
||||
extern "C" LONG
|
||||
DoPartialMAPIMailOperation(MAPISendDocumentsType *sendDocPtr)
|
||||
{
|
||||
CGenericDoc *pDocument;
|
||||
|
||||
// Get a context to use for this call...
|
||||
MWContext *pOldContext = GetUsableContext();
|
||||
if (!pOldContext)
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
// Don't allow a compose window to be created if the user hasn't
|
||||
// specified an email address
|
||||
const char *real_addr = FE_UsersMailAddress();
|
||||
if (MISC_ValidateReturnAddress(pOldContext, real_addr) < 0)
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
//
|
||||
// Now, build the fields object w/o much info...
|
||||
//
|
||||
BOOL bEncrypt = FALSE;
|
||||
BOOL bSign = FALSE;
|
||||
|
||||
PREF_GetBoolPref("mail.crypto_sign_outgoing_mail", &bSign);
|
||||
PREF_GetBoolPref("mail.encrypt_outgoing_mail", &bEncrypt);
|
||||
|
||||
MSG_CompositionFields *fields =
|
||||
MSG_CreateCompositionFields(real_addr, real_addr, NULL,
|
||||
"", "",
|
||||
"", "", "",
|
||||
"", "", "",
|
||||
"", "", "",
|
||||
"",
|
||||
bEncrypt,
|
||||
bSign);
|
||||
if (!fields)
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
// RICHIE - INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(pOldContext);
|
||||
// int16 win_csid = INTL_GetCSIWinCSID(csi);
|
||||
|
||||
pDocument = (CGenericDoc*)theApp.m_TextComposeTemplate->OpenDocumentFile(NULL, NULL, /*RICHIE win_csid,*/ TRUE);
|
||||
if ( !pDocument )
|
||||
{
|
||||
// cleanup fields object
|
||||
MSG_DestroyCompositionFields(fields);
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
CWinCX * pContext = (CWinCX*) pDocument->GetContext();
|
||||
if ( !pContext )
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
MSG_CompositionPaneCallbacks Callbacks;
|
||||
Callbacks.CreateRecipientsDialog = CreateRecipientsDialog;
|
||||
Callbacks.CreateAskHTMLDialog = CreateAskHTMLDialog;
|
||||
|
||||
MWContext *context = pContext->GetContext();
|
||||
CComposeFrame *pCompose = (CComposeFrame *) pContext->GetFrame()->GetFrameWnd();
|
||||
pCompose->SetComposeStuff(context,fields); // squirl away stuff for post-create
|
||||
|
||||
// This needs to be set TRUE if using the old non-HTML text frame
|
||||
// to prevent dropping dragged URLs
|
||||
pContext->m_bDragging = !pCompose->UseHtml();
|
||||
if (!pCompose->UseHtml())
|
||||
{
|
||||
pCompose->SetMsgPane(MSG_CreateCompositionPane(
|
||||
pContext->GetContext(),
|
||||
context,
|
||||
g_MsgPrefs.m_pMsgPrefs, fields,
|
||||
WFE_MSGGetMaster()));
|
||||
}
|
||||
|
||||
ASSERT(pCompose->GetMsgPane());
|
||||
MSG_SetFEData(pCompose->GetMsgPane(),(void *)pCompose);
|
||||
|
||||
pCompose->UpdateAttachmentInfo();
|
||||
|
||||
// Pass doccsid info to new context for MailToWin conversion
|
||||
/***
|
||||
doccsid = INTL_GetCSIDocCSID(LO_GetDocumentCharacterSetInfo(pOldContext));
|
||||
|
||||
INTL_SetCSIDocCSID(LO_GetDocumentCharacterSetInfo(context),
|
||||
(doccsid ? doccsid : INTL_DefaultDocCharSetID(pOldContext)));
|
||||
****/
|
||||
|
||||
pCompose->DisplayHeaders(NULL);
|
||||
|
||||
CComposeBar * pBar = pCompose->GetComposeBar();
|
||||
ASSERT(pBar);
|
||||
LPADDRESSCONTROL pIAddressList = pBar->GetAddressWidgetInterface();
|
||||
|
||||
if (!pIAddressList->IsCreated())
|
||||
{
|
||||
pBar->CreateAddressingBlock();
|
||||
}
|
||||
|
||||
// Always do plain text composition!
|
||||
pCompose->CompleteComposeInitialization();
|
||||
|
||||
//
|
||||
// Finally deal with the attachments...
|
||||
//
|
||||
NSstringSeq mailInfoSeq = (NSstringSeq) &(sendDocPtr->dataBuf[0]);
|
||||
DWORD stringCount = 0;
|
||||
DWORD i;
|
||||
|
||||
TRACE("MAPI: ProcessMAPISendDocuments() # of Attachments = [%d]\n", sendDocPtr->nFileCount);
|
||||
|
||||
if (sendDocPtr->nFileCount > 0)
|
||||
{
|
||||
MSG_AttachmentData *pAttach = (MSG_AttachmentData *)
|
||||
XP_CALLOC((sendDocPtr->nFileCount + 1),
|
||||
sizeof(MSG_AttachmentData));
|
||||
if (!pAttach)
|
||||
{
|
||||
return(MAPI_E_INSUFFICIENT_MEMORY);
|
||||
}
|
||||
|
||||
memset(pAttach, 0, (sendDocPtr->nFileCount + 1) *
|
||||
sizeof(MSG_AttachmentData));
|
||||
for (i=0; i<sendDocPtr->nFileCount; i++)
|
||||
{
|
||||
CString cs;
|
||||
// Create URL from filename...
|
||||
WFE_ConvertFile2Url(cs,
|
||||
(const char *)NSStrSeqGet(mailInfoSeq, stringCount++));
|
||||
pAttach[i].url = XP_STRDUP(cs);
|
||||
|
||||
// Now also include the "display" name...
|
||||
StrAllocCopy(pAttach[i].real_name, NSStrSeqGet(mailInfoSeq, stringCount++));
|
||||
}
|
||||
|
||||
// Set the list!
|
||||
MSG_SetAttachmentList(pCompose->GetMsgPane(), pAttach);
|
||||
|
||||
// Now free everything...
|
||||
for (i=0; i<sendDocPtr->nFileCount; i++)
|
||||
{
|
||||
if (pAttach[i].url)
|
||||
XP_FREE(pAttach[i].url);
|
||||
|
||||
if (pAttach[i].real_name)
|
||||
XP_FREE(pAttach[i].real_name);
|
||||
}
|
||||
|
||||
XP_FREE(pAttach);
|
||||
}
|
||||
|
||||
//
|
||||
// Now some checking for ... well I'm not sure...
|
||||
//
|
||||
if (MSG_GetAttachmentList(pCompose->GetMsgPane()))
|
||||
pCompose->SetModified(TRUE);
|
||||
else
|
||||
pCompose->SetModified(FALSE);
|
||||
|
||||
// Post message to compose window to set the initial focus.
|
||||
pCompose->PostMessage(WM_COMP_SET_INITIAL_FOCUS);
|
||||
|
||||
//
|
||||
// Now, just popup the window...
|
||||
//
|
||||
pCompose->ShowWindow(TRUE);
|
||||
|
||||
// return pCompose->GetMsgPane(); rhp - used to return the MsgPane
|
||||
return(SUCCESS_SUCCESS);
|
||||
}
|
||||
|
||||
static void _GetMailCallback(HWND hwnd, MSG_Pane *pane, void *closure)
|
||||
{
|
||||
if (pane != NULL)
|
||||
{
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
MSG_Command( pane, MSG_GetNewMail, NULL, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
static void _GetMailDoneCallback(HWND hwnd, MSG_Pane *pane, void *closure)
|
||||
{
|
||||
for(CGenericFrame * f = theApp.m_pFrameList; f; f = f->m_pNext)
|
||||
f->PostMessage(WM_COMMAND, (WPARAM) ID_DONEGETTINGMAIL, (LPARAM) 0);
|
||||
}
|
||||
|
||||
//
|
||||
// This will fire off a "get mail in background operation" in an
|
||||
// async. fashion.
|
||||
//
|
||||
extern "C" void
|
||||
MAPIGetNewMessagesInBackground(void)
|
||||
{
|
||||
CGenericFrame *pFrame = (CGenericFrame * )FEU_GetLastActiveFrame();
|
||||
|
||||
// rhp - we should not hit the net if we are offline!
|
||||
if (NET_IsOffline())
|
||||
return;
|
||||
|
||||
if (!pFrame)
|
||||
return;
|
||||
|
||||
MWContext *pOldContext = GetUsableContext();
|
||||
if (!pOldContext)
|
||||
return;
|
||||
|
||||
TRACE("MAPI: DOWNLOAD MAIL IN BACKGROUND\n");
|
||||
new CProgressDialog(
|
||||
pFrame->GetFrameWnd(),
|
||||
NULL,
|
||||
_GetMailCallback, NULL, NULL,
|
||||
_GetMailDoneCallback);
|
||||
}
|
||||
|
||||
//
|
||||
// This function will save a message into the Communicator "Drafts"
|
||||
// folder with no UI showing.
|
||||
//
|
||||
// Return: appropriate MAPI return code...
|
||||
//
|
||||
//
|
||||
extern "C" LONG
|
||||
DoMAPISaveMailOperation(MAPISendMailType *sendMailPtr,
|
||||
const char *pInitialText)
|
||||
{
|
||||
CGenericDoc *pDocument;
|
||||
LPSTR subject;
|
||||
NSstringSeq mailInfoSeq;
|
||||
DWORD stringCount = 6;
|
||||
DWORD i;
|
||||
BOOL winShowFlag = FALSE;
|
||||
|
||||
// Get a context to use for this call...
|
||||
MWContext *pOldContext = GetUsableContext();
|
||||
if (!pOldContext)
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
// Don't allow a compose window to be created if the user hasn't
|
||||
// specified an email address
|
||||
const char *real_addr = FE_UsersMailAddress();
|
||||
if (MISC_ValidateReturnAddress(pOldContext, real_addr) < 0)
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
//
|
||||
// Now, we must build the fields object...
|
||||
//
|
||||
mailInfoSeq = (NSstringSeq) &(sendMailPtr->dataBuf[0]);
|
||||
subject = NSStrSeqGet(mailInfoSeq, 0);
|
||||
|
||||
TRACE("MAPI: ProcessMAPISendMail() Subject = [%s]\n", subject);
|
||||
TRACE("MAPI: ProcessMAPISendMail() Text Size = [%d]\n", strlen((const char *)pInitialText));
|
||||
TRACE("MAPI: ProcessMAPISendMail() # of Recipients = [%d]\n", sendMailPtr->MSG_nRecipCount);
|
||||
|
||||
|
||||
char toString[1024] = "";
|
||||
char ccString[1024] = "";
|
||||
char bccString[1024] = "";
|
||||
|
||||
for (i=0; i<sendMailPtr->MSG_nRecipCount; i++)
|
||||
{
|
||||
LPSTR ptr;
|
||||
UCHAR tempString[256];
|
||||
|
||||
ULONG addrType = atoi(NSStrSeqGet(mailInfoSeq, stringCount++));
|
||||
|
||||
// figure which type of address this is?
|
||||
if (addrType == MAPI_CC)
|
||||
ptr = ccString;
|
||||
else if (addrType == MAPI_BCC)
|
||||
ptr = bccString;
|
||||
else
|
||||
ptr = toString;
|
||||
|
||||
LPSTR namePtr = (LPSTR) NSStrSeqGet(mailInfoSeq, stringCount++);
|
||||
LPSTR emailPtr = (LPSTR) NSStrSeqGet(mailInfoSeq, stringCount++);
|
||||
|
||||
if ( (!emailPtr) && (!namePtr))
|
||||
{
|
||||
return(MAPI_E_INVALID_RECIPS);
|
||||
}
|
||||
|
||||
if (!emailPtr)
|
||||
emailPtr = namePtr;
|
||||
|
||||
char *tptr = strchr(emailPtr, ':');
|
||||
if (tptr != NULL)
|
||||
{
|
||||
if ( (*tptr != '\0') && (*(tptr+1) != '\0') )
|
||||
{
|
||||
emailPtr = (tptr + 1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
if ( (lstrlen(emailPtr) > 5) && (*(emailPtr + 4) == ':') )
|
||||
{
|
||||
emailPtr += 5;
|
||||
}
|
||||
**/
|
||||
// Now build the temp string to tack on in the format
|
||||
// "Rich Pizzarro" <rhp@netscape.com>
|
||||
wsprintf((LPSTR) tempString, "\"%s\" <%s>", namePtr, emailPtr);
|
||||
|
||||
// add a comma if not the first one
|
||||
if (ptr[0] != '\0')
|
||||
lstrcat(ptr, ",");
|
||||
|
||||
// tack on string!
|
||||
lstrcat(ptr, (LPSTR) tempString);
|
||||
}
|
||||
|
||||
BOOL bEncrypt = FALSE;
|
||||
BOOL bSign = FALSE;
|
||||
|
||||
PREF_GetBoolPref("mail.crypto_sign_outgoing_mail", &bSign);
|
||||
PREF_GetBoolPref("mail.encrypt_outgoing_mail", &bEncrypt);
|
||||
MSG_CompositionFields *fields =
|
||||
MSG_CreateCompositionFields(real_addr, real_addr,
|
||||
toString,
|
||||
ccString,
|
||||
bccString,
|
||||
"", "", "",
|
||||
"", subject, "",
|
||||
"", "", "",
|
||||
"",
|
||||
bEncrypt,
|
||||
bSign);
|
||||
if (!fields)
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
// RICHIE
|
||||
// INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(pOldContext);
|
||||
// int16 win_csid = INTL_GetCSIWinCSID(csi);
|
||||
|
||||
pDocument = (CGenericDoc*)theApp.m_TextComposeTemplate->OpenDocumentFile(NULL, NULL, /*win_csid RICHIE*/ winShowFlag);
|
||||
if ( !pDocument )
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
CWinCX * pContext = (CWinCX*) pDocument->GetContext();
|
||||
if ( !pContext )
|
||||
{
|
||||
return(MAPI_E_FAILURE);
|
||||
}
|
||||
|
||||
MSG_CompositionPaneCallbacks Callbacks;
|
||||
Callbacks.CreateRecipientsDialog = CreateRecipientsDialog;
|
||||
Callbacks.CreateAskHTMLDialog = CreateAskHTMLDialog;
|
||||
|
||||
int16 doccsid;
|
||||
MWContext *context = pContext->GetContext();
|
||||
CComposeFrame *pCompose = (CComposeFrame *) pContext->GetFrame()->GetFrameWnd();
|
||||
|
||||
pCompose->SetComposeStuff(context, fields); // squirl away stuff for post-create
|
||||
|
||||
// This needs to be set TRUE if using the old non-HTML text frame
|
||||
// to prevent dropping dragged URLs
|
||||
pContext->m_bDragging = !pCompose->UseHtml();
|
||||
if (!pCompose->UseHtml())
|
||||
{
|
||||
pCompose->SetMsgPane(
|
||||
MSG_CreateCompositionPane(pContext->GetContext(),
|
||||
context,
|
||||
g_MsgPrefs.m_pMsgPrefs,
|
||||
fields,
|
||||
WFE_MSGGetMaster())
|
||||
);
|
||||
}
|
||||
|
||||
ASSERT(pCompose->GetMsgPane());
|
||||
MSG_SetFEData(pCompose->GetMsgPane(),(void *)pCompose);
|
||||
pCompose->UpdateAttachmentInfo();
|
||||
|
||||
// Pass doccsid info to new context for MailToWin conversion
|
||||
doccsid = INTL_GetCSIDocCSID(LO_GetDocumentCharacterSetInfo(context));
|
||||
INTL_SetCSIDocCSID(LO_GetDocumentCharacterSetInfo(context),
|
||||
(doccsid ? doccsid : INTL_DefaultDocCharSetID(context)));
|
||||
|
||||
pCompose->DisplayHeaders(NULL);
|
||||
|
||||
CComposeBar * pBar = pCompose->GetComposeBar();
|
||||
ASSERT(pBar);
|
||||
LPADDRESSCONTROL pIAddressList = pBar->GetAddressWidgetInterface();
|
||||
|
||||
if (!pIAddressList->IsCreated())
|
||||
{
|
||||
pBar->CreateAddressingBlock();
|
||||
}
|
||||
|
||||
// rhp - Deal with addressing the brute force way! This is a
|
||||
// "fix" for bad behavior when creating these windows and not
|
||||
// showing them on the desktop.
|
||||
if (!winShowFlag) // Hack to fix the window not being mapped
|
||||
{
|
||||
pCompose->AppendAddress(MSG_TO_HEADER_MASK, "");
|
||||
pCompose->AppendAddress(MSG_CC_HEADER_MASK, "");
|
||||
pCompose->AppendAddress(MSG_BCC_HEADER_MASK, "");
|
||||
}
|
||||
|
||||
// Always do plain text composition!
|
||||
pCompose->CompleteComposeInitialization();
|
||||
|
||||
// Do this so we don't get popups on "empty" messages
|
||||
if ( (!pInitialText) || (!(*pInitialText)) )
|
||||
pInitialText = " ";
|
||||
|
||||
const char * pBody = pInitialText ? pInitialText : MSG_GetCompBody(pCompose->GetMsgPane());
|
||||
if (pBody)
|
||||
{
|
||||
FE_InsertMessageCompositionText(context,pBody,TRUE);
|
||||
}
|
||||
|
||||
//
|
||||
// Now set the message as being edited!
|
||||
//
|
||||
pCompose->SetModified(TRUE);
|
||||
|
||||
//
|
||||
// Finally deal with the attachments...
|
||||
//
|
||||
if (sendMailPtr->MSG_nFileCount > 0)
|
||||
{
|
||||
// Send this puppy when done with the attachments...
|
||||
if (!winShowFlag)
|
||||
{
|
||||
pCompose->SetMAPISendMode(MAPI_SAVE);
|
||||
}
|
||||
|
||||
MSG_AttachmentData *pAttach = (MSG_AttachmentData *)
|
||||
XP_CALLOC((sendMailPtr->MSG_nFileCount + 1),
|
||||
sizeof(MSG_AttachmentData));
|
||||
if (!pAttach)
|
||||
{
|
||||
return(MAPI_E_INSUFFICIENT_MEMORY);
|
||||
}
|
||||
|
||||
memset(pAttach, 0, (sendMailPtr->MSG_nFileCount + 1) *
|
||||
sizeof(MSG_AttachmentData));
|
||||
for (i=0; i<sendMailPtr->MSG_nFileCount; i++)
|
||||
{
|
||||
CString cs;
|
||||
// Create URL from filename...
|
||||
WFE_ConvertFile2Url(cs,
|
||||
(const char *)NSStrSeqGet(mailInfoSeq, stringCount++));
|
||||
pAttach[i].url = XP_STRDUP(cs);
|
||||
|
||||
// Now also include the "display" name...
|
||||
StrAllocCopy(pAttach[i].real_name, NSStrSeqGet(mailInfoSeq, stringCount++));
|
||||
}
|
||||
|
||||
// Set the list!
|
||||
MSG_SetAttachmentList(pCompose->GetMsgPane(), pAttach);
|
||||
|
||||
// Now free everything...
|
||||
for (i=0; i<sendMailPtr->MSG_nFileCount; i++)
|
||||
{
|
||||
if (pAttach[i].url)
|
||||
XP_FREE(pAttach[i].url);
|
||||
|
||||
if (pAttach[i].real_name)
|
||||
XP_FREE(pAttach[i].real_name);
|
||||
}
|
||||
|
||||
XP_FREE(pAttach);
|
||||
}
|
||||
|
||||
//
|
||||
// Now, if we were supposed to do the blind send...do it, otherwise,
|
||||
// just popup the window...
|
||||
//
|
||||
if (winShowFlag)
|
||||
{
|
||||
// Post message to compose window to set the initial focus.
|
||||
pCompose->PostMessage(WM_COMP_SET_INITIAL_FOCUS);
|
||||
}
|
||||
else if (sendMailPtr->MSG_nFileCount <= 0) // Send NOW if no attachments!
|
||||
{
|
||||
pCompose->PostMessage(WM_COMMAND, IDM_SAVEASDRAFT);
|
||||
}
|
||||
|
||||
return(SUCCESS_SUCCESS);
|
||||
}
|
||||
89
mozilla/mailnews/mapi/old/hook/mapimail.h
Normal file
89
mozilla/mailnews/mapi/old/hook/mapimail.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef _MAPI_MAIL_H_
|
||||
#define _MAPI_MAIL_H_
|
||||
|
||||
#include "nscpmapi.h"
|
||||
#include <structs.h> // for MWContext
|
||||
|
||||
//extern "C" {
|
||||
|
||||
//
|
||||
// This function will create a composition window and either do
|
||||
// a blind send or pop up the compose window for the user to
|
||||
// complete the operation
|
||||
//
|
||||
// Return: appropriate MAPI return code...
|
||||
//
|
||||
//
|
||||
extern "C" LONG
|
||||
DoFullMAPIMailOperation(MAPISendMailType *sendMailPtr,
|
||||
const char *pInitialText,
|
||||
BOOL winShowFlag);
|
||||
|
||||
//
|
||||
// This function will create a composition window and just attach
|
||||
// the attachments of interest and pop up the window...
|
||||
//
|
||||
// Return: appropriate MAPI return code...
|
||||
//
|
||||
//
|
||||
extern "C" LONG
|
||||
DoPartialMAPIMailOperation(MAPISendDocumentsType *sendDocPtr);
|
||||
|
||||
//
|
||||
// This function will save a message into the Communicator "Drafts"
|
||||
// folder with no UI showing.
|
||||
//
|
||||
// Return: appropriate MAPI return code...
|
||||
//
|
||||
//
|
||||
extern "C" LONG
|
||||
DoMAPISaveMailOperation(MAPISendMailType *sendMailPtr,
|
||||
const char *pInitialText);
|
||||
|
||||
//
|
||||
// This will fire off a "get mail in background operation" in an
|
||||
// async. fashion.
|
||||
//
|
||||
extern "C" void
|
||||
MAPIGetNewMessagesInBackground(void);
|
||||
|
||||
|
||||
// } // extern "C"
|
||||
|
||||
#endif // _MAPI_MAIL_H_
|
||||
50
mozilla/mailnews/mapi/old/lib/Makefile.win
Normal file
50
mozilla/mailnews/mapi/old/lib/Makefile.win
Normal file
@@ -0,0 +1,50 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE=mapiutils
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
################################################################################
|
||||
## exports
|
||||
|
||||
EXPORTS= mapismem.h \
|
||||
nsstrseq.h \
|
||||
$(NULL)
|
||||
|
||||
################################################################################
|
||||
## library
|
||||
|
||||
LIBRARY_NAME=mapiutils_s
|
||||
|
||||
|
||||
CPP_OBJS= .\$(OBJDIR)\mapismem.obj \
|
||||
.\$(OBJDIR)\nsstrseq.obj \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
173
mozilla/mailnews/mapi/old/lib/mapismem.cpp
Normal file
173
mozilla/mailnews/mapi/old/lib/mapismem.cpp
Normal file
@@ -0,0 +1,173 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
// smem.cpp - This deals with all shared memory functions needed for
|
||||
// the MAPI component of Communicator
|
||||
// Written by: Rich Pizzarro (rhp@netscape.com)
|
||||
// November 1997
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "mapismem.h"
|
||||
|
||||
|
||||
#ifndef ZeroMemory
|
||||
#include <memory.h>
|
||||
#define ZeroMemory(PTR, SIZE) memset(PTR, 0, SIZE)
|
||||
#endif // ZeroMemory
|
||||
|
||||
//
|
||||
// *create new* shared memory chunk
|
||||
// once this is created, use the pointer
|
||||
// to the segment to to store data
|
||||
// e.g.:
|
||||
// lpString = "string for communicator";
|
||||
// lstrcpy((LPSTR)pData->m_buf[0], lpString);
|
||||
//
|
||||
CSharedMem *
|
||||
NSCreateSharedMemory(DWORD memSize, LPCTSTR memName, HANDLE *hSharedMemory)
|
||||
{
|
||||
#ifdef WIN32
|
||||
|
||||
BOOL bExistedBefore;
|
||||
CSharedMem *pData;
|
||||
|
||||
LPCTSTR szObjectName = memName;
|
||||
DWORD dwSize = sizeof(CSharedMem) + memSize;
|
||||
*hSharedMemory = CreateFileMapping(
|
||||
(HANDLE)0xFFFFFFFF,0,PAGE_READWRITE,0,dwSize,szObjectName);
|
||||
if(*hSharedMemory == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
bExistedBefore = (GetLastError() == ERROR_ALREADY_EXISTS);
|
||||
if(bExistedBefore)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pData = (CSharedMem *)MapViewOfFile(
|
||||
*hSharedMemory, FILE_MAP_ALL_ACCESS, 0, 0, 0);
|
||||
if(pData == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMemory(pData, dwSize);
|
||||
pData->m_dwSize = memSize;
|
||||
|
||||
return pData;
|
||||
#else
|
||||
CSharedMem *sMemChunk = NULL;
|
||||
DWORD dwSize = memSize = (sizeof(CSharedMem) + memSize);
|
||||
|
||||
if (sMemChunk != NULL)
|
||||
return(sMemChunk);
|
||||
|
||||
sMemChunk = (CSharedMem *) GlobalAllocPtr(GMEM_MOVEABLE, dwSize);
|
||||
ZeroMemory(sMemChunk, (size_t) dwSize);
|
||||
sMemChunk->m_dwSize = dwSize; // Missing in Communicator code!
|
||||
return(sMemChunk);
|
||||
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
//
|
||||
// *open existing* shared memory chunk
|
||||
// once you have the pointer to the new segment
|
||||
// use this pointer to access data, e.g.:
|
||||
//
|
||||
CSharedMem *
|
||||
NSOpenExistingSharedMemory(LPCTSTR memName, HANDLE *hSharedMemory)
|
||||
{
|
||||
#ifdef WIN32
|
||||
CSharedMem *pData;
|
||||
DWORD dwSize;
|
||||
|
||||
LPCTSTR szObjectName = memName;
|
||||
*hSharedMemory = OpenFileMapping(
|
||||
FILE_MAP_WRITE,FALSE,szObjectName);
|
||||
if(*hSharedMemory == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pData = (CSharedMem *)MapViewOfFile(
|
||||
*hSharedMemory,FILE_MAP_ALL_ACCESS,0,0,0);
|
||||
if(pData == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dwSize = pData->m_dwSize;
|
||||
return pData;
|
||||
#else
|
||||
|
||||
return(NULL); // In Win16, this is really meaningless...
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// to close shared memory segment
|
||||
//
|
||||
void
|
||||
NSCloseSharedMemory(CSharedMem *pData, HANDLE hSharedMemory)
|
||||
{
|
||||
#ifdef WIN32
|
||||
if(pData != 0)
|
||||
{
|
||||
UnmapViewOfFile(pData);
|
||||
pData = 0;
|
||||
}
|
||||
|
||||
if(hSharedMemory != 0)
|
||||
{
|
||||
CloseHandle(hSharedMemory);
|
||||
hSharedMemory = 0;
|
||||
}
|
||||
#else
|
||||
|
||||
if (pData != NULL)
|
||||
{
|
||||
GlobalFreePtr(pData);
|
||||
pData = NULL;
|
||||
}
|
||||
|
||||
#endif // WIN32
|
||||
}
|
||||
116
mozilla/mailnews/mapi/old/lib/mapismem.h
Normal file
116
mozilla/mailnews/mapi/old/lib/mapismem.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef __SMEM_HPP__
|
||||
#define __SMEM_HPP__
|
||||
|
||||
//
|
||||
// Need this for Win16 since it is an undocumented message
|
||||
//
|
||||
#ifndef WIN32
|
||||
|
||||
#define WM_COPYDATA 0x004A
|
||||
|
||||
/*
|
||||
* lParam of WM_COPYDATA message points to...
|
||||
*/
|
||||
typedef struct tagCOPYDATASTRUCT {
|
||||
DWORD dwData;
|
||||
DWORD cbData;
|
||||
LPVOID lpData;
|
||||
} COPYDATASTRUCT, *PCOPYDATASTRUCT;
|
||||
|
||||
# ifndef LPCTSTR
|
||||
# define LPCTSTR LPCSTR
|
||||
# endif
|
||||
|
||||
|
||||
#endif // ifndef WIN32
|
||||
|
||||
// The following structure will be stored in the shared memory
|
||||
// and will be used to pass data back and forth
|
||||
|
||||
#pragma pack(4)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD m_dwSize; // size of the shared memory block
|
||||
BYTE m_buf[1]; // this is the buffer of memory to be used
|
||||
} CSharedMem;
|
||||
|
||||
#pragma pack(4)
|
||||
|
||||
// ******************************************************
|
||||
// Public routines...
|
||||
// ******************************************************
|
||||
//
|
||||
//
|
||||
// *create new* shared memory chunk
|
||||
// once this is created, use the pointer
|
||||
// to the segment to to store data
|
||||
// e.g.:
|
||||
// lpString = "string for communicator";
|
||||
// lstrcpy((LPSTR)pData->m_buf[0], lpString);
|
||||
// pData->m_dwBytesUsed = lstrlen(lpString) + 1; // count '\0'
|
||||
//
|
||||
CSharedMem *
|
||||
NSCreateSharedMemory(DWORD memSize, LPCTSTR memName, HANDLE *hSharedMemory);
|
||||
|
||||
//
|
||||
// *open existing* shared memory chunk
|
||||
// once you have the pointer to the new segment
|
||||
// use this pointer to access data, e.g.:
|
||||
//
|
||||
// This will return the pointer to the memory chunk as well as
|
||||
// fill out the hSharedMemory argument that is needed for subsequent
|
||||
// operations.
|
||||
//
|
||||
// if(pData->m_dwBytesUsed > 0)
|
||||
// {
|
||||
// // use pData->m_buf here
|
||||
// }
|
||||
//
|
||||
CSharedMem *
|
||||
NSOpenExistingSharedMemory(LPCTSTR memName, HANDLE *hSharedMemory);
|
||||
|
||||
//
|
||||
// You must pass in the pointer to the memory chunk as well as
|
||||
// the hSharedMemory HANDLE to close shared memory segment
|
||||
//
|
||||
void
|
||||
NSCloseSharedMemory(CSharedMem *pData, HANDLE hSharedMemory);
|
||||
|
||||
#endif // __SMEM_HPP__
|
||||
230
mozilla/mailnews/mapi/old/lib/nsstrseq.cpp
Normal file
230
mozilla/mailnews/mapi/old/lib/nsstrseq.cpp
Normal file
@@ -0,0 +1,230 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
// This is a string sequence handling routine to take complex
|
||||
// structures and merge them into a chunk of memory.
|
||||
//
|
||||
// Written by: Rich Pizzarro (rhp@netscape.com)
|
||||
// November 1997
|
||||
//
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "nsstrseq.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL '\0'
|
||||
#endif
|
||||
|
||||
#define MARKER '\377'
|
||||
|
||||
//
|
||||
// Delete an existing string sequence
|
||||
//
|
||||
void NSStrSeqDelete(NSstringSeq seq)
|
||||
{
|
||||
if (seq != NULL)
|
||||
free(seq);
|
||||
|
||||
seq = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate a new sequence, copying the given strings into it.
|
||||
//
|
||||
NSstringSeq NSStrSeqNew(LPSTR strings[])
|
||||
{
|
||||
int size;
|
||||
if (!strings)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
{
|
||||
int i;
|
||||
for (i=0,size=0; strings[i]; i++)
|
||||
{
|
||||
size+=strlen(strings[i])+1;
|
||||
switch (strings[i][0])
|
||||
{
|
||||
// Need to pad "" or anything starting with 255
|
||||
// to allow for multiple blank strings in a row
|
||||
case 0:
|
||||
case MARKER:
|
||||
size++;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
NSstringSeq s=(NSstringSeq)malloc(size+1);
|
||||
if (!s)
|
||||
{ return NULL;}
|
||||
|
||||
{
|
||||
int i,offset;
|
||||
for (i=0,offset=0; strings[i]; i++)
|
||||
{
|
||||
switch (strings[i][0])
|
||||
{
|
||||
// Need to pad "" or anything starting with 255
|
||||
case 0:
|
||||
case MARKER:
|
||||
s[offset++]=MARKER;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
strcpy(s+offset,strings[i]);
|
||||
offset+=strlen(strings[i])+1;
|
||||
}
|
||||
s[offset]=0;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Get the # of bytes required for the sequence
|
||||
//
|
||||
LONG NSStrSeqSize(NSstringSeq seq)
|
||||
{
|
||||
const char* s;
|
||||
if (!seq)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (s=seq+1; ((*s) || (*(s-1))); s++)
|
||||
;
|
||||
|
||||
// At this point, s points to the second 0
|
||||
// of the double 0 at the end
|
||||
return (s-seq)+1;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the # of strings in the sequence
|
||||
//
|
||||
LONG NSStrSeqNumStrs(NSstringSeq seq)
|
||||
{
|
||||
const char* s;
|
||||
int N;
|
||||
if (!seq)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (s=seq+1,N=0; ((*s) || (*(s-1))); s++)
|
||||
{
|
||||
if (!(*s))
|
||||
N++;
|
||||
}
|
||||
|
||||
return N;
|
||||
}
|
||||
|
||||
static LPSTR correct(LPSTR s)
|
||||
{
|
||||
if (s[0]==MARKER)
|
||||
return s+1;
|
||||
else // Anup , 4/96
|
||||
return s;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract the index'th string in the sequence
|
||||
//
|
||||
LPSTR NSStrSeqGet(NSstringSeq seq, LONG index)
|
||||
{
|
||||
char* s;
|
||||
int N;
|
||||
|
||||
if (!seq)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (index<0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!index)
|
||||
return correct(seq);
|
||||
|
||||
for (s=seq+1,N=0; ((*s) || (*(s-1))) && (N<index); s++)
|
||||
{
|
||||
if (!(*s))
|
||||
N++;
|
||||
}
|
||||
|
||||
if (N==index)
|
||||
return correct(s);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LPSTR * NSStrSeqGetAll(NSstringSeq seq)
|
||||
{
|
||||
LONG N=NSStrSeqNumStrs(seq);
|
||||
if (N<0)
|
||||
return NULL;
|
||||
|
||||
{
|
||||
char** res=(char**)malloc( (size_t) ((N+1)*sizeof(char*)) );
|
||||
int i;
|
||||
|
||||
if (!res)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
for (i=0; i<N; i++)
|
||||
res[i]=NSStrSeqGet(seq,i);
|
||||
res[N]=NULL;
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
68
mozilla/mailnews/mapi/old/lib/nsstrseq.h
Normal file
68
mozilla/mailnews/mapi/old/lib/nsstrseq.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef __SEQUENCES_OF_STRINGS_H_
|
||||
#define __SEQUENCES_OF_STRINGS_H
|
||||
|
||||
|
||||
typedef LPSTR NSstringSeq;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void NSStrSeqDelete(NSstringSeq seq);
|
||||
NSstringSeq NSStrSeqNew(LPSTR strings[]);
|
||||
|
||||
// Get the # of bytes required for the sequence
|
||||
LONG NSStrSeqSize(NSstringSeq seq);
|
||||
|
||||
// Get the # of strings in the sequence
|
||||
LONG NSStrSeqNumStrs(NSstringSeq seq);
|
||||
|
||||
// Extract the index'th string in the sequence
|
||||
LPSTR NSStrSeqGet(NSstringSeq seq, LONG index);
|
||||
|
||||
// Build an array of all the strings in the sequence
|
||||
LPSTR *NSStrSeqGetAll(NSstringSeq seq);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // __sequences_of_strings_h_
|
||||
26
mozilla/mailnews/mapi/old/makefile.win
Normal file
26
mozilla/mailnews/mapi/old/makefile.win
Normal file
@@ -0,0 +1,26 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
DIRS=public lib mapi32 tests hook
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
100
mozilla/mailnews/mapi/old/mapi32/maindll.cpp
Normal file
100
mozilla/mailnews/mapi/old/mapi32/maindll.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
// DLLMain to get a handle on an hInstance
|
||||
// Written by: Rich Pizzarro (rhp@netscape.com)
|
||||
// November 1997
|
||||
#include <windows.h>
|
||||
|
||||
//
|
||||
// global variables
|
||||
//
|
||||
HINSTANCE hInstance;
|
||||
|
||||
//
|
||||
// DLL entry
|
||||
//
|
||||
#ifdef WIN32
|
||||
/****************************************************************************
|
||||
FUNCTION: DllMain(HANDLE, DWORD, LPVOID)
|
||||
|
||||
PURPOSE: DllMain is called by Windows when
|
||||
the DLL is initialized, Thread Attached, and other times.
|
||||
Refer to SDK documentation, as to the different ways this
|
||||
may be called.
|
||||
|
||||
The DllMain function should perform additional initialization
|
||||
tasks required by the DLL. In this example, no initialization
|
||||
tasks are required. DllMain should return a value of 1 if
|
||||
the initialization is successful.
|
||||
|
||||
*******************************************************************************/
|
||||
BOOL APIENTRY DllMain(HANDLE hInstLocal, DWORD ul_reason_being_called, LPVOID lpReserved)
|
||||
{
|
||||
hInstance = (HINSTANCE)hInstLocal;
|
||||
|
||||
if (hInstance != NULL)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else // WIN16
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// LibMain( hInstance, wDataSegment, wHeapSize, lpszCmdLine ) : WORD
|
||||
//
|
||||
// hInstance library instance handle
|
||||
// wDataSegment library data segment
|
||||
// wHeapSize default heap size
|
||||
// lpszCmdLine command line arguments
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
int CALLBACK LibMain(HINSTANCE hInstLocal, WORD wDataSegment, WORD wHeapSize, LPSTR lpszCmdLine)
|
||||
{
|
||||
hInstance = hInstLocal;
|
||||
/* return result 1 = success; 0 = fail */
|
||||
if (hInstance != NULL)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // WIN16
|
||||
|
||||
70
mozilla/mailnews/mapi/old/mapi32/makefile.win
Normal file
70
mozilla/mailnews/mapi/old/mapi32/makefile.win
Normal file
@@ -0,0 +1,70 @@
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE=mapi32
|
||||
|
||||
################################################################################
|
||||
## exports
|
||||
|
||||
#EXPORTS =
|
||||
|
||||
|
||||
################################################################################
|
||||
## library
|
||||
|
||||
LIBNAME = .\$(OBJDIR)\mapi32
|
||||
DEFINES= -NS_DEBUG
|
||||
DEFFILE=MAPI32.def
|
||||
|
||||
!ifdef MOZ_STATIC_COMPONENT_LIBS
|
||||
LIB = $(LIBNAME).lib
|
||||
!else
|
||||
DLL = $(LIBNAME).dll
|
||||
!endif
|
||||
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\maindll.obj \
|
||||
.\$(OBJDIR)\mapi32.obj \
|
||||
.\$(OBJDIR)\mapiipc.obj \
|
||||
.\$(OBJDIR)\mapimem.obj \
|
||||
.\$(OBJDIR)\mapiutl.obj \
|
||||
.\$(OBJDIR)\smem.obj \
|
||||
.\$(OBJDIR)\trace.obj \
|
||||
.\$(OBJDIR)\xpapi.obj \
|
||||
$(NULL)
|
||||
|
||||
LLIBS= \
|
||||
$(LLIBS) \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\xppref32.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\mapiutils_s.lib \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
!ifdef MOZ_STATIC_COMPONENT_LIBS
|
||||
install:: $(LIB)
|
||||
$(MAKE_INSTALL) $(LIBNAME).$(LIB_SUFFIX) $(DIST)\bin\components
|
||||
!else
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) $(LIBNAME).$(DLL_SUFFIX) $(DIST)\bin\components
|
||||
!endif
|
||||
2291
mozilla/mailnews/mapi/old/mapi32/mapi32.cpp
Normal file
2291
mozilla/mailnews/mapi/old/mapi32/mapi32.cpp
Normal file
File diff suppressed because it is too large
Load Diff
14
mozilla/mailnews/mapi/old/mapi32/mapi32.def
Normal file
14
mozilla/mailnews/mapi/old/mapi32/mapi32.def
Normal file
@@ -0,0 +1,14 @@
|
||||
EXPORTS
|
||||
MAPILogon
|
||||
MAPILogoff
|
||||
MAPISendMail
|
||||
MAPISendDocuments
|
||||
MAPIFreeBuffer
|
||||
MAPIFindNext
|
||||
MAPIReadMail
|
||||
MAPISaveMail
|
||||
MAPIDeleteMail
|
||||
MAPIAddress
|
||||
MAPIDetails
|
||||
MAPIResolveName
|
||||
MAPIGetNetscapeVersion
|
||||
146
mozilla/mailnews/mapi/old/mapi32/mapi32.rc
Normal file
146
mozilla/mailnews/mapi/old/mapi32/mapi32.rc
Normal file
@@ -0,0 +1,146 @@
|
||||
// Insert copyright and license here 1997
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
ID_DIALOG_MAPI DIALOGEX 0, 0, 186, 111
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_TOOLWINDOW
|
||||
CAPTION "Netscape MAPI Support"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,41,95,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,104,95,50,14
|
||||
GROUPBOX "Diagnostic Information",IDC_STATIC,2,2,182,91
|
||||
CTEXT "This window will contain MAPI relative\ninformation for Netscape Communicator",
|
||||
IDC_STATIC,11,14,159,30
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
ID_DIALOG_MAPI, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 2
|
||||
RIGHTMARGIN, 184
|
||||
TOPMARGIN, 2
|
||||
BOTTOMMARGIN, 109
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 5,0,0,1
|
||||
PRODUCTVERSION 5,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "Simple MAPI DLL\0"
|
||||
VALUE "CompanyName", "Netscape Communications Corporation\0"
|
||||
VALUE "FileDescription", "mapi32\0"
|
||||
VALUE "FileVersion", "5, 0, 0, 1\0"
|
||||
VALUE "InternalName", "mapi32\0"
|
||||
VALUE "LegalCopyright", "Copyright © 1997\0"
|
||||
VALUE "LegalTrademarks", "Netscape and Netscape Navigator are registered trademarks of Netscape Communications Corporation.\0"
|
||||
VALUE "OriginalFilename", "mapi32.dll\0"
|
||||
VALUE "ProductName", "Netscape Communications Simple MAPI\0"
|
||||
VALUE "ProductVersion", "5, 0, 0, 1\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
249
mozilla/mailnews/mapi/old/mapi32/mapiipc.cpp
Normal file
249
mozilla/mailnews/mapi/old/mapi32/mapiipc.cpp
Normal file
@@ -0,0 +1,249 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
// MAPI IPC Routines
|
||||
// Written by: Rich Pizzarro (rhp@netscape.com)
|
||||
// November 1997
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <nscpmapi.h> // Should live in Communicator
|
||||
|
||||
#include "resource.h"
|
||||
#include "mapiipc.h"
|
||||
#include "mapismem.h"
|
||||
#include "trace.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Necessary variables...
|
||||
//
|
||||
static LONG instanceCount = 0;
|
||||
HWND hWndMAPI = NULL;
|
||||
char szClassName[] = "NetscapeMAPIClient";
|
||||
char szWindowName[] = "NetscapeMAPI";
|
||||
|
||||
//
|
||||
// External declares...
|
||||
//
|
||||
extern HINSTANCE hInstance;
|
||||
|
||||
void
|
||||
ProcessCommand(HWND hWnd, int id, HWND hCtl, UINT codeNotify)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
{
|
||||
ShowWindow(hWnd, SW_HIDE);
|
||||
}
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CALLBACK LOADDS
|
||||
MyDlgProc(HWND hWndMain, UINT wMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (wMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
hWndMAPI = hWndMain;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
// DestroyWindow(hWndMain);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
hWndMain = NULL;
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
HANDLE_WM_COMMAND(hWndMAPI, wParam, lParam, ProcessCommand);
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
InitInstance(HINSTANCE hInstance)
|
||||
{
|
||||
//
|
||||
// Create a main window for this application instance.
|
||||
//
|
||||
/* RICHIE - TRY SOME CHANGES!!!
|
||||
hWndMAPI = CreateDialog((HINSTANCE) hInstance,
|
||||
MAKEINTRESOURCE(ID_DIALOG_QAHOOK),
|
||||
(HWND) NULL, (DLGPROC) MyDlgProc);
|
||||
******/
|
||||
hWndMAPI = CreateWindow(
|
||||
szClassName, // pointer to registered class name
|
||||
szWindowName, // pointer to window name
|
||||
WS_CHILD, // window style
|
||||
-10, // horizontal position of window
|
||||
-10, // vertical position of window
|
||||
1, // window width
|
||||
1, // window height
|
||||
GetDesktopWindow(), // handle to parent or owner window
|
||||
NULL, // handle to menu or child-window identifier
|
||||
hInstance, // handle to application instance
|
||||
NULL // pointer to window-creation data
|
||||
);
|
||||
if (!hWndMAPI)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
InitApp(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
WNDCLASS wc;
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = DefDlgProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = DLGWINDOWEXTRA;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ID_ICON_APP));
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = szClassName;
|
||||
|
||||
if(!RegisterClass(&wc))
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
} // end InitApp
|
||||
|
||||
BOOL
|
||||
InitDLL(void)
|
||||
{
|
||||
if (hWndMAPI != NULL)
|
||||
return TRUE;
|
||||
|
||||
if (!InitApp())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!InitInstance(hInstance))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ShowWindow(hWndMAPI, SW_SHOW); Just for jollies
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
//*************************************************************
|
||||
//* Calls exposed for rest of DLL...
|
||||
//*************************************************************
|
||||
//
|
||||
// Purpose: Open the API
|
||||
// Return: 1 on success
|
||||
// 0 on failure
|
||||
//
|
||||
DWORD nsMAPI_OpenAPI(void)
|
||||
{
|
||||
if (instanceCount > 0)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
|
||||
++instanceCount;
|
||||
return(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Purpose: Close the API
|
||||
//
|
||||
void nsMAPI_CloseAPI(void)
|
||||
{
|
||||
--instanceCount;
|
||||
if (instanceCount <= 0)
|
||||
{
|
||||
instanceCount = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Send the actual request to Communicator
|
||||
//
|
||||
LRESULT
|
||||
SendMAPIRequest(HWND hWnd,
|
||||
DWORD mapiRequestID,
|
||||
MAPIIPCType *ipcInfo)
|
||||
{
|
||||
LRESULT returnVal = 0;
|
||||
COPYDATASTRUCT cds;
|
||||
|
||||
if (!InitDLL())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
cds.dwData = mapiRequestID;
|
||||
cds.cbData = sizeof(MAPIIPCType);
|
||||
cds.lpData = ipcInfo;
|
||||
|
||||
// Make the call into Communicator
|
||||
returnVal = SendMessage(hWnd, WM_COPYDATA, (WPARAM) hWndMAPI, (LPARAM) &cds);
|
||||
|
||||
// Now kill the window...
|
||||
DestroyWindow(hWndMAPI);
|
||||
hWndMAPI = NULL;
|
||||
UnregisterClass(szClassName, hInstance);
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
63
mozilla/mailnews/mapi/old/mapi32/mapiipc.h
Normal file
63
mozilla/mailnews/mapi/old/mapi32/mapiipc.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef __MAPIIPC_HPP__
|
||||
#define __MAPIIPC_HPP__
|
||||
|
||||
#include "port.h"
|
||||
#include <nscpmapi.h>
|
||||
|
||||
//********************************************************
|
||||
// Open and close functions for API
|
||||
//********************************************************
|
||||
// Open the API
|
||||
// Return: 1 on success, 0 on failure
|
||||
//
|
||||
DWORD nsMAPI_OpenAPI(void);
|
||||
|
||||
//
|
||||
// Purpose: Close the API
|
||||
//
|
||||
void nsMAPI_CloseAPI(void);
|
||||
|
||||
//
|
||||
// Send the actual request to Communicator
|
||||
//
|
||||
LRESULT SendMAPIRequest(HWND hWnd,
|
||||
DWORD mapiRequestID,
|
||||
MAPIIPCType *ipcInfo);
|
||||
|
||||
#endif // __MAPIIPC_HPP__
|
||||
363
mozilla/mailnews/mapi/old/mapi32/mapimem.cpp
Normal file
363
mozilla/mailnews/mapi/old/mapi32/mapimem.cpp
Normal file
@@ -0,0 +1,363 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
// mem.cpp
|
||||
// Written by: Rich Pizzarro (rhp@netscape.com)
|
||||
// November 1997
|
||||
// This implements various memory management functions for use with
|
||||
// MAPI features of Communicator
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <memory.h>
|
||||
#include <malloc.h>
|
||||
#include "mapimem.h"
|
||||
#include <nscpmapi.h> // lives in communicator winfe
|
||||
#include "nsstrseq.h"
|
||||
#include "trace.h"
|
||||
#include "mapiutl.h"
|
||||
#include "xpapi.h"
|
||||
|
||||
LPSTR
|
||||
CheckNullString(LPSTR inStr)
|
||||
{
|
||||
static UCHAR str[1];
|
||||
|
||||
str[0] = '\0';
|
||||
if (inStr == NULL)
|
||||
return((LPSTR)str);
|
||||
else
|
||||
return(inStr);
|
||||
}
|
||||
|
||||
void
|
||||
FreeMAPIFile(lpMapiFileDesc pv)
|
||||
{
|
||||
if (!pv)
|
||||
return;
|
||||
|
||||
if (pv->lpszPathName != NULL)
|
||||
free(pv->lpszPathName);
|
||||
|
||||
if (pv->lpszFileName != NULL)
|
||||
free(pv->lpszFileName);
|
||||
}
|
||||
|
||||
void
|
||||
FreeMAPIMessage(lpMapiMessage pv)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
if (!pv)
|
||||
return;
|
||||
|
||||
if (pv->lpszSubject != NULL)
|
||||
free(pv->lpszSubject);
|
||||
|
||||
if (pv->lpszNoteText)
|
||||
free(pv->lpszNoteText);
|
||||
|
||||
if (pv->lpszMessageType)
|
||||
free(pv->lpszMessageType);
|
||||
|
||||
if (pv->lpszDateReceived)
|
||||
free(pv->lpszDateReceived);
|
||||
|
||||
if (pv->lpszConversationID)
|
||||
free(pv->lpszConversationID);
|
||||
|
||||
if (pv->lpOriginator)
|
||||
FreeMAPIRecipient(pv->lpOriginator);
|
||||
|
||||
for (i=0; i<pv->nRecipCount; i++)
|
||||
{
|
||||
if (&(pv->lpRecips[i]) != NULL)
|
||||
{
|
||||
FreeMAPIRecipient(&(pv->lpRecips[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if (pv->lpRecips != NULL)
|
||||
{
|
||||
free(pv->lpRecips);
|
||||
}
|
||||
|
||||
for (i=0; i<pv->nFileCount; i++)
|
||||
{
|
||||
if (&(pv->lpFiles[i]) != NULL)
|
||||
{
|
||||
FreeMAPIFile(&(pv->lpFiles[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if (pv->lpFiles != NULL)
|
||||
{
|
||||
free(pv->lpFiles);
|
||||
}
|
||||
|
||||
free(pv);
|
||||
pv = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
FreeMAPIRecipient(lpMapiRecipDesc pv)
|
||||
{
|
||||
if (!pv)
|
||||
return;
|
||||
|
||||
if (pv->lpszName != NULL)
|
||||
free(pv->lpszName);
|
||||
|
||||
if (pv->lpszAddress != NULL)
|
||||
free(pv->lpszAddress);
|
||||
|
||||
if (pv->lpEntryID != NULL)
|
||||
free(pv->lpEntryID);
|
||||
}
|
||||
|
||||
//
|
||||
// This routine will take an lpMapiMessage structure and "flatten" it into
|
||||
// one contiguous chunk of memory that can be easily passed around. After this
|
||||
// is done, "extract" routines will be written to get complicated string routines
|
||||
// out of the chunk of memory at the end.
|
||||
//
|
||||
LPVOID
|
||||
FlattenMAPIMessageStructure(lpMapiMessage msg, DWORD *totalSize)
|
||||
{
|
||||
MAPISendMailType *mailPtr;
|
||||
LPSTR *strArray;
|
||||
DWORD strCount = 0;
|
||||
DWORD currentString = 0;
|
||||
DWORD arrayBufSize = 0;
|
||||
DWORD i;
|
||||
|
||||
*totalSize = 0;
|
||||
if (!msg)
|
||||
return(NULL);
|
||||
|
||||
//
|
||||
// Allocate the initial structure to hold all of the mail info.
|
||||
//
|
||||
*totalSize = sizeof(MAPISendMailType);
|
||||
mailPtr = (MAPISendMailType *) malloc(sizeof(MAPISendMailType));
|
||||
if (!mailPtr)
|
||||
return(NULL);
|
||||
memset(mailPtr, 0, sizeof(MAPISendMailType));
|
||||
|
||||
//
|
||||
// First, assign all of the easy numeric values...
|
||||
//
|
||||
mailPtr->MSG_flFlags = msg->flFlags; // unread,return receipt
|
||||
mailPtr->MSG_nRecipCount = msg->nRecipCount; // Number of recipients
|
||||
mailPtr->MSG_nFileCount = msg->nFileCount; // # of file attachments
|
||||
if (msg->lpOriginator != NULL)
|
||||
{
|
||||
mailPtr->MSG_ORIG_ulRecipClass = msg->lpOriginator->ulRecipClass; // Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG
|
||||
}
|
||||
|
||||
//
|
||||
// Now, figure out how many string pointers we need...
|
||||
//
|
||||
strCount = 4; // These are the 4 KNOWN strings up front for a message
|
||||
strCount += 2; // This is for the originator name and address
|
||||
|
||||
strCount += msg->nRecipCount * 3; // Name, address & class (cc, bcc) for each recipient
|
||||
strCount += msg->nFileCount * 2; // filename and display name for each attachment
|
||||
|
||||
//
|
||||
// Now allocate a new string sequence...add one entry for NULL at the end
|
||||
//
|
||||
arrayBufSize = sizeof(LPSTR) * (strCount + 1);
|
||||
|
||||
#ifdef WIN16 // Check for max mem allocation...
|
||||
if ((sizeof(MAPISendMailType) + arrayBufSize) > 64000)
|
||||
{
|
||||
free(mailPtr);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Allocate a buffer for the string pointers and if this fails,
|
||||
// cleanup and return.
|
||||
//
|
||||
strArray = (LPSTR *)malloc( (size_t) arrayBufSize);
|
||||
if (!strArray)
|
||||
{
|
||||
free(mailPtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(strArray, 0, (size_t) arrayBufSize); // Set the array to NULL
|
||||
strArray[currentString++] = CheckNullString(msg->lpszSubject); // Message Subject
|
||||
strArray[currentString++] = CheckNullString(msg->lpszNoteText); // Message Text
|
||||
strArray[currentString++] = CheckNullString(msg->lpszDateReceived); // in YYYY/MM/DD HH:MM format
|
||||
strArray[currentString++] = CheckNullString(msg->lpszConversationID); // conversation thread ID
|
||||
|
||||
if (msg->lpOriginator)
|
||||
{
|
||||
strArray[currentString++] = CheckNullString(msg->lpOriginator[0].lpszName);
|
||||
strArray[currentString++] = CheckNullString(msg->lpOriginator[0].lpszAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
strArray[currentString++] = CheckNullString(NULL);
|
||||
strArray[currentString++] = CheckNullString(NULL);
|
||||
}
|
||||
|
||||
//
|
||||
// Assign pointers for the Name and address of each recipient
|
||||
//
|
||||
LPSTR toString = "1";
|
||||
LPSTR ccString = "2";
|
||||
LPSTR bccString = "3";
|
||||
|
||||
for (i=0; i<msg->nRecipCount; i++)
|
||||
{
|
||||
// rhp - need message class
|
||||
if (msg->lpRecips[i].ulRecipClass == MAPI_BCC)
|
||||
strArray[currentString++] = CheckNullString(bccString);
|
||||
else if (msg->lpRecips[i].ulRecipClass == MAPI_CC)
|
||||
strArray[currentString++] = CheckNullString(ccString);
|
||||
else
|
||||
strArray[currentString++] = CheckNullString(toString);
|
||||
|
||||
strArray[currentString++] = CheckNullString(msg->lpRecips[i].lpszName);
|
||||
strArray[currentString++] = CheckNullString(msg->lpRecips[i].lpszAddress);
|
||||
}
|
||||
|
||||
BYTE szNewFileName[_MAX_PATH];
|
||||
|
||||
for (i=0; i<msg->nFileCount; i++)
|
||||
{
|
||||
char *namePtr;
|
||||
// have to copy/create temp files here of office won't work...
|
||||
|
||||
if (
|
||||
(msg->lpFiles[i].lpszFileName != NULL) &&
|
||||
(*msg->lpFiles[i].lpszFileName != '\0')
|
||||
)
|
||||
{
|
||||
namePtr = (char *)msg->lpFiles[i].lpszFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
namePtr = (char *)msg->lpFiles[i].lpszPathName;
|
||||
}
|
||||
|
||||
if (GetTempMailNameWithExtension((char *)szNewFileName, namePtr) == 0)
|
||||
{
|
||||
free(strArray);
|
||||
free(mailPtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!XP_CopyFile((char *)msg->lpFiles[i].lpszPathName, (char *)szNewFileName, TRUE))
|
||||
{
|
||||
free(strArray);
|
||||
free(mailPtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strArray[currentString++] = CheckNullString((char *)szNewFileName);
|
||||
strArray[currentString++] = CheckNullString(msg->lpFiles[i].lpszFileName);
|
||||
|
||||
AddTempFile((LPSTR) szNewFileName);
|
||||
// strArray[currentString++] = CheckNullString(msg->lpFiles[i].lpszPathName);
|
||||
// strArray[currentString++] = CheckNullString(msg->lpFiles[i].lpszFileName);
|
||||
}
|
||||
|
||||
if (currentString != strCount)
|
||||
{
|
||||
TRACE("MAPI PROBLEM!!!!!! FlattenMAPIMessageStructure() currentString != strCount\n");
|
||||
}
|
||||
|
||||
strArray[strCount] = NULL; // terminate at the end
|
||||
NSstringSeq strSeq = NSStrSeqNew(strArray);
|
||||
if (!strSeq)
|
||||
{
|
||||
free(strArray);
|
||||
free(mailPtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Now we need to copy the structure into a big, contiguous chunk of memory
|
||||
//
|
||||
LONG totalArraySize = NSStrSeqSize(strSeq);
|
||||
LONG totalMemSize = sizeof(MAPISendMailType) + totalArraySize;
|
||||
|
||||
#ifdef WIN16
|
||||
if (totalMemSize > 64000)
|
||||
{
|
||||
free(strArray);
|
||||
NSStrSeqDelete(strSeq);
|
||||
free(mailPtr);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
MAPISendMailType *newMailPtr = (MAPISendMailType *)malloc((size_t)totalMemSize);
|
||||
if (!newMailPtr)
|
||||
{
|
||||
free(strArray);
|
||||
NSStrSeqDelete(strSeq);
|
||||
free(mailPtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(newMailPtr, 0, (size_t) totalMemSize);
|
||||
//
|
||||
// Finally do the copy...
|
||||
//
|
||||
memcpy(newMailPtr, mailPtr, sizeof(MAPISendMailType));
|
||||
memcpy(newMailPtr->dataBuf, strSeq, (size_t) totalArraySize);
|
||||
*totalSize = totalMemSize;
|
||||
|
||||
//
|
||||
// Cleanup and scram...
|
||||
//
|
||||
if (strArray)
|
||||
free(strArray);
|
||||
|
||||
if (strSeq)
|
||||
NSStrSeqDelete(strSeq);
|
||||
|
||||
if (mailPtr)
|
||||
free(mailPtr);
|
||||
|
||||
return(newMailPtr);
|
||||
}
|
||||
76
mozilla/mailnews/mapi/old/mapi32/mapimem.h
Normal file
76
mozilla/mailnews/mapi/old/mapi32/mapimem.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef __MY_MEM_HPP__
|
||||
#define __MY_MEM_HPP__
|
||||
|
||||
#ifndef MAPI_OLE // Because MSFT doesn't do this for us :-(
|
||||
#include <mapi.h>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Needed for turning NULL's into ""'s for string sequence routines...
|
||||
//
|
||||
LPSTR CheckNullString(LPSTR inStr);
|
||||
|
||||
//
|
||||
// Memory allocation functions...
|
||||
//
|
||||
|
||||
//
|
||||
// This will free an lpMapiMessage structure allocated by this DLL
|
||||
//
|
||||
void FreeMAPIMessage(lpMapiMessage pv);
|
||||
|
||||
//
|
||||
// This will free an lpMapiRecipDesc structure allocated by this DLL
|
||||
//
|
||||
void FreeMAPIRecipient(lpMapiRecipDesc pv);
|
||||
|
||||
//
|
||||
// Frees a mapi file object...
|
||||
//
|
||||
void FreeMAPIFile(lpMapiFileDesc pv);
|
||||
|
||||
//
|
||||
// This routine will take an lpMapiMessage structure and "flatten" it into
|
||||
// one contiguous chunk of memory that can be easily passed around.
|
||||
//
|
||||
LPVOID FlattenMAPIMessageStructure(lpMapiMessage msg, DWORD *totalSize);
|
||||
|
||||
|
||||
|
||||
#endif // __MY_MEM_HPP__
|
||||
899
mozilla/mailnews/mapi/old/mapi32/mapiutl.cpp
Normal file
899
mozilla/mailnews/mapi/old/mapi32/mapiutl.cpp
Normal file
@@ -0,0 +1,899 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
// Various utils needed for the MAPI functions
|
||||
// Written by: Rich Pizzarro (rhp@netscape.com)
|
||||
// November 1997
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <io.h>
|
||||
#include "xpapi.h"
|
||||
#include "trace.h"
|
||||
#include "mapiipc.h"
|
||||
#include "mapiutl.h"
|
||||
|
||||
//
|
||||
// Global variables
|
||||
//
|
||||
BOOL gLoggingEnabled = FALSE;
|
||||
|
||||
void
|
||||
SetLoggingEnabled(BOOL val)
|
||||
{
|
||||
gLoggingEnabled = val;
|
||||
}
|
||||
|
||||
// Log File
|
||||
void
|
||||
LogString(LPCSTR pStr1)
|
||||
{
|
||||
// Off of the declaration line...
|
||||
LPCSTR pStr2 = NULL;
|
||||
BOOL useStr1 = TRUE;
|
||||
|
||||
if (gLoggingEnabled)
|
||||
{
|
||||
char tempPath[_MAX_PATH] = "";
|
||||
if (getenv("TEMP"))
|
||||
{
|
||||
lstrcpy((LPSTR) tempPath, getenv("TEMP")); // environmental variable
|
||||
}
|
||||
|
||||
int len = lstrlen(tempPath);
|
||||
if ((len > 1) && tempPath[len - 1] != '\\')
|
||||
{
|
||||
lstrcat(tempPath, "\\");
|
||||
}
|
||||
lstrcat(tempPath, szMapiLog);
|
||||
HFILE hFile = _lopen(tempPath, OF_WRITE);
|
||||
if (hFile == HFILE_ERROR)
|
||||
{
|
||||
hFile = _lcreat(tempPath, 0);
|
||||
}
|
||||
if (hFile != HFILE_ERROR)
|
||||
{
|
||||
_llseek(hFile, 0, SEEK_END); // seek to the end of the file
|
||||
LPCSTR pTemp = useStr1 ? pStr1 : pStr2;
|
||||
_lwrite(hFile, pTemp, lstrlen(pTemp));
|
||||
_lclose(hFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Find Communicator and return an HWND, if not, start Communicator,
|
||||
// then find an HWND
|
||||
//
|
||||
HWND
|
||||
GetCommunicatorIPCWindow(void)
|
||||
{
|
||||
HWND hWnd = NULL;
|
||||
DWORD timeCount = 0;
|
||||
BOOL launchTry = FALSE;
|
||||
|
||||
//
|
||||
// This will wait for 10 seconds before giving up and failing
|
||||
//
|
||||
while ((hWnd == NULL) && (timeCount < 20))
|
||||
{
|
||||
if ((hWnd = FindWindow("AfxFrameOrView", NULL)) && !FindWindow("aHiddenFrameClass", NULL))
|
||||
return(hWnd);
|
||||
else if ((hWnd = FindWindow("aHiddenFrameClass", NULL)))
|
||||
return(hWnd);
|
||||
|
||||
if (!launchTry)
|
||||
{
|
||||
char szPath[_MAX_PATH] = "";
|
||||
DWORD nMAPIERROR;
|
||||
|
||||
if ((nMAPIERROR = XP_GetInstallLocation(szPath, _MAX_PATH)) != SUCCESS_SUCCESS)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
WORD nReturn = XP_CallProcess(szPath, " -MAPICLIENT");
|
||||
launchTry = TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Pause for 1/2 a second and try to connect again...
|
||||
//
|
||||
#ifdef WIN32
|
||||
Sleep(500);
|
||||
#else
|
||||
Yield();
|
||||
#endif
|
||||
|
||||
timeCount++;
|
||||
}
|
||||
|
||||
return(hWnd);
|
||||
}
|
||||
|
||||
void
|
||||
BuildMemName(LPSTR name, ULONG winSeed)
|
||||
{
|
||||
static DWORD id = 0;
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
// Seed the random-number generator with current time so that
|
||||
// the numbers will be different every time we run.
|
||||
srand( (unsigned)time( NULL ) );
|
||||
id = rand();
|
||||
}
|
||||
|
||||
wsprintf(name, "MAPI_IPC_SMEM-%d", (winSeed + id++));
|
||||
TRACE("Shared Memory Name = [%s]\n", name);
|
||||
}
|
||||
|
||||
DWORD
|
||||
ValidateFile(LPCSTR szFile)
|
||||
{
|
||||
struct _stat buf;
|
||||
int result;
|
||||
|
||||
result = _stat( szFile, &buf );
|
||||
if (result != 0)
|
||||
return(1);
|
||||
|
||||
if (!(buf.st_mode & S_IREAD))
|
||||
return(2);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// return of zero is ok
|
||||
// 1 = MAPI_E_ATTACHMENT_NOT_FOUND
|
||||
// 2 = MAPI_E_ATTACHMENT_OPEN_FAILURE
|
||||
//
|
||||
DWORD
|
||||
SanityCheckAttachmentFiles(lpMapiMessage lpMessage)
|
||||
{
|
||||
ULONG i;
|
||||
DWORD rc;
|
||||
|
||||
for (i=0; i<lpMessage->nFileCount; i++)
|
||||
{
|
||||
if ((rc = ValidateFile(lpMessage->lpFiles[i].lpszPathName)) != 0)
|
||||
{
|
||||
return(rc);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
DWORD
|
||||
GetFileCount(LPSTR pFiles, LPSTR delimChar)
|
||||
{
|
||||
DWORD count = 1;
|
||||
if ((!pFiles) || (!*pFiles))
|
||||
return(0);
|
||||
|
||||
for (DWORD i=0; i<strlen(pFiles); i++)
|
||||
{
|
||||
if (pFiles[i] == delimChar[0])
|
||||
{
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return(count);
|
||||
}
|
||||
|
||||
//
|
||||
// Extract a filename from a string
|
||||
// Return TRUE if file found, else FALSE
|
||||
//
|
||||
BOOL
|
||||
ExtractFile(LPSTR pFiles, LPSTR delimChar, DWORD fIndex, LPSTR fName)
|
||||
{
|
||||
LPSTR ptr = pFiles;
|
||||
DWORD loc;
|
||||
DWORD count = 0;
|
||||
|
||||
if ((!pFiles) || (!*pFiles))
|
||||
return(0);
|
||||
|
||||
// Get to the fIndex'th entry
|
||||
for (loc=0; loc<strlen(pFiles); loc++)
|
||||
{
|
||||
if (count == fIndex)
|
||||
break;
|
||||
if (pFiles[loc] == delimChar[0])
|
||||
count++;
|
||||
}
|
||||
|
||||
if (loc >= strlen(pFiles)) // Got to the end of string!
|
||||
return(FALSE);
|
||||
|
||||
lstrcpy(fName, (LPSTR)pFiles + loc);
|
||||
//
|
||||
// Truncate at 2nd delimiter
|
||||
//
|
||||
for (DWORD i=0; i<strlen(fName); i++)
|
||||
{
|
||||
if (fName[i] == delimChar[0])
|
||||
{
|
||||
fName[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
ULONG
|
||||
GetFileSize(LPSTR fName)
|
||||
{
|
||||
struct _stat buf;
|
||||
int result;
|
||||
|
||||
result = _stat( fName, &buf );
|
||||
if (result != 0)
|
||||
return(0);
|
||||
|
||||
return(buf.st_size);
|
||||
}
|
||||
|
||||
LPVOID
|
||||
LoadBlobToMemory(LPSTR fName)
|
||||
{
|
||||
UCHAR *ptr = NULL;
|
||||
ULONG bufSize = GetFileSize(fName);
|
||||
|
||||
if (bufSize == 0)
|
||||
{
|
||||
_unlink(fName);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ptr = (UCHAR *)malloc( (size_t) bufSize);
|
||||
if (!ptr)
|
||||
{
|
||||
_unlink(fName);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
HFILE hFile = _lopen(fName, OF_READ);
|
||||
if (hFile == HFILE_ERROR)
|
||||
{
|
||||
_unlink(fName);
|
||||
free(ptr);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
UINT numRead = _lread(hFile, ptr, (size_t) bufSize);
|
||||
_lclose(hFile);
|
||||
|
||||
if (numRead != bufSize)
|
||||
{
|
||||
_unlink(fName);
|
||||
free(ptr);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
_unlink(fName);
|
||||
return(ptr);
|
||||
}
|
||||
|
||||
LONG
|
||||
WriteMemoryBufferToDisk(LPSTR fName, LONG bufSize, LPSTR buf)
|
||||
{
|
||||
if (!buf)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
HFILE hFile = _lcreat(fName, 0);
|
||||
if (hFile == HFILE_ERROR)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
|
||||
LONG writeCount = _lwrite(hFile, buf, (size_t) bufSize);
|
||||
_lclose(hFile);
|
||||
|
||||
if (writeCount != bufSize)
|
||||
{
|
||||
_unlink(fName);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
LPSTR
|
||||
GetTheTempDirectoryOnTheSystem(void)
|
||||
{
|
||||
static UCHAR retPath[_MAX_PATH];
|
||||
|
||||
if (getenv("TEMP"))
|
||||
{
|
||||
lstrcpy((LPSTR) retPath, getenv("TEMP")); // environmental variable
|
||||
}
|
||||
else if (getenv("TMP"))
|
||||
{
|
||||
lstrcpy((LPSTR) retPath, getenv("TMP")); // How about this environmental variable?
|
||||
}
|
||||
else
|
||||
{
|
||||
GetWindowsDirectory((LPSTR) retPath, sizeof(retPath));
|
||||
}
|
||||
|
||||
return((LPSTR) &(retPath[0]));
|
||||
}
|
||||
|
||||
#ifdef WIN16
|
||||
int WINAPI EXPORT ISGetTempFileName(LPCSTR a_pDummyPath, LPCSTR a_pPrefix, UINT a_uUnique, LPSTR a_pResultName)
|
||||
{
|
||||
#ifdef GetTempFileName // we need the real thing comming up next...
|
||||
#undef GetTempFileName
|
||||
#endif
|
||||
return GetTempFileName(0, a_pPrefix, a_uUnique, a_pResultName);
|
||||
}
|
||||
#endif
|
||||
|
||||
LONG
|
||||
GetTempAttachmentName(LPSTR fName)
|
||||
{
|
||||
UINT res;
|
||||
static UINT uUnique = 1;
|
||||
|
||||
if (!fName)
|
||||
return(-1);
|
||||
|
||||
LPSTR szTempPath = GetTheTempDirectoryOnTheSystem();
|
||||
|
||||
TRYAGAIN:
|
||||
#ifdef WIN32
|
||||
res = GetTempFileName(szTempPath, "MAPI", uUnique++, fName);
|
||||
#else
|
||||
res = ISGetTempFileName(szTempPath, "MAPI", uUnique++, fName);
|
||||
#endif
|
||||
|
||||
if (ValidateFile(fName) != 1)
|
||||
{
|
||||
if (uUnique < 32000)
|
||||
{
|
||||
goto TRYAGAIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// RICHIE - strip all of the HTML stuff out of the message...
|
||||
int
|
||||
CheckForInlineHTML(char *noteBody, DWORD len, DWORD *curPos, char *newBody, DWORD *realLen)
|
||||
{
|
||||
LPSTR tags[] = {" ", "<", "&", NULL};
|
||||
UCHAR tagsSubst[] = {' ', '<', '&', NULL};
|
||||
int x = 0;
|
||||
|
||||
while (tags[x])
|
||||
{
|
||||
// should we check for first tag
|
||||
if ( (*curPos+strlen(tags[x])) < len)
|
||||
{
|
||||
if (strncmp(tags[x], noteBody, strlen(tags[x])) == 0)
|
||||
{
|
||||
*curPos += strlen(tags[x]) - 1;
|
||||
newBody[*realLen] = tagsSubst[x];
|
||||
*realLen += 1;
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
++x;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// RICHIE - This is also temporary fix for now...
|
||||
//
|
||||
LPSTR
|
||||
StripSignedMessage(LPSTR noteText, DWORD totalCR)
|
||||
{
|
||||
char *newBuf;
|
||||
LPSTR startTag = "<HTML>";
|
||||
LPSTR endTag = "/HTML>";
|
||||
DWORD i;
|
||||
DWORD realLen = 0;
|
||||
DWORD startPos = 0;
|
||||
DWORD len = strlen(noteText);;
|
||||
|
||||
// create a new buffer...
|
||||
newBuf = (char *) malloc((size_t)(len + totalCR));
|
||||
if (!newBuf)
|
||||
return(noteText);
|
||||
|
||||
newBuf[0] = '\0';
|
||||
|
||||
// First, find the start of the HTML for the message...
|
||||
for (i=0; i<len; i++)
|
||||
{
|
||||
// should we check for first tag
|
||||
if ( (i+strlen(startTag)) < len)
|
||||
{
|
||||
if (strncmp(startTag, (noteText + i), strlen(startTag)) == 0)
|
||||
{
|
||||
startPos = i + strlen(startTag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Didn't find any HTML start tag
|
||||
if (i == len)
|
||||
return(noteText);
|
||||
|
||||
BOOL inHTML = FALSE;
|
||||
BOOL firstChar = FALSE;
|
||||
|
||||
for (i=startPos; i<len; i++)
|
||||
{
|
||||
char *ptr = (noteText + i);
|
||||
|
||||
if ( ((*ptr == 0x0D) || (*ptr == 0x20)) && (!firstChar) )
|
||||
continue;
|
||||
else
|
||||
firstChar = TRUE;
|
||||
|
||||
// First, check for the end /HTML> tag
|
||||
if ( (i+strlen(endTag)) < len)
|
||||
{
|
||||
if (strncmp(endTag, ptr, strlen(endTag)) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If we are in HTML, check for a ">"...
|
||||
if (inHTML)
|
||||
{
|
||||
if (*ptr == '>')
|
||||
{
|
||||
inHTML = FALSE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for NEW HTML...
|
||||
if (*ptr == '<')
|
||||
{
|
||||
inHTML = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CheckForInlineHTML(ptr, len, &i, newBuf, &realLen))
|
||||
continue;
|
||||
|
||||
newBuf[realLen++] = *ptr;
|
||||
// Tack on a line feed if we hit a CR...
|
||||
if ( *ptr == 0x0D )
|
||||
{
|
||||
newBuf[realLen++] = 0x0A;
|
||||
}
|
||||
}
|
||||
|
||||
// terminate the buffer - reallocate and move on...
|
||||
newBuf[realLen++] = '\0';
|
||||
newBuf = (LPSTR) realloc(newBuf, (size_t) realLen);
|
||||
|
||||
// check if the realloc worked and if so, free old memory and
|
||||
// return...if not, just return the original buffer
|
||||
if (!newBuf)
|
||||
{
|
||||
return(noteText);
|
||||
}
|
||||
else
|
||||
{
|
||||
free(noteText);
|
||||
return(newBuf);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// RICHIE - this is a temporary fix for now to get rid of
|
||||
// html stuff within the text of a message - if there was a
|
||||
// valid noteText buffer coming into this call, we need to
|
||||
// free it on the way out.
|
||||
//
|
||||
LPSTR
|
||||
StripHTML(LPSTR noteText)
|
||||
{
|
||||
char *newBuf;
|
||||
LPSTR signTag = "This is a cryptographically signed message in MIME format.";
|
||||
LPSTR mimeTag = "This is a multi-part message in MIME format.";
|
||||
|
||||
DWORD i;
|
||||
DWORD realLen = 0;
|
||||
DWORD totalCR = 0;
|
||||
|
||||
// do sanity checking...
|
||||
if ((!noteText) || (!(*noteText)))
|
||||
return(noteText);
|
||||
|
||||
// more sanity checking...
|
||||
DWORD len = strlen(noteText) + 1;
|
||||
if (len <= 0)
|
||||
return(noteText);
|
||||
|
||||
// Get the number of CR's in this message and add room for
|
||||
// the LF's
|
||||
for (i=0; i<len; i++)
|
||||
{
|
||||
if ( (*(noteText + i)) == 0x0D )
|
||||
++totalCR;
|
||||
}
|
||||
|
||||
// This is a check for a signed message in the start of a message
|
||||
// check for sign line...
|
||||
if ( strlen(signTag) < len)
|
||||
{
|
||||
if (
|
||||
(strncmp(signTag, noteText, strlen(signTag)) == 0) ||
|
||||
(strncmp(mimeTag, noteText, strlen(mimeTag)) == 0)
|
||||
)
|
||||
{
|
||||
return( StripSignedMessage(noteText, totalCR) );
|
||||
}
|
||||
}
|
||||
|
||||
// create a new buffer...
|
||||
newBuf = (char *) malloc((size_t)(len + totalCR));
|
||||
if (!newBuf)
|
||||
return(noteText);
|
||||
|
||||
newBuf[0] = '\0';
|
||||
|
||||
BOOL firstChar = FALSE;
|
||||
|
||||
// Now do the translation for the body of the note...
|
||||
for (i=0; i<len; i++)
|
||||
{
|
||||
char *ptr = (noteText + i);
|
||||
|
||||
if ( ((*ptr == 0x0D) || (*ptr == 0x20)) && (!firstChar) )
|
||||
continue;
|
||||
else
|
||||
firstChar = TRUE;
|
||||
|
||||
if (CheckForInlineHTML(ptr, len, &i, newBuf, &realLen))
|
||||
continue;
|
||||
|
||||
newBuf[realLen++] = *ptr;
|
||||
if ( *ptr == 0x0D )
|
||||
{
|
||||
newBuf[realLen++] = 0x0A;
|
||||
}
|
||||
}
|
||||
|
||||
// terminate the buffer - reallocate and move on...
|
||||
newBuf[realLen++] = '\0';
|
||||
newBuf = (LPSTR) realloc(newBuf, (size_t) realLen);
|
||||
|
||||
// check if the realloc worked and if so, free old memory and
|
||||
// return...if not, just return the original buffer
|
||||
if (!newBuf)
|
||||
{
|
||||
return(noteText);
|
||||
}
|
||||
else
|
||||
{
|
||||
free(noteText);
|
||||
return(newBuf);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN16
|
||||
|
||||
void
|
||||
GetWin16TempName(LPSTR realFileName, LPSTR tempPath,
|
||||
LPSTR szTempFileName, UINT uUnique)
|
||||
{
|
||||
char *dotPtr = strrchr(realFileName, '.');
|
||||
if (dotPtr != NULL)
|
||||
{
|
||||
*dotPtr = '\0';
|
||||
}
|
||||
|
||||
int nameLen = lstrlen(realFileName);
|
||||
if (dotPtr != NULL)
|
||||
{
|
||||
*dotPtr = '.';
|
||||
}
|
||||
|
||||
if (nameLen <= 7)
|
||||
{
|
||||
wsprintf(szTempFileName, "%s\\%d%s", tempPath, uUnique, realFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(szTempFileName, "%s\\%d%s", tempPath, uUnique, (realFileName + 1));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define MAXTRY 9999 // How many times do we try..
|
||||
|
||||
UINT
|
||||
GetTempMailNameWithExtension(LPSTR szTempFileName,
|
||||
LPSTR origName)
|
||||
{
|
||||
UINT res = 1;
|
||||
UINT uUnique = 0;
|
||||
char *szTempPath = GetTheTempDirectoryOnTheSystem();
|
||||
char *tmpPtr;
|
||||
char *realFileName = NULL;
|
||||
|
||||
if ( (origName != NULL) && (*origName != '\0') )
|
||||
{
|
||||
tmpPtr = origName;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpPtr = szTempFileName;
|
||||
}
|
||||
|
||||
realFileName = strrchr(tmpPtr, '\\');
|
||||
if (!realFileName)
|
||||
realFileName = tmpPtr;
|
||||
else
|
||||
realFileName++;
|
||||
|
||||
TRYAGAIN:
|
||||
|
||||
#ifdef WIN32
|
||||
if (uUnique == 0)
|
||||
{
|
||||
wsprintf(szTempFileName, "%s\\%s", szTempPath, realFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(szTempFileName, "%s\\%d_%s",
|
||||
szTempPath, uUnique, realFileName);
|
||||
}
|
||||
#else // WIN16
|
||||
if ( (uUnique == 0) && (strlen(realFileName) <= 12) )
|
||||
{
|
||||
wsprintf(szTempFileName, "%s\\%s", szTempPath, realFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uUnique < 10)
|
||||
{
|
||||
GetWin16TempName(realFileName, szTempPath, szTempFileName, uUnique);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = ISGetTempFileName(szTempPath, "ns", uUnique++, szTempFileName);
|
||||
}
|
||||
|
||||
// Now add the correct extension...
|
||||
char *origExt = strrchr(realFileName, '.');
|
||||
if (origExt != NULL)
|
||||
{
|
||||
char *tmpExt = strrchr(szTempFileName, '.');
|
||||
if (tmpExt != NULL)
|
||||
{
|
||||
origExt++;
|
||||
tmpExt++;
|
||||
|
||||
while ( ((tmpExt) && (origExt)) && (*origExt != '\0') )
|
||||
{
|
||||
*tmpExt = *origExt;
|
||||
tmpExt++;
|
||||
origExt++;
|
||||
}
|
||||
|
||||
*tmpExt = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( (ValidateFile(szTempFileName) != 1) && (uUnique < MAXTRY) )
|
||||
{
|
||||
uUnique++;
|
||||
if (uUnique >= MAXTRY)
|
||||
return(1);
|
||||
goto TRYAGAIN;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#define kMaxTempFiles 10
|
||||
#define kMaxListLength (10 * _MAX_PATH)
|
||||
|
||||
void GetTempFiles(LPSTR pBuf, int lenBuf)
|
||||
{
|
||||
if (!GetConfigInfoStr(szMapiSection, szTempFiles, pBuf, lenBuf, HKEY_ROOT))
|
||||
{
|
||||
*pBuf = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void WriteTempFiles(LPSTR pBuf)
|
||||
{
|
||||
SetConfigInfoStr(szMapiSection, szTempFiles, pBuf, HKEY_ROOT);
|
||||
}
|
||||
|
||||
void AddTempFile(LPCSTR pFileName)
|
||||
{
|
||||
if ( (!pFileName) || (pFileName[0] == '\0') )
|
||||
return;
|
||||
|
||||
char *files = (char *)malloc(kMaxListLength);
|
||||
|
||||
if (!files)
|
||||
return;
|
||||
|
||||
GetTempFiles(files, kMaxListLength);
|
||||
if ((lstrlen(files) + lstrlen(pFileName) + 2) >= kMaxListLength)
|
||||
{
|
||||
free(files);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lstrlen(files) != 0)
|
||||
{
|
||||
lstrcat(files, ";");
|
||||
}
|
||||
|
||||
lstrcat(files, pFileName);
|
||||
WriteTempFiles(files);
|
||||
free(files);
|
||||
}
|
||||
|
||||
void DeleteFirstTempFile(LPSTR pFiles)
|
||||
{
|
||||
if (!*pFiles)
|
||||
return;
|
||||
LPSTR pTemp = strchr(pFiles, ';');
|
||||
if (pTemp)
|
||||
{
|
||||
*pTemp = 0;
|
||||
}
|
||||
|
||||
//#ifndef _DEBUG
|
||||
_unlink(pFiles);
|
||||
//#endif
|
||||
|
||||
if (pTemp)
|
||||
{
|
||||
memmove(pFiles, pTemp + 1, lstrlen(pTemp + 1) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
*pFiles = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RemoveAllTempFiles(void)
|
||||
{
|
||||
char *files = (char *)malloc(kMaxListLength);
|
||||
|
||||
if (!files)
|
||||
return;
|
||||
|
||||
GetTempFiles(files, kMaxListLength);
|
||||
|
||||
while (*files)
|
||||
{
|
||||
DeleteFirstTempFile(files);
|
||||
}
|
||||
|
||||
WriteTempFiles(files);
|
||||
free(files);
|
||||
}
|
||||
|
||||
void CheckAgeTempFiles(void)
|
||||
{
|
||||
char *files = (char *)malloc(kMaxListLength);
|
||||
|
||||
if (!files)
|
||||
return;
|
||||
|
||||
GetTempFiles(files, kMaxListLength);
|
||||
int i = 0;
|
||||
LPSTR pTemp = files;
|
||||
while (TRUE)
|
||||
{
|
||||
pTemp = strchr(pTemp, ';');
|
||||
if (!pTemp)
|
||||
break;
|
||||
++pTemp;
|
||||
++i;
|
||||
}
|
||||
|
||||
if (i >= 10)
|
||||
{
|
||||
DeleteFirstTempFile(files);
|
||||
WriteTempFiles(files);
|
||||
}
|
||||
|
||||
free(files);
|
||||
}
|
||||
|
||||
void
|
||||
CleanupMAPITempFiles(void)
|
||||
{
|
||||
if (Is_16_OR_32_BIT_CommunitorRunning() == 0)
|
||||
{
|
||||
RemoveAllTempFiles(); // if Communicator not running, clean up all the temp files
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckAgeTempFiles();
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
CleanMalloc(size_t mallocSize)
|
||||
{
|
||||
void *ptr = malloc(mallocSize);
|
||||
if (!ptr)
|
||||
return(NULL);
|
||||
|
||||
memset(ptr, 0, mallocSize);
|
||||
return(ptr);
|
||||
}
|
||||
|
||||
void
|
||||
SafeFree(void *ptr)
|
||||
{
|
||||
if (!ptr)
|
||||
return;
|
||||
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
89
mozilla/mailnews/mapi/old/mapi32/mapiutl.h
Normal file
89
mozilla/mailnews/mapi/old/mapi32/mapiutl.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef __UTILS_
|
||||
#define __UTILS_
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifndef MAPI_OLE // Because MSFT doesn't do this for us :-(
|
||||
#include <mapi.h>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Utility functions...
|
||||
//
|
||||
void SetLoggingEnabled(BOOL val); // Set a logging enabled flag
|
||||
void LogString(LPCSTR pStr1); // Log a string to a file...
|
||||
void BuildMemName(LPSTR name, ULONG winSeed); // Shared memory name
|
||||
HWND GetCommunicatorIPCWindow(void); // Get the IPC window we will use...
|
||||
DWORD SanityCheckAttachmentFiles(lpMapiMessage lpMessage); // Check attachments
|
||||
DWORD ValidateFile(LPCSTR szFile); // Is this a valid file - 0=Yes 1 = NOT_FOUND 2 = OPEN_FAILURE
|
||||
|
||||
DWORD GetFileCount(LPSTR pFiles, LPSTR delimChar); // Get File count from string of file1;file2, etc..
|
||||
BOOL ExtractFile(LPSTR pFiles, LPSTR delimChar, DWORD fIndex, LPSTR fName); // Extract a filename from a string
|
||||
|
||||
LPVOID LoadBlobToMemory(LPSTR fName); // Load the blob into memory!
|
||||
LONG GetTempAttachmentName(LPSTR fName); // Get a temp file name and put it in fName
|
||||
|
||||
UINT GetTempMailNameWithExtension(LPSTR szTempFileName, LPSTR origName);
|
||||
void CleanupMAPITempFiles(void);
|
||||
void AddTempFile(LPCSTR pFileName);
|
||||
|
||||
void *CleanMalloc(size_t mallocSize);
|
||||
void SafeFree(void *ptr);
|
||||
|
||||
//
|
||||
// RICHIE - this is a temporary fix for now to get rid of
|
||||
// html stuff within the text of a message - if there was a
|
||||
// valid noteText buffer coming into this call, we need to
|
||||
// free it on the way out.
|
||||
//
|
||||
LPSTR StripHTML(LPSTR noteText);
|
||||
|
||||
//
|
||||
// Write a buffer to disk
|
||||
// Return 0 on success -1 on failure
|
||||
//
|
||||
LONG WriteMemoryBufferToDisk(LPSTR fName, LONG bufSize, LPSTR buf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __UTILS_
|
||||
303
mozilla/mailnews/mapi/old/mapi32/port.h
Normal file
303
mozilla/mailnews/mapi/old/mapi32/port.h
Normal file
@@ -0,0 +1,303 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
|
||||
#ifndef PORT_H
|
||||
#define PORT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*****************************************************************\
|
||||
* *
|
||||
* PORT.H *
|
||||
* *
|
||||
* Win16/Win32 portability stuff *
|
||||
* *
|
||||
* A.Sokolsky *
|
||||
* 3.10.94 distilled into this header *
|
||||
* *
|
||||
\*****************************************************************/
|
||||
|
||||
/*
|
||||
* calling conventions
|
||||
*/
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#ifndef CDECL
|
||||
#define CDECL __cdecl
|
||||
#endif // CDECL
|
||||
|
||||
#ifndef PASCAL
|
||||
#define PASCAL __pascal
|
||||
#endif // PASCAL
|
||||
|
||||
#ifdef FASTCALL
|
||||
#error FASTCALL defined
|
||||
#endif // FASTCALL
|
||||
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define FASTCALL __fastcall
|
||||
#else
|
||||
#define FASTCALL PASCAL
|
||||
#endif // NDEBUG
|
||||
|
||||
|
||||
|
||||
#ifndef HWND2DWORD
|
||||
# ifdef WIN32
|
||||
# define HWND2DWORD(X_hWnd) ( (DWORD)(X_hWnd) )
|
||||
# else // WIN16
|
||||
# define HWND2DWORD(X_hWnd) ( (DWORD)MAKELONG(((WORD)(X_hWnd)), 0) )
|
||||
# endif
|
||||
#endif // HWND2DWORD
|
||||
|
||||
|
||||
/*
|
||||
* WIN16 - WIN32 compatibility stuff
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
# define DLLEXPORT __declspec( dllexport )
|
||||
# define EXPORT
|
||||
# define LOADDS
|
||||
# define HUGE
|
||||
# ifndef FAR
|
||||
# define FAR
|
||||
# endif // FAR
|
||||
# ifndef NEAR
|
||||
# define NEAR
|
||||
# endif // NEAR
|
||||
# ifdef UNICODE
|
||||
# define SIZEOF(x) (sizeof(x)/sizeof(WCHAR))
|
||||
# else
|
||||
# define SIZEOF(x) sizeof(x)
|
||||
# endif
|
||||
|
||||
#else // !WIN32 == WIN16
|
||||
|
||||
# define DLLEXPORT
|
||||
# define EXPORT __export
|
||||
# define LOADDS __loadds
|
||||
# define HUGE __huge
|
||||
# ifndef FAR
|
||||
# define FAR __far
|
||||
# define NEAR __near
|
||||
# endif // FAR
|
||||
# define CONST const
|
||||
# define SIZEOF(x) sizeof(x)
|
||||
# define CHAR char
|
||||
# define TCHAR char
|
||||
# define WCHAR char
|
||||
# ifndef LPTSTR
|
||||
# define LPTSTR LPSTR
|
||||
# endif
|
||||
# ifndef LPCTSTR
|
||||
# define LPCTSTR LPCSTR
|
||||
# endif
|
||||
# define UNREFERENCED_PARAMETER(x) x;
|
||||
# ifndef TEXT
|
||||
# define TEXT(x) x
|
||||
# endif
|
||||
# define GetWindowTextW GetWindowText
|
||||
# define lstrcpyW lstrcpy
|
||||
|
||||
# define BN_DBLCLK BN_DOUBLECLICKED // ~~MRJ needed for custom control.
|
||||
// ~~MRJ begin Win95 backward compat section
|
||||
# define LPWSTR LPSTR
|
||||
# define LPCWSTR LPCSTR
|
||||
|
||||
// button check state for WIN16
|
||||
#ifndef BST_UNCHECKED
|
||||
#define BST_UNCHECKED 0x0000
|
||||
#endif
|
||||
|
||||
#ifndef BST_CHECKED
|
||||
#define BST_CHECKED 0x0001
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef WIN95_COMPAT
|
||||
# define WIN95_COMPAT
|
||||
#endif
|
||||
|
||||
// ~~MRJ end Win95 compat section.
|
||||
|
||||
// critical section API stubs
|
||||
typedef DWORD CRITICAL_SECTION;
|
||||
typedef CRITICAL_SECTION FAR * LPCRITICAL_SECTION;
|
||||
#ifdef __cplusplus
|
||||
inline void InitializeCriticalSection(LPCRITICAL_SECTION lpSection) {}
|
||||
inline void DeleteCriticalSection(LPCRITICAL_SECTION lpSection) {}
|
||||
inline void EnterCriticalSection(LPCRITICAL_SECTION lpSection) {}
|
||||
inline void LeaveCriticalSection(LPCRITICAL_SECTION lpSection) {}
|
||||
#endif // __cplusplus
|
||||
|
||||
// Added for nssock16 ---Neeti
|
||||
#ifndef ZeroMemory
|
||||
#include <memory.h>
|
||||
#define ZeroMemory(PTR, SIZE) memset(PTR, 0, SIZE)
|
||||
#endif // ZeroMemory
|
||||
|
||||
#endif // WIN16
|
||||
|
||||
/*
|
||||
* unix - windows compatibility stuff
|
||||
*/
|
||||
typedef DWORD u_int32;
|
||||
typedef WORD u_int16;
|
||||
typedef BYTE u_int8;
|
||||
#ifdef WIN32
|
||||
typedef short int Bool16;
|
||||
#else // WIN16
|
||||
typedef BOOL Bool16;
|
||||
#endif // WIN16
|
||||
|
||||
/*
|
||||
* Cross Platform Compatibility
|
||||
*/
|
||||
#ifndef UNALIGNED
|
||||
# ifdef _M_ALPHA
|
||||
# define UNALIGNED __unaligned
|
||||
# else // !_M_ALPHA
|
||||
# define UNALIGNED
|
||||
# endif // !_M_ALPHA
|
||||
#endif // UNALIGNED
|
||||
|
||||
//
|
||||
// RICHIE - for the Alpha port
|
||||
//
|
||||
#ifdef _M_ALPHA
|
||||
# undef pascal
|
||||
# undef PASCAL
|
||||
# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
|
||||
# define pascal __stdcall
|
||||
# define PASCAL __stdcall
|
||||
# else
|
||||
# define PASCAL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Useful Types
|
||||
*/
|
||||
typedef char HUGE *HPSTR;
|
||||
typedef const char HUGE *HPCSTR;
|
||||
typedef unsigned char HUGE *HPBYTE;
|
||||
typedef WORD HUGE *HPWORD;
|
||||
typedef UINT FAR *LPUINT;
|
||||
typedef BOOL (CALLBACK *USERABORTPROC)();
|
||||
typedef BOOL (CALLBACK *PROGRESSPROC)(UINT uPos, UINT uRange);
|
||||
typedef int INT; // ~~MRJ a function needed this defined.
|
||||
typedef MINMAXINFO FAR *LPMINMAXINFO; // ~~MRJ
|
||||
|
||||
//
|
||||
// stuff missing from windows.h
|
||||
//
|
||||
#ifndef MAKEWORD
|
||||
#define MAKEWORD(low, high) ((WORD)(((BYTE)(low)) | (((WORD)((BYTE)(high))) << 8)))
|
||||
#endif // MAKEWORD
|
||||
|
||||
#ifdef WIN32
|
||||
# ifndef hmemcpy
|
||||
# define hmemcpy memcpy
|
||||
# endif // !defined(hmemcpy)
|
||||
# define _fmemset memset
|
||||
|
||||
# include <malloc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
inline BOOL IsGDIObject(HGDIOBJ hObj) { return (hObj != 0); }
|
||||
inline void *_halloc(long num, unsigned int size) { return malloc(num * size); }
|
||||
inline void _hfree( void *memblock ) { free(memblock); }
|
||||
/*
|
||||
inline BOOL IsInstance(HINSTANCE hInst) {
|
||||
# ifdef WIN32
|
||||
return (hInst != 0);
|
||||
# else // WIN16
|
||||
return (hInst > HINSTANCE_ERROR);
|
||||
# endif
|
||||
}
|
||||
*/
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
WINUSERAPI HANDLE WINAPI LoadImageA(HINSTANCE, LPCSTR, UINT, int, int, UINT);
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline BOOL IsInstance(HINSTANCE hInst) {
|
||||
# ifdef WIN32
|
||||
return (hInst != 0);
|
||||
# else // WIN16
|
||||
return (hInst > HINSTANCE_ERROR);
|
||||
# endif
|
||||
}
|
||||
inline void SetWindowSmallIcon(HINSTANCE hInst, HWND hWnd, UINT uIconResourceId) {
|
||||
#ifdef WIN32
|
||||
# ifndef WM_SETICON
|
||||
# define WM_SETICON 0x0080
|
||||
# endif // WM_SETICON
|
||||
# ifndef IMAGE_ICON
|
||||
# define IMAGE_ICON 1
|
||||
# endif
|
||||
assert(IsWindow(hWnd));
|
||||
HICON hIcon = (HICON)LoadImageA(hInst, MAKEINTRESOURCE(uIconResourceId), IMAGE_ICON,
|
||||
16, 16, 0);
|
||||
if(NULL != hIcon) {
|
||||
SendMessage(hWnd, WM_SETICON, FALSE, (LPARAM)hIcon);
|
||||
} else {
|
||||
HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(uIconResourceId));
|
||||
assert(hIcon != 0);
|
||||
SendMessage(hWnd, WM_SETICON, FALSE, (LPARAM)hIcon);
|
||||
}
|
||||
#endif // WIN32
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* PORT_H */
|
||||
54
mozilla/mailnews/mapi/old/mapi32/resource.h
Normal file
54
mozilla/mailnews/mapi/old/mapi32/resource.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by mapi32.rc
|
||||
//
|
||||
#define ID_DIALOG_QAHOOK 101
|
||||
#define ID_DIALOG_MAPI 101
|
||||
#define ID_ICON_APP 102
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
172
mozilla/mailnews/mapi/old/mapi32/smem.cpp
Normal file
172
mozilla/mailnews/mapi/old/mapi32/smem.cpp
Normal file
@@ -0,0 +1,172 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
// smem.cpp - This deals with all shared memory functions needed for
|
||||
// the MAPI component of Communicator
|
||||
// Written by: Rich Pizzarro (rhp@netscape.com)
|
||||
// November 1997
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "mapismem.h"
|
||||
|
||||
#ifndef ZeroMemory
|
||||
#include <memory.h>
|
||||
#define ZeroMemory(PTR, SIZE) memset(PTR, 0, SIZE)
|
||||
#endif // ZeroMemory
|
||||
|
||||
//
|
||||
// *create new* shared memory chunk
|
||||
// once this is created, use the pointer
|
||||
// to the segment to to store data
|
||||
// e.g.:
|
||||
// lpString = "string for communicator";
|
||||
// lstrcpy((LPSTR)pData->m_buf[0], lpString);
|
||||
//
|
||||
CSharedMem *
|
||||
NSCreateSharedMemory(DWORD memSize, LPCTSTR memName, HANDLE *hSharedMemory)
|
||||
{
|
||||
#ifdef WIN32
|
||||
|
||||
BOOL bExistedBefore;
|
||||
CSharedMem *pData;
|
||||
|
||||
LPCTSTR szObjectName = memName;
|
||||
DWORD dwSize = sizeof(CSharedMem) + memSize;
|
||||
*hSharedMemory = CreateFileMapping(
|
||||
(HANDLE)0xFFFFFFFF,0,PAGE_READWRITE,0,dwSize,szObjectName);
|
||||
if(*hSharedMemory == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
bExistedBefore = (GetLastError() == ERROR_ALREADY_EXISTS);
|
||||
if(bExistedBefore)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pData = (CSharedMem *)MapViewOfFile(
|
||||
*hSharedMemory, FILE_MAP_ALL_ACCESS, 0, 0, 0);
|
||||
if(pData == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMemory(pData, dwSize);
|
||||
pData->m_dwSize = memSize;
|
||||
|
||||
return pData;
|
||||
#else
|
||||
CSharedMem *sMemChunk = NULL;
|
||||
DWORD dwSize = memSize = (sizeof(CSharedMem) + memSize);
|
||||
|
||||
if (sMemChunk != NULL)
|
||||
return(sMemChunk);
|
||||
|
||||
sMemChunk = (CSharedMem *) GlobalAllocPtr(GMEM_MOVEABLE, dwSize);
|
||||
ZeroMemory(sMemChunk, (size_t) dwSize);
|
||||
sMemChunk->m_dwSize = dwSize; // Missing in Communicator code!
|
||||
return(sMemChunk);
|
||||
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
//
|
||||
// *open existing* shared memory chunk
|
||||
// once you have the pointer to the new segment
|
||||
// use this pointer to access data, e.g.:
|
||||
//
|
||||
CSharedMem *
|
||||
NSOpenExistingSharedMemory(LPCTSTR memName, HANDLE *hSharedMemory)
|
||||
{
|
||||
#ifdef WIN32
|
||||
CSharedMem *pData;
|
||||
DWORD dwSize;
|
||||
|
||||
LPCTSTR szObjectName = memName;
|
||||
*hSharedMemory = OpenFileMapping(
|
||||
PAGE_READWRITE,FALSE,szObjectName);
|
||||
if(*hSharedMemory == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pData = (CSharedMem *)MapViewOfFile(
|
||||
*hSharedMemory,FILE_MAP_ALL_ACCESS,0,0,0);
|
||||
if(pData == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dwSize = pData->m_dwSize;
|
||||
return pData;
|
||||
#else
|
||||
|
||||
return(NULL); // In Win16, this is really meaningless...
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// to close shared memory segment
|
||||
//
|
||||
void
|
||||
NSCloseSharedMemory(CSharedMem *pData, HANDLE hSharedMemory)
|
||||
{
|
||||
#ifdef WIN32
|
||||
if(pData != 0)
|
||||
{
|
||||
UnmapViewOfFile(pData);
|
||||
pData = 0;
|
||||
}
|
||||
|
||||
if(hSharedMemory != 0)
|
||||
{
|
||||
CloseHandle(hSharedMemory);
|
||||
hSharedMemory = 0;
|
||||
}
|
||||
#else
|
||||
|
||||
if (pData != NULL)
|
||||
{
|
||||
GlobalFreePtr(pData);
|
||||
pData = NULL;
|
||||
}
|
||||
|
||||
#endif // WIN32
|
||||
}
|
||||
68
mozilla/mailnews/mapi/old/mapi32/trace.cpp
Normal file
68
mozilla/mailnews/mapi/old/mapi32/trace.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <tchar.h>
|
||||
#include "trace.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#ifndef WIN16
|
||||
void CDECL AfxTrace(LPCTSTR lpszFormat, ...)
|
||||
#else
|
||||
void CDECL AfxTrace(LPCSTR lpszFormat, ...)
|
||||
#endif
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, lpszFormat);
|
||||
|
||||
int nBuf;
|
||||
TCHAR szBuffer[512];
|
||||
|
||||
nBuf = _vstprintf(szBuffer, lpszFormat, args);
|
||||
va_end(args);
|
||||
OutputDebugString(szBuffer);
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL AfxAssertFailedLine(LPCSTR lpszFileName, int nLine)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
81
mozilla/mailnews/mapi/old/mapi32/trace.h
Normal file
81
mozilla/mailnews/mapi/old/mapi32/trace.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
BOOL AfxAssertFailedLine(LPCSTR lpszFileName, int nLine);
|
||||
|
||||
#ifndef WIN16
|
||||
void CDECL AfxTrace(LPCTSTR lpszFormat, ...);
|
||||
#else
|
||||
void CDECL AfxTrace(LPCSTR lpszFormat, ...);
|
||||
#endif
|
||||
|
||||
#define TRACE ::AfxTrace
|
||||
#define THIS_FILE __FILE__
|
||||
#define ASSERT(f) \
|
||||
do \
|
||||
{ \
|
||||
if (!(f) && AfxAssertFailedLine(THIS_FILE, __LINE__)) \
|
||||
AfxDebugBreak(); \
|
||||
} while (0) \
|
||||
|
||||
#define VERIFY(f) ASSERT(f)
|
||||
#define TRACE_FN(name) LogFn __logFn(name)
|
||||
class LogFn
|
||||
{
|
||||
public:
|
||||
LogFn(LPCSTR pFnName) {m_pFnName = pFnName; TRACE("--%s: In--\n", pFnName);}
|
||||
~LogFn() {TRACE("--%s: Out--\n", m_pFnName);}
|
||||
private:
|
||||
LPCSTR m_pFnName;
|
||||
};
|
||||
#else
|
||||
// NDEBUG
|
||||
#define ASSERT(f) ((void)0)
|
||||
#define VERIFY(f) ((void)(f))
|
||||
#define ASSERT_VALID(pOb) ((void)0)
|
||||
#define DEBUG_ONLY(f) ((void)0)
|
||||
#ifdef WIN32
|
||||
inline void CDECL AfxTrace(LPCTSTR, ...) { }
|
||||
#else
|
||||
inline void CDECL AfxTrace(LPCSTR, ...) { }
|
||||
#endif
|
||||
#define TRACE 1 ? (void)0 : ::AfxTrace
|
||||
#define TRACE_FN(name)
|
||||
#endif // _DEBUG
|
||||
|
||||
347
mozilla/mailnews/mapi/old/mapi32/xpapi.cpp
Normal file
347
mozilla/mailnews/mapi/old/mapi32/xpapi.cpp
Normal file
@@ -0,0 +1,347 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
// XPAPI.CPP
|
||||
// API implementation file for mapi16.dll and mapi32.dll
|
||||
// Written by: Rich Pizzarro (rhp@netscape.com)
|
||||
// November 1997
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "xpapi.h"
|
||||
#include "mapiutl.h"
|
||||
|
||||
WORD LOAD_DS XP_CallProcess(LPCSTR pPath, LPCSTR pCmdLine)
|
||||
{
|
||||
WORD wReturn = 0;
|
||||
#ifndef WIN16
|
||||
STARTUPINFO startupInfo;
|
||||
PROCESS_INFORMATION processInfo;
|
||||
|
||||
memset(&startupInfo, 0, sizeof(startupInfo));
|
||||
startupInfo.cb = sizeof(startupInfo);
|
||||
if (wReturn = CreateProcess(pPath, (LPTSTR)pCmdLine, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_PROCESS_GROUP, NULL, NULL, &startupInfo, &processInfo))
|
||||
{
|
||||
WaitForInputIdle(processInfo.hProcess, 120000);
|
||||
}
|
||||
#else
|
||||
// char szMsg[80];
|
||||
char szExecute[512];
|
||||
lstrcpy(szExecute, pPath);
|
||||
lstrcat(szExecute, " ");
|
||||
lstrcat(szExecute, pCmdLine);
|
||||
wReturn = WinExec(szExecute,SW_SHOW);
|
||||
|
||||
if (wReturn < 32)
|
||||
{
|
||||
wReturn = 0;
|
||||
}
|
||||
#endif
|
||||
return wReturn;
|
||||
}
|
||||
|
||||
HKEY LOAD_DS RegOpenParent(LPCSTR pSection, HKEY hRootKey, REGSAM access)
|
||||
{
|
||||
HKEY hKey;
|
||||
#ifndef WIN16
|
||||
if (RegOpenKeyEx(hRootKey, pSection, 0, access, &hKey) != ERROR_SUCCESS)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
#else
|
||||
if (RegOpenKey(hRootKey, pSection, &hKey) != ERROR_SUCCESS)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
#endif
|
||||
return(hKey);
|
||||
}
|
||||
|
||||
HKEY LOAD_DS RegCreateParent(LPCSTR pSection, HKEY hMasterKey)
|
||||
{
|
||||
HKEY hKey;
|
||||
if (RegCreateKey(hMasterKey, pSection, &hKey) != ERROR_SUCCESS)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
return(hKey);
|
||||
}
|
||||
|
||||
BOOL LOAD_DS GetConfigInfoStr(LPCSTR pSection, LPCSTR pKey, LPSTR pBuf, int lenBuf, HKEY hMasterKey)
|
||||
{
|
||||
HKEY hKey;
|
||||
hKey = RegOpenParent(pSection, hMasterKey, KEY_QUERY_VALUE);
|
||||
if (!hKey)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
DWORD len = (DWORD)lenBuf;
|
||||
#ifndef WIN16
|
||||
BOOL retVal = (RegQueryValueEx(hKey, pKey, NULL, NULL, (LPBYTE)pBuf, &len) == ERROR_SUCCESS);
|
||||
#else
|
||||
BOOL retVal = (RegQueryValue(hKey, pKey, pBuf, (long far*)&len) == ERROR_SUCCESS);
|
||||
#endif
|
||||
RegCloseKey(hKey);
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
BOOL LOAD_DS GetConfigInfoNum(LPCSTR pSection, LPCSTR pKey, DWORD* pVal, HKEY hMasterKey)
|
||||
{
|
||||
HKEY hKey;
|
||||
hKey = RegOpenParent(pSection, hMasterKey, KEY_QUERY_VALUE);
|
||||
if (!hKey)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
DWORD len = sizeof(DWORD);
|
||||
#ifndef WIN16
|
||||
BOOL retVal = (RegQueryValueEx(hKey, pKey, NULL, NULL, (LPBYTE)pVal, &len) == ERROR_SUCCESS);
|
||||
#else
|
||||
BOOL retVal = (RegQueryValue(hKey, pKey, (char far*)pVal, (long far*)&len) == ERROR_SUCCESS);
|
||||
#endif
|
||||
RegCloseKey(hKey);
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
BOOL LOAD_DS SetConfigInfoStr(LPCSTR pSection, LPCSTR pKey, LPSTR pStr, HKEY hMasterKey)
|
||||
{
|
||||
HKEY hKey;
|
||||
hKey = RegCreateParent(pSection, hMasterKey);
|
||||
if (!hKey)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
#ifndef WIN16
|
||||
BOOL retVal = (RegSetValueEx(hKey, pKey, 0, REG_SZ, (LPBYTE)pStr, lstrlen(pStr) + 1) == ERROR_SUCCESS);
|
||||
#else
|
||||
BOOL retVal = (RegSetValue(hKey, pKey, REG_SZ, pStr, lstrlen(pStr) + 1) == ERROR_SUCCESS);
|
||||
#endif
|
||||
RegCloseKey(hKey);
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
BOOL LOAD_DS XP_GetInstallDirectory(LPCSTR pcurVersionSection, LPCSTR pInstallDirKey, LPSTR path, UINT nSize, HKEY hKey)
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (!GetConfigInfoStr(pcurVersionSection, pInstallDirKey, path, nSize, hKey))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
if ( 0 < GetPrivateProfileString(pcurVersionSection, pInstallDirKey,"ERROR", path, nSize, szNetscapeINI))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
BOOL LOAD_DS XP_GetVersionInfoString(LPCSTR pNavigatorSection, LPCSTR pCurrentVersionKey, LPSTR pcurVersionStr, UINT nSize, HKEY hKey)
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (!GetConfigInfoStr(pNavigatorSection, pCurrentVersionKey, pcurVersionStr, nSize, HKEY_LOCAL_MACHINE))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
if ( 0 < GetPrivateProfileString(pNavigatorSection, pCurrentVersionKey,"ERROR", pcurVersionStr, nSize, szNetscapeINI))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
DWORD LOAD_DS XP_GetInstallLocation(LPSTR pPath, UINT nSize)
|
||||
{
|
||||
char curVersionStr[256];
|
||||
char curVersionSection[256];
|
||||
|
||||
if (!pPath)
|
||||
return MAPI_E_LOGON_FAILURE;
|
||||
|
||||
#ifdef WIN32
|
||||
if (!XP_GetVersionInfoString(szNavigatorSection, szCurrentVersionKey, curVersionStr,
|
||||
sizeof(curVersionStr), HKEY_LOCAL_MACHINE))
|
||||
{
|
||||
return (MAPI_E_LOGON_FAILURE);
|
||||
}
|
||||
|
||||
wsprintf(curVersionSection, szNavigatorCurVersionSection, curVersionStr);
|
||||
|
||||
if (!XP_GetInstallDirectory(curVersionSection, szInstallDirKey, pPath,
|
||||
nSize, HKEY_LOCAL_MACHINE))
|
||||
{
|
||||
return (MAPI_E_ACCESS_DENIED);
|
||||
|
||||
}
|
||||
|
||||
lstrcat(pPath, "\\");
|
||||
lstrcat(pPath, "Program\\netscape.exe");
|
||||
|
||||
return SUCCESS_SUCCESS;
|
||||
#else
|
||||
if (32 == Is_16_OR_32_BIT_CommunitorRunning())
|
||||
{
|
||||
if (!GetConfigInfoStr("snews\\shell\\open", "command", curVersionStr, sizeof(curVersionStr), HKEY_CLASSES_ROOT))
|
||||
{
|
||||
return (MAPI_E_ACCESS_DENIED);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *pFind = strstr(curVersionStr,"-h");
|
||||
|
||||
if (pFind)
|
||||
{
|
||||
*pFind=0;
|
||||
lstrcpy(pPath,curVersionStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (MAPI_E_ACCESS_DENIED);
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS_SUCCESS;
|
||||
}
|
||||
else //setup up to start navstart since we are a sixteen bit DLL.
|
||||
{
|
||||
if (!XP_GetVersionInfoString(szNavigatorSection, szCurrentVersionKey, curVersionStr, sizeof(curVersionStr), HKEY_LOCAL_MACHINE))
|
||||
{
|
||||
return (MAPI_E_LOGON_FAILURE);
|
||||
}
|
||||
|
||||
wsprintf(curVersionSection, szNavigatorCurVersionSection, curVersionStr);
|
||||
|
||||
if (!XP_GetInstallDirectory(curVersionSection, szInstallDirKey, pPath,nSize, HKEY_LOCAL_MACHINE))
|
||||
{
|
||||
return (MAPI_E_ACCESS_DENIED);
|
||||
}
|
||||
|
||||
lstrcat(pPath, "\\");
|
||||
lstrcat(pPath, "NAVSTART.EXE");
|
||||
return SUCCESS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int LOAD_DS Is_16_OR_32_BIT_CommunitorRunning()
|
||||
{
|
||||
if (FindWindow("AfxFrameOrView", NULL) && !FindWindow("aHiddenFrameClass", NULL))
|
||||
return(16);
|
||||
else if (FindWindow("aHiddenFrameClass", NULL))
|
||||
return(32);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
// size of buffer to use for copying files.
|
||||
#define COPYBUFSIZE 1024
|
||||
|
||||
#ifdef WIN16
|
||||
|
||||
BOOL Win16CopyFile(LPCSTR a_Src, LPCSTR a_Dest, BOOL a_bOverwrite)
|
||||
{
|
||||
OFSTRUCT ofSrc, ofDest;
|
||||
HFILE hSrc, hDest;
|
||||
BOOL bResult;
|
||||
|
||||
ofDest.cBytes = ofSrc.cBytes = sizeof(OFSTRUCT);
|
||||
hDest = OpenFile(a_Dest, &ofDest, OF_EXIST);
|
||||
if (hDest != HFILE_ERROR && !a_bOverwrite)
|
||||
bResult = FALSE; // file exists but caller doesn't want file overwritten
|
||||
else { // file either doesn't exist, or caller wants it overwritten.
|
||||
hSrc = OpenFile(a_Src, &ofSrc, OF_READ);
|
||||
hDest = OpenFile(a_Dest, &ofDest, OF_WRITE | OF_CREATE);
|
||||
if (hSrc != HFILE_ERROR && hDest != HFILE_ERROR) {
|
||||
unsigned char buf[COPYBUFSIZE];
|
||||
UINT bufsize = COPYBUFSIZE;
|
||||
UINT bytesread;
|
||||
|
||||
bResult = TRUE;
|
||||
while (0 != (bytesread = _lread(hSrc, (LPVOID)buf, bufsize))) {
|
||||
if ((bytesread == HFILE_ERROR) || // check for read error...
|
||||
// and write error
|
||||
(bytesread != _lwrite(hDest, (LPVOID)buf, bytesread))) {
|
||||
bResult = FALSE; // could be out of diskspace
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
bResult = FALSE;
|
||||
|
||||
if (hSrc != HFILE_ERROR)
|
||||
_lclose(hSrc);
|
||||
if (hDest != HFILE_ERROR)
|
||||
_lclose(hDest);
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
#endif // WIN16
|
||||
|
||||
BOOL LOAD_DS
|
||||
XP_CopyFile(LPCSTR lpExistingFile, LPCSTR lpNewFile, BOOL bFailifExist)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return CopyFile(lpExistingFile, lpNewFile, bFailifExist);
|
||||
#else
|
||||
return Win16CopyFile(lpExistingFile, lpNewFile, TRUE);
|
||||
#endif
|
||||
}
|
||||
138
mozilla/mailnews/mapi/old/mapi32/xpapi.h
Normal file
138
mozilla/mailnews/mapi/old/mapi32/xpapi.h
Normal file
@@ -0,0 +1,138 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
// Various routines for MAPI functions.
|
||||
// Written by: Rich Pizzarro (rhp@netscape.com)
|
||||
// November 1997
|
||||
//
|
||||
#ifndef __XPAPI_H
|
||||
#define __XPAPI_H
|
||||
|
||||
#ifdef WIN16
|
||||
|
||||
#include <string.h>
|
||||
#include <direct.h>
|
||||
#include <shellapi.h>
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <winreg.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN16
|
||||
extern "C" {
|
||||
#ifndef MAPI_OLE // Because MSFT doesn't do this for us :-(
|
||||
#include <mapi.h>
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
//#include <mapi.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#define MAPI_IMPLEMENT(param) param PASCAL
|
||||
#define LOAD_DS
|
||||
#else
|
||||
#define LOAD_DS __loadds
|
||||
#define MAPI_IMPLEMENT(param) extern "C" param FAR PASCAL
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WIN16
|
||||
#define _MAX_PATH 260 /* max. length of full pathname*/
|
||||
#define MAPI_E_LOGON_FAILURE 3
|
||||
#define MAPI_E_ACCESS_DENIED 6
|
||||
#define INVALID_HANDLE_VALUE (HANDLE)-1
|
||||
#define KEY_QUERY_VALUE 0x0001
|
||||
#define HKEY_LOCAL_MACHINE ((HKEY)0x80000002)
|
||||
#define HKEY_ROOT HKEY_CLASSES_ROOT
|
||||
#else
|
||||
#define HKEY_ROOT ((HKEY)0x80000002)
|
||||
#endif
|
||||
|
||||
//
|
||||
// registry keys
|
||||
//
|
||||
#ifdef WIN32
|
||||
static char szNavigatorSection[] = "Software\\Netscape\\Netscape Navigator";
|
||||
static char szNavigatorCurVersionSection[] = "Software\\Netscape\\Netscape Navigator\\%s\\Main";
|
||||
static char szCurrentVersionKey[] = "CurrentVersion";
|
||||
static char szInstallDirKey[] = "Install Directory";
|
||||
static char szMapiSection[] = "Software\\Netscape\\Netscape Navigator\\MAPI";
|
||||
static char szTempFiles[] = "TempFiles";
|
||||
static char szMapiLog[] = "NSMAPI32.LOG";
|
||||
#else
|
||||
//32 bit key strings for trying to read the 32bit registry
|
||||
static char szNavigatorSection32[] = "Software\\Netscape\\Netscape Navigator";
|
||||
static char szNavigatorCurVersionSection32[] = "Software\\Netscape\\Netscape Navigator\\%s\\Main";
|
||||
static char szMapiSection32[] = "Software\\Netscape\\Netscape Navigator\\MAPI";
|
||||
|
||||
// ini section and key strings
|
||||
static char szNetscapeINI[] = "nscp.ini";
|
||||
static char szNavigatorSection[] = "Netscape Navigator";
|
||||
static char szNavigatorCurVersionSection[] = "Netscape Navigator-%s";
|
||||
static char szCurrentVersionKey[] = "CurrentVersion";
|
||||
static char szInstallDirKey[] = "Install Directory";
|
||||
static char szMapiSection[] = "MAPI";
|
||||
static char szTempFiles[] = "TempFiles";
|
||||
static char szExeName[] = "NAVSTART.EXE";
|
||||
static char szMapiLog[] = "NSMAPI16.LOG";
|
||||
#endif
|
||||
|
||||
//Since REGSAM is just an ACCESS_MASK which is just a DWORD and it's not
|
||||
//declared in win16 we'll make one hear for the purpose of keeping parameters
|
||||
//the same even though the access rights don't get used for win16.
|
||||
|
||||
typedef DWORD REGSAM;
|
||||
|
||||
|
||||
// XP declarations
|
||||
|
||||
int LOAD_DS Is_16_OR_32_BIT_CommunitorRunning();
|
||||
WORD LOAD_DS XP_CallProcess(LPCSTR pPath, LPCSTR pCmdLine);
|
||||
HKEY LOAD_DS RegOpenParent(LPCSTR pSection, HKEY hRootKey, REGSAM access);
|
||||
HKEY LOAD_DS RegCreateParent(LPCSTR pSection, HKEY hMasterKey);
|
||||
BOOL LOAD_DS GetConfigInfoStr(LPCSTR pSection, LPCSTR pKey, LPSTR pBuf, int lenBuf, HKEY hMasterKey);
|
||||
BOOL LOAD_DS GetConfigInfoNum(LPCSTR pSection, LPCSTR pKey, DWORD* pVal, HKEY hMasterKey);
|
||||
BOOL LOAD_DS SetConfigInfoStr(LPCSTR pSection, LPCSTR pKey, LPSTR pStr, HKEY hMasterKey);
|
||||
|
||||
BOOL LOAD_DS XP_GetInstallDirectory(LPCSTR pcurVersionSection, LPCSTR pInstallDirKey, LPSTR path, UINT nSize, HKEY hKey);
|
||||
BOOL LOAD_DS XP_GetVersionInfoString(LPCSTR pNavigatorSection, LPCSTR pCurrentVersionKey, LPSTR pcurVersionStr, UINT nSize, HKEY hKey);
|
||||
DWORD LOAD_DS XP_GetInstallLocation(LPSTR pPath, UINT nSize);
|
||||
BOOL LOAD_DS XP_CopyFile(LPCSTR lpExistingFile, LPCSTR lpNewFile, BOOL bFailifExist);
|
||||
|
||||
#endif // __XPAPI_H
|
||||
31
mozilla/mailnews/mapi/old/public/makefile.win
Normal file
31
mozilla/mailnews/mapi/old/public/makefile.win
Normal file
@@ -0,0 +1,31 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE=mime
|
||||
|
||||
EXPORTS = \
|
||||
nscpmapi.h \
|
||||
$(NULL)
|
||||
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
351
mozilla/mailnews/mapi/old/public/nscpmapi.h
Normal file
351
mozilla/mailnews/mapi/old/public/nscpmapi.h
Normal file
@@ -0,0 +1,351 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
// This is a header file for the MAPI support within
|
||||
// Communicator.
|
||||
//
|
||||
// Written by: Rich Pizzarro (rhp@netscape.com)
|
||||
//
|
||||
#ifndef _NSCPMAPI
|
||||
#define _NSCPMAPI
|
||||
|
||||
#ifndef MAPI_OLE // Because MSFT doesn't do this for us :-(
|
||||
#include <mapi.h> // for MAPI specific types...
|
||||
#endif
|
||||
|
||||
#ifdef WIN16
|
||||
typedef unsigned char UCHAR;
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_NAME_LEN 256
|
||||
#define MAX_PW_LEN 256
|
||||
#define MAX_MSGINFO_LEN 512
|
||||
#define MAX_CON 4 // Maximum MAPI session supported
|
||||
#define MAX_POINTERS 32
|
||||
|
||||
//
|
||||
// The MAPI class that will act as the internal mechanism for
|
||||
// Communicator to control multiple MAPI sessions.
|
||||
//
|
||||
class CMAPIConnection
|
||||
{
|
||||
protected:
|
||||
LONG m_ID;
|
||||
BOOL m_defaultConnection;
|
||||
LONG m_sessionCount;
|
||||
LONG m_messageIndex;
|
||||
LPVOID m_cookie;
|
||||
UCHAR m_messageFindInfo[MAX_MSGINFO_LEN];
|
||||
UCHAR m_profileName[MAX_NAME_LEN];
|
||||
UCHAR m_password[MAX_PW_LEN];
|
||||
|
||||
// Methods
|
||||
|
||||
public:
|
||||
CMAPIConnection ( LONG, LPSTR, LPSTR );
|
||||
~CMAPIConnection ( );
|
||||
|
||||
// ID related methods
|
||||
LONG GetID( ) { return m_ID; } ;
|
||||
|
||||
// Dealing with the default session...
|
||||
BOOL IsDefault( ) { return m_defaultConnection; } ;
|
||||
void SetDefault( BOOL flag ) { m_defaultConnection = flag; } ;
|
||||
|
||||
// For handling multiple sessions on a profile name...
|
||||
LONG GetSessionCount( ) { return m_sessionCount; } ;
|
||||
void IncrementSessionCount() { ++m_sessionCount; } ;
|
||||
void DecrementSessionCount() { --m_sessionCount; } ;
|
||||
|
||||
// Information retrieval stuff...
|
||||
LPSTR GetProfileName( ) { return (LPSTR) m_profileName; };
|
||||
LPSTR GetPassword( ) { return (LPSTR) m_password; };
|
||||
|
||||
// Dealing with message information...
|
||||
void SetMessageIndex( LONG mIndex ) { m_messageIndex = mIndex; } ;
|
||||
LONG GetMessageIndex( ) { return m_messageIndex; };
|
||||
|
||||
void SetMessageFindInfo( LPSTR info ) { lstrcpy((LPSTR)m_messageFindInfo, info); } ;
|
||||
LPSTR GetMessageFindInfo( ) { return (LPSTR) m_messageFindInfo; };
|
||||
|
||||
// For enumerating Messages...
|
||||
void SetMapiListContext( LPVOID cookie) { m_cookie = cookie; } ;
|
||||
LPVOID GetMapiListContext( ) { return m_cookie; };
|
||||
};
|
||||
|
||||
//
|
||||
// Defines needed for requests being made with the WM_COPYDATA call...
|
||||
//
|
||||
typedef enum {
|
||||
NSCP_MAPIStartRequestID = 0,
|
||||
NSCP_MAPILogon,
|
||||
NSCP_MAPILogoff,
|
||||
NSCP_MAPIFree,
|
||||
NSCP_MAPISendMail,
|
||||
NSCP_MAPISendDocuments,
|
||||
NSCP_MAPIFindNext,
|
||||
NSCP_MAPIReadMail,
|
||||
NSCP_MAPISaveMail,
|
||||
NSCP_MAPIDeleteMail,
|
||||
NSCP_MAPIAddress,
|
||||
NSCP_MAPIDetails,
|
||||
NSCP_MAPIResolveName,
|
||||
NSCP_MAPIEndRequestID // Note: this is a marker for MAPI IPC requests
|
||||
} NSCP_IPC_REQUEST;
|
||||
|
||||
//
|
||||
// This is to keep track of the pointers allocated in the MAPI DLL
|
||||
// and deal with them correctly.
|
||||
//
|
||||
#define MAPI_MESSAGE_TYPE 0
|
||||
#define MAPI_RECIPIENT_TYPE 1
|
||||
|
||||
typedef struct {
|
||||
LPVOID lpMem;
|
||||
UCHAR memType;
|
||||
} memTrackerType;
|
||||
|
||||
//
|
||||
// This is the generic message that WM_COPYDATA will send to the
|
||||
// Communicator product to allow it to attach to shared memory.
|
||||
// NOTE: On Win16, this will simply reference a pointer.
|
||||
//
|
||||
typedef struct {
|
||||
UCHAR smemName[64]; // Name of shared memory
|
||||
DWORD smemSize; // Size of shared memory
|
||||
LPVOID lpsmem; // Will be really used in Win16 only
|
||||
} MAPIIPCType;
|
||||
|
||||
//
|
||||
// These are message specific structures that will be used for
|
||||
// the various MAPI operations.
|
||||
//
|
||||
typedef struct {
|
||||
ULONG ulUIParam;
|
||||
FLAGS flFlags;
|
||||
LHANDLE lhSession;
|
||||
DWORD ipcWorked; // Necessary for IPC check with Communicator
|
||||
// LPSTR strSequence, // LPSTR lpszProfileName, LPSTR lpszPassword
|
||||
// This is here to document the fact there will be a string sequence at
|
||||
// this location
|
||||
} MAPILogonType;
|
||||
|
||||
typedef struct {
|
||||
LHANDLE lhSession;
|
||||
ULONG ulUIParam;
|
||||
FLAGS flFlags;
|
||||
DWORD ipcWorked; // Necessary for IPC check with Communicator
|
||||
} MAPILogoffType;
|
||||
|
||||
typedef struct {
|
||||
LHANDLE lhSession;
|
||||
ULONG ulUIParam;
|
||||
FLAGS flFlags;
|
||||
DWORD ipcWorked; // Necessary for IPC check with Communicator
|
||||
// The following is the "FLAT" representation of the (lpMapiMessage lpMessage)
|
||||
// argument of this structure
|
||||
FLAGS MSG_flFlags; // unread,return receipt
|
||||
ULONG MSG_nRecipCount; // Number of recipients
|
||||
ULONG MSG_nFileCount; // # of file attachments
|
||||
ULONG MSG_ORIG_ulRecipClass; // Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG
|
||||
BYTE dataBuf[1]; // For easy referencing
|
||||
//
|
||||
// This is where it gets CONFUSING...the following buffer of memory is a
|
||||
// contiguous chunk of memory for various strings that are part of this
|
||||
// multilevel structure. For any of the following structure, any numbers
|
||||
// are represented by strings that will have to be converted back to numeric
|
||||
// values with atoi() calls.
|
||||
|
||||
// String 0: LPSTR lpszSubject; // Message Subject
|
||||
// String 1: LPSTR lpszNoteText FILE NAME; // Message Text will be
|
||||
// stored into a temp file and this will be the pointer to that file.
|
||||
// String 2: LPSTR lpszDateReceived; // in YYYY/MM/DD HH:MM format
|
||||
// String 3: LPSTR lpszConversationID; // conversation thread ID
|
||||
//
|
||||
// The following are for the originator of the message. Only ONE of these.
|
||||
//
|
||||
// String 4: LPSTR lpszName; // Originator name
|
||||
// String 5: LPSTR lpszAddress; // Originator address (optional)
|
||||
//
|
||||
// The following strings are for the recipients for this message. There are
|
||||
// MSG_nRecipCount of these in a row:
|
||||
//
|
||||
// for (i=0; i<MSG_nRecipCount; i++)
|
||||
// String x: LPSTR lpszRecipClass (ULONG) // Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG
|
||||
// String x: LPSTR lpszName; // Recipient N name
|
||||
// String x: LPSTR lpszAddress; // Recipient N address (optional)
|
||||
//
|
||||
// Now, finally, add the attachments for this beast. There are MSG_nFileCount
|
||||
// attachments so it would look like the following:
|
||||
//
|
||||
// for (i=0; i<MSG_nFileCount; i++)
|
||||
//
|
||||
// String x: LPSTR lpszPathName // Fully qualified path of the attached file.
|
||||
// // This path should include the disk drive letter and directory name.
|
||||
// String x: LPSTR lpszFileName // The display name for the attached file
|
||||
//
|
||||
} MAPISendMailType;
|
||||
|
||||
typedef struct {
|
||||
ULONG ulUIParam;
|
||||
ULONG nFileCount;
|
||||
DWORD ipcWorked; // Necessary for IPC check with Communicator
|
||||
BYTE dataBuf[1]; // For easy referencing
|
||||
//
|
||||
// The sequence of strings to follow are groups of PathName/FileName couples.
|
||||
// The strings will be parsed in MAPI[32].DLL and then put into this format:
|
||||
//
|
||||
// for (i=0; i<nFileCount; i++)
|
||||
//
|
||||
// String x: LPSTR lpszPathName // Fully qualified path of the attached file.
|
||||
// // This path should include the disk drive letter and directory name.
|
||||
// String x: LPSTR lpszFileName // The display name for the attached file
|
||||
} MAPISendDocumentsType;
|
||||
|
||||
typedef struct {
|
||||
LHANDLE lhSession;
|
||||
ULONG ulUIParam;
|
||||
FLAGS flFlags;
|
||||
DWORD ipcWorked; // Necessary for IPC check with Communicator
|
||||
UCHAR lpszSeedMessageID[MAX_MSGINFO_LEN];
|
||||
UCHAR lpszMessageID[MAX_MSGINFO_LEN];
|
||||
} MAPIFindNextType;
|
||||
|
||||
typedef struct {
|
||||
LHANDLE lhSession;
|
||||
ULONG ulUIParam;
|
||||
DWORD ipcWorked; // Necessary for IPC check with Communicator
|
||||
UCHAR lpszMessageID[MAX_MSGINFO_LEN];
|
||||
} MAPIDeleteMailType;
|
||||
|
||||
typedef struct {
|
||||
LHANDLE lhSession;
|
||||
ULONG ulUIParam;
|
||||
FLAGS flFlags;
|
||||
DWORD ipcWorked; // Necessary for IPC check with Communicator
|
||||
UCHAR lpszName[MAX_NAME_LEN];
|
||||
// These are returned by Communicator
|
||||
UCHAR lpszABookID[MAX_NAME_LEN];
|
||||
UCHAR lpszABookName[MAX_NAME_LEN];
|
||||
UCHAR lpszABookAddress[MAX_NAME_LEN];
|
||||
} MAPIResolveNameType;
|
||||
|
||||
typedef struct {
|
||||
LHANDLE lhSession;
|
||||
ULONG ulUIParam;
|
||||
FLAGS flFlags;
|
||||
DWORD ipcWorked; // Necessary for IPC check with Communicator
|
||||
UCHAR lpszABookID[MAX_NAME_LEN];
|
||||
} MAPIDetailsType;
|
||||
|
||||
typedef struct {
|
||||
LHANDLE lhSession;
|
||||
ULONG ulUIParam;
|
||||
FLAGS flFlags;
|
||||
DWORD ipcWorked; // Necessary for IPC check with Communicator
|
||||
UCHAR lpszMessageID[MAX_MSGINFO_LEN];
|
||||
//
|
||||
// The following is the "FLAT" representation of the (lpMapiMessage lpMessage)
|
||||
// argument of this structure
|
||||
//
|
||||
FLAGS MSG_flFlags; // unread, return or receipt
|
||||
ULONG MSG_nRecipCount; // Number of recipients
|
||||
ULONG MSG_nFileCount; // # of file attachments
|
||||
ULONG MSG_ORIG_ulRecipClass; // Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG
|
||||
//
|
||||
// Output parameter for blob of information that will live on disk.
|
||||
//
|
||||
UCHAR lpszBlob[MAX_MSGINFO_LEN]; // file name on disk
|
||||
//
|
||||
// The format of this blob of information will be:
|
||||
//
|
||||
// String 0: LPSTR lpszSubject; // Message Subject
|
||||
// String 1: LPSTR lpszNoteText FILE NAME; // Message Text will be
|
||||
// stored into a temp file and this will be the pointer to that file.
|
||||
// String 2: LPSTR lpszDateReceived; // in YYYY/MM/DD HH:MM format
|
||||
// String 3: LPSTR lpszConversationID; // conversation thread ID
|
||||
//
|
||||
// The following are for the originator of the message. Only ONE of these.
|
||||
//
|
||||
// String 4: LPSTR lpszName; // Originator name
|
||||
// String 5: LPSTR lpszAddress; // Originator address (optional)
|
||||
//
|
||||
// The following strings are for the recipients for this message. There are
|
||||
// MSG_nRecipCount of these in a row:
|
||||
//
|
||||
// for (i=0; i<MSG_nRecipCount; i++)
|
||||
// String x: LPSTR lpszName; // Recipient N name
|
||||
// String x: LPSTR lpszAddress; // Recipient N address (optional)
|
||||
// String x: LPSTR lpszRecipClass // recipient class - sprintf of ULONG
|
||||
//
|
||||
// Now, finally, add the attachments for this beast. There are MSG_nFileCount
|
||||
// attachments so it would look like the following:
|
||||
//
|
||||
// for (i=0; i<MSG_nFileCount; i++)
|
||||
//
|
||||
// String x: LPSTR lpszPathName // Fully qualified path of the attached file.
|
||||
// // This path should include the disk drive letter and directory name.
|
||||
// String x: LPSTR lpszFileName // The display name for the attached file
|
||||
//
|
||||
} MAPIReadMailType;
|
||||
|
||||
typedef struct {
|
||||
LHANDLE lhSession;
|
||||
ULONG ulUIParam;
|
||||
FLAGS flFlags;
|
||||
UCHAR lpszCaption[MAX_MSGINFO_LEN];
|
||||
DWORD ipcWorked; // Necessary for IPC check with Communicator
|
||||
// The following is the "FLAT" representation of the (lpMapiRecipDesc lpRecips)
|
||||
// argument of this structure
|
||||
ULONG nRecips; // number of recips to start with...
|
||||
ULONG nNewRecips; // number of recips returned...
|
||||
UCHAR lpszBlob[MAX_MSGINFO_LEN]; // file name for blob of information
|
||||
// that will live on disk.
|
||||
BYTE dataBuf[1]; // For easy referencing
|
||||
//
|
||||
// The following contiguous chunk of memory is the buffer that holds
|
||||
// the recipients to load into the address picker...
|
||||
//
|
||||
// for (i=0; i<MSG_nRecipCount; i++)
|
||||
// String x: LPSTR lpszRecipClass (ULONG) // Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG
|
||||
// String x: LPSTR lpszName; // Recipient N name
|
||||
// String x: LPSTR lpszAddress; // Recipient N address (optional)
|
||||
//
|
||||
} MAPIAddressType;
|
||||
|
||||
#endif // _NSCPMAPI
|
||||
27
mozilla/mailnews/mapi/old/tests/makefile.win
Normal file
27
mozilla/mailnews/mapi/old/tests/makefile.win
Normal file
@@ -0,0 +1,27 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
|
||||
DIRS=mapitest
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
239
mozilla/mailnews/mapi/old/tests/mapitest/main.cpp
Normal file
239
mozilla/mailnews/mapi/old/tests/mapitest/main.cpp
Normal file
@@ -0,0 +1,239 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#ifndef MAPI_OLE // Because MSFT doesn't do this for us :-(
|
||||
#include <mapi.h>
|
||||
#endif
|
||||
|
||||
#include "port.h"
|
||||
#include "resource.h"
|
||||
|
||||
#ifndef WM_PAINTICON
|
||||
#define WM_PAINTICON 0x26
|
||||
#endif // WM_PAINTICON
|
||||
|
||||
/*
|
||||
* Forward Declarations...
|
||||
*/
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow);
|
||||
BOOL CALLBACK LOADDS MyDlgProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
|
||||
extern void ProcessCommand(HWND hWnd, int id, HWND hCtl, UINT codeNotify);
|
||||
BOOL OpenMAPI(void);
|
||||
void CloseMAPI(void);
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
HINSTANCE hInst;
|
||||
HWND hWnd;
|
||||
|
||||
#ifdef WIN16
|
||||
HICON hIconApp;
|
||||
#endif
|
||||
|
||||
char NEAR szAppName[] = "Netscape QA Helper";
|
||||
char NEAR szShortAppName[] = "QAHelper";
|
||||
char szClassName[] = "Netscape_QAHelper_Class_Name";
|
||||
|
||||
void
|
||||
AppCleanup(void)
|
||||
{
|
||||
extern void DoMAPILogoff(HWND hWnd);
|
||||
static BOOL isDone = FALSE;
|
||||
|
||||
if (isDone)
|
||||
return;
|
||||
|
||||
extern LHANDLE mapiSession;
|
||||
|
||||
if (mapiSession != 0)
|
||||
{
|
||||
DoMAPILogoff(hWnd);
|
||||
}
|
||||
|
||||
CloseMAPI();
|
||||
isDone = TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
/* Create a main window for this application instance. */
|
||||
hWnd = CreateDialog((HINSTANCE) hInstance,
|
||||
MAKEINTRESOURCE(ID_DIALOG),
|
||||
(HWND) NULL, (DLGPROC) MyDlgProc);
|
||||
|
||||
if (!hWnd)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL InitApp(void)
|
||||
{
|
||||
#ifndef WIN16
|
||||
WNDCLASS wc;
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = DefDlgProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = DLGWINDOWEXTRA;
|
||||
wc.hInstance = hInst;
|
||||
wc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON_APP));
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = szClassName;
|
||||
|
||||
if(!RegisterClass(&wc))
|
||||
return FALSE;
|
||||
|
||||
#else
|
||||
hIconApp = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON_APP));
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
} // end InitApp
|
||||
|
||||
// Win Main
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
hInst = hInstance;
|
||||
|
||||
if (!InitApp())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!InitInstance(hInstance, nCmdShow))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!OpenMAPI())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ShowWindow(hWnd, SW_SHOW);
|
||||
|
||||
// Start the application
|
||||
while ((GetMessage(&msg, (HWND) NULL, (UINT) NULL, (UINT) NULL)))
|
||||
{
|
||||
if(IsDialogMessage(hWnd, &msg))
|
||||
continue;
|
||||
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return(msg.wParam);
|
||||
}
|
||||
|
||||
BOOL CALLBACK LOADDS
|
||||
MyDlgProc(HWND hWndMain, UINT wMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (wMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
hWnd = hWndMain;
|
||||
SetDlgItemText(hWnd, ID_EDIT_ROW, "0");
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
{
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
AppCleanup();
|
||||
|
||||
#ifndef WIN16
|
||||
UnregisterClass(szClassName, hInst);
|
||||
#else
|
||||
// Destroy the 16 bit windows icon
|
||||
if(hIconApp != 0)
|
||||
DestroyIcon(hIconApp);
|
||||
#endif
|
||||
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
case WM_COMMAND:
|
||||
HANDLE_WM_COMMAND(hWnd, wParam, lParam, ProcessCommand);
|
||||
break;
|
||||
|
||||
case WM_QUERYDRAGICON:
|
||||
#ifdef WIN16
|
||||
return (BOOL)hIconApp;
|
||||
#endif
|
||||
|
||||
case WM_PAINTICON:
|
||||
#ifdef WIN16
|
||||
SetClassWord(hWnd, GCW_HICON, 0);
|
||||
|
||||
// fall trough
|
||||
case WM_PAINT:
|
||||
{
|
||||
if(!IsIconic(hWnd))
|
||||
return FALSE;
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC = BeginPaint(hWnd, &ps);
|
||||
SetMapMode(hDC, MM_TEXT);
|
||||
DrawIcon(hDC, 2, 2, hIconApp);
|
||||
EndPaint(hWnd, &ps);
|
||||
break;
|
||||
}
|
||||
#endif //WIN16
|
||||
break; // RICHIE - if this is not here NT 3.51 Pukes!!!!
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//~~av return (DefWindowProc(hWnd, wMsg, wParam, lParam));
|
||||
return TRUE;
|
||||
}
|
||||
240
mozilla/mailnews/mapi/old/tests/mapitest/makefile.win
Normal file
240
mozilla/mailnews/mapi/old/tests/mapitest/makefile.win
Normal file
@@ -0,0 +1,240 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on mapitest.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=mapitest - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to mapitest - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "mapitest - Win32 Release" && "$(CFG)" != "mapitest - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "mapitest.mak" CFG="mapitest - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "mapitest - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "mapitest - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "mapitest - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\mapitest.exe"
|
||||
|
||||
export :
|
||||
libs :
|
||||
install :
|
||||
|
||||
clobber_all : clobber
|
||||
|
||||
clobber:
|
||||
-@erase "$(INTDIR)\main.obj"
|
||||
-@erase "$(INTDIR)\mapimail.obj"
|
||||
-@erase "$(INTDIR)\mapiproc.obj"
|
||||
-@erase "$(INTDIR)\mtest32.res"
|
||||
-@erase "$(INTDIR)\readmail.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(OUTDIR)\mapitest.exe"
|
||||
-@erase "$(OUTDIR)\mapitest.pch"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\mapitest.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mtest32.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\mapitest.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\mapitest.pdb" /machine:I386 /out:"$(OUTDIR)\mapitest.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\main.obj" \
|
||||
"$(INTDIR)\mapimail.obj" \
|
||||
"$(INTDIR)\mapiproc.obj" \
|
||||
"$(INTDIR)\readmail.obj" \
|
||||
"$(INTDIR)\mtest32.res"
|
||||
|
||||
"$(OUTDIR)\mapitest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "mapitest - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\mapitest.exe"
|
||||
|
||||
export :
|
||||
libs :
|
||||
install :
|
||||
|
||||
clobber_all : clobber
|
||||
|
||||
clobber :
|
||||
-@erase "$(INTDIR)\main.obj"
|
||||
-@erase "$(INTDIR)\mapimail.obj"
|
||||
-@erase "$(INTDIR)\mapiproc.obj"
|
||||
-@erase "$(INTDIR)\mtest32.res"
|
||||
-@erase "$(INTDIR)\readmail.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(OUTDIR)\mapitest.exe"
|
||||
-@erase "$(OUTDIR)\mapitest.ilk"
|
||||
-@erase "$(OUTDIR)\mapitest.pdb"
|
||||
-@erase "$(OUTDIR)\mapitest.pch"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\mapitest.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\mtest32.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\mapitest.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\mapitest.pdb" /debug /machine:I386 /out:"$(OUTDIR)\mapitest.exe" /pdbtype:sept
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\main.obj" \
|
||||
"$(INTDIR)\mapimail.obj" \
|
||||
"$(INTDIR)\mapiproc.obj" \
|
||||
"$(INTDIR)\readmail.obj" \
|
||||
"$(INTDIR)\mtest32.res"
|
||||
|
||||
"$(OUTDIR)\mapitest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("mapitest.dep")
|
||||
!INCLUDE "mapitest.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "mapitest.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "mapitest - Win32 Release" || "$(CFG)" == "mapitest - Win32 Debug"
|
||||
SOURCE=.\main.cpp
|
||||
|
||||
"$(INTDIR)\main.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\mapimail.cpp
|
||||
|
||||
"$(INTDIR)\mapimail.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\mapiproc.cpp
|
||||
|
||||
"$(INTDIR)\mapiproc.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\mtest32.rc
|
||||
|
||||
"$(INTDIR)\mtest32.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=.\readmail.cpp
|
||||
|
||||
"$(INTDIR)\readmail.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
772
mozilla/mailnews/mapi/old/tests/mapitest/mapimail.cpp
Normal file
772
mozilla/mailnews/mapi/old/tests/mapitest/mapimail.cpp
Normal file
@@ -0,0 +1,772 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <string.h>
|
||||
#include <mapi.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "port.h"
|
||||
#include "resource.h"
|
||||
|
||||
//
|
||||
// Variables...
|
||||
//
|
||||
extern HINSTANCE m_hInstMapi;
|
||||
extern LHANDLE mapiSession;
|
||||
|
||||
//
|
||||
// Forward declarations...
|
||||
//
|
||||
void DoMAPIFreeBuffer(HWND hWnd, LPVOID buf, BOOL alert);
|
||||
extern void ShowMessage(HWND hWnd, LPSTR msg);
|
||||
void DoMAPISendMail(HWND hWnd);
|
||||
void DoMAPISendDocuments(HWND hWnd);
|
||||
void DoMAPISaveMail(HWND hWnd);
|
||||
void DoMAPIAddress(HWND hWnd);
|
||||
extern void SetFooter(LPSTR msg);
|
||||
extern LPSTR GetMAPIError(LONG errorCode);
|
||||
|
||||
void
|
||||
ProcessMailCommand(HWND hWnd, int id, HWND hCtl, UINT codeNotify)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case IDCANCEL:
|
||||
EndDialog(hWnd, 0);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_MAPISENDMAIL:
|
||||
DoMAPISendMail(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_MAPISENDDOCUMENTS:
|
||||
DoMAPISendDocuments(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_MAPISAVEMAIL:
|
||||
DoMAPISaveMail(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_MAPIADDRESS:
|
||||
DoMAPIAddress(hWnd);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CALLBACK LOADDS
|
||||
MailDlgProc(HWND hWndMain, UINT wMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (wMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
HANDLE_WM_COMMAND(hWndMain, wParam, lParam, ProcessMailCommand);
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static LPSTR lpszDelimChar = ";";
|
||||
|
||||
void
|
||||
TackItOn(LPSTR fileBuf, LPSTR nameBuf, LPSTR addOn)
|
||||
{
|
||||
if (addOn[0] != '\0')
|
||||
{
|
||||
lstrcat(fileBuf, addOn);
|
||||
lstrcat(fileBuf, lpszDelimChar);
|
||||
|
||||
lstrcat(nameBuf, "NAMEOF.FILE");
|
||||
lstrcat(nameBuf, lpszDelimChar);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPISendDocuments(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPISendDocuments) (ULONG ulUIParam,
|
||||
LPTSTR lpszDelimChar, LPTSTR lpszFullPaths,
|
||||
LPTSTR lpszFileNames, ULONG ulReserved);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPISendDocuments = GetProcAddress(m_hInstMapi, "MAPISENDDOCUMENTS");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPISendDocuments = GetProcAddress(m_hInstMapi, "MAPISendDocuments");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPISendDocuments)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
char msg[1024];
|
||||
char tempFileName[_MAX_PATH] = "";
|
||||
char lpszFullPaths[(_MAX_PATH + 1) * 4] = "";
|
||||
char lpszFileNames[(_MAX_PATH + 1) * 4] = "";
|
||||
|
||||
// Now get the names of the files to attach...
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH1, tempFileName, sizeof(tempFileName));
|
||||
TackItOn(lpszFullPaths, lpszFileNames, tempFileName);
|
||||
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH2, tempFileName, sizeof(tempFileName));
|
||||
TackItOn(lpszFullPaths, lpszFileNames, tempFileName);
|
||||
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH3, tempFileName, sizeof(tempFileName));
|
||||
TackItOn(lpszFullPaths, lpszFileNames, tempFileName);
|
||||
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH4, tempFileName, sizeof(tempFileName));
|
||||
TackItOn(lpszFullPaths, lpszFileNames, tempFileName);
|
||||
|
||||
LONG rc = (*lpfnMAPISendDocuments)
|
||||
( (ULONG) hWnd,
|
||||
lpszDelimChar,
|
||||
lpszFullPaths,
|
||||
lpszFileNames,
|
||||
0);
|
||||
|
||||
if (rc == SUCCESS_SUCCESS)
|
||||
{
|
||||
ShowMessage(hWnd, "Success with MAPISendDocuments");
|
||||
SetFooter("MAPISendDocuments success");
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from MAPISendDocuments\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("MAPISendDocuments failed");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FreeMAPIFile(lpMapiFileDesc pv)
|
||||
{
|
||||
if (!pv)
|
||||
return;
|
||||
|
||||
if (pv->lpszPathName != NULL)
|
||||
free(pv->lpszPathName);
|
||||
|
||||
if (pv->lpszFileName != NULL)
|
||||
free(pv->lpszFileName);
|
||||
}
|
||||
|
||||
void
|
||||
FreeMAPIRecipient(lpMapiRecipDesc pv)
|
||||
{
|
||||
if (!pv)
|
||||
return;
|
||||
|
||||
if (pv->lpszName != NULL)
|
||||
free(pv->lpszName);
|
||||
|
||||
if (pv->lpszAddress != NULL)
|
||||
free(pv->lpszAddress);
|
||||
|
||||
if (pv->lpEntryID != NULL)
|
||||
free(pv->lpEntryID);
|
||||
}
|
||||
|
||||
void
|
||||
FreeMAPIMessage(lpMapiMessage pv)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
if (!pv)
|
||||
return;
|
||||
|
||||
if (pv->lpszSubject != NULL)
|
||||
free(pv->lpszSubject);
|
||||
|
||||
if (pv->lpszNoteText)
|
||||
free(pv->lpszNoteText);
|
||||
|
||||
if (pv->lpszMessageType)
|
||||
free(pv->lpszMessageType);
|
||||
|
||||
if (pv->lpszDateReceived)
|
||||
free(pv->lpszDateReceived);
|
||||
|
||||
if (pv->lpszConversationID)
|
||||
free(pv->lpszConversationID);
|
||||
|
||||
if (pv->lpOriginator)
|
||||
FreeMAPIRecipient(pv->lpOriginator);
|
||||
|
||||
for (i=0; i<pv->nRecipCount; i++)
|
||||
{
|
||||
if (&(pv->lpRecips[i]) != NULL)
|
||||
{
|
||||
FreeMAPIRecipient(&(pv->lpRecips[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if (pv->lpRecips != NULL)
|
||||
{
|
||||
free(pv->lpRecips);
|
||||
}
|
||||
|
||||
for (i=0; i<pv->nFileCount; i++)
|
||||
{
|
||||
if (&(pv->lpFiles[i]) != NULL)
|
||||
{
|
||||
FreeMAPIFile(&(pv->lpFiles[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if (pv->lpFiles != NULL)
|
||||
{
|
||||
free(pv->lpFiles);
|
||||
}
|
||||
|
||||
free(pv);
|
||||
pv = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPISendMail(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPISendMail) (LHANDLE lhSession, ULONG ulUIParam,
|
||||
lpMapiMessage lpMessage, FLAGS flFlags, ULONG ulReserved);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPISendMail = GetProcAddress(m_hInstMapi, "MAPISENDMAIL");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPISendMail = GetProcAddress(m_hInstMapi, "MAPISendMail");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPISendMail)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
FLAGS flFlags = 0;
|
||||
char msg[512];
|
||||
char file1[_MAX_PATH] = "";
|
||||
char file2[_MAX_PATH] = "";
|
||||
char file3[_MAX_PATH] = "";
|
||||
char file4[_MAX_PATH] = "";
|
||||
char toAddr[128];
|
||||
char ccAddr[128];
|
||||
char bccAddr[128];
|
||||
char subject[128];
|
||||
char noteText[4096];
|
||||
char dateReceived[128] = "N/A";
|
||||
char threadID[128] = "N/A";;
|
||||
char origName[128] = "N/A";;
|
||||
char origAddress[128] = "N/A";;
|
||||
|
||||
GetDlgItemText(hWnd, ID_EDIT_TOADDRESS, toAddr, sizeof(toAddr));
|
||||
GetDlgItemText(hWnd, ID_EDIT_CCADDRESS, ccAddr, sizeof(ccAddr));
|
||||
GetDlgItemText(hWnd, ID_EDIT_BCCADDRESS, bccAddr, sizeof(bccAddr));
|
||||
GetDlgItemText(hWnd, ID_EDIT_SUBJECT, subject, sizeof(subject));
|
||||
GetDlgItemText(hWnd, ID_EDIT_NOTETEXT, noteText, sizeof(noteText));
|
||||
|
||||
// Do the one flag we support for this call...
|
||||
if (BST_CHECKED == Button_GetCheck(GetDlgItem(hWnd, ID_CHECK_SHOWDIALOG)))
|
||||
{
|
||||
flFlags |= MAPI_DIALOG;
|
||||
}
|
||||
|
||||
// Build the message to send off...
|
||||
lpMapiMessage msgPtr = (MapiMessage *)malloc(sizeof(MapiMessage));
|
||||
if (msgPtr == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
memset(msgPtr, 0, sizeof(MapiMessage));
|
||||
|
||||
//
|
||||
// At this point, we need to populate the structure of information
|
||||
// we are passing in via the *lppMessage
|
||||
//
|
||||
|
||||
// Set all of the general information first!
|
||||
msgPtr->lpszSubject = strdup(subject);
|
||||
msgPtr->lpszNoteText = strdup(noteText);
|
||||
msgPtr->lpszDateReceived = strdup(dateReceived);
|
||||
msgPtr->lpszConversationID = strdup(threadID);
|
||||
msgPtr->flFlags = flFlags;
|
||||
|
||||
// Now deal with the recipients of this message
|
||||
DWORD realRecips = 0;
|
||||
if (toAddr[0] != '\0') ++realRecips;
|
||||
if (ccAddr[0] != '\0') ++realRecips;
|
||||
if (bccAddr[0] != '\0') ++realRecips;
|
||||
|
||||
msgPtr->lpRecips = (lpMapiRecipDesc) malloc((size_t) (sizeof(MapiRecipDesc) * realRecips));
|
||||
if (!msgPtr->lpRecips)
|
||||
{
|
||||
FreeMAPIMessage(msgPtr);
|
||||
return;
|
||||
}
|
||||
|
||||
msgPtr->nRecipCount = realRecips;
|
||||
memset(msgPtr->lpRecips, 0, (size_t) (sizeof(MapiRecipDesc) * msgPtr->nRecipCount));
|
||||
|
||||
DWORD rCount = 0;
|
||||
if (toAddr[0] != '\0')
|
||||
{
|
||||
msgPtr->lpRecips[rCount].lpszName = strdup(toAddr);
|
||||
msgPtr->lpRecips[rCount].lpszAddress = strdup(toAddr);
|
||||
msgPtr->lpRecips[rCount].ulRecipClass = MAPI_TO;
|
||||
rCount++;
|
||||
}
|
||||
|
||||
if (ccAddr[0] != '\0')
|
||||
{
|
||||
msgPtr->lpRecips[rCount].lpszName = strdup(ccAddr);
|
||||
msgPtr->lpRecips[rCount].lpszAddress = strdup(ccAddr);
|
||||
msgPtr->lpRecips[rCount].ulRecipClass = MAPI_CC;
|
||||
rCount++;
|
||||
}
|
||||
|
||||
if (bccAddr[0] != '\0')
|
||||
{
|
||||
msgPtr->lpRecips[rCount].lpszName = strdup(bccAddr);
|
||||
msgPtr->lpRecips[rCount].lpszAddress = strdup(bccAddr);
|
||||
msgPtr->lpRecips[rCount].ulRecipClass = MAPI_BCC;
|
||||
rCount++;
|
||||
}
|
||||
|
||||
// Now get the names of the files to attach...
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH1, file1, sizeof(file1));
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH2, file2, sizeof(file2));
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH3, file3, sizeof(file3));
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH4, file4, sizeof(file4));
|
||||
|
||||
DWORD realFiles = 0;
|
||||
if (file1[0] != '\0') ++realFiles;
|
||||
if (file2[0] != '\0') ++realFiles;
|
||||
if (file3[0] != '\0') ++realFiles;
|
||||
if (file4[0] != '\0') ++realFiles;
|
||||
|
||||
// Now deal with the list of attachments! Since the nFileCount should be set
|
||||
// correctly, this loop will automagically be correct
|
||||
//
|
||||
msgPtr->nFileCount = realFiles;
|
||||
if (realFiles > 0)
|
||||
{
|
||||
msgPtr->lpFiles = (lpMapiFileDesc) malloc((size_t) (sizeof(MapiFileDesc) * realFiles));
|
||||
if (!msgPtr->lpFiles)
|
||||
{
|
||||
FreeMAPIMessage(msgPtr);
|
||||
return;
|
||||
}
|
||||
|
||||
memset(msgPtr->lpFiles, 0, (size_t) (sizeof(MapiFileDesc) * msgPtr->nFileCount));
|
||||
}
|
||||
|
||||
rCount = 0;
|
||||
if (file1[0] != '\0')
|
||||
{
|
||||
msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file1);
|
||||
msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file1);
|
||||
++rCount;
|
||||
}
|
||||
|
||||
if (file2[0] != '\0')
|
||||
{
|
||||
msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file2);
|
||||
msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file2);
|
||||
++rCount;
|
||||
}
|
||||
|
||||
if (file3[0] != '\0')
|
||||
{
|
||||
msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file3);
|
||||
msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file3);
|
||||
++rCount;
|
||||
}
|
||||
|
||||
if (file4[0] != '\0')
|
||||
{
|
||||
msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file4);
|
||||
msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file4);
|
||||
++rCount;
|
||||
}
|
||||
|
||||
// Finally, make the call...
|
||||
LONG rc = (*lpfnMAPISendMail)
|
||||
(mapiSession,
|
||||
(ULONG) hWnd,
|
||||
msgPtr,
|
||||
flFlags,
|
||||
0);
|
||||
|
||||
if (rc == SUCCESS_SUCCESS)
|
||||
{
|
||||
ShowMessage(hWnd, "Success with MAPISendMail");
|
||||
SetFooter("MAPISendMail success");
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from MAPISendMail\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("MAPISendMail failed");
|
||||
}
|
||||
|
||||
// Now cleanup and move on...
|
||||
FreeMAPIMessage(msgPtr);
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPISaveMail(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPISaveMail) (LHANDLE lhSession, ULONG ulUIParam,
|
||||
lpMapiMessage lpMessage, FLAGS flFlags, ULONG ulReserved,
|
||||
LPTSTR lpszMessageID);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPISaveMail = GetProcAddress(m_hInstMapi, "MAPISAVEMAIL");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPISaveMail = GetProcAddress(m_hInstMapi, "MAPISaveMail");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPISaveMail)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
FLAGS flFlags = 0;
|
||||
char msg[512];
|
||||
char file1[_MAX_PATH] = "";
|
||||
char file2[_MAX_PATH] = "";
|
||||
char file3[_MAX_PATH] = "";
|
||||
char file4[_MAX_PATH] = "";
|
||||
char toAddr[128];
|
||||
char ccAddr[128];
|
||||
char bccAddr[128];
|
||||
char subject[128];
|
||||
char noteText[4096];
|
||||
char dateReceived[128] = "N/A";
|
||||
char threadID[128] = "N/A";;
|
||||
char origName[128] = "N/A";;
|
||||
char origAddress[128] = "N/A";;
|
||||
|
||||
GetDlgItemText(hWnd, ID_EDIT_TOADDRESS, toAddr, sizeof(toAddr));
|
||||
GetDlgItemText(hWnd, ID_EDIT_CCADDRESS, ccAddr, sizeof(ccAddr));
|
||||
GetDlgItemText(hWnd, ID_EDIT_BCCADDRESS, bccAddr, sizeof(bccAddr));
|
||||
GetDlgItemText(hWnd, ID_EDIT_SUBJECT, subject, sizeof(subject));
|
||||
GetDlgItemText(hWnd, ID_EDIT_NOTETEXT, noteText, sizeof(noteText));
|
||||
|
||||
// Build the message to send off...
|
||||
lpMapiMessage msgPtr = (MapiMessage *)malloc(sizeof(MapiMessage));
|
||||
if (msgPtr == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
memset(msgPtr, 0, sizeof(MapiMessage));
|
||||
|
||||
//
|
||||
// At this point, we need to populate the structure of information
|
||||
// we are passing in via the *lppMessage
|
||||
//
|
||||
|
||||
// Set all of the general information first!
|
||||
msgPtr->lpszSubject = strdup(subject);
|
||||
msgPtr->lpszNoteText = strdup(noteText);
|
||||
msgPtr->lpszDateReceived = strdup(dateReceived);
|
||||
msgPtr->lpszConversationID = strdup(threadID);
|
||||
msgPtr->flFlags = flFlags;
|
||||
|
||||
// Now deal with the recipients of this message
|
||||
DWORD realRecips = 0;
|
||||
if (toAddr[0] != '\0') ++realRecips;
|
||||
if (ccAddr[0] != '\0') ++realRecips;
|
||||
if (bccAddr[0] != '\0') ++realRecips;
|
||||
|
||||
msgPtr->lpRecips = (lpMapiRecipDesc) malloc((size_t) (sizeof(MapiRecipDesc) * realRecips));
|
||||
if (!msgPtr->lpRecips)
|
||||
{
|
||||
FreeMAPIMessage(msgPtr);
|
||||
return;
|
||||
}
|
||||
|
||||
msgPtr->nRecipCount = realRecips;
|
||||
memset(msgPtr->lpRecips, 0, (size_t) (sizeof(MapiRecipDesc) * msgPtr->nRecipCount));
|
||||
|
||||
DWORD rCount = 0;
|
||||
if (toAddr[0] != '\0')
|
||||
{
|
||||
msgPtr->lpRecips[rCount].lpszName = strdup(toAddr);
|
||||
msgPtr->lpRecips[rCount].lpszAddress = strdup(toAddr);
|
||||
msgPtr->lpRecips[rCount].ulRecipClass = MAPI_TO;
|
||||
rCount++;
|
||||
}
|
||||
|
||||
if (ccAddr[0] != '\0')
|
||||
{
|
||||
msgPtr->lpRecips[rCount].lpszName = strdup(ccAddr);
|
||||
msgPtr->lpRecips[rCount].lpszAddress = strdup(ccAddr);
|
||||
msgPtr->lpRecips[rCount].ulRecipClass = MAPI_CC;
|
||||
rCount++;
|
||||
}
|
||||
|
||||
if (bccAddr[0] != '\0')
|
||||
{
|
||||
msgPtr->lpRecips[rCount].lpszName = strdup(bccAddr);
|
||||
msgPtr->lpRecips[rCount].lpszAddress = strdup(bccAddr);
|
||||
msgPtr->lpRecips[rCount].ulRecipClass = MAPI_BCC;
|
||||
rCount++;
|
||||
}
|
||||
|
||||
// Now get the names of the files to attach...
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH1, file1, sizeof(file1));
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH2, file2, sizeof(file2));
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH3, file3, sizeof(file3));
|
||||
GetDlgItemText(hWnd, ID_EDIT_ATTACH4, file4, sizeof(file4));
|
||||
|
||||
DWORD realFiles = 0;
|
||||
if (file1[0] != '\0') ++realFiles;
|
||||
if (file2[0] != '\0') ++realFiles;
|
||||
if (file3[0] != '\0') ++realFiles;
|
||||
if (file4[0] != '\0') ++realFiles;
|
||||
|
||||
// Now deal with the list of attachments! Since the nFileCount should be set
|
||||
// correctly, this loop will automagically be correct
|
||||
//
|
||||
msgPtr->nFileCount = realFiles;
|
||||
if (realFiles > 0)
|
||||
{
|
||||
msgPtr->lpFiles = (lpMapiFileDesc) malloc((size_t) (sizeof(MapiFileDesc) * realFiles));
|
||||
if (!msgPtr->lpFiles)
|
||||
{
|
||||
FreeMAPIMessage(msgPtr);
|
||||
return;
|
||||
}
|
||||
|
||||
memset(msgPtr->lpFiles, 0, (size_t) (sizeof(MapiFileDesc) * msgPtr->nFileCount));
|
||||
}
|
||||
|
||||
rCount = 0;
|
||||
if (file1[0] != '\0')
|
||||
{
|
||||
msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file1);
|
||||
msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file1);
|
||||
++rCount;
|
||||
}
|
||||
|
||||
if (file2[0] != '\0')
|
||||
{
|
||||
msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file2);
|
||||
msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file2);
|
||||
++rCount;
|
||||
}
|
||||
|
||||
if (file3[0] != '\0')
|
||||
{
|
||||
msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file3);
|
||||
msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file3);
|
||||
++rCount;
|
||||
}
|
||||
|
||||
if (file4[0] != '\0')
|
||||
{
|
||||
msgPtr->lpFiles[rCount].lpszPathName = strdup((LPSTR)file4);
|
||||
msgPtr->lpFiles[rCount].lpszFileName = strdup((LPSTR)file4);
|
||||
++rCount;
|
||||
}
|
||||
|
||||
// Finally, make the call...
|
||||
LONG rc = (*lpfnMAPISaveMail)
|
||||
(mapiSession,
|
||||
(ULONG) hWnd,
|
||||
msgPtr,
|
||||
flFlags,
|
||||
0, NULL);
|
||||
|
||||
if (rc == SUCCESS_SUCCESS)
|
||||
{
|
||||
ShowMessage(hWnd, "Success with MAPISaveMail");
|
||||
SetFooter("MAPISaveMail success");
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from MAPISaveMail\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("MAPISaveMail failed");
|
||||
}
|
||||
|
||||
// Now cleanup and move on...
|
||||
FreeMAPIMessage(msgPtr);
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPIAddress(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPIAddress)
|
||||
(LHANDLE lhSession,
|
||||
ULONG ulUIParam,
|
||||
LPSTR lpszCaption,
|
||||
ULONG nEditFields,
|
||||
LPSTR lpszLabels,
|
||||
ULONG nRecips,
|
||||
lpMapiRecipDesc lpRecips,
|
||||
FLAGS flFlags,
|
||||
ULONG ulReserved,
|
||||
LPULONG lpnNewRecips,
|
||||
lpMapiRecipDesc FAR *lppNewRecips);
|
||||
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPIAddress = GetProcAddress(m_hInstMapi, "MAPIADDRESS");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPIAddress = GetProcAddress(m_hInstMapi, "MAPIAddress");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPIAddress)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD i;
|
||||
FLAGS flFlags = 0;
|
||||
DWORD addrCount = 0;
|
||||
char msg[512];
|
||||
char toAddr[128];
|
||||
char ccAddr[128];
|
||||
char bccAddr[128];
|
||||
|
||||
GetDlgItemText(hWnd, ID_EDIT_TOADDRESS, toAddr, sizeof(toAddr));
|
||||
GetDlgItemText(hWnd, ID_EDIT_CCADDRESS, ccAddr, sizeof(ccAddr));
|
||||
GetDlgItemText(hWnd, ID_EDIT_BCCADDRESS, bccAddr, sizeof(bccAddr));
|
||||
|
||||
if (toAddr[0]) ++addrCount;
|
||||
if (ccAddr[0]) ++addrCount;
|
||||
if (bccAddr[0]) ++addrCount;
|
||||
|
||||
lpMapiRecipDesc lpRecips = (lpMapiRecipDesc) malloc((size_t) (sizeof(MapiRecipDesc) * addrCount));
|
||||
if (!lpRecips)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
memset(lpRecips, 0, (size_t) (sizeof(MapiRecipDesc) * addrCount));
|
||||
|
||||
DWORD rCount = 0;
|
||||
if (toAddr[0] != '\0')
|
||||
{
|
||||
lpRecips[rCount].lpszName = strdup("To Address Name");
|
||||
lpRecips[rCount].lpszAddress = strdup(toAddr);
|
||||
lpRecips[rCount].ulRecipClass = MAPI_TO;
|
||||
rCount++;
|
||||
}
|
||||
|
||||
if (ccAddr[0] != '\0')
|
||||
{
|
||||
lpRecips[rCount].lpszName = strdup("CC Address Name");
|
||||
lpRecips[rCount].lpszAddress = strdup(ccAddr);
|
||||
lpRecips[rCount].ulRecipClass = MAPI_CC;
|
||||
rCount++;
|
||||
}
|
||||
|
||||
if (bccAddr[0] != '\0')
|
||||
{
|
||||
lpRecips[rCount].lpszName = strdup("BCC Address Name");
|
||||
lpRecips[rCount].lpszAddress = strdup(bccAddr);
|
||||
lpRecips[rCount].ulRecipClass = MAPI_BCC;
|
||||
rCount++;
|
||||
}
|
||||
|
||||
ULONG newRecips;
|
||||
lpMapiRecipDesc lpNewRecips;
|
||||
|
||||
// Finally, make the call...
|
||||
LONG rc = (*lpfnMAPIAddress)
|
||||
(mapiSession,
|
||||
0,
|
||||
"MAPI Test Address Picker",
|
||||
0,
|
||||
NULL,
|
||||
rCount,
|
||||
lpRecips,
|
||||
0,
|
||||
0,
|
||||
&newRecips,
|
||||
&lpNewRecips);
|
||||
if (rc == SUCCESS_SUCCESS)
|
||||
{
|
||||
for (i=0; i<newRecips; i++)
|
||||
{
|
||||
char tMsg[512];
|
||||
|
||||
wsprintf(tMsg, "User %d\nName=[%s]\nEmail=[%s]\nType=[%d]",
|
||||
i,
|
||||
lpNewRecips[i].lpszName,
|
||||
lpNewRecips[i].lpszAddress,
|
||||
lpNewRecips[i].ulRecipClass);
|
||||
ShowMessage(hWnd, tMsg);
|
||||
}
|
||||
|
||||
SetFooter("MAPIAddress success");
|
||||
|
||||
DoMAPIFreeBuffer(hWnd, lpNewRecips, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from MAPIAddress\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("MAPIAddress failed");
|
||||
}
|
||||
|
||||
// Now cleanup and move on...
|
||||
for (i=0; i<rCount; i++)
|
||||
{
|
||||
FreeMAPIRecipient(&(lpRecips[i]));
|
||||
}
|
||||
}
|
||||
832
mozilla/mailnews/mapi/old/tests/mapitest/mapiproc.cpp
Normal file
832
mozilla/mailnews/mapi/old/tests/mapitest/mapiproc.cpp
Normal file
@@ -0,0 +1,832 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef MAPI_OLE // Because MSFT doesn't do this for us :-(
|
||||
#include <mapi.h>
|
||||
#endif
|
||||
|
||||
#include "port.h"
|
||||
#include "resource.h"
|
||||
|
||||
//
|
||||
// Variables...
|
||||
//
|
||||
extern HINSTANCE hInst;
|
||||
HINSTANCE m_hInstMapi;
|
||||
LHANDLE mapiSession = 0;
|
||||
|
||||
//
|
||||
// Forward declarations...
|
||||
//
|
||||
void LoadNSCPVersionFunc(HWND hWnd);
|
||||
void DoMAPILogon(HWND hWnd);
|
||||
void DoMAPILogoff(HWND hWnd);
|
||||
void DoMAPIFreeBuffer(HWND hWnd, LPVOID buf, BOOL alert);
|
||||
void DoMAPISendMail(HWND hWnd);
|
||||
void DoMAPISendDocuments(HWND hWnd);
|
||||
void DoMAPIFindNext(HWND hWnd);
|
||||
void DoMAPIReadMail(HWND hWnd);
|
||||
void DoMAPIDeleteMail(HWND hWnd);
|
||||
void DoMAPIDetails(HWND hWnd);
|
||||
void DoMAPIResolveName(HWND hWnd);
|
||||
void DoMAPIResolveNameFreeBuffer(HWND hWnd);
|
||||
void SetFooter(LPSTR msg);
|
||||
void DoMAPI_NSCP_Sync(HWND hWnd);
|
||||
LPSTR GetMAPIError(LONG errorCode);
|
||||
extern void DisplayMAPIReadMail(HWND hWnd, lpMapiMessage msgPtr);
|
||||
lpMapiMessage GetMessage(HWND hWnd, LPSTR id);
|
||||
|
||||
void
|
||||
SetFooter(LPSTR msg)
|
||||
{
|
||||
extern HWND hWnd;
|
||||
|
||||
SetDlgItemText(hWnd, ID_STATIC_RESULT, msg);
|
||||
}
|
||||
|
||||
char FAR *
|
||||
GetMAPIError(LONG errorCode)
|
||||
{
|
||||
static char FAR msg[128];
|
||||
|
||||
switch (errorCode) {
|
||||
case MAPI_E_FAILURE:
|
||||
lstrcpy(msg, "General MAPI Failure");
|
||||
break;
|
||||
|
||||
case MAPI_E_INSUFFICIENT_MEMORY:
|
||||
strcpy(msg, "Insufficient Memory");
|
||||
break;
|
||||
|
||||
case MAPI_E_LOGIN_FAILURE:
|
||||
strcpy(msg, "Login Failure");
|
||||
break;
|
||||
|
||||
case MAPI_E_TOO_MANY_SESSIONS:
|
||||
strcpy(msg, "Too many MAPI sessions");
|
||||
break;
|
||||
|
||||
case MAPI_E_INVALID_SESSION:
|
||||
strcpy(msg, "Invalid Session!");
|
||||
break;
|
||||
|
||||
case MAPI_E_INVALID_MESSAGE:
|
||||
strcpy(msg, "Message identifier was bad!");
|
||||
break;
|
||||
|
||||
case MAPI_E_NO_MESSAGES:
|
||||
strcpy(msg, "No messages were found!");
|
||||
break;
|
||||
|
||||
case MAPI_E_ATTACHMENT_WRITE_FAILURE:
|
||||
strcpy(msg, "Attachment write failure!");
|
||||
break;
|
||||
|
||||
case MAPI_E_DISK_FULL:
|
||||
strcpy(msg, "Attachment write failure! DISK FULL");
|
||||
break;
|
||||
|
||||
case MAPI_E_AMBIGUOUS_RECIPIENT:
|
||||
strcpy(msg, "Recipient requested is not a unique address list entry.");
|
||||
break;
|
||||
|
||||
case MAPI_E_UNKNOWN_RECIPIENT:
|
||||
strcpy(msg, "Recipient requested does not exist.");
|
||||
break;
|
||||
|
||||
case MAPI_E_NOT_SUPPORTED:
|
||||
strcpy(msg, "Not supported by messaging system");
|
||||
break;
|
||||
|
||||
case SUCCESS_SUCCESS:
|
||||
strcpy(msg, "Success on MAPI operation");
|
||||
break;
|
||||
|
||||
case MAPI_E_INVALID_RECIPS:
|
||||
strcpy(msg, "Recipient specified in the lpRecip parameter was\nunknown. No dialog box was displayed.");
|
||||
break;
|
||||
|
||||
case MAPI_E_ATTACHMENT_OPEN_FAILURE:
|
||||
strcpy(msg, "One or more files could not be located. No message was sent.");
|
||||
break;
|
||||
|
||||
case MAPI_E_ATTACHMENT_NOT_FOUND:
|
||||
strcpy(msg, "The specified attachment was not found. No message was sent.");
|
||||
break;
|
||||
|
||||
case MAPI_E_BAD_RECIPTYPE:
|
||||
strcpy(msg, "The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC. No message was sent.");
|
||||
break;
|
||||
|
||||
default:
|
||||
strcpy(msg, "Unknown MAPI Return Code");
|
||||
break;
|
||||
}
|
||||
|
||||
return((LPSTR) &(msg[0]));
|
||||
}
|
||||
|
||||
void
|
||||
ShowMessage(HWND hWnd, LPSTR msg)
|
||||
{
|
||||
MessageBox(hWnd, msg, "Info Message", MB_ICONINFORMATION);
|
||||
}
|
||||
|
||||
BOOL
|
||||
OpenMAPI(void)
|
||||
{
|
||||
#ifdef WIN16
|
||||
m_hInstMapi = LoadLibrary("Y:\\ns\\cmd\\winfe\\mapi\\MAPI.DLL");
|
||||
#else
|
||||
m_hInstMapi = LoadLibrary(".\\COMPONENTS\\MAPI32.DLL");
|
||||
#endif
|
||||
|
||||
if (!m_hInstMapi)
|
||||
{
|
||||
ShowMessage(NULL, "Error Loading the MAPI DLL...Probably not found!");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
CloseMAPI(void)
|
||||
{
|
||||
if(m_hInstMapi)
|
||||
{
|
||||
FreeLibrary(m_hInstMapi);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ProcessCommand(HWND hWnd, int id, HWND hCtl, UINT codeNotify)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case ID_BUTTON_SYNC:
|
||||
DoMAPI_NSCP_Sync(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_NSCPVERSION:
|
||||
LoadNSCPVersionFunc(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_LOGON:
|
||||
DoMAPILogon(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_LOGOFF:
|
||||
DoMAPILogoff(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_FINDNEXT:
|
||||
case ID_MENU_MAPIFINDNEXT:
|
||||
DoMAPIFindNext(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_READMAIL:
|
||||
case ID_MENU_MAPIREADMAIL:
|
||||
DoMAPIReadMail(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_MAIL:
|
||||
{
|
||||
extern CALLBACK LOADDS
|
||||
MailDlgProc(HWND hWndMain, UINT wMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
DialogBox(hInst, MAKEINTRESOURCE(ID_DIALOG_MAIL), hWnd,
|
||||
(DLGPROC)MailDlgProc);
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_BUTTON_DELETEMAIL:
|
||||
case ID_MENU_MAPIDELETEMAIL:
|
||||
DoMAPIDeleteMail(hWnd);
|
||||
break;
|
||||
|
||||
case ID_MENU_MYEXIT:
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_CLEAR:
|
||||
case ID_MENU_CLEARRESULTS:
|
||||
ListBox_ResetContent(GetDlgItem(hWnd, ID_LIST_RESULT));
|
||||
break;
|
||||
|
||||
case ID_BUTTON_FREEBUFFER:
|
||||
DoMAPIResolveNameFreeBuffer(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_RESOLVENAME:
|
||||
DoMAPIResolveName(hWnd);
|
||||
break;
|
||||
|
||||
case ID_BUTTON_DETAILS:
|
||||
DoMAPIDetails(hWnd);
|
||||
break;
|
||||
|
||||
case ID_MENU_MYABOUT:
|
||||
MessageBox(hWnd,
|
||||
"Netscape MAPI Test Harness\nWritten by: Rich Pizzarro (rhp@netscape.com)",
|
||||
"About",
|
||||
MB_ICONINFORMATION);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPILogon(HWND hWnd)
|
||||
{
|
||||
char msg[1024];
|
||||
char user[128] = "";
|
||||
char pw[128] = "";
|
||||
|
||||
// Get Address of MAPI function...
|
||||
ULONG (FAR PASCAL *lpfnMAPILogon)(ULONG, LPSTR, LPSTR, FLAGS, ULONG, LPLHANDLE);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPILogon = GetProcAddress(m_hInstMapi, "MAPILOGON");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPILogon = GetProcAddress(m_hInstMapi, "MAPILogon");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPILogon)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
GetDlgItemText(hWnd, ID_EDIT_USERNAME, user, sizeof(user));
|
||||
GetDlgItemText(hWnd, ID_EDIT_PW, pw, sizeof(pw));
|
||||
|
||||
LONG rc = (*lpfnMAPILogon)((ULONG) hWnd, user, pw,
|
||||
MAPI_FORCE_DOWNLOAD | MAPI_NEW_SESSION, 0, &mapiSession);
|
||||
if (rc == SUCCESS_SUCCESS)
|
||||
{
|
||||
wsprintf(msg, "Success with session = %d", mapiSession);
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("Logon success");
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from Logon\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("Logon failed");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPILogoff(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPILogoff) ( LHANDLE lhSession, ULONG ulUIParam,
|
||||
FLAGS flFlags, ULONG ulReserved);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPILogoff = GetProcAddress(m_hInstMapi, "MAPILOGOFF");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPILogoff = GetProcAddress(m_hInstMapi, "MAPILogoff");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPILogoff)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
char msg[1024];
|
||||
LONG rc = (*lpfnMAPILogoff)(mapiSession, (ULONG) hWnd, 0, 0);
|
||||
if (rc == SUCCESS_SUCCESS)
|
||||
{
|
||||
wsprintf(msg, "Successful logoff");
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from Logoff\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("Logoff failed");
|
||||
}
|
||||
|
||||
mapiSession = 0;
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPIFreeBuffer(HWND hWnd, LPVOID buf, BOOL alert)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPIFreeBuffer) (LPVOID lpBuffer);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPIFreeBuffer = GetProcAddress(m_hInstMapi, "MAPIFREEBUFFER");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPIFreeBuffer = GetProcAddress(m_hInstMapi, "MAPIFreeBuffer");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPIFreeBuffer)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
char msg[1024];
|
||||
LONG rc = (*lpfnMAPIFreeBuffer)(buf);
|
||||
#ifdef WIN32
|
||||
if (rc == S_OK)
|
||||
#else
|
||||
if (rc == SUCCESS_SUCCESS)
|
||||
#endif
|
||||
{
|
||||
wsprintf(msg, "Successful Free Buffer Operation");
|
||||
if (alert)
|
||||
ShowMessage(hWnd, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from Logoff", rc);
|
||||
ShowMessage(hWnd, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPIFindNext(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPIFindNext) (LHANDLE lhSession, ULONG ulUIParam,
|
||||
LPTSTR lpszMessageType, LPTSTR lpszSeedMessageID, FLAGS flFlags,
|
||||
ULONG ulReserved, LPTSTR lpszMessageID);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPIFindNext = GetProcAddress(m_hInstMapi, "MAPIFINDNEXT");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPIFindNext = GetProcAddress(m_hInstMapi, "MAPIFindNext");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPIFindNext)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the list before we start...
|
||||
ListBox_ResetContent(GetDlgItem(hWnd, ID_LIST_RESULT));
|
||||
|
||||
char msg[1024];
|
||||
char messageID[512];
|
||||
LONG rc;
|
||||
#ifdef WIN32
|
||||
FLAGS flags = MAPI_GUARANTEE_FIFO | MAPI_LONG_MSGID | MAPI_UNREAD_ONLY;
|
||||
#else
|
||||
FLAGS flags = MAPI_GUARANTEE_FIFO | MAPI_UNREAD_ONLY;
|
||||
#endif
|
||||
|
||||
while ( (rc = (*lpfnMAPIFindNext) (mapiSession,
|
||||
(ULONG) hWnd,
|
||||
NULL,
|
||||
NULL,
|
||||
flags,
|
||||
0,
|
||||
messageID)) == SUCCESS_SUCCESS)
|
||||
{
|
||||
//
|
||||
|
||||
lpMapiMessage mapiMsg = GetMessage(hWnd, messageID);
|
||||
if (mapiMsg != NULL)
|
||||
{
|
||||
wsprintf(msg, "%s: \"%s\" Sender: %s",
|
||||
messageID,
|
||||
mapiMsg->lpszSubject,
|
||||
mapiMsg->lpOriginator->lpszName);
|
||||
DoMAPIFreeBuffer(hWnd, mapiMsg, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
lstrcpy(msg, messageID);
|
||||
}
|
||||
|
||||
ListBox_InsertString(GetDlgItem(hWnd, ID_LIST_RESULT), 0, msg);
|
||||
}
|
||||
|
||||
wsprintf(msg, "Enumeration ended: Return code %d from MAPIFindNext\nCondition=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("Enumeration ended");
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPIReadMail(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPIReadMail) (LHANDLE lhSession, ULONG ulUIParam,
|
||||
LPTSTR lpszMessageID, FLAGS flFlags, ULONG ulReserved,
|
||||
lpMapiMessage FAR * lppMessage);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPIReadMail = GetProcAddress(m_hInstMapi, "MAPIREADMAIL");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPIReadMail = GetProcAddress(m_hInstMapi, "MAPIReadMail");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPIReadMail)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
char msg[1024];
|
||||
char lpszMessageID[512];
|
||||
lpMapiMessage lpMessage = NULL;
|
||||
FLAGS flFlags = 0;
|
||||
|
||||
DWORD selected = ListBox_GetCurSel(GetDlgItem(hWnd, ID_LIST_RESULT));
|
||||
if (selected == LB_ERR)
|
||||
{
|
||||
ShowMessage(hWnd, "You need to select a valid message. Make sure\nyou have done a MAPIFindNext and selected\none of the resulting messages.");
|
||||
return;
|
||||
}
|
||||
|
||||
ListBox_GetText(GetDlgItem(hWnd, ID_LIST_RESULT), selected, lpszMessageID);
|
||||
|
||||
// Do the various flags for this call...
|
||||
if (BST_CHECKED == Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK_BODYASFILE)))
|
||||
{
|
||||
flFlags |= MAPI_BODY_AS_FILE;
|
||||
}
|
||||
|
||||
if (BST_CHECKED == Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK_ENVELOPEONLY)))
|
||||
{
|
||||
flFlags |= MAPI_ENVELOPE_ONLY;
|
||||
}
|
||||
|
||||
if (BST_CHECKED == Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK_PEEK)))
|
||||
{
|
||||
flFlags |= MAPI_PEEK;
|
||||
}
|
||||
|
||||
if (BST_CHECKED == Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK_SUPPRESSATTACH)))
|
||||
{
|
||||
flFlags |= MAPI_SUPPRESS_ATTACH;
|
||||
}
|
||||
|
||||
char *ptr = strchr( (const char *) lpszMessageID, ':');
|
||||
if (ptr) *ptr = '\0';
|
||||
|
||||
LONG rc = (*lpfnMAPIReadMail)
|
||||
(mapiSession,
|
||||
(ULONG) hWnd,
|
||||
lpszMessageID,
|
||||
flFlags,
|
||||
0,
|
||||
&lpMessage);
|
||||
|
||||
// Deal with error up front and return if need be...
|
||||
if (rc != SUCCESS_SUCCESS)
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from MAPIReadMail\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("ReadMail failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// Now display the message and then return...
|
||||
DisplayMAPIReadMail(hWnd, lpMessage);
|
||||
DoMAPIFreeBuffer(hWnd, lpMessage, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPIDeleteMail(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPIDeleteMail) (LHANDLE lhSession, ULONG ulUIParam,
|
||||
LPTSTR lpszMessageID, FLAGS flFlags, ULONG ulReserved);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPIDeleteMail = GetProcAddress(m_hInstMapi, "MAPIDELETEMAIL");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPIDeleteMail = GetProcAddress(m_hInstMapi, "MAPIDeleteMail");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPIDeleteMail)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
char msg[1024];
|
||||
char lpszMessageID[512];
|
||||
lpMapiMessage lpMessage = NULL;
|
||||
|
||||
DWORD selected = ListBox_GetCurSel(GetDlgItem(hWnd, ID_LIST_RESULT));
|
||||
if (selected == LB_ERR)
|
||||
{
|
||||
ShowMessage(hWnd, "You need to select a valid message. Make sure\nyou have done a MAPIFindNext and selected\none of the resulting messages.");
|
||||
return;
|
||||
}
|
||||
|
||||
ListBox_GetText(GetDlgItem(hWnd, ID_LIST_RESULT), selected, lpszMessageID);
|
||||
|
||||
char *ptr = strchr( (const char *) lpszMessageID, ':');
|
||||
if (ptr) *ptr = '\0';
|
||||
|
||||
LONG rc = (*lpfnMAPIDeleteMail)
|
||||
(mapiSession,
|
||||
(ULONG) hWnd,
|
||||
lpszMessageID,
|
||||
0,
|
||||
0);
|
||||
|
||||
// Deal with the return code...
|
||||
if (rc == SUCCESS_SUCCESS)
|
||||
{
|
||||
wsprintf(msg, "Successful deletion");
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter(msg);
|
||||
|
||||
// If it worked, refresh the list...
|
||||
ShowMessage(hWnd, "The message list will now be refreshed\nsince one message was deleted.");
|
||||
DoMAPIFindNext(hWnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from MAPIDeleteMail\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("Logoff failed");
|
||||
}
|
||||
}
|
||||
|
||||
// This is for the name lookup stuff...
|
||||
lpMapiRecipDesc lpRecip = NULL;
|
||||
|
||||
void
|
||||
DoMAPIResolveName(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPIResolveName) (LHANDLE lhSession, ULONG ulUIParam,
|
||||
LPTSTR lpszName, FLAGS flFlags, ULONG ulReserved,
|
||||
lpMapiRecipDesc FAR * lppRecip);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPIResolveName = GetProcAddress(m_hInstMapi, "MAPIRESOLVENAME");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPIResolveName = GetProcAddress(m_hInstMapi, "MAPIResolveName");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPIResolveName)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lpRecip != NULL)
|
||||
{
|
||||
ShowMessage(hWnd, "We need to free memory from a previous call...");
|
||||
DoMAPIFreeBuffer(hWnd, lpRecip, TRUE);
|
||||
lpRecip = NULL;
|
||||
}
|
||||
|
||||
char userName[512];
|
||||
char msg[1024];
|
||||
FLAGS flFlags = 0; // We support none...
|
||||
|
||||
GetDlgItemText(hWnd, IDC_EDIT_RESOLVENAME, userName, sizeof(userName));
|
||||
LONG rc = (*lpfnMAPIResolveName)
|
||||
(mapiSession,
|
||||
(ULONG) hWnd,
|
||||
userName,
|
||||
flFlags,
|
||||
0,
|
||||
&lpRecip);
|
||||
|
||||
// Deal with error up front and return if need be...
|
||||
if (rc != SUCCESS_SUCCESS)
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from DoMAPIResolveName\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("DoMAPIResolveName failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// If we get here, we should probably show the information that we
|
||||
// got back
|
||||
wsprintf(msg, "Received information for %s\nName=[%s]\nAddress=[%s]\nID=[%s]",
|
||||
userName, lpRecip->lpszName, lpRecip->lpszAddress, (LPSTR) lpRecip->lpEntryID);
|
||||
ShowMessage(hWnd, msg);
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPIResolveNameFreeBuffer(HWND hWnd)
|
||||
{
|
||||
if (lpRecip == NULL)
|
||||
{
|
||||
ShowMessage(hWnd, "There is no memory allocated from MAPIResolveName()\nto be freed. Request ignored.");
|
||||
}
|
||||
else
|
||||
{
|
||||
DoMAPIFreeBuffer(hWnd, lpRecip, TRUE);
|
||||
lpRecip = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPIDetails(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPIDetails) (LHANDLE lhSession, ULONG ulUIParam,
|
||||
lpMapiRecipDesc lpRecip, FLAGS flFlags, ULONG ulReserved);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPIDetails = GetProcAddress(m_hInstMapi, "MAPIDetails");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPIDetails = GetProcAddress(m_hInstMapi, "MAPIDetails");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPIDetails)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
char msg[1024];
|
||||
FLAGS flFlags = 0; // We really don't support these...
|
||||
|
||||
LONG rc = (*lpfnMAPIDetails)
|
||||
(mapiSession,
|
||||
(ULONG) hWnd,
|
||||
lpRecip,
|
||||
flFlags,
|
||||
0);
|
||||
|
||||
if (rc == SUCCESS_SUCCESS)
|
||||
{
|
||||
|
||||
wsprintf(msg, "MAPIDetails call succeeded");
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
wsprintf(msg, "FAILURE: Return code %d from MAPIDetails\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
|
||||
if (lpRecip == NULL)
|
||||
{
|
||||
lstrcat(msg, "\nNOTE: There is no valid pointer from a MAPIResolveName()\ncall to show details about.");
|
||||
}
|
||||
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("MAPIDetails failed");
|
||||
}
|
||||
}
|
||||
|
||||
lpMapiMessage
|
||||
GetMessage(HWND hWnd, LPSTR id)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnMAPIReadMail) (LHANDLE lhSession, ULONG ulUIParam,
|
||||
LPTSTR lpszMessageID, FLAGS flFlags, ULONG ulReserved,
|
||||
lpMapiMessage FAR * lppMessage);
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnMAPIReadMail = GetProcAddress(m_hInstMapi, "MAPIREADMAIL");
|
||||
#else
|
||||
(FARPROC&) lpfnMAPIReadMail = GetProcAddress(m_hInstMapi, "MAPIReadMail");
|
||||
#endif
|
||||
|
||||
if (!lpfnMAPIReadMail)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char msg[1024];
|
||||
lpMapiMessage lpMessage = NULL;
|
||||
FLAGS flFlags = 0;
|
||||
|
||||
flFlags |= MAPI_ENVELOPE_ONLY;
|
||||
LONG rc = (*lpfnMAPIReadMail)
|
||||
(mapiSession,
|
||||
(ULONG) hWnd,
|
||||
id,
|
||||
flFlags,
|
||||
0,
|
||||
&lpMessage);
|
||||
|
||||
// Deal with error up front and return if need be...
|
||||
if (rc != SUCCESS_SUCCESS)
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from MAPIReadMail\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("ReadMail failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return(lpMessage);
|
||||
}
|
||||
|
||||
void
|
||||
LoadNSCPVersionFunc(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnLoadNSCPVersion) ( void );
|
||||
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnLoadNSCPVersion = GetProcAddress(m_hInstMapi, "MAPIGETNERSCAPEVERSION");
|
||||
#else
|
||||
(FARPROC&) lpfnLoadNSCPVersion = GetProcAddress(m_hInstMapi, "MAPIGetNetscapeVersion");
|
||||
#endif
|
||||
|
||||
if (!lpfnLoadNSCPVersion)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPIGetNetscapeVersion() function.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage(hWnd, "MAPIGetNetscapeVersion() function was FOUND!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DoMAPI_NSCP_Sync(HWND hWnd)
|
||||
{
|
||||
ULONG (FAR PASCAL *lpfnNSCPSync) ( LHANDLE lhSession,
|
||||
ULONG ulReserved );
|
||||
#ifdef WIN16
|
||||
(FARPROC&) lpfnNSCPSync = GetProcAddress(m_hInstMapi, "MAPI_NSCP_SYNCHRONIZECLIENT");
|
||||
#else
|
||||
(FARPROC&) lpfnNSCPSync = GetProcAddress(m_hInstMapi, "MAPI_NSCP_SynchronizeClient");
|
||||
#endif
|
||||
|
||||
if (!lpfnNSCPSync)
|
||||
{
|
||||
ShowMessage(hWnd, "Unable to locate MAPI function.");
|
||||
return;
|
||||
}
|
||||
|
||||
LONG rc = (*lpfnNSCPSync) (mapiSession, 0);
|
||||
|
||||
char msg[256];
|
||||
|
||||
// Deal with error up front and return if need be...
|
||||
if (rc != SUCCESS_SUCCESS)
|
||||
{
|
||||
wsprintf(msg, "FAILURE: Return code %d from MAPI_NSCP_SynchronizeClient\nError=[%s]",
|
||||
rc, GetMAPIError(rc));
|
||||
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("MAPI_NSCP_SynchronizeClient failed");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(msg, "Success for MAPI_NSCP_SynchronizeClient");
|
||||
ShowMessage(hWnd, msg);
|
||||
SetFooter("MAPI_NSCP_SynchronizeClient success");
|
||||
}
|
||||
}
|
||||
25
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.dep
Normal file
25
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.dep
Normal file
@@ -0,0 +1,25 @@
|
||||
# Microsoft Developer Studio Generated Dependency File, included by mapitest.mak
|
||||
|
||||
.\main.cpp : \
|
||||
".\port.h"\
|
||||
"c:\program files\msdev\vc98\include\basetsd.h"\
|
||||
|
||||
|
||||
.\mapimail.cpp : \
|
||||
".\port.h"\
|
||||
"c:\program files\msdev\vc98\include\basetsd.h"\
|
||||
|
||||
|
||||
.\mapiproc.cpp : \
|
||||
".\port.h"\
|
||||
"c:\program files\msdev\vc98\include\basetsd.h"\
|
||||
|
||||
|
||||
.\mtest32.rc : \
|
||||
".\nscicon.ico"\
|
||||
|
||||
|
||||
.\readmail.cpp : \
|
||||
".\port.h"\
|
||||
"c:\program files\msdev\vc98\include\basetsd.h"\
|
||||
|
||||
121
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.dsp
Normal file
121
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.dsp
Normal file
@@ -0,0 +1,121 @@
|
||||
# Microsoft Developer Studio Project File - Name="mapitest" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=mapitest - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "mapitest.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "mapitest.mak" CFG="mapitest - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "mapitest - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "mapitest - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "mapitest - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "mapitest - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "mapitest - Win32 Release"
|
||||
# Name "mapitest - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\main.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mapimail.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mapiproc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mtest32.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readmail.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.dsw
Normal file
29
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "mapitest"=.\mapitest.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
BIN
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.ncb
Normal file
BIN
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.ncb
Normal file
Binary file not shown.
BIN
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.opt
Normal file
BIN
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.opt
Normal file
Binary file not shown.
44
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.plg
Normal file
44
mozilla/mailnews/mapi/old/tests/mapitest/mapitest.plg
Normal file
@@ -0,0 +1,44 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: mapitest - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating command line "rc.exe /l 0x409 /fo"Debug/mtest32.res" /d "_DEBUG" "Y:\mozilla\mailnews\mapi\tests\mapitest\mtest32.rc""
|
||||
Creating temporary file "C:\TEMP\RSP38A.tmp" with contents
|
||||
[
|
||||
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Debug/mapitest.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
|
||||
"Y:\mozilla\mailnews\mapi\tests\mapitest\readmail.cpp"
|
||||
"Y:\mozilla\mailnews\mapi\tests\mapitest\mapimail.cpp"
|
||||
"Y:\mozilla\mailnews\mapi\tests\mapitest\mapiproc.cpp"
|
||||
"Y:\mozilla\mailnews\mapi\tests\mapitest\main.cpp"
|
||||
]
|
||||
Creating command line "cl.exe @C:\TEMP\RSP38A.tmp"
|
||||
Creating temporary file "C:\TEMP\RSP38B.tmp" with contents
|
||||
[
|
||||
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/mapitest.pdb" /debug /machine:I386 /out:"Debug/mapitest.exe" /pdbtype:sept
|
||||
.\Debug\readmail.obj
|
||||
.\Debug\mapimail.obj
|
||||
.\Debug\mapiproc.obj
|
||||
.\Debug\mtest32.res
|
||||
.\Debug\main.obj
|
||||
]
|
||||
Creating command line "link.exe @C:\TEMP\RSP38B.tmp"
|
||||
<h3>Output Window</h3>
|
||||
Compiling resources...
|
||||
Compiling...
|
||||
readmail.cpp
|
||||
mapimail.cpp
|
||||
mapiproc.cpp
|
||||
main.cpp
|
||||
Linking...
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
mapitest.exe - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
245
mozilla/mailnews/mapi/old/tests/mapitest/mtest32.rc
Normal file
245
mozilla/mailnews/mapi/old/tests/mapitest/mtest32.rc
Normal file
@@ -0,0 +1,245 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
ID_DIALOG DIALOG DISCARDABLE 0, 0, 344, 229
|
||||
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Netscape MAPI Test Harness"
|
||||
MENU ID_MENU
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
GROUPBOX "Open/Close",IDC_STATIC,4,4,336,27
|
||||
LTEXT "User:",IDC_STATIC,9,17,18,11
|
||||
EDITTEXT ID_EDIT_USERNAME,28,15,41,12,ES_AUTOHSCROLL
|
||||
LTEXT "Password:",IDC_STATIC,74,17,38,11
|
||||
EDITTEXT ID_EDIT_PW,112,15,41,12,ES_PASSWORD | ES_AUTOHSCROLL
|
||||
PUSHBUTTON "MAPILogon",ID_BUTTON_LOGON,157,13,46,14
|
||||
PUSHBUTTON "MAPILogoff",ID_BUTTON_LOGOFF,209,13,46,14
|
||||
GROUPBOX "Mail Operations",IDC_STATIC,4,36,336,142
|
||||
PUSHBUTTON "MAPIFindNext",ID_BUTTON_FINDNEXT,17,50,57,14
|
||||
PUSHBUTTON "MAPIDeleteMail",ID_BUTTON_DELETEMAIL,80,50,57,14
|
||||
PUSHBUTTON "Clear Results",ID_BUTTON_CLEAR,143,50,57,14
|
||||
PUSHBUTTON "Send Mail",ID_BUTTON_MAIL,206,50,57,14
|
||||
LISTBOX ID_LIST_RESULT,9,66,325,56,LBS_SORT |
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL |
|
||||
WS_TABSTOP
|
||||
GROUPBOX "User Information",IDC_STATIC,4,181,336,28
|
||||
PUSHBUTTON "MAPIResolveName",ID_BUTTON_RESOLVENAME,9,192,68,14
|
||||
EDITTEXT IDC_EDIT_RESOLVENAME,82,192,130,14,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "MAPIDetails",ID_BUTTON_DETAILS,219,192,48,14
|
||||
LTEXT "",ID_STATIC_RESULT,4,214,336,13,SS_SUNKEN
|
||||
PUSHBUTTON "MAPIReadMail",ID_BUTTON_READMAIL,34,142,57,14
|
||||
CONTROL "MAPI_BODY_AS_FILE - Body as attachment",
|
||||
IDC_CHECK_BODYASFILE,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,121,125,188,9
|
||||
CONTROL "MAPI_ENVELOPE_ONLY - Header information only",
|
||||
IDC_CHECK_ENVELOPEONLY,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,121,138,188,9
|
||||
CONTROL "MAPI_PEEK - Don't mark message as read",IDC_CHECK_PEEK,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,121,151,188,9
|
||||
CONTROL "MAPI_SUPPRESS_ATTACH - Suppress attachments",
|
||||
IDC_CHECK_SUPPRESSATTACH,"Button",BS_AUTOCHECKBOX |
|
||||
WS_TABSTOP,121,164,188,9
|
||||
PUSHBUTTON "<- MAPIFreeBuffer",ID_BUTTON_FREEBUFFER,272,192,63,14
|
||||
PUSHBUTTON "MAPIGetNSCPVersion",ID_BUTTON_NSCPVERSION,261,13,76,14
|
||||
PUSHBUTTON "Synchronize",ID_BUTTON_SYNC,269,50,57,14
|
||||
END
|
||||
|
||||
ID_DIALOG_MAIL DIALOG DISCARDABLE 0, 0, 285, 246
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Composition"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
GROUPBOX "Address Information",IDC_STATIC,4,4,275,55
|
||||
LTEXT "To:",IDC_STATIC,21,19,12,8
|
||||
EDITTEXT ID_EDIT_TOADDRESS,36,16,239,13,ES_AUTOHSCROLL
|
||||
EDITTEXT ID_EDIT_CCADDRESS,36,30,239,13,ES_AUTOHSCROLL
|
||||
EDITTEXT ID_EDIT_BCCADDRESS,36,44,239,13,ES_AUTOHSCROLL
|
||||
LTEXT "Subject:",IDC_STATIC,5,65,29,9
|
||||
EDITTEXT ID_EDIT_SUBJECT,36,63,239,13,ES_AUTOHSCROLL
|
||||
EDITTEXT ID_EDIT_NOTETEXT,4,78,271,72,ES_MULTILINE |
|
||||
ES_AUTOHSCROLL
|
||||
GROUPBOX "Attachments",IDC_STATIC,4,153,275,39
|
||||
EDITTEXT ID_EDIT_ATTACH1,16,162,122,13,ES_AUTOHSCROLL
|
||||
EDITTEXT ID_EDIT_ATTACH2,16,176,122,13,ES_AUTOHSCROLL
|
||||
EDITTEXT ID_EDIT_ATTACH3,147,162,122,13,ES_AUTOHSCROLL
|
||||
EDITTEXT ID_EDIT_ATTACH4,147,175,122,13,ES_AUTOHSCROLL
|
||||
PUSHBUTTON "MAPISendMail",ID_BUTTON_MAPISENDMAIL,70,204,58,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,50,225,84,14
|
||||
PUSHBUTTON "MAPISendDocuments",ID_BUTTON_MAPISENDDOCUMENTS,132,204,
|
||||
79,14
|
||||
CONTROL "Show Dialog",ID_CHECK_SHOWDIALOG,"Button",
|
||||
BS_AUTOCHECKBOX | WS_TABSTOP,8,207,55,9
|
||||
LTEXT "cc:",IDC_STATIC,22,32,12,8
|
||||
LTEXT "bcc:",IDC_STATIC,18,47,15,8
|
||||
GROUPBOX "Send Operations",IDC_STATIC,4,196,275,26
|
||||
PUSHBUTTON "MAPISaveMail",ID_BUTTON_MAPISAVEMAIL,215,204,57,14
|
||||
PUSHBUTTON "MAPIAddress",ID_BUTTON_MAPIADDRESS,150,225,84,14
|
||||
END
|
||||
|
||||
ID_DIALOG_READMAIL DIALOG DISCARDABLE 0, 0, 269, 266
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Mail Message"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "Subject:",IDC_STATIC,5,71,27,9
|
||||
EDITTEXT IDC_EDIT_SUBJECT,36,69,229,12,ES_AUTOHSCROLL |
|
||||
ES_READONLY
|
||||
LISTBOX IDC_LIST_ATTACHMENTS,4,211,261,37,LBS_SORT |
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
EDITTEXT IDC_EDIT_BODYTEXT,4,113,261,85,ES_MULTILINE |
|
||||
ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY |
|
||||
ES_WANTRETURN
|
||||
LISTBOX IDC_LIST_RECIPIENTS,4,29,261,36,LBS_SORT |
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Recipients:",IDC_STATIC,4,19,43,9
|
||||
LTEXT "Attachments:",IDC_STATIC,4,202,43,9
|
||||
EDITTEXT IDC_EDIT_DATETIME,36,83,229,12,ES_AUTOHSCROLL |
|
||||
ES_READONLY
|
||||
LTEXT "Date:",IDC_STATIC,13,84,19,9
|
||||
PUSHBUTTON "OK",ID_OK,114,249,42,13
|
||||
EDITTEXT IDC_EDIT_THREAD,36,97,229,12,ES_AUTOHSCROLL |
|
||||
ES_READONLY
|
||||
LTEXT "Thread:",IDC_STATIC,6,99,25,9
|
||||
LTEXT "From:",IDC_STATIC,4,6,19,9
|
||||
EDITTEXT IDC_EDIT_FROM,27,4,238,12,ES_AUTOHSCROLL | ES_READONLY
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
ID_DIALOG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 4
|
||||
RIGHTMARGIN, 340
|
||||
VERTGUIDE, 9
|
||||
VERTGUIDE, 309
|
||||
TOPMARGIN, 4
|
||||
BOTTOMMARGIN, 227
|
||||
HORZGUIDE, 206
|
||||
END
|
||||
|
||||
ID_DIALOG_MAIL, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 4
|
||||
RIGHTMARGIN, 281
|
||||
TOPMARGIN, 4
|
||||
BOTTOMMARGIN, 239
|
||||
END
|
||||
|
||||
ID_DIALOG_READMAIL, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 4
|
||||
RIGHTMARGIN, 265
|
||||
TOPMARGIN, 4
|
||||
BOTTOMMARGIN, 262
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
ID_ICON_APP ICON DISCARDABLE "nscicon.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
ID_MENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "MAPI&FindNext", ID_MENU_MAPIFINDNEXT
|
||||
MENUITEM "MAPI&ReadMail", ID_MENU_MAPIREADMAIL
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_MENU_MYEXIT
|
||||
END
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "MAPI&DeleteMail", ID_MENU_MAPIDELETEMAIL
|
||||
MENUITEM "&Clear Results", ID_MENU_CLEARRESULTS
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About...", ID_MENU_MYABOUT
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
BIN
mozilla/mailnews/mapi/old/tests/mapitest/nscicon.ico
Normal file
BIN
mozilla/mailnews/mapi/old/tests/mapitest/nscicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 766 B |
303
mozilla/mailnews/mapi/old/tests/mapitest/port.h
Normal file
303
mozilla/mailnews/mapi/old/tests/mapitest/port.h
Normal file
@@ -0,0 +1,303 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
|
||||
#ifndef PORT_H
|
||||
#define PORT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*****************************************************************\
|
||||
* *
|
||||
* PORT.H *
|
||||
* *
|
||||
* Win16/Win32 portability stuff *
|
||||
* *
|
||||
* A.Sokolsky *
|
||||
* 3.10.94 distilled into this header *
|
||||
* *
|
||||
\*****************************************************************/
|
||||
|
||||
/*
|
||||
* calling conventions
|
||||
*/
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#ifndef CDECL
|
||||
#define CDECL __cdecl
|
||||
#endif // CDECL
|
||||
|
||||
#ifndef PASCAL
|
||||
#define PASCAL __pascal
|
||||
#endif // PASCAL
|
||||
|
||||
#ifdef FASTCALL
|
||||
#error FASTCALL defined
|
||||
#endif // FASTCALL
|
||||
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define FASTCALL __fastcall
|
||||
#else
|
||||
#define FASTCALL PASCAL
|
||||
#endif // NDEBUG
|
||||
|
||||
|
||||
|
||||
#ifndef HWND2DWORD
|
||||
# ifdef WIN32
|
||||
# define HWND2DWORD(X_hWnd) ( (DWORD)(X_hWnd) )
|
||||
# else // WIN16
|
||||
# define HWND2DWORD(X_hWnd) ( (DWORD)MAKELONG(((WORD)(X_hWnd)), 0) )
|
||||
# endif
|
||||
#endif // HWND2DWORD
|
||||
|
||||
|
||||
/*
|
||||
* WIN16 - WIN32 compatibility stuff
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
# define DLLEXPORT __declspec( dllexport )
|
||||
# define EXPORT
|
||||
# define LOADDS
|
||||
# define HUGE
|
||||
# ifndef FAR
|
||||
# define FAR
|
||||
# endif // FAR
|
||||
# ifndef NEAR
|
||||
# define NEAR
|
||||
# endif // NEAR
|
||||
# ifdef UNICODE
|
||||
# define SIZEOF(x) (sizeof(x)/sizeof(WCHAR))
|
||||
# else
|
||||
# define SIZEOF(x) sizeof(x)
|
||||
# endif
|
||||
|
||||
#else // !WIN32 == WIN16
|
||||
|
||||
# define DLLEXPORT
|
||||
# define EXPORT __export
|
||||
# define LOADDS __loadds
|
||||
# define HUGE __huge
|
||||
# ifndef FAR
|
||||
# define FAR __far
|
||||
# define NEAR __near
|
||||
# endif // FAR
|
||||
# define CONST const
|
||||
# define SIZEOF(x) sizeof(x)
|
||||
# define CHAR char
|
||||
# define TCHAR char
|
||||
# define WCHAR char
|
||||
# ifndef LPTSTR
|
||||
# define LPTSTR LPSTR
|
||||
# endif
|
||||
# ifndef LPCTSTR
|
||||
# define LPCTSTR LPCSTR
|
||||
# endif
|
||||
# define UNREFERENCED_PARAMETER(x) x;
|
||||
# ifndef TEXT
|
||||
# define TEXT(x) x
|
||||
# endif
|
||||
# define GetWindowTextW GetWindowText
|
||||
# define lstrcpyW lstrcpy
|
||||
|
||||
# define BN_DBLCLK BN_DOUBLECLICKED // ~~MRJ needed for custom control.
|
||||
// ~~MRJ begin Win95 backward compat section
|
||||
# define LPWSTR LPSTR
|
||||
# define LPCWSTR LPCSTR
|
||||
|
||||
// button check state for WIN16
|
||||
#ifndef BST_UNCHECKED
|
||||
#define BST_UNCHECKED 0x0000
|
||||
#endif
|
||||
|
||||
#ifndef BST_CHECKED
|
||||
#define BST_CHECKED 0x0001
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef WIN95_COMPAT
|
||||
# define WIN95_COMPAT
|
||||
#endif
|
||||
|
||||
// ~~MRJ end Win95 compat section.
|
||||
|
||||
// critical section API stubs
|
||||
typedef DWORD CRITICAL_SECTION;
|
||||
typedef CRITICAL_SECTION FAR * LPCRITICAL_SECTION;
|
||||
#ifdef __cplusplus
|
||||
inline void InitializeCriticalSection(LPCRITICAL_SECTION lpSection) {}
|
||||
inline void DeleteCriticalSection(LPCRITICAL_SECTION lpSection) {}
|
||||
inline void EnterCriticalSection(LPCRITICAL_SECTION lpSection) {}
|
||||
inline void LeaveCriticalSection(LPCRITICAL_SECTION lpSection) {}
|
||||
#endif // __cplusplus
|
||||
|
||||
// Added for nssock16 ---Neeti
|
||||
#ifndef ZeroMemory
|
||||
#include <memory.h>
|
||||
#define ZeroMemory(PTR, SIZE) memset(PTR, 0, SIZE)
|
||||
#endif // ZeroMemory
|
||||
|
||||
#endif // WIN16
|
||||
|
||||
/*
|
||||
* unix - windows compatibility stuff
|
||||
*/
|
||||
typedef DWORD u_int32;
|
||||
typedef WORD u_int16;
|
||||
typedef BYTE u_int8;
|
||||
#ifdef WIN32
|
||||
typedef short int Bool16;
|
||||
#else // WIN16
|
||||
typedef BOOL Bool16;
|
||||
#endif // WIN16
|
||||
|
||||
/*
|
||||
* Cross Platform Compatibility
|
||||
*/
|
||||
#ifndef UNALIGNED
|
||||
# ifdef _M_ALPHA
|
||||
# define UNALIGNED __unaligned
|
||||
# else // !_M_ALPHA
|
||||
# define UNALIGNED
|
||||
# endif // !_M_ALPHA
|
||||
#endif // UNALIGNED
|
||||
|
||||
//
|
||||
// RICHIE - for the Alpha port
|
||||
//
|
||||
#ifdef _M_ALPHA
|
||||
# undef pascal
|
||||
# undef PASCAL
|
||||
# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
|
||||
# define pascal __stdcall
|
||||
# define PASCAL __stdcall
|
||||
# else
|
||||
# define PASCAL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Useful Types
|
||||
*/
|
||||
typedef char HUGE *HPSTR;
|
||||
typedef const char HUGE *HPCSTR;
|
||||
typedef unsigned char HUGE *HPBYTE;
|
||||
typedef WORD HUGE *HPWORD;
|
||||
typedef UINT FAR *LPUINT;
|
||||
typedef BOOL (CALLBACK *USERABORTPROC)();
|
||||
typedef BOOL (CALLBACK *PROGRESSPROC)(UINT uPos, UINT uRange);
|
||||
typedef int INT; // ~~MRJ a function needed this defined.
|
||||
typedef MINMAXINFO FAR *LPMINMAXINFO; // ~~MRJ
|
||||
|
||||
//
|
||||
// stuff missing from windows.h
|
||||
//
|
||||
#ifndef MAKEWORD
|
||||
#define MAKEWORD(low, high) ((WORD)(((BYTE)(low)) | (((WORD)((BYTE)(high))) << 8)))
|
||||
#endif // MAKEWORD
|
||||
|
||||
#ifdef WIN32
|
||||
# ifndef hmemcpy
|
||||
# define hmemcpy memcpy
|
||||
# endif // !defined(hmemcpy)
|
||||
# define _fmemset memset
|
||||
|
||||
# include <malloc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
inline BOOL IsGDIObject(HGDIOBJ hObj) { return (hObj != 0); }
|
||||
inline void *_halloc(long num, unsigned int size) { return malloc(num * size); }
|
||||
inline void _hfree( void *memblock ) { free(memblock); }
|
||||
/*
|
||||
inline BOOL IsInstance(HINSTANCE hInst) {
|
||||
# ifdef WIN32
|
||||
return (hInst != 0);
|
||||
# else // WIN16
|
||||
return (hInst > HINSTANCE_ERROR);
|
||||
# endif
|
||||
}
|
||||
*/
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
WINUSERAPI HANDLE WINAPI LoadImageA(HINSTANCE, LPCSTR, UINT, int, int, UINT);
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline BOOL IsInstance(HINSTANCE hInst) {
|
||||
# ifdef WIN32
|
||||
return (hInst != 0);
|
||||
# else // WIN16
|
||||
return (hInst > HINSTANCE_ERROR);
|
||||
# endif
|
||||
}
|
||||
inline void SetWindowSmallIcon(HINSTANCE hInst, HWND hWnd, UINT uIconResourceId) {
|
||||
#ifdef WIN32
|
||||
# ifndef WM_SETICON
|
||||
# define WM_SETICON 0x0080
|
||||
# endif // WM_SETICON
|
||||
# ifndef IMAGE_ICON
|
||||
# define IMAGE_ICON 1
|
||||
# endif
|
||||
assert(IsWindow(hWnd));
|
||||
HICON hIcon = (HICON)LoadImageA(hInst, MAKEINTRESOURCE(uIconResourceId), IMAGE_ICON,
|
||||
16, 16, 0);
|
||||
if(NULL != hIcon) {
|
||||
SendMessage(hWnd, WM_SETICON, FALSE, (LPARAM)hIcon);
|
||||
} else {
|
||||
HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(uIconResourceId));
|
||||
assert(hIcon != 0);
|
||||
SendMessage(hWnd, WM_SETICON, FALSE, (LPARAM)hIcon);
|
||||
}
|
||||
#endif // WIN32
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* PORT_H */
|
||||
137
mozilla/mailnews/mapi/old/tests/mapitest/readmail.cpp
Normal file
137
mozilla/mailnews/mapi/old/tests/mapitest/readmail.cpp
Normal file
@@ -0,0 +1,137 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#ifndef MAPI_OLE // Because MSFT doesn't do this for us :-(
|
||||
#include <mapi.h>
|
||||
#endif
|
||||
|
||||
#include "port.h"
|
||||
#include "resource.h"
|
||||
|
||||
//
|
||||
// Variables...
|
||||
//
|
||||
extern HINSTANCE hInst;
|
||||
extern HINSTANCE m_hInstMapi;
|
||||
extern LHANDLE mapiSession;
|
||||
|
||||
//
|
||||
// Forward declarations...
|
||||
//
|
||||
extern void ShowMessage(HWND hWnd, LPSTR msg);
|
||||
extern void SetFooter(LPSTR msg);
|
||||
extern LPSTR GetMAPIError(LONG errorCode);
|
||||
lpMapiMessage mailPtr = NULL;
|
||||
|
||||
void
|
||||
ProcessReadMailCommand(HWND hWnd, int id, HWND hCtl, UINT codeNotify)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case ID_OK:
|
||||
case IDCANCEL:
|
||||
EndDialog(hWnd, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CALLBACK LOADDS
|
||||
ReadMailDlgProc(HWND hWndMail, UINT wMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (wMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
DWORD i;
|
||||
// Do everything we need to display the message pointed to by
|
||||
// mailPtr
|
||||
if (!mailPtr)
|
||||
break;
|
||||
|
||||
// Start with the basics...
|
||||
SetDlgItemText(hWndMail, IDC_EDIT_SUBJECT, mailPtr->lpszSubject);
|
||||
SetDlgItemText(hWndMail, IDC_EDIT_DATETIME, mailPtr->lpszDateReceived);
|
||||
SetDlgItemText(hWndMail, IDC_EDIT_THREAD, mailPtr->lpszConversationID);
|
||||
SetDlgItemText(hWndMail, IDC_EDIT_BODYTEXT, mailPtr->lpszNoteText);
|
||||
|
||||
char buf[1024];
|
||||
wsprintf(buf, "%s (%s)", mailPtr->lpOriginator->lpszName,
|
||||
mailPtr->lpOriginator->lpszAddress);
|
||||
SetDlgItemText(hWndMail, IDC_EDIT_FROM, buf);
|
||||
|
||||
for (i=0; i<mailPtr->nRecipCount; i++)
|
||||
{
|
||||
wsprintf(buf, "%s (%s)", mailPtr->lpRecips[i].lpszName,
|
||||
mailPtr->lpRecips[i].lpszAddress);
|
||||
ListBox_InsertString(GetDlgItem(hWndMail, IDC_LIST_RECIPIENTS),
|
||||
ListBox_GetCount(GetDlgItem(hWndMail, IDC_LIST_RECIPIENTS)),
|
||||
buf);
|
||||
}
|
||||
|
||||
for (i=0; i<mailPtr->nFileCount; i++)
|
||||
{
|
||||
ListBox_InsertString(GetDlgItem(hWndMail, IDC_LIST_ATTACHMENTS),
|
||||
ListBox_GetCount(GetDlgItem(hWndMail, IDC_LIST_ATTACHMENTS)),
|
||||
mailPtr->lpFiles[i].lpszPathName);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
HANDLE_WM_COMMAND(hWndMail, wParam, lParam, ProcessReadMailCommand);
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
DisplayMAPIReadMail(HWND hWnd, lpMapiMessage msgPtr)
|
||||
{
|
||||
mailPtr = msgPtr;
|
||||
DialogBox(hInst, MAKEINTRESOURCE(ID_DIALOG_READMAIL), hWnd,
|
||||
(DLGPROC)ReadMailDlgProc);
|
||||
}
|
||||
108
mozilla/mailnews/mapi/old/tests/mapitest/resource.h
Normal file
108
mozilla/mailnews/mapi/old/tests/mapitest/resource.h
Normal file
@@ -0,0 +1,108 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by mtest32.rc
|
||||
//
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#define ID_GUI_MESSAGE1 1
|
||||
#define ID_BUTTON_MAPIADDRESS 3
|
||||
#define ID_DIALOG 101
|
||||
#define ID_ICON_APP 102
|
||||
#define ID_MENU 104
|
||||
#define ID_DIALOG_MAIL 105
|
||||
#define ID_DIALOG_READMAIL 106
|
||||
#define ID_SETFROMEDIT 1000
|
||||
#define ID_SETTEXT 1001
|
||||
#define ID_GETROWS 1001
|
||||
#define ID_EDIT 1002
|
||||
#define ID_EDIT_HWND 1002
|
||||
#define ID_RESOURCETEXT 1003
|
||||
#define ID_GETTEXT 1003
|
||||
#define ID_STATIC_RESULT 1004
|
||||
#define ID_GETVISROWS 1005
|
||||
#define ID_GETWINID 1006
|
||||
#define ID_SETROWFOCUS 1007
|
||||
#define ID_GETROWFOCUS 1008
|
||||
#define ID_EDIT_ROW 1009
|
||||
#define ID_LIST_RESULT 1010
|
||||
#define ID_GETCOLCOUNT 1011
|
||||
#define ID_BUTTON_LOGON 1011
|
||||
#define ID_SETROWINVIEW 1012
|
||||
#define ID_BUTTON_LOGOFF 1012
|
||||
#define ID_GETNUMCHILDREN 1013
|
||||
#define ID_EDIT_USERNAME 1013
|
||||
#define ID_CLEARRESULTS 1014
|
||||
#define ID_EDIT_PW 1014
|
||||
#define ID_BUTTON_FINDNEXT 1015
|
||||
#define ID_BUTTON_CLEAR 1016
|
||||
#define ID_BUTTON_READMAIL 1017
|
||||
#define ID_BUTTON_DELETEMAIL 1018
|
||||
#define IDC_EDIT_RESOLVENAME 1019
|
||||
#define ID_BUTTON_MAPISENDMAIL 1020
|
||||
#define ID_BUTTON_NSCPVERSION 1020
|
||||
#define ID_BUTTON_RESOLVENAME 1021
|
||||
#define ID_BUTTON_MAPISENDDOCUMENTS 1021
|
||||
#define ID_EDIT_TOADDRESS 1022
|
||||
#define ID_EDIT_CCADDRESS 1023
|
||||
#define ID_BUTTON_DETAILS 1024
|
||||
#define ID_EDIT_BCCADDRESS 1024
|
||||
#define ID_EDIT_SUBJECT 1025
|
||||
#define ID_BUTTON_MAIL 1025
|
||||
#define ID_BUTTON_FREEBUFFER 1026
|
||||
#define ID_EDIT_NOTETEXT 1026
|
||||
#define ID_EDIT_ATTACH1 1027
|
||||
#define ID_BUTTON_SYNC 1027
|
||||
#define ID_EDIT_ATTACH2 1028
|
||||
#define IDC_CHECK_BODYASFILE 1028
|
||||
#define ID_EDIT_ATTACH3 1029
|
||||
#define IDC_CHECK_ENVELOPEONLY 1029
|
||||
#define IDC_LIST_ATTACHMENTS 1029
|
||||
#define ID_EDIT_ATTACH4 1030
|
||||
#define IDC_CHECK_PEEK 1030
|
||||
#define IDC_EDIT_BODYTEXT 1030
|
||||
#define IDC_CHECK_SUPPRESSATTACH 1031
|
||||
#define IDC_LIST_RECIPIENTS 1031
|
||||
#define ID_BUTTON_MAPISAVEMAIL 1031
|
||||
#define IDC_EDIT_SUBJECT 1032
|
||||
#define IDC_EDIT_DATETIME 1033
|
||||
#define ID_OK 1034
|
||||
#define IDC_EDIT_THREAD 1035
|
||||
#define ID_CHECK_SHOWDIALOG 1035
|
||||
#define IDC_EDIT_FROM 1036
|
||||
#define ID_MENU_MYEXIT 30001
|
||||
#define ID_MENU_CLEAR 30002
|
||||
#define ID_MENU_MYABOUT 30003
|
||||
#define ID_MENU_CLEARRESULTS 30004
|
||||
#define ID_MENU_MAPIDELETEMAIL 30005
|
||||
#define ID_MENU_MAPIFINDNEXT 30006
|
||||
#define ID_MENU_MAPIREADMAIL 30007
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 107
|
||||
#define _APS_NEXT_COMMAND_VALUE 30008
|
||||
#define _APS_NEXT_CONTROL_VALUE 1036
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
117
mozilla/mailnews/mapi/resources/content/contents.rdf
Normal file
117
mozilla/mailnews/mapi/resources/content/contents.rdf
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- If you modify this file, please also update the following files -->
|
||||
<!-- mailnews/mapi/resources/content/contents.rdf in the ns tree -->
|
||||
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
|
||||
|
||||
<!-- list all the packages being supplied by this jar -->
|
||||
<RDF:Seq about="urn:mozilla:package:root">
|
||||
<RDF:li resource="urn:mozilla:package:messenger"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- package information -->
|
||||
<RDF:Description about="urn:mozilla:package:messenger"
|
||||
chrome:displayName="Messenger"
|
||||
chrome:author="mozilla.org"
|
||||
chrome:name="messenger"
|
||||
chrome:localeVersion="0.9.4"
|
||||
chrome:skinVersion="0.9.4">
|
||||
</RDF:Description>
|
||||
|
||||
<!-- overlay information -->
|
||||
<RDF:Seq about="urn:mozilla:overlays">
|
||||
<RDF:li resource="chrome://communicator/content/pref/preftree.xul"/>
|
||||
<RDF:li resource="chrome://communicator/content/pref/pref-appearance.xul"/>
|
||||
<RDF:li resource="chrome://communicator/content/pref/pref-advanced.xul"/>
|
||||
<RDF:li resource="chrome://communicator/content/tasksOverlay.xul"/>
|
||||
<RDF:li resource="chrome://navigator/content/navigatorOverlay.xul"/>
|
||||
<RDF:li resource="chrome://communicator/content/history/history.xul"/>
|
||||
<RDF:li resource="chrome://communicator/content/bookmarks/bookmarks.xul"/>
|
||||
<RDF:li resource="chrome://communicator/content/bookmarks/bm-find.xul"/>
|
||||
<RDF:li resource="chrome://messenger/content/messenger.xul"/>
|
||||
<RDF:li resource="chrome://messenger/content/mail3PaneWindowVertLayout.xul"/>
|
||||
<RDF:li resource="chrome://messenger/content/messengercompose/messengercompose.xul"/>
|
||||
<RDF:li resource="chrome://messenger/content/addressbook/addressbook.xul"/>
|
||||
<RDF:li resource="chrome://messenger/content/addressbook/abSelectAddressesDialog.xul"/>
|
||||
<RDF:li resource="chrome://editor/content/editor.xul"/>
|
||||
<RDF:li resource="chrome://messenger/content/pref-mailnews.xul"/>
|
||||
</RDF:Seq>
|
||||
|
||||
|
||||
<!-- messenger preferences branches -->
|
||||
<RDF:Seq about="chrome://communicator/content/pref/preftree.xul">
|
||||
<RDF:li>chrome://messenger/content/mailPrefsOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger startup pref -->
|
||||
<RDF:Seq about="chrome://communicator/content/pref/pref-appearance.xul">
|
||||
<RDF:li>chrome://messenger/content/mailPrefsOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger js toggle pref -->
|
||||
<RDF:Seq about="chrome://communicator/content/pref/pref-advanced.xul">
|
||||
<RDF:li>chrome://messenger/content/mailPrefsOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger taskbar/tasks menu items -->
|
||||
<RDF:Seq about="chrome://communicator/content/tasksOverlay.xul">
|
||||
<RDF:li>chrome://messenger/content/mailTasksOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger items for History -->
|
||||
<RDF:Seq about="chrome://communicator/content/history/history.xul">
|
||||
<RDF:li>chrome://messenger/content/mailNavigatorOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger items for Bookmarks -->
|
||||
<RDF:Seq about="chrome://communicator/content/bookmarks/bookmarks.xul">
|
||||
<RDF:li>chrome://messenger/content/mailNavigatorOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger items for History -->
|
||||
<RDF:Seq about="chrome://communicator/content/bookmarks/bm-find.xul">
|
||||
<RDF:li>chrome://messenger/content/mailNavigatorOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger items for Navigator -->
|
||||
<RDF:Seq about="chrome://navigator/content/navigatorOverlay.xul">
|
||||
<RDF:li>chrome://messenger/content/mailNavigatorOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger items for Messenger -->
|
||||
<RDF:Seq about="chrome://messenger/content/messenger.xul">
|
||||
<RDF:li>chrome://messenger/content/mailMessengerOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
<RDF:Seq about="chrome://messenger/content/mail3PaneWindowVertLayout.xul">
|
||||
<RDF:li>chrome://messenger/content/mailMessengerOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger items for Mail Compose -->
|
||||
<RDF:Seq about="chrome://messenger/content/messengercompose/messengercompose.xul">
|
||||
<RDF:li>chrome://messenger/content/mailMessengerComposeOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger items for Addressbook -->
|
||||
<RDF:Seq about="chrome://messenger/content/addressbook/addressbook.xul">
|
||||
<RDF:li>chrome://messenger/content/mailABOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger items for Select Addresses dialog -->
|
||||
<RDF:Seq about="chrome://messenger/content/addressbook/abSelectAddressesDialog.xul">
|
||||
<RDF:li>chrome://messenger/content/mailOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
|
||||
<!-- messenger items for Composer -->
|
||||
<RDF:Seq about="chrome://editor/content/editor.xul">
|
||||
<RDF:li>chrome://messenger/content/mailEditorOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- mapi items for Mail And Newsgroups preferences pane -->
|
||||
<RDF:Seq about="chrome://messenger/content/pref-mailnews.xul">
|
||||
<RDF:li>chrome://messenger/content/pref-mailnewsOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
</RDF:RDF>
|
||||
4
mozilla/mailnews/mapi/resources/content/jar.mn
Normal file
4
mozilla/mailnews/mapi/resources/content/jar.mn
Normal file
@@ -0,0 +1,4 @@
|
||||
messenger.jar:
|
||||
content/messenger/pref-mailnewsOverlay.xul
|
||||
+ content/messenger/contents.rdf
|
||||
content/messenger/pref-mailnewsOverlay.js
|
||||
26
mozilla/mailnews/mapi/resources/content/makefile.win
Normal file
26
mozilla/mailnews/mapi/resources/content/makefile.win
Normal file
@@ -0,0 +1,26 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Srilatha Moturi <srilatha@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
14
mozilla/mailnews/mapi/resources/content/overlays.rdf
Normal file
14
mozilla/mailnews/mapi/resources/content/overlays.rdf
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<RDF:RDF xmlns:chrome="http://www.mozilla.org/rdf/chrome#"
|
||||
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
|
||||
<!-- mapi items for mailnews preferences -->
|
||||
<RDF:Seq about="urn:mozilla:overlays">
|
||||
<RDF:li resource="chrome://messenger/content/pref-mailnews.xul"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<RDF:Seq about="chrome://messenger/content/pref-mailnews.xul">
|
||||
<RDF:li>chrome://messenger/content/pref-mailnewsOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
</RDF:RDF>
|
||||
104
mozilla/mailnews/mapi/resources/content/pref-mailnewsOverlay.js
Normal file
104
mozilla/mailnews/mapi/resources/content/pref-mailnewsOverlay.js
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Srilatha Moturi <srilatha@netscape.com>
|
||||
*/
|
||||
|
||||
function mailnewsOverlayStartup() {
|
||||
mailnewsOverlayInit();
|
||||
parent.hPrefWindow.registerOKCallbackFunc(onOK);
|
||||
if (!("mapiPref" in parent)) {
|
||||
parent.mapiPref = new Object;
|
||||
parent.mapiPref.isDefaultMailClient =
|
||||
document.getElementById("mailnewsEnableMapi").checked;
|
||||
}
|
||||
else {
|
||||
// when we switch between different panes
|
||||
// set the checkbox based on the saved state
|
||||
var mailnewsEnableMapi = document.getElementById("mailnewsEnableMapi");
|
||||
if (parent.mapiPref.isDefaultMailClient)
|
||||
mailnewsEnableMapi.setAttribute("checked", "true");
|
||||
else
|
||||
mailnewsEnableMapi.setAttribute("checked", "false");
|
||||
}
|
||||
}
|
||||
|
||||
function mailnewsOverlayInit() {
|
||||
try {
|
||||
var mapiRegistry = Components.classes[ "@mozilla.org/mapiregistry;1" ].
|
||||
getService( Components.interfaces.nsIMapiRegistry );
|
||||
}
|
||||
catch(ex){
|
||||
mapiRegistry = null;
|
||||
}
|
||||
|
||||
const prefbase = "system.windows.lock_ui.";
|
||||
var mailnewsEnableMapi = document.getElementById("mailnewsEnableMapi");
|
||||
if (mapiRegistry) {
|
||||
// initialise preference component.
|
||||
// While the data is coming from the system registry, we use a set
|
||||
// of parallel preferences to indicate if the ui should be locked.
|
||||
try {
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService()
|
||||
.QueryInterface(Components.interfaces.nsIPrefService);
|
||||
var prefBranch = prefService.getBranch(prefbase);
|
||||
if (prefBranch && prefBranch.prefIsLocked("default_mail_client")) {
|
||||
if (prefBranch.getBoolPref("default_mail_client"))
|
||||
mapiRegistry.setDefaultMailClient();
|
||||
else
|
||||
mapiRegistry.unsetDefaultMailClient();
|
||||
mailnewsEnableMapi.setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
catch(ex) {}
|
||||
if (mapiRegistry.isDefaultMailClient)
|
||||
mailnewsEnableMapi.setAttribute("checked", "true");
|
||||
else
|
||||
mailnewsEnableMapi.setAttribute("checked", "false");
|
||||
}
|
||||
else
|
||||
mailnewsEnableMapi.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
function onEnableMapi() {
|
||||
// save the state of the checkbox
|
||||
if ("mapiPref" in parent)
|
||||
parent.mapiPref.isDefaultMailClient =
|
||||
document.getElementById("mailnewsEnableMapi").checked;
|
||||
}
|
||||
|
||||
function onOK()
|
||||
{
|
||||
try {
|
||||
var mapiRegistry = Components.classes[ "@mozilla.org/mapiregistry;1" ].
|
||||
getService( Components.interfaces.nsIMapiRegistry );
|
||||
}
|
||||
catch(ex){
|
||||
mapiRegistry = null;
|
||||
}
|
||||
if (mapiRegistry &&
|
||||
("mapiPref" in parent) &&
|
||||
(mapiRegistry.isDefaultMailClient != parent.mapiPref.isDefaultMailClient)) {
|
||||
if (parent.mapiPref.isDefaultMailClient)
|
||||
mapiRegistry.setDefaultMailClient();
|
||||
else
|
||||
mapiRegistry.unsetDefaultMailClient();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
The contents of this file are subject to the Mozilla Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/MPL/
|
||||
|
||||
oftware distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is mozilla.org code.
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Srilatha Moturi <srilatha@netscape.com>
|
||||
-->
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
|
||||
%brandDTD;
|
||||
<!ENTITY % prefMailnewsOverlayDTD SYSTEM "chrome://messenger/locale/pref-mailnewsOverlay.dtd" >
|
||||
%prefMailnewsOverlayDTD;
|
||||
]>
|
||||
<overlay id="prefMailnewsOverlay"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
_elementIDs.push("mailnewsEnableMapi");
|
||||
]]>
|
||||
</script>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/pref-mailnewsOverlay.js"/>
|
||||
<hbox autostretch="never" id="mapi">
|
||||
<checkbox id="mailnewsEnableMapi" label="&enableMapi.label;"
|
||||
accesskey="&enableMapi.accesskey;"
|
||||
oncommand="onEnableMapi();"
|
||||
startFunc="mailnewsOverlayStartup();"/>
|
||||
</hbox>
|
||||
</overlay>
|
||||
3
mozilla/mailnews/mapi/resources/locale/en-US/jar.mn
Normal file
3
mozilla/mailnews/mapi/resources/locale/en-US/jar.mn
Normal file
@@ -0,0 +1,3 @@
|
||||
en-US.jar:
|
||||
locale/en-US/messenger/pref-mailnewsOverlay.dtd
|
||||
locale/en-US/messenger/mapi.properties
|
||||
26
mozilla/mailnews/mapi/resources/locale/en-US/makefile.win
Normal file
26
mozilla/mailnews/mapi/resources/locale/en-US/makefile.win
Normal file
@@ -0,0 +1,26 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Srilatha Moturi <srilatha@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..\..
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
18
mozilla/mailnews/mapi/resources/locale/en-US/mapi.properties
Normal file
18
mozilla/mailnews/mapi/resources/locale/en-US/mapi.properties
Normal file
@@ -0,0 +1,18 @@
|
||||
# Mail Integration Dialog
|
||||
dialogTitle=%S Mail
|
||||
dialogText=Do you want to use %S as the default mail application?
|
||||
checkboxText=Do not display this dialog again
|
||||
|
||||
# MAPI Messages
|
||||
loginText=Please enter your password for %S:
|
||||
loginTextwithName=Please enter your username and password
|
||||
loginTitle=%S Mail
|
||||
PasswordTitle=%S Mail
|
||||
|
||||
# MAPI Error Messages
|
||||
errorMessage=%S Mail could not be set as the default mail application because a registry key could not be updated. Verify with your system administrator that you have write access to your system registry, and then try again.
|
||||
errorMessageTitle=%S Mail
|
||||
|
||||
# MAPI Security Messages
|
||||
mapiBlindSendWarning=Another application is attempting to send mail using your user profile. Are you sure you want to send mail?
|
||||
mapiBlindSendDontShowAgain=Warn me whenever other applications try to send mail from me
|
||||
@@ -0,0 +1,3 @@
|
||||
<!ENTITY enableMapiTitle.label "When sending mail from other applications">
|
||||
<!ENTITY enableMapi.label "Use &vendorShortName; Mail as the default mail application.">
|
||||
<!ENTITY enableMapi.accesskey "u">
|
||||
28
mozilla/mailnews/mapi/resources/locale/makefile.win
Normal file
28
mozilla/mailnews/mapi/resources/locale/makefile.win
Normal file
@@ -0,0 +1,28 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Srilatha Moturi <srilatha@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
DIRS=en-US
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
27
mozilla/mailnews/mapi/resources/makefile.win
Normal file
27
mozilla/mailnews/mapi/resources/makefile.win
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Srilatha Moturi <srilatha@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS=content locale
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -1,152 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape security libraries.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1994-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Dr Vipul Gupta <vipul.gupta@sun.com> and
|
||||
# Douglas Stebila <douglas@stebila.ca>, Sun Microsystems
|
||||
# Laboratories
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
CORE_DEPTH = ../../..
|
||||
|
||||
MODULE = nss
|
||||
|
||||
ifndef FREEBL_RECURSIVE_BUILD
|
||||
LIBRARY_NAME = freebl
|
||||
else
|
||||
ifdef USE_PURE_32
|
||||
CORE_DEPTH = ../../../..
|
||||
LIBRARY_NAME = freebl_pure32
|
||||
else
|
||||
LIBRARY_NAME = freebl_hybrid
|
||||
endif
|
||||
endif
|
||||
|
||||
# same version as rest of freebl
|
||||
LIBRARY_VERSION = _3
|
||||
|
||||
DEFINES += -DSHLIB_SUFFIX=\"$(DLL_SUFFIX)\" -DSHLIB_PREFIX=\"$(DLL_PREFIX)\"
|
||||
|
||||
REQUIRES =
|
||||
|
||||
EXPORTS = \
|
||||
blapit.h \
|
||||
shsign.h \
|
||||
ecl-exp.h \
|
||||
$(NULL)
|
||||
|
||||
PRIVATE_EXPORTS = \
|
||||
blapi.h \
|
||||
secmpi.h \
|
||||
secrng.h \
|
||||
ec.h \
|
||||
ecl.h \
|
||||
ecl-curve.h \
|
||||
$(NULL)
|
||||
|
||||
MPI_HDRS = mpi-config.h mpi.h mpi-priv.h mplogic.h mpprime.h logtab.h mp_gf2m.h
|
||||
MPI_SRCS = mpprime.c mpmontg.c mplogic.c mpi.c mp_gf2m.c mpcpucache.c
|
||||
ECL_HDRS = ecl-exp.h ecl.h ec2.h ecp.h ecl-priv.h
|
||||
ifdef NSS_ENABLE_ECC
|
||||
ECL_SRCS = ecl.c ecl_curve.c ecl_mult.c ecl_gf.c \
|
||||
ec2_aff.c ec2_mont.c ec2_proj.c \
|
||||
ec2_163.c ec2_193.c ec2_233.c \
|
||||
ecp_aff.c ecp_jac.c ecp_mont.c \
|
||||
ecp_192.c ecp_224.c \
|
||||
ec_naf.c ecp_jm.c
|
||||
else
|
||||
ECL_SRCS = $(NULL)
|
||||
endif
|
||||
|
||||
CSRCS = \
|
||||
ldvector.c \
|
||||
prng_fips1861.c \
|
||||
sysrand.c \
|
||||
sha_fast.c \
|
||||
md2.c \
|
||||
md5.c \
|
||||
sha512.c \
|
||||
alg2268.c \
|
||||
arcfour.c \
|
||||
arcfive.c \
|
||||
desblapi.c \
|
||||
des.c \
|
||||
rijndael.c \
|
||||
aeskeywrap.c \
|
||||
dh.c \
|
||||
ec.c \
|
||||
pqg.c \
|
||||
dsa.c \
|
||||
rsa.c \
|
||||
shvfy.c \
|
||||
$(MPI_SRCS) \
|
||||
$(ECL_SRCS) \
|
||||
$(NULL)
|
||||
|
||||
ALL_CSRCS := $(CSRCS)
|
||||
|
||||
ALL_HDRS = \
|
||||
blapi.h \
|
||||
blapit.h \
|
||||
des.h \
|
||||
ec.h \
|
||||
loader.h \
|
||||
rijndael.h \
|
||||
secmpi.h \
|
||||
sha.h \
|
||||
sha_fast.h \
|
||||
shsign.h \
|
||||
vis_proto.h \
|
||||
$(NULL)
|
||||
|
||||
ifdef NSS_ENABLE_ECC
|
||||
DEFINES += -DNSS_ENABLE_ECC
|
||||
endif
|
||||
|
||||
ifdef AES_GEN_TBL
|
||||
DEFINES += -DRIJNDAEL_GENERATE_TABLES
|
||||
else
|
||||
ifdef AES_GEN_TBL_M
|
||||
DEFINES += -DRIJNDAEL_GENERATE_TABLES_MACRO
|
||||
else
|
||||
ifdef AES_GEN_VAL
|
||||
DEFINES += -DRIJNDAEL_GENERATE_VALUES
|
||||
else
|
||||
ifdef AES_GEN_VAL_M
|
||||
DEFINES += -DRIJNDAEL_GENERATE_VALUES_MACRO
|
||||
else
|
||||
DEFINES += -DRIJNDAEL_INCLUDE_TABLES
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@@ -1,278 +0,0 @@
|
||||
#
|
||||
# Makefile for MPI library
|
||||
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Michael J. Fromberger <sting@linguist.dartmouth.edu>.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Netscape Communications Corporation
|
||||
# Richard C. Swift (swift@netscape.com)
|
||||
# Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
#
|
||||
# $Id: Makefile,v 1.21 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
#
|
||||
|
||||
## Define CC to be the C compiler you wish to use. The GNU cc
|
||||
## compiler (gcc) should work, at the very least
|
||||
#CC=cc
|
||||
#CC=gcc
|
||||
|
||||
##
|
||||
## Define PERL to point to your local Perl interpreter. It
|
||||
## should be Perl 5.x, although it's conceivable that Perl 4
|
||||
## might work ... I haven't tested it.
|
||||
##
|
||||
#PERL=/usr/bin/perl
|
||||
PERL=perl
|
||||
|
||||
include target.mk
|
||||
|
||||
CFLAGS+= $(XCFLAGS)
|
||||
|
||||
##
|
||||
## Define LIBS to include any libraries you need to link against.
|
||||
## If NO_TABLE is define, LIBS should include '-lm' or whatever is
|
||||
## necessary to bring in the math library. Otherwise, it can be
|
||||
## left alone, unless your system has other peculiar requirements.
|
||||
##
|
||||
LIBS=#-lmalloc#-lefence#-lm
|
||||
|
||||
##
|
||||
## Define RANLIB to be the library header randomizer; you might not
|
||||
## need this on some systems (just set it to 'echo' on these systems,
|
||||
## such as IRIX)
|
||||
##
|
||||
RANLIB=echo
|
||||
|
||||
##
|
||||
## This is the version string used for the documentation and
|
||||
## building the distribution tarball. Don't mess with it unless
|
||||
## you are releasing a new version
|
||||
VERS=1.7p6
|
||||
|
||||
## ----------------------------------------------------------------------
|
||||
## You probably don't need to change anything below this line...
|
||||
##
|
||||
|
||||
##
|
||||
## This is the list of source files that need to be packed into
|
||||
## the distribution file
|
||||
SRCS= mpi.c mpprime.c mplogic.c mp_gf2m.c mpmontg.c mpi-test.c primes.c tests/ \
|
||||
utils/gcd.c utils/invmod.c utils/lap.c \
|
||||
utils/ptab.pl utils/sieve.c utils/isprime.c\
|
||||
utils/dec2hex.c utils/hex2dec.c utils/bbs_rand.c \
|
||||
utils/bbsrand.c utils/prng.c utils/primegen.c \
|
||||
utils/basecvt.c utils/makeprime.c\
|
||||
utils/fact.c utils/exptmod.c utils/pi.c utils/metime.c \
|
||||
utils/mpi.h utils/mpprime.h mulsqr.c \
|
||||
make-test-arrays test-arrays.txt all-tests make-logtab \
|
||||
types.pl stats timetest multest
|
||||
|
||||
## These are the header files that go into the distribution file
|
||||
HDRS=mpi.h mpi-config.h utils/mpi.h utils/mpi-config.h mpprime.h mplogic.h mp_gf2m.h \
|
||||
mp_gf2m-priv.h utils/bbs_rand.h tests/mpi.h tests/mpprime.h
|
||||
|
||||
## These are the documentation files that go into the distribution file
|
||||
DOCS=README doc utils/README utils/PRIMES
|
||||
|
||||
## This is the list of tools built by 'make tools'
|
||||
TOOLS=gcd invmod isprime lap dec2hex hex2dec primegen prng \
|
||||
basecvt fact exptmod pi makeprime identest
|
||||
|
||||
LIBOBJS = mpprime.o mpmontg.o mplogic.o mp_gf2m.o mpi.o $(AS_OBJS)
|
||||
LIBHDRS = mpi-config.h mpi-priv.h mpi.h
|
||||
APPHDRS = mpi-config.h mpi.h mplogic.h mp_gf2m.h mpprime.h
|
||||
|
||||
help:
|
||||
@ echo ""
|
||||
@ echo "The following targets can be built with this Makefile:"
|
||||
@ echo ""
|
||||
@ echo "libmpi.a - arithmetic and prime testing library"
|
||||
@ echo "mpi-test - test driver (requires MP_IOFUNC)"
|
||||
@ echo "tools - command line tools"
|
||||
@ echo "doc - manual pages for tools"
|
||||
@ echo "clean - clean up objects and such"
|
||||
@ echo "distclean - get ready for distribution"
|
||||
@ echo "dist - distribution tarball"
|
||||
@ echo ""
|
||||
|
||||
.SUFFIXES: .c .o .i
|
||||
|
||||
.c.i:
|
||||
$(CC) $(CFLAGS) -E $< > $@
|
||||
|
||||
#.c.o: $*.h $*.c
|
||||
# $(CC) $(CFLAGS) -c $<
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
$(LIBOBJS): $(LIBHDRS)
|
||||
|
||||
logtab.h: make-logtab
|
||||
$(PERL) make-logtab > logtab.h
|
||||
|
||||
mpi.o: mpi.c logtab.h $(LIBHDRS)
|
||||
|
||||
mplogic.o: mplogic.c mpi-priv.h mplogic.h $(LIBHDRS)
|
||||
|
||||
mp_gf2m.o: mp_gf2m.c mpi-priv.h mp_gf2m.h mp_gf2m-priv.h $(LIBHDRS)
|
||||
|
||||
mpmontg.o: mpmontg.c mpi-priv.h mplogic.h mpprime.h $(LIBHDRS)
|
||||
|
||||
mpprime.o: mpprime.c mpi-priv.h mpprime.h mplogic.h primes.c $(LIBHDRS)
|
||||
|
||||
mpi_mips.o: mpi_mips.s
|
||||
$(CC) -o $@ $(ASFLAGS) -c mpi_mips.s
|
||||
|
||||
mpi_sparc.o : montmulf.h
|
||||
|
||||
mpv_sparcv9.s: vis_64.il mpv_sparc.c
|
||||
$(CC) -o $@ $(SOLARIS_FPU_FLAGS) -S vis_64.il mpv_sparc.c
|
||||
|
||||
mpv_sparcv8.s: vis_64.il mpv_sparc.c
|
||||
$(CC) -o $@ $(SOLARIS_FPU_FLAGS) -S vis_32.il mpv_sparc.c
|
||||
|
||||
montmulfv8.o montmulfv9.o mpv_sparcv8.o mpv_sparcv9.o : %.o : %.s
|
||||
$(CC) -o $@ $(SOLARIS_ASM_FLAGS) -c $<
|
||||
|
||||
# This rule is used to build the .s sources, which are then hand optimized.
|
||||
#montmulfv8.s montmulfv9.s : montmulf%.s : montmulf%.il montmulf.c montmulf.h
|
||||
# $(CC) -o $@ $(SOLARIS_ASM_FLAGS) -S montmulf$*.il montmulf.c
|
||||
|
||||
|
||||
libmpi.a: $(LIBOBJS)
|
||||
ar -cvr libmpi.a $(LIBOBJS)
|
||||
$(RANLIB) libmpi.a
|
||||
|
||||
lib libs: libmpi.a
|
||||
|
||||
mpi.i: mpi.h
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
MPTESTOBJS = mptest1.o mptest2.o mptest3.o mptest3a.o mptest4.o mptest4a.o \
|
||||
mptest4b.o mptest6.o mptest7.o mptest8.o mptest9.o mptestb.o
|
||||
MPTESTS = $(MPTESTOBJS:.o=)
|
||||
|
||||
$(MPTESTOBJS): mptest%.o: tests/mptest-%.c $(LIBHDRS)
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
$(MPTESTS): mptest%: mptest%.o libmpi.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
tests: mptest1 mptest2 mptest3 mptest3a mptest4 mptest4a mptest4b mptest6 \
|
||||
mptestb bbsrand
|
||||
|
||||
utests: mptest7 mptest8 mptest9
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
EXTRAOBJS = bbsrand.o bbs_rand.o prng.o
|
||||
UTILOBJS = primegen.o metime.o identest.o basecvt.o fact.o exptmod.o pi.o \
|
||||
makeprime.o gcd.o invmod.o lap.o isprime.o \
|
||||
dec2hex.o hex2dec.o
|
||||
UTILS = $(UTILOBJS:.o=)
|
||||
|
||||
$(UTILS): % : %.o libmpi.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
$(UTILOBJS) $(EXTRAOBJS): %.o : utils/%.c $(LIBHDRS)
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
prng: prng.o bbs_rand.o libmpi.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
bbsrand: bbsrand.o bbs_rand.o libmpi.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
utils: $(UTILS) prng bbsrand
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
test-info.c: test-arrays.txt
|
||||
$(PERL) make-test-arrays test-arrays.txt > test-info.c
|
||||
|
||||
mpi-test.o: mpi-test.c test-info.c $(LIBHDRS)
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
mpi-test: mpi-test.o libmpi.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
mdxptest.o: mdxptest.c $(LIBHDRS) mpi-priv.h
|
||||
|
||||
mdxptest: mdxptest.o libmpi.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
mulsqr.o: mulsqr.c logtab.h mpi.h mpi-config.h mpprime.h
|
||||
$(CC) $(CFLAGS) -DMP_SQUARE=1 -o $@ -c mulsqr.c
|
||||
|
||||
mulsqr: mulsqr.o libmpi.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
alltests: tests utests mpi-test
|
||||
|
||||
tools: $(TOOLS)
|
||||
|
||||
doc:
|
||||
(cd doc; ./build)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a *.i
|
||||
rm -f core
|
||||
rm -f *~ .*~
|
||||
rm -f utils/*.o
|
||||
rm -f utils/core
|
||||
rm -f utils/*~ utils/.*~
|
||||
|
||||
clobber: clean
|
||||
rm -f $(TOOLS) $(UTILS)
|
||||
|
||||
distclean: clean
|
||||
rm -f mptest? mpi-test metime mulsqr karatsuba
|
||||
rm -f mptest?a mptest?b
|
||||
rm -f utils/mptest?
|
||||
rm -f test-info.c logtab.h
|
||||
rm -f libmpi.a
|
||||
rm -f $(TOOLS)
|
||||
|
||||
dist: Makefile $(HDRS) $(SRCS) $(DOCS)
|
||||
tar -cvf mpi-$(VERS).tar Makefile $(HDRS) $(SRCS) $(DOCS)
|
||||
pgps -ab mpi-$(VERS).tar
|
||||
chmod +r mpi-$(VERS).tar.asc
|
||||
gzip -9 mpi-$(VERS).tar
|
||||
|
||||
# END
|
||||
@@ -1,280 +0,0 @@
|
||||
#
|
||||
# Makefile.win - gmake Makefile for building MPI with VACPP on OS/2
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Michael J. Fromberger <sting@linguist.dartmouth.edu>.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Netscape Communications Corporation
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
#
|
||||
# $Id: Makefile.os2,v 1.3 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
#
|
||||
|
||||
## Define CC to be the C compiler you wish to use. The GNU cc
|
||||
## compiler (gcc) should work, at the very least
|
||||
#CC=cc
|
||||
#CC=gcc
|
||||
CC=icc.exe
|
||||
AS=alp.exe
|
||||
|
||||
##
|
||||
## Define PERL to point to your local Perl interpreter. It
|
||||
## should be Perl 5.x, although it's conceivable that Perl 4
|
||||
## might work ... I haven't tested it.
|
||||
##
|
||||
#PERL=/usr/bin/perl
|
||||
PERL=perl
|
||||
|
||||
##
|
||||
## Define CFLAGS to contain any local options your compiler
|
||||
## setup requires.
|
||||
##
|
||||
## Conditional compilation options are no longer here; see
|
||||
## the file 'mpi-config.h' instead.
|
||||
##
|
||||
MPICMN = -I. -DMP_API_COMPATIBLE -DMP_IOFUNC -DMP_USE_UINT_DIGIT -DMP_NO_MP_WORD
|
||||
|
||||
#OS/2
|
||||
AS_SRCS = mpi_x86.asm
|
||||
MPICMN += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE -DMP_ASSEMBLY_DIV_2DX1D
|
||||
#CFLAGS= -Od -Z7 -MD -W3 -nologo -D_X86_ -DXP_PC \
|
||||
-DDEBUG -D_DEBUG -UNDEBUG -DWIN32 -D_WINDOWS -DWIN95 $(MPICMN)
|
||||
#CFLAGS = -O2 -MD -W3 -nologo -D_X86_ -DXP_PC -UDEBUG -U_DEBUG -DNDEBUG \
|
||||
-DWIN32 -D_WINDOWS -DWIN95 $(MPICMN)
|
||||
#CFLAGS = -Od -Z7 -MD -W3 -nologo -D_X86_ -DXP_PC -UDEBUG -U_DEBUG -DNDEBUG \
|
||||
-DWIN32 -D_WINDOWS -DWIN95 $(MPICMN)
|
||||
CFLAGS = /Ti+ -D_X86_ -DXP_PC -UDEBUG -U_DEBUG -DNDEBUG \
|
||||
$(MPICMN)
|
||||
ASFLAGS =
|
||||
|
||||
##
|
||||
## Define LIBS to include any libraries you need to link against.
|
||||
## If NO_TABLE is define, LIBS should include '-lm' or whatever is
|
||||
## necessary to bring in the math library. Otherwise, it can be
|
||||
## left alone, unless your system has other peculiar requirements.
|
||||
##
|
||||
LIBS=#-lmalloc#-lefence#-lm
|
||||
|
||||
##
|
||||
## Define RANLIB to be the library header randomizer; you might not
|
||||
## need this on some systems (just set it to 'echo' on these systems,
|
||||
## such as IRIX)
|
||||
##
|
||||
RANLIB=echo
|
||||
|
||||
##
|
||||
## This is the version string used for the documentation and
|
||||
## building the distribution tarball. Don't mess with it unless
|
||||
## you are releasing a new version
|
||||
VERS=1.7p6
|
||||
|
||||
## ----------------------------------------------------------------------
|
||||
## You probably don't need to change anything below this line...
|
||||
##
|
||||
|
||||
##
|
||||
## This is the list of source files that need to be packed into
|
||||
## the distribution file
|
||||
SRCS= mpi.c mpprime.c mplogic.c mpmontg.c mpi-test.c primes.c tests/ \
|
||||
utils/gcd.c utils/invmod.c utils/lap.c \
|
||||
utils/ptab.pl utils/sieve.c utils/isprime.c\
|
||||
utils/dec2hex.c utils/hex2dec.c utils/bbs_rand.c \
|
||||
utils/bbsrand.c utils/prng.c utils/primegen.c \
|
||||
utils/basecvt.c utils/makeprime.c\
|
||||
utils/fact.c utils/exptmod.c utils/pi.c utils/metime.c \
|
||||
utils/mpi.h utils/mpprime.h mulsqr.c \
|
||||
make-test-arrays test-arrays.txt all-tests make-logtab \
|
||||
types.pl stats timetest multest
|
||||
|
||||
## These are the header files that go into the distribution file
|
||||
HDRS=mpi.h mpi-config.h utils/mpi.h utils/mpi-config.h mpprime.h mplogic.h \
|
||||
utils/bbs_rand.h tests/mpi.h tests/mpprime.h
|
||||
|
||||
## These are the documentation files that go into the distribution file
|
||||
DOCS=README doc utils/README utils/PRIMES
|
||||
|
||||
## This is the list of tools built by 'make tools'
|
||||
TOOLS=gcd.exe invmod.exe isprime.exe lap.exe dec2hex.exe hex2dec.exe \
|
||||
primegen.exe prng.exe basecvt.exe fact.exe exptmod.exe pi.exe makeprime.exe
|
||||
|
||||
AS_OBJS = $(AS_SRCS:.asm=.obj)
|
||||
LIBOBJS = mpprime.obj mpmontg.obj mplogic.obj mpi.obj $(AS_OBJS)
|
||||
LIBHDRS = mpi-config.h mpi-priv.h mpi.h
|
||||
APPHDRS = mpi-config.h mpi.h mplogic.h mpprime.h
|
||||
|
||||
|
||||
help:
|
||||
@ echo ""
|
||||
@ echo "The following targets can be built with this Makefile:"
|
||||
@ echo ""
|
||||
@ echo "mpi.lib - arithmetic and prime testing library"
|
||||
@ echo "mpi-test.exe - test driver (requires MP_IOFUNC)"
|
||||
@ echo "tools - command line tools"
|
||||
@ echo "doc - manual pages for tools"
|
||||
@ echo "clean - clean up objects and such"
|
||||
@ echo "distclean - get ready for distribution"
|
||||
@ echo "dist - distribution tarball"
|
||||
@ echo ""
|
||||
|
||||
.SUFFIXES: .c .obj .i .lib .exe .asm
|
||||
|
||||
.c.i:
|
||||
$(CC) $(CFLAGS) -E $< > $@
|
||||
|
||||
.c.obj:
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
.asm.obj:
|
||||
$(AS) $(ASFLAGS) $<
|
||||
|
||||
.obj.exe:
|
||||
$(CC) $(CFLAGS) -Fo$@ $<
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
$(LIBOBJS): $(LIBHDRS)
|
||||
|
||||
logtab.h: make-logtab
|
||||
$(PERL) make-logtab > logtab.h
|
||||
|
||||
mpi.obj: mpi.c logtab.h $(LIBHDRS)
|
||||
|
||||
mplogic.obj: mplogic.c mpi-priv.h mplogic.h $(LIBHDRS)
|
||||
|
||||
mpmontg.obj: mpmontg.c mpi-priv.h mplogic.h mpprime.h $(LIBHDRS)
|
||||
|
||||
mpprime.obj: mpprime.c mpi-priv.h mpprime.h mplogic.h primes.c $(LIBHDRS)
|
||||
|
||||
mpi_mips.obj: mpi_mips.s
|
||||
$(CC) -Fo$@ $(ASFLAGS) -c mpi_mips.s
|
||||
|
||||
mpi.lib: $(LIBOBJS)
|
||||
ilib /out:mpi.lib $(LIBOBJS)
|
||||
$(RANLIB) mpi.lib
|
||||
|
||||
lib libs: mpi.lib
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
MPTESTOBJS = mptest1.obj mptest2.obj mptest3.obj mptest3a.obj mptest4.obj \
|
||||
mptest4a.obj mptest4b.obj mptest6.obj mptest7.obj mptest8.obj mptest9.obj
|
||||
MPTESTS = $(MPTESTOBJS:.obj=.exe)
|
||||
|
||||
$(MPTESTOBJS): mptest%.obj: tests/mptest-%.c $(LIBHDRS)
|
||||
$(CC) $(CFLAGS) -Fo$@ -c $<
|
||||
|
||||
$(MPTESTS): mptest%.exe: mptest%.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
tests: mptest1.exe mptest2.exe mptest3.exe mptest3a.exe mptest4.exe \
|
||||
mptest4a.exe mptest4b.exe mptest6.exe bbsrand.exe
|
||||
|
||||
utests: mptest7.exe mptest8.exe mptest9.exe
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
EXTRAOBJS = bbsrand.obj bbs_rand.obj prng.obj
|
||||
UTILOBJS = primegen.obj metime.obj identest.obj basecvt.obj fact.obj \
|
||||
exptmod.obj pi.obj makeprime.obj karatsuba.obj gcd.obj invmod.obj lap.obj \
|
||||
isprime.obj dec2hex.obj hex2dec.obj
|
||||
UTILS = $(UTILOBJS:.obj=.exe)
|
||||
|
||||
$(UTILS): %.exe : %.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
$(UTILOBJS) $(EXTRAOBJS): %.obj : utils/%.c $(LIBHDRS)
|
||||
$(CC) $(CFLAGS) -Fo$@ -c $<
|
||||
|
||||
prng.exe: prng.obj bbs_rand.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
bbsrand.exe: bbsrand.obj bbs_rand.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
utils: $(UTILS) prng.exe bbsrand.exe
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
test-info.c: test-arrays.txt
|
||||
$(PERL) make-test-arrays test-arrays.txt > test-info.c
|
||||
|
||||
mpi-test.obj: mpi-test.c test-info.c $(LIBHDRS)
|
||||
$(CC) $(CFLAGS) -Fo$@ -c $<
|
||||
|
||||
mpi-test.exe: mpi-test.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
mdxptest.obj: mdxptest.c $(LIBHDRS) mpi-priv.h
|
||||
|
||||
mdxptest.exe: mdxptest.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
mulsqr.obj: mulsqr.c logtab.h mpi.h mpi-config.h mpprime.h
|
||||
$(CC) $(CFLAGS) -DMP_SQUARE=1 -Fo$@ -c mulsqr.c
|
||||
|
||||
mulsqr.exe: mulsqr.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
alltests: tests utests mpi-test.exe
|
||||
|
||||
tools: $(TOOLS)
|
||||
|
||||
doc:
|
||||
(cd doc; ./build)
|
||||
|
||||
clean:
|
||||
rm -f *.obj *.lib *.pdb *.ilk
|
||||
cd utils; rm -f *.obj *.lib *.pdb *.ilk
|
||||
|
||||
distclean: clean
|
||||
rm -f mptest? mpi-test metime mulsqr karatsuba
|
||||
rm -f mptest?a mptest?b
|
||||
rm -f utils/mptest?
|
||||
rm -f test-info.c logtab.h
|
||||
rm -f mpi.lib
|
||||
rm -f $(TOOLS)
|
||||
|
||||
dist: Makefile $(HDRS) $(SRCS) $(DOCS)
|
||||
tar -cvf mpi-$(VERS).tar Makefile $(HDRS) $(SRCS) $(DOCS)
|
||||
pgps -ab mpi-$(VERS).tar
|
||||
chmod +r mpi-$(VERS).tar.asc
|
||||
gzip -9 mpi-$(VERS).tar
|
||||
|
||||
|
||||
print:
|
||||
@echo LIBOBJS = $(LIBOBJS)
|
||||
# END
|
||||
@@ -1,280 +0,0 @@
|
||||
#
|
||||
# Makefile.win - gmake Makefile for building MPI with MSVC on NT
|
||||
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Michael J. Fromberger <sting@linguist.dartmouth.edu>.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Netscape Communications Corporation
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
#
|
||||
# $Id: Makefile.win,v 1.3 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
#
|
||||
|
||||
## Define CC to be the C compiler you wish to use. The GNU cc
|
||||
## compiler (gcc) should work, at the very least
|
||||
#CC=cc
|
||||
#CC=gcc
|
||||
CC=cl.exe
|
||||
AS=ml.exe
|
||||
|
||||
##
|
||||
## Define PERL to point to your local Perl interpreter. It
|
||||
## should be Perl 5.x, although it's conceivable that Perl 4
|
||||
## might work ... I haven't tested it.
|
||||
##
|
||||
#PERL=/usr/bin/perl
|
||||
PERL=perl
|
||||
|
||||
##
|
||||
## Define CFLAGS to contain any local options your compiler
|
||||
## setup requires.
|
||||
##
|
||||
## Conditional compilation options are no longer here; see
|
||||
## the file 'mpi-config.h' instead.
|
||||
##
|
||||
MPICMN = -I. -DMP_API_COMPATIBLE -DMP_IOFUNC
|
||||
|
||||
#NT
|
||||
AS_SRCS = mpi_x86.asm
|
||||
MPICMN += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE -DMP_ASSEMBLY_DIV_2DX1D
|
||||
#CFLAGS= -Od -Z7 -MD -W3 -nologo -D_X86_ -DXP_PC \
|
||||
-DDEBUG -D_DEBUG -UNDEBUG -DWIN32 -D_WINDOWS -DWIN95 $(MPICMN)
|
||||
#CFLAGS = -O2 -MD -W3 -nologo -D_X86_ -DXP_PC -UDEBUG -U_DEBUG -DNDEBUG \
|
||||
-DWIN32 -D_WINDOWS -DWIN95 $(MPICMN)
|
||||
#CFLAGS = -Od -Z7 -MD -W3 -nologo -D_X86_ -DXP_PC -UDEBUG -U_DEBUG -DNDEBUG \
|
||||
-DWIN32 -D_WINDOWS -DWIN95 $(MPICMN)
|
||||
CFLAGS = -O2 -Z7 -MD -W3 -nologo -D_X86_ -DXP_PC -UDEBUG -U_DEBUG -DNDEBUG \
|
||||
-DWIN32 -D_WINDOWS -DWIN95 $(MPICMN)
|
||||
ASFLAGS = -Cp -Sn -Zi -coff -I.
|
||||
|
||||
##
|
||||
## Define LIBS to include any libraries you need to link against.
|
||||
## If NO_TABLE is define, LIBS should include '-lm' or whatever is
|
||||
## necessary to bring in the math library. Otherwise, it can be
|
||||
## left alone, unless your system has other peculiar requirements.
|
||||
##
|
||||
LIBS=#-lmalloc#-lefence#-lm
|
||||
|
||||
##
|
||||
## Define RANLIB to be the library header randomizer; you might not
|
||||
## need this on some systems (just set it to 'echo' on these systems,
|
||||
## such as IRIX)
|
||||
##
|
||||
RANLIB=echo
|
||||
|
||||
##
|
||||
## This is the version string used for the documentation and
|
||||
## building the distribution tarball. Don't mess with it unless
|
||||
## you are releasing a new version
|
||||
VERS=1.7p6
|
||||
|
||||
## ----------------------------------------------------------------------
|
||||
## You probably don't need to change anything below this line...
|
||||
##
|
||||
|
||||
##
|
||||
## This is the list of source files that need to be packed into
|
||||
## the distribution file
|
||||
SRCS= mpi.c mpprime.c mplogic.c mpmontg.c mpi-test.c primes.c tests/ \
|
||||
utils/gcd.c utils/invmod.c utils/lap.c \
|
||||
utils/ptab.pl utils/sieve.c utils/isprime.c\
|
||||
utils/dec2hex.c utils/hex2dec.c utils/bbs_rand.c \
|
||||
utils/bbsrand.c utils/prng.c utils/primegen.c \
|
||||
utils/basecvt.c utils/makeprime.c\
|
||||
utils/fact.c utils/exptmod.c utils/pi.c utils/metime.c \
|
||||
utils/mpi.h utils/mpprime.h mulsqr.c \
|
||||
make-test-arrays test-arrays.txt all-tests make-logtab \
|
||||
types.pl stats timetest multest
|
||||
|
||||
## These are the header files that go into the distribution file
|
||||
HDRS=mpi.h mpi-config.h utils/mpi.h utils/mpi-config.h mpprime.h mplogic.h \
|
||||
utils/bbs_rand.h tests/mpi.h tests/mpprime.h
|
||||
|
||||
## These are the documentation files that go into the distribution file
|
||||
DOCS=README doc utils/README utils/PRIMES
|
||||
|
||||
## This is the list of tools built by 'make tools'
|
||||
TOOLS=gcd.exe invmod.exe isprime.exe lap.exe dec2hex.exe hex2dec.exe \
|
||||
primegen.exe prng.exe basecvt.exe fact.exe exptmod.exe pi.exe makeprime.exe
|
||||
|
||||
AS_OBJS = $(AS_SRCS:.asm=.obj)
|
||||
LIBOBJS = mpprime.obj mpmontg.obj mplogic.obj mpi.obj $(AS_OBJS)
|
||||
LIBHDRS = mpi-config.h mpi-priv.h mpi.h
|
||||
APPHDRS = mpi-config.h mpi.h mplogic.h mpprime.h
|
||||
|
||||
|
||||
help:
|
||||
@ echo ""
|
||||
@ echo "The following targets can be built with this Makefile:"
|
||||
@ echo ""
|
||||
@ echo "mpi.lib - arithmetic and prime testing library"
|
||||
@ echo "mpi-test - test driver (requires MP_IOFUNC)"
|
||||
@ echo "tools - command line tools"
|
||||
@ echo "doc - manual pages for tools"
|
||||
@ echo "clean - clean up objects and such"
|
||||
@ echo "distclean - get ready for distribution"
|
||||
@ echo "dist - distribution tarball"
|
||||
@ echo ""
|
||||
|
||||
.SUFFIXES: .c .obj .i .lib .exe .asm
|
||||
|
||||
.c.i:
|
||||
$(CC) $(CFLAGS) -E $< > $@
|
||||
|
||||
.c.obj:
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
.asm.obj:
|
||||
$(AS) $(ASFLAGS) -c $<
|
||||
|
||||
.obj.exe:
|
||||
$(CC) $(CFLAGS) -Fo$@ $<
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
$(LIBOBJS): $(LIBHDRS)
|
||||
|
||||
logtab.h: make-logtab
|
||||
$(PERL) make-logtab > logtab.h
|
||||
|
||||
mpi.obj: mpi.c logtab.h $(LIBHDRS)
|
||||
|
||||
mplogic.obj: mplogic.c mpi-priv.h mplogic.h $(LIBHDRS)
|
||||
|
||||
mpmontg.obj: mpmontg.c mpi-priv.h mplogic.h mpprime.h $(LIBHDRS)
|
||||
|
||||
mpprime.obj: mpprime.c mpi-priv.h mpprime.h mplogic.h primes.c $(LIBHDRS)
|
||||
|
||||
mpi_mips.obj: mpi_mips.s
|
||||
$(CC) -Fo$@ $(ASFLAGS) -c mpi_mips.s
|
||||
|
||||
mpi.lib: $(LIBOBJS)
|
||||
ar -cvr mpi.lib $(LIBOBJS)
|
||||
$(RANLIB) mpi.lib
|
||||
|
||||
lib libs: mpi.lib
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
MPTESTOBJS = mptest1.obj mptest2.obj mptest3.obj mptest3a.obj mptest4.obj \
|
||||
mptest4a.obj mptest4b.obj mptest6.obj mptest7.obj mptest8.obj mptest9.obj
|
||||
MPTESTS = $(MPTESTOBJS:.obj=.exe)
|
||||
|
||||
$(MPTESTOBJS): mptest%.obj: tests/mptest-%.c $(LIBHDRS)
|
||||
$(CC) $(CFLAGS) -Fo$@ -c $<
|
||||
|
||||
$(MPTESTS): mptest%.exe: mptest%.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
tests: mptest1.exe mptest2.exe mptest3.exe mptest3a.exe mptest4.exe \
|
||||
mptest4a.exe mptest4b.exe mptest6.exe bbsrand.exe
|
||||
|
||||
utests: mptest7.exe mptest8.exe mptest9.exe
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
EXTRAOBJS = bbsrand.obj bbs_rand.obj prng.obj
|
||||
UTILOBJS = primegen.obj metime.obj identest.obj basecvt.obj fact.obj \
|
||||
exptmod.obj pi.obj makeprime.obj karatsuba.obj gcd.obj invmod.obj lap.obj \
|
||||
isprime.obj dec2hex.obj hex2dec.obj
|
||||
UTILS = $(UTILOBJS:.obj=.exe)
|
||||
|
||||
$(UTILS): %.exe : %.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
$(UTILOBJS) $(EXTRAOBJS): %.obj : utils/%.c $(LIBHDRS)
|
||||
$(CC) $(CFLAGS) -Fo$@ -c $<
|
||||
|
||||
prng.exe: prng.obj bbs_rand.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
bbsrand.exe: bbsrand.obj bbs_rand.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
utils: $(UTILS) prng.exe bbsrand.exe
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
test-info.c: test-arrays.txt
|
||||
$(PERL) make-test-arrays test-arrays.txt > test-info.c
|
||||
|
||||
mpi-test.obj: mpi-test.c test-info.c $(LIBHDRS)
|
||||
$(CC) $(CFLAGS) -Fo$@ -c $<
|
||||
|
||||
mpi-test.exe: mpi-test.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
mdxptest.obj: mdxptest.c $(LIBHDRS) mpi-priv.h
|
||||
|
||||
mdxptest.exe: mdxptest.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
mulsqr.obj: mulsqr.c logtab.h mpi.h mpi-config.h mpprime.h
|
||||
$(CC) $(CFLAGS) -DMP_SQUARE=1 -Fo$@ -c mulsqr.c
|
||||
|
||||
mulsqr.exe: mulsqr.obj mpi.lib $(LIBS)
|
||||
$(CC) $(CFLAGS) -Fo$@ $^
|
||||
|
||||
#---------------------------------------
|
||||
|
||||
alltests: tests utests mpi-test.exe
|
||||
|
||||
tools: $(TOOLS)
|
||||
|
||||
doc:
|
||||
(cd doc; ./build)
|
||||
|
||||
clean:
|
||||
rm -f *.obj *.lib *.pdb *.ilk
|
||||
cd utils; rm -f *.obj *.lib *.pdb *.ilk
|
||||
|
||||
distclean: clean
|
||||
rm -f mptest? mpi-test metime mulsqr karatsuba
|
||||
rm -f mptest?a mptest?b
|
||||
rm -f utils/mptest?
|
||||
rm -f test-info.c logtab.h
|
||||
rm -f mpi.lib
|
||||
rm -f $(TOOLS)
|
||||
|
||||
dist: Makefile $(HDRS) $(SRCS) $(DOCS)
|
||||
tar -cvf mpi-$(VERS).tar Makefile $(HDRS) $(SRCS) $(DOCS)
|
||||
pgps -ab mpi-$(VERS).tar
|
||||
chmod +r mpi-$(VERS).tar.asc
|
||||
gzip -9 mpi-$(VERS).tar
|
||||
|
||||
|
||||
print:
|
||||
@echo LIBOBJS = $(LIBOBJS)
|
||||
# END
|
||||
@@ -1,799 +0,0 @@
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is the MPI Arbitrary Precision Integer Arithmetic
|
||||
library.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Portions created by the Initial Developer are Copyright (C) 1997-2000
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
About the MPI Library
|
||||
---------------------
|
||||
|
||||
The files 'mpi.h' and 'mpi.c' define a simple, arbitrary precision
|
||||
signed integer arithmetic package. The implementation is not the most
|
||||
efficient possible, but the code is small and should be fairly easily
|
||||
portable to just about any machine that supports an ANSI C compiler,
|
||||
as long as it is capable of at least 16-bit arithmetic (but also see
|
||||
below for more on this).
|
||||
|
||||
This library was written with an eye to cryptographic applications;
|
||||
thus, some care is taken to make sure that temporary values are not
|
||||
left lying around in memory when they are no longer in use. This adds
|
||||
some overhead for zeroing buffers before they are released back into
|
||||
the free pool; however, it gives you the assurance that there is only
|
||||
one copy of your important values residing in your process's address
|
||||
space at a time. Obviously, it is difficult to guarantee anything, in
|
||||
a pre-emptive multitasking environment, but this at least helps you
|
||||
keep a lid on the more obvious ways your data can get spread around in
|
||||
memory.
|
||||
|
||||
|
||||
Using the Library
|
||||
-----------------
|
||||
|
||||
To use the MPI library in your program, you must include the header:
|
||||
|
||||
#include "mpi.h"
|
||||
|
||||
This header provides all the type and function declarations you'll
|
||||
need to use the library. Almost all the names defined by the library
|
||||
begin with the prefix 'mp_', so it should be easy to keep them from
|
||||
clashing with your program's namespace (he says, glibly, knowing full
|
||||
well there are always pathological cases).
|
||||
|
||||
There are a few things you may want to configure about the library.
|
||||
By default, the MPI library uses an unsigned short for its digit type,
|
||||
and an unsigned int for its word type. The word type must be big
|
||||
enough to contain at least two digits, for the primitive arithmetic to
|
||||
work out. On my machine, a short is 2 bytes and an int is 4 bytes --
|
||||
but if you have 64-bit ints, you might want to use a 4-byte digit and
|
||||
an 8-byte word. I have tested the library using 1-byte digits and
|
||||
2-byte words, as well. Whatever you choose to do, the things you need
|
||||
to change are:
|
||||
|
||||
(1) The type definitions for mp_digit and mp_word.
|
||||
|
||||
(2) The macro DIGIT_FMT which tells mp_print() how to display a
|
||||
single digit. This is just a printf() format string, so you
|
||||
can adjust it appropriately.
|
||||
|
||||
(3) The macros DIGIT_MAX and MP_WORD_MAX, which specify the
|
||||
largest value expressible in an mp_digit and an mp_word,
|
||||
respectively.
|
||||
|
||||
Both the mp_digit and mp_word should be UNSIGNED integer types. The
|
||||
code relies on having the full positive precision of the type used for
|
||||
digits and words.
|
||||
|
||||
The remaining type definitions should be left alone, for the most
|
||||
part. The code in the library does not make any significant
|
||||
assumptions about the sizes of things, but there is little if any
|
||||
reason to change the other parameters, so I would recommend you leave
|
||||
them as you found them.
|
||||
|
||||
The library comes with a Perl script, 'types.pl', which will scan your
|
||||
current Makefile settings, and attempt to find good definitions for
|
||||
these types. It relies on a Unix sort of build environment, so it
|
||||
probably won't work under MacOS or Windows, but it can be convenient
|
||||
if you're porting to a new flavour of Unix. Just run 'types.pl' at
|
||||
the command line, and it will spit out its results to the standard
|
||||
output.
|
||||
|
||||
|
||||
Conventions
|
||||
-----------
|
||||
|
||||
Most functions in the library return a value of type mp_err. This
|
||||
permits the library to communicate success or various kinds of failure
|
||||
to the calling program. The return values currently defined are:
|
||||
|
||||
MP_OKAY - okay, operation succeeded, all's well
|
||||
MP_YES - okay, the answer is yes (same as MP_OKAY)
|
||||
MP_NO - okay, but answer is no (not MP_OKAY)
|
||||
MP_MEM - operation ran out of memory
|
||||
MP_RANGE - input parameter was out of range
|
||||
MP_BADARG - an invalid input parameter was provided
|
||||
MP_UNDEF - no output value is defined for this input
|
||||
|
||||
The only function which currently uses MP_UNDEF is mp_invmod().
|
||||
Division by zero is undefined, but the division functions will return
|
||||
MP_RANGE for a zero divisor. MP_BADARG usually means you passed a
|
||||
bogus mp_int structure to the function. MP_YES and MP_NO are not used
|
||||
by the library itself; they're defined so you can use them in your own
|
||||
extensions.
|
||||
|
||||
If you need a readable interpretation of these error codes in your
|
||||
program, you may also use the mp_strerror() function. This function
|
||||
takes an mp_err as input, and returns a pointer to a human-readable
|
||||
string describing the meaning of the error. These strings are stored
|
||||
as constants within the library, so the caller should not attempt to
|
||||
modify or free the memory associated with these strings.
|
||||
|
||||
The library represents values in signed-magnitude format. Values
|
||||
strictly less than zero are negative, all others are considered
|
||||
positive (zero is positive by fiat). You can access the 'sign' member
|
||||
of the mp_int structure directly, but better is to use the mp_cmp_z()
|
||||
function, to find out which side of zero the value lies on.
|
||||
|
||||
Most arithmetic functions have a single-digit variant, as well as the
|
||||
full arbitrary-precision. An mp_digit is an unsigned value between 0
|
||||
and DIGIT_MAX inclusive. The radix is available as RADIX. The number
|
||||
of bits in a given digit is given as DIGIT_BIT.
|
||||
|
||||
Generally, input parameters are given before output parameters.
|
||||
Unless otherwise specified, any input parameter can be re-used as an
|
||||
output parameter, without confusing anything.
|
||||
|
||||
The basic numeric type defined by the library is an mp_int. Virtually
|
||||
all the functions in the library take a pointer to an mp_int as one of
|
||||
their parameters. An explanation of how to create and use these
|
||||
<HR>
|
||||
<A NAME="p23">
|
||||
<H3>Problem 23:</H3>
|
||||
|
||||
structures follows. And so, without further ado...
|
||||
|
||||
|
||||
Initialization and Cleanup
|
||||
--------------------------
|
||||
|
||||
The basic numeric type defined by the library is an 'mp_int'.
|
||||
However, it is not sufficient to simply declare a variable of type
|
||||
mp_int in your program. These variables also need to be initialized
|
||||
before they can be used, to allocate the internal storage they require
|
||||
for computation.
|
||||
|
||||
This is done using one of the following functions:
|
||||
|
||||
mp_init(mp_int *mp);
|
||||
mp_init_copy(mp_int *mp, mp_int *from);
|
||||
mp_init_size(mp_int *mp, mp_size p);
|
||||
|
||||
Each of these requires a pointer to a structure of type mp_int. The
|
||||
basic mp_init() simply initializes the mp_int to a default size, and
|
||||
sets its value to zero. If you would like to initialize a copy of an
|
||||
existing mp_int, use mp_init_copy(), where the 'from' parameter is the
|
||||
mp_int you'd like to make a copy of. The third function,
|
||||
mp_init_size(), permits you to specify how many digits of precision
|
||||
should be preallocated for your mp_int. This can help the library
|
||||
avoid unnecessary re-allocations later on.
|
||||
|
||||
The default precision used by mp_init() can be retrieved using:
|
||||
|
||||
precision = mp_get_prec();
|
||||
|
||||
This returns the number of digits that will be allocated. You can
|
||||
change this value by using:
|
||||
|
||||
mp_set_prec(unsigned int prec);
|
||||
|
||||
Any positive value is acceptable -- if you pass zero, the default
|
||||
precision will be re-set to the compiled-in library default (this is
|
||||
specified in the header file 'mpi-config.h', and typically defaults to
|
||||
8 or 16).
|
||||
|
||||
Just as you must allocate an mp_int before you can use it, you must
|
||||
clean up the structure when you are done with it. This is performed
|
||||
using the mp_clear() function. Remember that any mp_int that you
|
||||
create as a local variable in a function must be mp_clear()'d before
|
||||
that function exits, or else the memory allocated to that mp_int will
|
||||
be orphaned and unrecoverable.
|
||||
|
||||
To set an mp_int to a given value, the following functions are given:
|
||||
|
||||
mp_set(mp_int *mp, mp_digit d);
|
||||
mp_set_int(mp_int *mp, long z);
|
||||
|
||||
The mp_set() function sets the mp_int to a single digit value, while
|
||||
mp_set_int() sets the mp_int to a signed long integer value.
|
||||
|
||||
To set an mp_int to zero, use:
|
||||
|
||||
mp_zero(mp_int *mp);
|
||||
|
||||
|
||||
Copying and Moving
|
||||
------------------
|
||||
|
||||
If you have two initialized mp_int's, and you want to copy the value
|
||||
of one into the other, use:
|
||||
|
||||
mp_copy(from, to)
|
||||
|
||||
This takes care of clearing the old value of 'to', and copies the new
|
||||
value into it. If 'to' is not yet initialized, use mp_init_copy()
|
||||
instead (see above).
|
||||
|
||||
Note: The library tries, whenever possible, to avoid allocating
|
||||
---- new memory. Thus, mp_copy() tries first to satisfy the needs
|
||||
of the copy by re-using the memory already allocated to 'to'.
|
||||
Only if this proves insufficient will mp_copy() actually
|
||||
allocate new memory.
|
||||
|
||||
For this reason, if you know a priori that 'to' has enough
|
||||
available space to hold 'from', you don't need to check the
|
||||
return value of mp_copy() for memory failure. The USED()
|
||||
macro tells you how many digits are used by an mp_int, and
|
||||
the ALLOC() macro tells you how many are allocated.
|
||||
|
||||
If you have two initialized mp_int's, and you want to exchange their
|
||||
values, use:
|
||||
|
||||
mp_exch(a, b)
|
||||
|
||||
This is better than using mp_copy() with a temporary, since it will
|
||||
not (ever) touch the memory allocator -- it just swaps the exact
|
||||
contents of the two structures. The mp_exch() function cannot fail;
|
||||
if you pass it an invalid structure, it just ignores it, and does
|
||||
nothing.
|
||||
|
||||
|
||||
Basic Arithmetic
|
||||
----------------
|
||||
|
||||
Once you have initialized your integers, you can operate on them. The
|
||||
basic arithmetic functions on full mp_int values are:
|
||||
|
||||
mp_add(a, b, c) - computes c = a + b
|
||||
mp_sub(a, b, c) - computes c = a - b
|
||||
mp_mul(a, b, c) - computes c = a * b
|
||||
mp_sqr(a, b) - computes b = a * a
|
||||
mp_div(a, b, q, r) - computes q, r such that a = bq + r
|
||||
mp_div_2d(a, d, q, r) - computes q = a / 2^d, r = a % 2^d
|
||||
mp_expt(a, b, c) - computes c = a ** b
|
||||
mp_2expt(a, k) - computes a = 2^k
|
||||
mp_sqrt(a, c) - computes c = floor(sqrt(a))
|
||||
|
||||
The mp_div_2d() function efficiently computes division by powers of
|
||||
two. Either the q or r parameter may be NULL, in which case that
|
||||
portion of the computation will be discarded.
|
||||
|
||||
The algorithms used for some of the computations here are described in
|
||||
the following files which are included with this distribution:
|
||||
|
||||
mul.txt Describes the multiplication algorithm
|
||||
div.txt Describes the division algorithm
|
||||
expt.txt Describes the exponentiation algorithm
|
||||
sqrt.txt Describes the square-root algorithm
|
||||
square.txt Describes the squaring algorithm
|
||||
|
||||
There are single-digit versions of most of these routines, as well.
|
||||
In the following prototypes, 'd' is a single mp_digit:
|
||||
|
||||
mp_add_d(a, d, c) - computes c = a + d
|
||||
mp_sub_d(a, d, c) - computes c = a - d
|
||||
mp_mul_d(a, d, c) - computes c = a * d
|
||||
mp_mul_2(a, c) - computes c = a * 2
|
||||
mp_div_d(a, d, q, r) - computes q, r such that a = bq + r
|
||||
mp_div_2(a, c) - computes c = a / 2
|
||||
mp_expt_d(a, d, c) - computes c = a ** d
|
||||
|
||||
The mp_mul_2() and mp_div_2() functions take advantage of the internal
|
||||
representation of an mp_int to do multiplication by two more quickly
|
||||
than mp_mul_d() would. Other basic functions of an arithmetic variety
|
||||
include:
|
||||
|
||||
mp_zero(a) - assign 0 to a
|
||||
mp_neg(a, c) - negate a: c = -a
|
||||
mp_abs(a, c) - absolute value: c = |a|
|
||||
|
||||
|
||||
Comparisons
|
||||
-----------
|
||||
|
||||
Several comparison functions are provided. Each of these, unless
|
||||
otherwise specified, returns zero if the comparands are equal, < 0 if
|
||||
the first is less than the second, and > 0 if the first is greater
|
||||
than the second:
|
||||
|
||||
mp_cmp_z(a) - compare a <=> 0
|
||||
mp_cmp_d(a, d) - compare a <=> d, d is a single digit
|
||||
mp_cmp(a, b) - compare a <=> b
|
||||
mp_cmp_mag(a, b) - compare |a| <=> |b|
|
||||
mp_cmp_int(a, z) - compare a <=> z, z is a signed long integer
|
||||
mp_isodd(a) - return nonzero if odd, zero otherwise
|
||||
mp_iseven(a) - return nonzero if even, zero otherwise
|
||||
|
||||
|
||||
Modular Arithmetic
|
||||
------------------
|
||||
|
||||
Modular variations of the basic arithmetic functions are also
|
||||
supported. These are available if the MP_MODARITH parameter in
|
||||
mpi-config.h is turned on (it is by default). The modular arithmetic
|
||||
functions are:
|
||||
|
||||
mp_mod(a, m, c) - compute c = a (mod m), 0 <= c < m
|
||||
mp_mod_d(a, d, c) - compute c = a (mod d), 0 <= c < d (see below)
|
||||
mp_addmod(a, b, m, c) - compute c = (a + b) mod m
|
||||
mp_submod(a, b, m, c) - compute c = (a - b) mod m
|
||||
mp_mulmod(a, b, m, c) - compute c = (a * b) mod m
|
||||
mp_sqrmod(a, m, c) - compute c = (a * a) mod m
|
||||
mp_exptmod(a, b, m, c) - compute c = (a ** b) mod m
|
||||
mp_exptmod_d(a, d, m, c)- compute c = (a ** d) mod m
|
||||
|
||||
The mp_sqr() function squares its input argument. A call to mp_sqr(a,
|
||||
c) is identical in meaning to mp_mul(a, a, c); however, if the
|
||||
MP_SQUARE variable is set true in mpi-config.h (see below), then it
|
||||
will be implemented with a different algorithm, that is supposed to
|
||||
take advantage of the redundant computation that takes place during
|
||||
squaring. Unfortunately, some compilers result in worse performance
|
||||
on this code, so you can change the behaviour at will. There is a
|
||||
utility program "mulsqr.c" that lets you test which does better on
|
||||
your system.
|
||||
|
||||
The mp_sqrmod() function is analogous to the mp_sqr() function; it
|
||||
uses the mp_sqr() function rather than mp_mul(), and then performs the
|
||||
modular reduction. This probably won't help much unless you are doing
|
||||
a lot of them.
|
||||
|
||||
See the file 'square.txt' for a synopsis of the algorithm used.
|
||||
|
||||
Note: The mp_mod_d() function computes a modular reduction around
|
||||
---- a single digit d. The result is a single digit c.
|
||||
|
||||
Because an inverse is defined for a (mod m) if and only if (a, m) = 1
|
||||
(that is, if a and m are relatively prime), mp_invmod() may not be
|
||||
able to compute an inverse for the arguments. In this case, it
|
||||
returns the value MP_UNDEF, and does not modify c. If an inverse is
|
||||
defined, however, it returns MP_OKAY, and sets c to the value of the
|
||||
inverse (mod m).
|
||||
|
||||
See the file 'redux.txt' for a description of the modular reduction
|
||||
algorithm used by mp_exptmod().
|
||||
|
||||
|
||||
Greatest Common Divisor
|
||||
-----------------------
|
||||
|
||||
If The greates common divisor of two values can be found using one of the
|
||||
following functions:
|
||||
|
||||
mp_gcd(a, b, c) - compute c = (a, b) using binary algorithm
|
||||
mp_lcm(a, b, c) - compute c = [a, b] = ab / (a, b)
|
||||
mp_xgcd(a, b, g, x, y) - compute g, x, y so that ax + by = g = (a, b)
|
||||
|
||||
Also provided is a function to compute modular inverses, if they
|
||||
exist:
|
||||
|
||||
mp_invmod(a, m, c) - compute c = a^-1 (mod m), if it exists
|
||||
|
||||
The function mp_xgcd() computes the greatest common divisor, and also
|
||||
returns values of x and y satisfying Bezout's identity. This is used
|
||||
by mp_invmod() to find modular inverses. However, if you do not need
|
||||
these values, you will find that mp_gcd() is MUCH more efficient,
|
||||
since it doesn't need all the intermediate values that mp_xgcd()
|
||||
requires in order to compute x and y.
|
||||
|
||||
The mp_gcd() (and mp_xgcd()) functions use the binary (extended) GCD
|
||||
algorithm due to Josef Stein.
|
||||
|
||||
|
||||
Input & Output Functions
|
||||
------------------------
|
||||
|
||||
The following basic I/O routines are provided. These are present at
|
||||
all times:
|
||||
|
||||
mp_read_radix(mp, str, r) - convert a string in radix r to an mp_int
|
||||
mp_read_raw(mp, s, len) - convert a string of bytes to an mp_int
|
||||
mp_radix_size(mp, r) - return length of buffer needed by mp_toradix()
|
||||
mp_raw_size(mp) - return length of buffer needed by mp_toraw()
|
||||
mp_toradix(mp, str, r) - convert an mp_int to a string of radix r
|
||||
digits
|
||||
mp_toraw(mp, str) - convert an mp_int to a string of bytes
|
||||
mp_tovalue(ch, r) - convert ch to its value when taken as
|
||||
a radix r digit, or -1 if invalid
|
||||
mp_strerror(err) - get a string describing mp_err value 'err'
|
||||
|
||||
If you compile the MPI library with MP_IOFUNC defined, you will also
|
||||
have access to the following additional I/O function:
|
||||
|
||||
mp_print(mp, ofp) - print an mp_int as text to output stream ofp
|
||||
|
||||
Note that mp_radix_size() returns a size in bytes guaranteed to be AT
|
||||
LEAST big enough for the digits output by mp_toradix(). Because it
|
||||
uses an approximation technique to figure out how many digits will be
|
||||
needed, it may return a figure which is larger than necessary. Thus,
|
||||
the caller should not rely on the value to determine how many bytes
|
||||
will actually be written by mp_toradix(). The string mp_toradix()
|
||||
creates will be NUL terminated, so the standard C library function
|
||||
strlen() should be able to ascertain this for you, if you need it.
|
||||
|
||||
The mp_read_radix() and mp_toradix() functions support bases from 2 to
|
||||
64 inclusive. If you require more general radix conversion facilities
|
||||
than this, you will need to write them yourself (that's why mp_div_d()
|
||||
is provided, after all).
|
||||
|
||||
Note: mp_read_radix() will accept as digits either capital or
|
||||
---- lower-case letters. However, the current implementation of
|
||||
mp_toradix() only outputs upper-case letters, when writing
|
||||
bases betwee 10 and 36. The underlying code supports using
|
||||
lower-case letters, but the interface stub does not have a
|
||||
selector for it. You can add one yourself if you think it
|
||||
is worthwhile -- I do not. Bases from 36 to 64 use lower-
|
||||
case letters as distinct from upper-case. Bases 63 and
|
||||
64 use the characters '+' and '/' as digits.
|
||||
|
||||
Note also that compiling with MP_IOFUNC defined will cause
|
||||
inclusion of <stdio.h>, so if you are trying to write code
|
||||
which does not depend on the standard C library, you will
|
||||
probably want to avoid this option. This is needed because
|
||||
the mp_print() function takes a standard library FILE * as
|
||||
one of its parameters, and uses the fprintf() function.
|
||||
|
||||
The mp_toraw() function converts the integer to a sequence of bytes,
|
||||
in big-endian ordering (most-significant byte first). Assuming your
|
||||
bytes are 8 bits wide, this corresponds to base 256. The sign is
|
||||
encoded as a single leading byte, whose value is 0 for zero or
|
||||
positive values, or 1 for negative values. The mp_read_raw() function
|
||||
reverses this process -- it takes a buffer of bytes, interprets the
|
||||
first as a sign indicator (0 = zero/positive, nonzero = negative), and
|
||||
the rest as a sequence of 1-byte digits in big-endian ordering.
|
||||
|
||||
The mp_raw_size() function returns the exact number of bytes required
|
||||
to store the given integer in "raw" format (as described in the
|
||||
previous paragraph). Zero is returned in case of error; a valid
|
||||
integer will require at least three bytes of storage.
|
||||
|
||||
In previous versions of the MPI library, an "external representation
|
||||
format" was supported. This was removed, however, because I found I
|
||||
was never using it, it was not as portable as I would have liked, and
|
||||
I decided it was a waste of space.
|
||||
|
||||
|
||||
Other Functions
|
||||
---------------
|
||||
|
||||
The files 'mpprime.h' and 'mpprime.c' define some routines which are
|
||||
useful for divisibility testing and probabilistic primality testing.
|
||||
The routines defined are:
|
||||
|
||||
mpp_divis(a, b) - is a divisible by b?
|
||||
mpp_divis_d(a, d) - is a divisible by digit d?
|
||||
mpp_random(a) - set a to random value at current precision
|
||||
mpp_random_size(a, prec) - set a to random value at given precision
|
||||
|
||||
Note: The mpp_random() and mpp_random_size() functions use the C
|
||||
---- library's rand() function to generate random values. It is
|
||||
up to the caller to seed this generator before it is called.
|
||||
These functions are not suitable for generating quantities
|
||||
requiring cryptographic-quality randomness; they are intended
|
||||
primarily for use in primality testing.
|
||||
|
||||
Note too that the MPI library does not call srand(), so your
|
||||
application should do this, if you ever want the sequence
|
||||
to change.
|
||||
|
||||
mpp_divis_vector(a, v, s, w) - is a divisible by any of the s digits
|
||||
in v? If so, let w be the index of
|
||||
that digit
|
||||
|
||||
mpp_divis_primes(a, np) - is a divisible by any of the first np
|
||||
primes? If so, set np to the prime
|
||||
which divided a.
|
||||
|
||||
mpp_fermat(a, d) - test if w^a = w (mod a). If so,
|
||||
returns MP_YES, otherwise MP_NO.
|
||||
|
||||
mpp_pprime(a, nt) - perform nt iterations of the Rabin-
|
||||
Miller probabilistic primality test
|
||||
on a. Returns MP_YES if all tests
|
||||
passed, or MP_NO if any test fails.
|
||||
|
||||
The mpp_fermat() function works based on Fermat's little theorem, a
|
||||
consequence of which is that if p is a prime, and (w, p) = 1, then:
|
||||
|
||||
w^p = w (mod p)
|
||||
|
||||
Put another way, if w^p != w (mod p), then p is not prime. The test
|
||||
is expensive to compute, but it helps to quickly eliminate an enormous
|
||||
class of composite numbers prior to Rabin-Miller testing.
|
||||
|
||||
Building the Library
|
||||
--------------------
|
||||
|
||||
The MPI library is designed to be as self-contained as possible. You
|
||||
should be able to compile it with your favourite ANSI C compiler, and
|
||||
link it into your program directly. If you are on a Unix system using
|
||||
the GNU C compiler (gcc), the following should work:
|
||||
|
||||
% gcc -ansi -pedantic -Wall -O2 -c mpi.c
|
||||
|
||||
The file 'mpi-config.h' defines several configurable parameters for
|
||||
the library, which you can adjust to suit your application. At the
|
||||
time of this writing, the available options are:
|
||||
|
||||
MP_IOFUNC - Define true to include the mp_print() function,
|
||||
which is moderately useful for debugging. This
|
||||
implicitly includes <stdio.h>.
|
||||
|
||||
MP_MODARITH - Define true to include the modular arithmetic
|
||||
functions. If you don't need modular arithmetic
|
||||
in your application, you can set this to zero to
|
||||
leave out all the modular routines.
|
||||
|
||||
MP_NUMTH - Define true to include number theoretic functions
|
||||
such as mp_gcd(), mp_lcm(), and mp_invmod().
|
||||
|
||||
MP_LOGTAB - If true, the file "logtab.h" is included, which
|
||||
is basically a static table of base 2 logarithms.
|
||||
These are used to compute how big the buffers for
|
||||
radix conversion need to be. If you set this false,
|
||||
the library includes <math.h> and uses log(). This
|
||||
typically forces you to link against math libraries.
|
||||
|
||||
MP_MEMSET - If true, use memset() to zero buffers. If you run
|
||||
into weird alignment related bugs, set this to zero
|
||||
and an explicit loop will be used.
|
||||
|
||||
MP_MEMCPY - If true, use memcpy() to copy buffers. If you run
|
||||
into weird alignment bugs, set this to zero and an
|
||||
explicit loop will be used.
|
||||
|
||||
MP_CRYPTO - If true, whenever arrays of digits are free'd, they
|
||||
are zeroed first. This is useful if you're using
|
||||
the library in a cryptographic environment; however,
|
||||
it does add overhead to each free operation. For
|
||||
performance, if you don't care about zeroing your
|
||||
buffers, set this to false.
|
||||
|
||||
MP_ARGCHK - Set to 0, 1, or 2. This defines how the argument
|
||||
checking macro, ARGCHK(), gets expanded. If this
|
||||
is set to zero, ARGCHK() expands to nothing; no
|
||||
argument checks are performed. If this is 1, the
|
||||
ARGCHK() macro expands to code that returns MP_BADARG
|
||||
or similar at runtime. If it is 2, ARGCHK() expands
|
||||
to an assert() call that aborts the program on a
|
||||
bad input.
|
||||
|
||||
MP_DEBUG - Turns on debugging output. This is probably not at
|
||||
all useful unless you are debugging the library. It
|
||||
tends to spit out a LOT of output.
|
||||
|
||||
MP_DEFPREC - The default precision of a newly-created mp_int, in
|
||||
digits. The precision can be changed at runtime by
|
||||
the mp_set_prec() function, but this is its initial
|
||||
value.
|
||||
|
||||
MP_SQUARE - If this is set to a nonzero value, the mp_sqr()
|
||||
function will use an alternate algorithm that takes
|
||||
advantage of the redundant inner product computation
|
||||
when both multiplicands are identical. Unfortunately,
|
||||
with some compilers this is actually SLOWER than just
|
||||
calling mp_mul() with the same argument twice. So
|
||||
if you set MP_SQUARE to zero, mp_sqr() will be expan-
|
||||
ded into a call to mp_mul(). This applies to all
|
||||
the uses of mp_sqr(), including mp_sqrmod() and the
|
||||
internal calls to s_mp_sqr() inside mpi.c
|
||||
|
||||
The program 'mulsqr' (mulsqr.c) can be used to test
|
||||
which works best for your configuration. Set up the
|
||||
CC and CFLAGS variables in the Makefile, then type:
|
||||
|
||||
make mulsqr
|
||||
|
||||
Invoke it with arguments similar to the following:
|
||||
|
||||
mulsqr 25000 1024
|
||||
|
||||
That is, 25000 products computed on 1024-bit values.
|
||||
The output will compare the two timings, and recommend
|
||||
a setting for MP_SQUARE. It is off by default.
|
||||
|
||||
If you would like to use the mp_print() function (see above), be sure
|
||||
to define MP_IOFUNC in mpi-config.h. Many of the test drivers in the
|
||||
'tests' subdirectory expect this to be defined (although the test
|
||||
driver 'mpi-test' doesn't need it)
|
||||
|
||||
The Makefile which comes with the library should take care of building
|
||||
the library for you, if you have set the CC and CFLAGS variables at
|
||||
the top of the file appropriately. By default, they are set up to
|
||||
use the GNU C compiler:
|
||||
|
||||
CC=gcc
|
||||
CFLAGS=-ansi -pedantic -Wall -O2
|
||||
|
||||
If all goes well, the library should compile without warnings using
|
||||
this combination. You should, of course, make whatever adjustments
|
||||
you find necessary.
|
||||
|
||||
The MPI library distribution comes with several additional programs
|
||||
which are intended to demonstrate the use of the library, and provide
|
||||
a framework for testing it. There are a handful of test driver
|
||||
programs, in the files named 'mptest-X.c', where X is a digit. Also,
|
||||
there are some simple command-line utilities (in the 'utils'
|
||||
directory) for manipulating large numbers. These include:
|
||||
|
||||
basecvt.c A radix-conversion program, supporting bases from
|
||||
2 to 64 inclusive.
|
||||
|
||||
bbsrand.c A BBS (quadratic residue) pseudo-random number
|
||||
generator. The file 'bbsrand.c' is just the driver
|
||||
for the program; the real code lives in the files
|
||||
'bbs_rand.h' and 'bbs_rand.c'
|
||||
|
||||
dec2hex.c Converts decimal to hexadecimal
|
||||
|
||||
gcd.c Computes the greatest common divisor of two values.
|
||||
If invoked as 'xgcd', also computes constants x and
|
||||
y such that (a, b) = ax + by, in accordance with
|
||||
Bezout's identity.
|
||||
|
||||
hex2dec.c Converts hexadecimal to decimal
|
||||
|
||||
invmod.c Computes modular inverses
|
||||
|
||||
isprime.c Performs the Rabin-Miller probabilistic primality
|
||||
test on a number. Values which fail this test are
|
||||
definitely composite, and those which pass are very
|
||||
likely to be prime (although there are no guarantees)
|
||||
|
||||
lap.c Computes the order (least annihilating power) of
|
||||
a value v modulo m. Very dumb algorithm.
|
||||
|
||||
primegen.c Generates large (probable) primes.
|
||||
|
||||
prng.c A pseudo-random number generator based on the
|
||||
BBS generator code in 'bbs_rand.c'
|
||||
|
||||
sieve.c Implements the Sieve of Eratosthenes, using a big
|
||||
bitmap, to generate a list of prime numbers.
|
||||
|
||||
fact.c Computes the factorial of an arbitrary precision
|
||||
integer (iterative).
|
||||
|
||||
exptmod.c Computes arbitrary precision modular exponentiation
|
||||
from the command line (exptmod a b m -> a^b (mod m))
|
||||
|
||||
Most of these can be built from the Makefile that comes with the
|
||||
library. Try 'make tools', if your environment supports it. (If you
|
||||
are compiling on a Macintosh, I'm afraid you'll have to build them by
|
||||
hand -- fortunately, this is not difficult -- the library itself
|
||||
should compile just fine under Metrowerks CodeWarrior).
|
||||
|
||||
|
||||
Testing the Library
|
||||
-------------------
|
||||
|
||||
Automatic test vectors are included, in the form of a program called
|
||||
'mpi-test'. To build this program and run all the tests, simply
|
||||
invoke the shell script 'all-tests'. If all the tests pass, you
|
||||
should see a message:
|
||||
|
||||
All tests passed
|
||||
|
||||
If something went wrong, you'll get:
|
||||
|
||||
One or more tests failed.
|
||||
|
||||
If this happens, scan back through the preceding lines, to see which
|
||||
test failed. Any failure indicates a bug in the library, which needs
|
||||
to be fixed before it will give accurate results. If you get any such
|
||||
thing, please let me know, and I'll try to fix it. Please let me know
|
||||
what platform and compiler you were using, as well as which test
|
||||
failed. If a reason for failure was given, please send me that text
|
||||
as well.
|
||||
|
||||
If you're on a system such as the Macintosh, where the standard Unix
|
||||
build tools don't work, you can build the 'mpi-test' program manually,
|
||||
and run it by hand. This is tedious and obnoxious, sorry.
|
||||
|
||||
Further manual testing can be performed by building the manual testing
|
||||
programs, whose source is found in the 'tests' subdirectory. Each
|
||||
test is in a source file called 'mptest-X.c'. The Makefile contains a
|
||||
target to build all of them at once:
|
||||
|
||||
make tests
|
||||
|
||||
Read the comments at the top of each source file to see what the
|
||||
driver is supposed to test. You probably don't need to do this; these
|
||||
programs were only written to help me as I was developing the library.
|
||||
|
||||
The relevant files are:
|
||||
|
||||
mpi-test.c The source for the test driver
|
||||
|
||||
make-test-arrays A Perl script to generate some of the internal
|
||||
data structures used by mpi-test.c
|
||||
|
||||
test-arrays.txt The source file for make-test-arrays
|
||||
|
||||
all-tests A Bourne shell script which runs all the
|
||||
tests in the mpi-test suite
|
||||
|
||||
Running 'make mpi-test' should build the mpi-test program. If you
|
||||
cannot use make, here is what needs to be done:
|
||||
|
||||
(1) Use 'make-test-arrays' to generate the file 'test-info.c' from
|
||||
the 'test-arrays.txt' file. Since Perl can be found everywhere,
|
||||
even on the Macintosh, this should be no trouble. Under Unix,
|
||||
this looks like:
|
||||
|
||||
make-test-arrays test-arrays.txt > test-info.c
|
||||
|
||||
(2) Build the MPI library:
|
||||
|
||||
gcc -ansi -pedantic -Wall -c mpi.c
|
||||
|
||||
(3) Build the mpi-test program:
|
||||
|
||||
gcc -ansi -pedantic -Wall -o mpi-test mpi.o mpi-test.c
|
||||
|
||||
When you've got mpi-test, you can use 'all-tests' to run all the tests
|
||||
made available by mpi-test. If any of them fail, there should be a
|
||||
diagnostic indicating what went wrong. These are fairly high-level
|
||||
diagnostics, and won't really help you debug the problem; they're
|
||||
simply intended to help you isolate which function caused the problem.
|
||||
If you encounter a problem of this sort, feel free to e-mail me, and I
|
||||
will certainly attempt to help you debug it.
|
||||
|
||||
Note: Several of the tests hard-wired into 'mpi-test' operate under
|
||||
---- the assumption that you are using at least a 16-bit mp_digit
|
||||
type. If that is not true, several tests might fail, because
|
||||
of range problems with the maximum digit value.
|
||||
|
||||
If you are using an 8-bit digit, you will also need to
|
||||
modify the code for mp_read_raw(), which assumes that
|
||||
multiplication by 256 can be done with mp_mul_d(), a
|
||||
fact that fails when DIGIT_MAX is 255. You can replace
|
||||
the call with s_mp_lshd(), which will give you the same
|
||||
effect, and without doing as much work. :)
|
||||
|
||||
Acknowledgements:
|
||||
----------------
|
||||
|
||||
The algorithms used in this library were drawn primarily from Volume
|
||||
2 of Donald Knuth's magnum opus, _The Art of Computer Programming_,
|
||||
"Semi-Numerical Methods". Barrett's algorithm for modular reduction
|
||||
came from Menezes, Oorschot, and Vanstone's _Handbook of Applied
|
||||
Cryptography_, Chapter 14.
|
||||
|
||||
Thanks are due to Tom St. Denis, for finding an obnoxious sign-related
|
||||
bug in mp_read_raw() that made things break on platforms which use
|
||||
signed chars.
|
||||
|
||||
About the Author
|
||||
----------------
|
||||
|
||||
This software was written by Michael J. Fromberger. You can contact
|
||||
the author as follows:
|
||||
|
||||
E-mail: <sting@linguist.dartmouth.edu>
|
||||
|
||||
Postal: 8000 Cummings Hall, Thayer School of Engineering
|
||||
Dartmouth College, Hanover, New Hampshire, USA
|
||||
|
||||
PGP key: http://linguist.dartmouth.edu/~sting/keys/mjf.html
|
||||
9736 188B 5AFA 23D6 D6AA BE0D 5856 4525 289D 9907
|
||||
|
||||
Last updated: 16-Jan-2000
|
||||
@@ -1,115 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Michael J. Fromberger <sting@linguist.dartmouth.edu>.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1997
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
ECHO=/bin/echo
|
||||
MAKE=gmake
|
||||
|
||||
$ECHO "\n** Running unit tests for MPI library\n"
|
||||
|
||||
# Build the mpi-test program, which comprises all the unit tests for
|
||||
# the MPI library...
|
||||
|
||||
$ECHO "Bringing mpi-test up to date ... "
|
||||
if $MAKE mpi-test ; then
|
||||
:
|
||||
else
|
||||
$ECHO " "
|
||||
$ECHO "Make failed to build mpi-test."
|
||||
$ECHO " "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x mpi-test ] ; then
|
||||
$ECHO " "
|
||||
$ECHO "Cannot find 'mpi-test' program, testing cannot continue."
|
||||
$ECHO " "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the list of available test suites...
|
||||
tests=`mpi-test list | awk '{print $1}'`
|
||||
errs=0
|
||||
|
||||
# Run each test suite and check the result code of mpi-test
|
||||
for test in $tests ; do
|
||||
$ECHO "$test ... \c"
|
||||
if mpi-test $test ; then
|
||||
$ECHO "passed"
|
||||
else
|
||||
$ECHO "FAILED"
|
||||
errs=1
|
||||
fi
|
||||
done
|
||||
|
||||
# If any tests failed, we'll stop at this point
|
||||
if [ "$errs" = "0" ] ; then
|
||||
$ECHO "All unit tests passed"
|
||||
else
|
||||
$ECHO "One or more tests failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Now try to build the 'pi' program, and see if it can compute the
|
||||
# first thousand digits of pi correctly
|
||||
$ECHO "\n** Running other tests\n"
|
||||
|
||||
$ECHO "Bringing 'pi' up to date ... "
|
||||
if $MAKE pi ; then
|
||||
:
|
||||
else
|
||||
$ECHO "\nMake failed to build pi.\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x pi ] ; then
|
||||
$ECHO "\nCannot find 'pi' program; testing cannot continue.\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./pi 2000 > /tmp/pi.tmp.$$
|
||||
if cmp tests/pi2k.txt /tmp/pi.tmp.$$ ; then
|
||||
$ECHO "Okay! The pi test passes."
|
||||
else
|
||||
$ECHO "Oops! The pi test failed. :("
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f /tmp/pi.tmp.$$
|
||||
|
||||
exit 0
|
||||
|
||||
# Here there be dragons
|
||||
@@ -1,11 +0,0 @@
|
||||
Within this directory, each of the file listed below is licensed under
|
||||
the terms given in the file LICENSE-MPL, also in this directory.
|
||||
|
||||
basecvt.pod
|
||||
gcd.pod
|
||||
invmod.pod
|
||||
isprime.pod
|
||||
lap.pod
|
||||
mpi-test.pod
|
||||
prime.txt
|
||||
prng.pod
|
||||
@@ -1,32 +0,0 @@
|
||||
The contents of this file are subject to the Mozilla Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is the Netscape security libraries.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1994-2000 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the
|
||||
terms of the GNU General Public License Version 2 or later (the
|
||||
"GPL"), in which case the provisions of the GPL are applicable
|
||||
instead of those above. If you wish to allow use of your
|
||||
version of this file only under the terms of the GPL and not to
|
||||
allow others to use your version of this file under the MPL,
|
||||
indicate your decision by deleting the provisions above and
|
||||
replace them with the notice and other provisions required by
|
||||
the GPL. If you do not delete the provisions above, a recipient
|
||||
may use your version of this file under either the MPL or the
|
||||
GPL.
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
=head1 NAME
|
||||
|
||||
basecvt - radix conversion for arbitrary precision integers
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
basecvt <ibase> <obase> [values]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The B<basecvt> program is a command-line tool for converting integers
|
||||
of arbitrary precision from one radix to another. The current version
|
||||
supports radix values from 2 (binary) to 64, inclusive. The first two
|
||||
command line arguments specify the input and output radix, in base 10.
|
||||
Any further arguments are taken to be integers notated in the input
|
||||
radix, and these are converted to the output radix. The output is
|
||||
written, one integer per line, to standard output.
|
||||
|
||||
When reading integers, only digits considered "valid" for the input
|
||||
radix are considered. Processing of an integer terminates when an
|
||||
invalid input digit is encountered. So, for example, if you set the
|
||||
input radix to 10 and enter '10ACF', B<basecvt> would assume that you
|
||||
had entered '10' and ignore the rest of the string.
|
||||
|
||||
If no values are provided, no output is written, but the program
|
||||
simply terminates with a zero exit status. Error diagnostics are
|
||||
written to standard error in the event of out-of-range radix
|
||||
specifications. Regardless of the actual values of the input and
|
||||
output radix, the radix arguments are taken to be in base 10 (decimal)
|
||||
notation.
|
||||
|
||||
=head1 DIGITS
|
||||
|
||||
For radices from 2-10, standard ASCII decimal digits 0-9 are used for
|
||||
both input and output. For radices from 11-36, the ASCII letters A-Z
|
||||
are also included, following the convention used in hexadecimal. In
|
||||
this range, input is accepted in either upper or lower case, although
|
||||
on output only lower-case letters are used.
|
||||
|
||||
For radices from 37-62, the output includes both upper- and lower-case
|
||||
ASCII letters, and case matters. In this range, case is distinguished
|
||||
both for input and for output values.
|
||||
|
||||
For radices 63 and 64, the characters '+' (plus) and '/' (forward
|
||||
solidus) are also used. These are derived from the MIME base64
|
||||
encoding scheme. The overall encoding is not the same as base64,
|
||||
because the ASCII digits are used for the bottom of the range, and the
|
||||
letters are shifted upward; however, the output will consist of the
|
||||
same character set.
|
||||
|
||||
This input and output behaviour is inherited from the MPI library used
|
||||
by B<basecvt>, and so is not configurable at runtime.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
dec2hex(1), hex2dec(1)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Thayer School of Engineering, Hanover, New Hampshire, USA
|
||||
|
||||
$Date: 2000-07-14 00:44:31 $
|
||||
@@ -1,66 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Michael J. Fromberger <sting@linguist.dartmouth.edu>.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Netscape Communications Corporation
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# $Id: build,v 1.3 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
#
|
||||
|
||||
VERS="1.7p6"
|
||||
SECT="1"
|
||||
NAME="MPI Tools"
|
||||
|
||||
echo "Building manual pages ..."
|
||||
case $# in
|
||||
0)
|
||||
files=`ls *.pod`
|
||||
;;
|
||||
*)
|
||||
files=$*
|
||||
;;
|
||||
esac
|
||||
|
||||
for name in $files
|
||||
do
|
||||
echo -n "$name ... "
|
||||
# sname=`noext $name`
|
||||
sname=`basename $name .pod`
|
||||
pod2man --section="$SECT" --center="$NAME" --release="$VERS" $name > $sname.$SECT
|
||||
echo "(done)"
|
||||
done
|
||||
|
||||
echo "Finished building."
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
Division
|
||||
|
||||
This describes the division algorithm used by the MPI library.
|
||||
|
||||
Input: a, b; a > b
|
||||
Compute: Q, R; a = Qb + R
|
||||
|
||||
The input numbers are normalized so that the high-order digit of b is
|
||||
at least half the radix. This guarantees that we have a reasonable
|
||||
way to guess at the digits of the quotient (this method was taken from
|
||||
Knuth, vol. 2, with adaptations).
|
||||
|
||||
To normalize, test the high-order digit of b. If it is less than half
|
||||
the radix, multiply both a and b by d, where:
|
||||
|
||||
radix - 1
|
||||
d = -----------
|
||||
bmax + 1
|
||||
|
||||
...where bmax is the high-order digit of b. Otherwise, set d = 1.
|
||||
|
||||
Given normalize values for a and b, let the notation a[n] denote the
|
||||
nth digit of a. Let #a be the number of significant figures of a (not
|
||||
including any leading zeroes).
|
||||
|
||||
Let R = 0
|
||||
Let p = #a - 1
|
||||
|
||||
while(p >= 0)
|
||||
do
|
||||
R = (R * radix) + a[p]
|
||||
p = p - 1
|
||||
while(R < b and p >= 0)
|
||||
|
||||
if(R < b)
|
||||
break
|
||||
|
||||
q = (R[#R - 1] * radix) + R[#R - 2]
|
||||
q = q / b[#b - 1]
|
||||
|
||||
T = b * q
|
||||
|
||||
while(T > L)
|
||||
q = q - 1
|
||||
T = T - b
|
||||
endwhile
|
||||
|
||||
L = L - T
|
||||
|
||||
Q = (Q * radix) + q
|
||||
|
||||
endwhile
|
||||
|
||||
At this point, Q is the quotient, and R is the normalized remainder.
|
||||
To denormalize R, compute:
|
||||
|
||||
R = (R / d)
|
||||
|
||||
At this point, you are finished.
|
||||
|
||||
------------------------------------------------------------------
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is the MPI Arbitrary Precision Integer Arithmetic
|
||||
library.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Portions created by the Initial Developer are Copyright (C) 1998, 2000
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
$Id: div.txt,v 1.2 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
Exponentiation
|
||||
|
||||
For exponentiation, the MPI library uses a simple and fairly standard
|
||||
square-and-multiply method. The algorithm is this:
|
||||
|
||||
Input: a, b
|
||||
Output: a ** b
|
||||
|
||||
s = 1
|
||||
|
||||
while(b != 0)
|
||||
if(b is odd)
|
||||
s = s * a
|
||||
endif
|
||||
|
||||
b = b / 2
|
||||
|
||||
x = x * x
|
||||
endwhile
|
||||
|
||||
return s
|
||||
|
||||
The modular exponentiation is done the same way, except replacing:
|
||||
|
||||
s = s * a
|
||||
|
||||
with
|
||||
s = (s * a) mod m
|
||||
|
||||
and replacing
|
||||
|
||||
x = x * x
|
||||
|
||||
with
|
||||
|
||||
x = (x * x) mod m
|
||||
|
||||
Here is a sample exponentiation using the MPI library, as compared to
|
||||
the same problem solved by the Unix 'bc' program on my system:
|
||||
|
||||
Computation of 2,381,283 ** 235
|
||||
|
||||
'bc' says:
|
||||
|
||||
4385CA4A804D199FBEAD95FAD0796FAD0D0B51FC9C16743C45568C789666985DB719\
|
||||
4D90E393522F74C9601262C0514145A49F3B53D00983F95FDFCEA3D0043ECEF6227E\
|
||||
6FB59C924C3EE74447B359B5BF12A555D46CB819809EF423F004B55C587D6F0E8A55\
|
||||
4988036A42ACEF9F71459F97CEF6E574BD7373657111648626B1FF8EE15F663B2C0E\
|
||||
6BBE5082D4CDE8E14F263635AE8F35DB2C280819517BE388B5573B84C5A19C871685\
|
||||
FD408A6471F9D6AFAF5129A7548EAE926B40874B340285F44765BF5468CE20A13267\
|
||||
CD88CE6BC786ACED36EC7EA50F67FF27622575319068A332C3C0CB23E26FB55E26F4\
|
||||
5F732753A52B8E2FB4D4F42D894242613CA912A25486C3DEC9C66E5DB6182F6C1761\
|
||||
CF8CD0D255BE64B93836B27D452AE38F950EB98B517D4CF50D48F0165EF0CCCE1F5C\
|
||||
49BF18219FDBA0EEDD1A7E8B187B70C2BAED5EC5C6821EF27FAFB1CFF70111C52235\
|
||||
5E948B93A015AA1AE152B110BB5658CB14D3E45A48BFE7F082C1182672A455A695CD\
|
||||
A1855E8781E625F25B41B516E77F589FA420C3B058861EA138CF7A2C58DB3C7504FD\
|
||||
D29554D78237834CC5AE710D403CC4F6973D5012B7E117A8976B14A0B5AFA889BD47\
|
||||
92C461F0F96116F00A97AE9E83DC5203680CAF9A18A062566C145650AB86BE4F907F\
|
||||
A9F7AB4A700B29E1E5BACCD6DCBFA513E10832815F710807EED2E279081FEC61D619\
|
||||
AB270BEB3D3A1787B35A9DD41A8766CF21F3B5C693B3BAB1C2FA14A4ED202BC35743\
|
||||
E5CBE2391624D4F8C9BFBBC78D69764E7C6C5B11BF005677BFAD17D9278FFC1F158F\
|
||||
1B3683FF7960FA0608103792C4163DC0AF3E06287BB8624F8FE3A0FFBDF82ACECA2F\
|
||||
CFFF2E1AC93F3CA264A1B
|
||||
|
||||
MPI says:
|
||||
|
||||
4385CA4A804D199FBEAD95FAD0796FAD0D0B51FC9C16743C45568C789666985DB719\
|
||||
4D90E393522F74C9601262C0514145A49F3B53D00983F95FDFCEA3D0043ECEF6227E\
|
||||
6FB59C924C3EE74447B359B5BF12A555D46CB819809EF423F004B55C587D6F0E8A55\
|
||||
4988036A42ACEF9F71459F97CEF6E574BD7373657111648626B1FF8EE15F663B2C0E\
|
||||
6BBE5082D4CDE8E14F263635AE8F35DB2C280819517BE388B5573B84C5A19C871685\
|
||||
FD408A6471F9D6AFAF5129A7548EAE926B40874B340285F44765BF5468CE20A13267\
|
||||
CD88CE6BC786ACED36EC7EA50F67FF27622575319068A332C3C0CB23E26FB55E26F4\
|
||||
5F732753A52B8E2FB4D4F42D894242613CA912A25486C3DEC9C66E5DB6182F6C1761\
|
||||
CF8CD0D255BE64B93836B27D452AE38F950EB98B517D4CF50D48F0165EF0CCCE1F5C\
|
||||
49BF18219FDBA0EEDD1A7E8B187B70C2BAED5EC5C6821EF27FAFB1CFF70111C52235\
|
||||
5E948B93A015AA1AE152B110BB5658CB14D3E45A48BFE7F082C1182672A455A695CD\
|
||||
A1855E8781E625F25B41B516E77F589FA420C3B058861EA138CF7A2C58DB3C7504FD\
|
||||
D29554D78237834CC5AE710D403CC4F6973D5012B7E117A8976B14A0B5AFA889BD47\
|
||||
92C461F0F96116F00A97AE9E83DC5203680CAF9A18A062566C145650AB86BE4F907F\
|
||||
A9F7AB4A700B29E1E5BACCD6DCBFA513E10832815F710807EED2E279081FEC61D619\
|
||||
AB270BEB3D3A1787B35A9DD41A8766CF21F3B5C693B3BAB1C2FA14A4ED202BC35743\
|
||||
E5CBE2391624D4F8C9BFBBC78D69764E7C6C5B11BF005677BFAD17D9278FFC1F158F\
|
||||
1B3683FF7960FA0608103792C4163DC0AF3E06287BB8624F8FE3A0FFBDF82ACECA2F\
|
||||
CFFF2E1AC93F3CA264A1B
|
||||
|
||||
Diff says:
|
||||
% diff bc.txt mp.txt
|
||||
%
|
||||
|
||||
------------------------------------------------------------------
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is the MPI Arbitrary Precision Integer Arithmetic
|
||||
library.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Portions created by the Initial Developer are Copyright (C) 1998, 2000
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
$Id: expt.txt,v 1.2 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
=head1 NAME
|
||||
|
||||
gcd - compute greatest common divisor of two integers
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
gcd <a> <b>
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The B<gcd> program computes the greatest common divisor of two
|
||||
arbitrary-precision integers I<a> and I<b>. The result is written in
|
||||
standard decimal notation to the standard output.
|
||||
|
||||
If I<b> is zero, B<gcd> will print an error message and exit.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
invmod(1), isprime(1), lap(1)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Thayer School of Engineering, Hanover, New Hampshire, USA
|
||||
|
||||
$Date: 2000-07-14 00:44:32 $
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
=head1 NAME
|
||||
|
||||
invmod - compute modular inverse of an integer
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
invmod <a> <m>
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The B<invmod> program computes the inverse of I<a>, modulo I<m>, if
|
||||
that inverse exists. Both I<a> and I<m> are arbitrary-precision
|
||||
integers in decimal notation. The result is written in standard
|
||||
decimal notation to the standard output.
|
||||
|
||||
If there is no inverse, the message:
|
||||
|
||||
No inverse
|
||||
|
||||
...will be printed to the standard output (an inverse exists if and
|
||||
only if the greatest common divisor of I<a> and I<m> is 1).
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
gcd(1), isprime(1), lap(1)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Thayer School of Engineering, Hanover, New Hampshire, USA
|
||||
|
||||
$Date: 2000-07-14 00:44:33 $
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
=head1 NAME
|
||||
|
||||
isprime - probabilistic primality testing
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
isprime <a>
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The B<isprime> program attempts to determine whether the arbitrary
|
||||
precision integer I<a> is prime. It first tests I<a> for divisibility
|
||||
by the first 170 or so small primes, and assuming I<a> is not
|
||||
divisible by any of these, applies 15 iterations of the Rabin-Miller
|
||||
probabilistic primality test.
|
||||
|
||||
If the program discovers that the number is composite, it will print:
|
||||
|
||||
Not prime (reason)
|
||||
|
||||
Where I<reason> is either:
|
||||
|
||||
divisible by small prime x
|
||||
|
||||
Or:
|
||||
|
||||
failed nth pseudoprime test
|
||||
|
||||
In the first case, I<x> indicates the first small prime factor that
|
||||
was found. In the second case, I<n> indicates which of the
|
||||
pseudoprime tests failed (numbered from 1)
|
||||
|
||||
If this happens, the number is definitely not prime. However, if the
|
||||
number succeeds, this message results:
|
||||
|
||||
Probably prime, 1 in 4^15 chance of false positive
|
||||
|
||||
If this happens, the number is prime with very high probability, but
|
||||
its primality has not been absolutely proven, only demonstrated to a
|
||||
very convincing degree.
|
||||
|
||||
The value I<a> can be input in standard decimal notation, or, if it is
|
||||
prefixed with I<Ox>, it will be read as hexadecimal.
|
||||
|
||||
=head1 ENVIRONMENT
|
||||
|
||||
You can control how many iterations of Rabin-Miller are performed on
|
||||
the candidate number by setting the I<RM_TESTS> environment variable
|
||||
to an integer value before starting up B<isprime>. This will change
|
||||
the output slightly if the number passes all the tests.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
gcd(1), invmod(1), lap(1)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Thayer School of Engineering, Hanover, New Hampshire, USA
|
||||
|
||||
$Date: 2000-07-14 00:44:33 $
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
=head1 NAME
|
||||
|
||||
lap - compute least annihilating power of a number
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
lap <a> <m>
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The B<lap> program computes the order of I<a> modulo I<m>, for
|
||||
arbitrary precision integers I<a> and I<m>. The B<order> of I<a>
|
||||
modulo I<m> is defined as the smallest positive value I<n> for which
|
||||
I<a> raised to the I<n>th power, modulo I<m>, is equal to 1. The
|
||||
order may not exist, if I<m> is composite.
|
||||
|
||||
=head1 RESTRICTIONS
|
||||
|
||||
This program is very slow, especially for large moduli. It is
|
||||
intended as a way to help find primitive elements in a modular field,
|
||||
but it does not do so in a particularly inefficient manner. It was
|
||||
written simply to help verify that a particular candidate does not
|
||||
have an obviously short cycle mod I<m>.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
gcd(1), invmod(1), isprime(1)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Thayer School of Engineering, Hanover, New Hampshire, USA
|
||||
|
||||
$Date: 2000-07-14 00:44:34 $
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
=head1 NAME
|
||||
|
||||
mpi-test - automated test program for MPI library
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
mpi-test <suite-name> [quiet]
|
||||
mpi-test list
|
||||
mpi-test help
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The B<mpi-test> program is a general unit test driver for the MPI
|
||||
library. It is used to verify that the library works as it is
|
||||
supposed to on your architecture. As with most such things, passing
|
||||
all the tests in B<mpi-test> does not guarantee the code is correct,
|
||||
but if any of them fail, there are certainly problems.
|
||||
|
||||
Each major function of the library can be tested individually. For a
|
||||
list of the test suites understood by B<mpi-test>, run it with the
|
||||
I<list> command line option:
|
||||
|
||||
mpi-test list
|
||||
|
||||
This will display a list of the available test suites and a brief
|
||||
synopsis of what each one does. For a brief overview of this
|
||||
document, run B<mpi-test> I<help>.
|
||||
|
||||
B<mpi-test> exits with a zero status if the selected test succeeds, or
|
||||
a nonzero status if it fails. If a I<suite-name> which is not
|
||||
understood by B<mpi-test> is given, a diagnostic is printed to the
|
||||
standard error, and the program exits with a result code of 2. If a
|
||||
test fails, the result code will be 1, and a diagnostic is ordinarily
|
||||
printed to the standard error. However, if the I<quiet> option is
|
||||
provided, these diagnostics will be suppressed.
|
||||
|
||||
=head1 RESTRICTIONS
|
||||
|
||||
Only a few canned test cases are provided. The solutions have been
|
||||
verified using the GNU bc(1) program, so bugs there may cause problems
|
||||
here; however, this is very unlikely, so if a test fails, it is almost
|
||||
certainly my fault, not bc(1)'s.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Thayer School of Engineering, Hanover, New Hampshire, USA
|
||||
|
||||
$Date: 2000-07-14 00:44:34 $
|
||||
@@ -1,114 +0,0 @@
|
||||
Multiplication
|
||||
|
||||
This describes the multiplication algorithm used by the MPI library.
|
||||
|
||||
This is basically a standard "schoolbook" algorithm. It is slow --
|
||||
O(mn) for m = #a, n = #b -- but easy to implement and verify.
|
||||
Basically, we run two nested loops, as illustrated here (R is the
|
||||
radix):
|
||||
|
||||
k = 0
|
||||
for j <- 0 to (#b - 1)
|
||||
for i <- 0 to (#a - 1)
|
||||
w = (a[j] * b[i]) + k + c[i+j]
|
||||
c[i+j] = w mod R
|
||||
k = w div R
|
||||
endfor
|
||||
c[i+j] = k;
|
||||
k = 0;
|
||||
endfor
|
||||
|
||||
It is necessary that 'w' have room for at least two radix R digits.
|
||||
The product of any two digits in radix R is at most:
|
||||
|
||||
(R - 1)(R - 1) = R^2 - 2R + 1
|
||||
|
||||
Since a two-digit radix-R number can hold R^2 - 1 distinct values,
|
||||
this insures that the product will fit into the two-digit register.
|
||||
|
||||
To insure that two digits is enough for w, we must also show that
|
||||
there is room for the carry-in from the previous multiplication, and
|
||||
the current value of the product digit that is being recomputed.
|
||||
Assuming each of these may be as big as R - 1 (and no larger,
|
||||
certainly), two digits will be enough if and only if:
|
||||
|
||||
(R^2 - 2R + 1) + 2(R - 1) <= R^2 - 1
|
||||
|
||||
Solving this equation shows that, indeed, this is the case:
|
||||
|
||||
R^2 - 2R + 1 + 2R - 2 <= R^2 - 1
|
||||
|
||||
R^2 - 1 <= R^2 - 1
|
||||
|
||||
This suggests that a good radix would be one more than the largest
|
||||
value that can be held in half a machine word -- so, for example, as
|
||||
in this implementation, where we used a radix of 65536 on a machine
|
||||
with 4-byte words. Another advantage of a radix of this sort is that
|
||||
binary-level operations are easy on numbers in this representation.
|
||||
|
||||
Here's an example multiplication worked out longhand in radix-10,
|
||||
using the above algorithm:
|
||||
|
||||
a = 999
|
||||
b = x 999
|
||||
-------------
|
||||
p = 98001
|
||||
|
||||
w = (a[jx] * b[ix]) + kin + c[ix + jx]
|
||||
c[ix+jx] = w % RADIX
|
||||
k = w / RADIX
|
||||
product
|
||||
ix jx a[jx] b[ix] kin w c[i+j] kout 000000
|
||||
0 0 9 9 0 81+0+0 1 8 000001
|
||||
0 1 9 9 8 81+8+0 9 8 000091
|
||||
0 2 9 9 8 81+8+0 9 8 000991
|
||||
8 0 008991
|
||||
1 0 9 9 0 81+0+9 0 9 008901
|
||||
1 1 9 9 9 81+9+9 9 9 008901
|
||||
1 2 9 9 9 81+9+8 8 9 008901
|
||||
9 0 098901
|
||||
2 0 9 9 0 81+0+9 0 9 098001
|
||||
2 1 9 9 9 81+9+8 8 9 098001
|
||||
2 2 9 9 9 81+9+9 9 9 098001
|
||||
|
||||
------------------------------------------------------------------
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is the MPI Arbitrary Precision Integer Arithmetic
|
||||
library.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Portions created by the Initial Developer are Copyright (C) 1998, 2000
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
$Id: mul.txt,v 1.2 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
This file describes how pi is computed by the program in 'pi.c' (see
|
||||
the utils subdirectory).
|
||||
|
||||
Basically, we use Machin's formula, which is what everyone in the
|
||||
world uses as a simple method for computing approximations to pi.
|
||||
This works for up to a few thousand digits without too much effort.
|
||||
Beyond that, though, it gets too slow.
|
||||
|
||||
Machin's formula states:
|
||||
|
||||
pi := 16 * arctan(1/5) - 4 * arctan(1/239)
|
||||
|
||||
We compute this in integer arithmetic by first multiplying everything
|
||||
through by 10^d, where 'd' is the number of digits of pi we wanted to
|
||||
compute. It turns out, the last few digits will be wrong, but the
|
||||
number that are wrong is usually very small (ordinarly only 2-3).
|
||||
Having done this, we compute the arctan() function using the formula:
|
||||
|
||||
1 1 1 1 1
|
||||
arctan(1/x) := --- - ----- + ----- - ----- + ----- - ...
|
||||
x 3 x^3 5 x^5 7 x^7 9 x^9
|
||||
|
||||
This is done iteratively by computing the first term manually, and
|
||||
then iteratively dividing x^2 and k, where k = 3, 5, 7, ... out of the
|
||||
current figure. This is then added to (or subtracted from) a running
|
||||
sum, as appropriate. The iteration continues until we overflow our
|
||||
available precision and the current figure goes to zero under integer
|
||||
division. At that point, we're finished.
|
||||
|
||||
Actually, we get a couple extra bits of precision out of the fact that
|
||||
we know we're computing y * arctan(1/x), by setting up the multiplier
|
||||
as:
|
||||
|
||||
y * 10^d
|
||||
|
||||
... instead of just 10^d. There is also a bit of cleverness in how
|
||||
the loop is constructed, to avoid special-casing the first term.
|
||||
Check out the code for arctan() in 'pi.c', if you are interested in
|
||||
seeing how it is set up.
|
||||
|
||||
Thanks to Jason P. for this algorithm, which I assembled from notes
|
||||
and programs found on his cool "Pile of Pi Programs" page, at:
|
||||
|
||||
http://www.isr.umd.edu/~jasonp/pipage.html
|
||||
|
||||
Thanks also to Henrik Johansson <Henrik.Johansson@Nexus.Comm.SE>, from
|
||||
whose pi program I borrowed the clever idea of pre-multiplying by x in
|
||||
order to avoid a special case on the loop iteration.
|
||||
|
||||
------------------------------------------------------------------
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is the MPI Arbitrary Precision Integer Arithmetic
|
||||
library.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Portions created by the Initial Developer are Copyright (C) 1998, 2000
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
$Id: pi.txt,v 1.2 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,41 +0,0 @@
|
||||
=head1 NAME
|
||||
|
||||
prng - pseudo-random number generator
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
prng [count]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<Prng> generates 32-bit pseudo-random integers using the
|
||||
Blum-Blum-Shub (BBS) quadratic residue generator. It is seeded using
|
||||
the standard C library's rand() function, which itself seeded from the
|
||||
system clock and the process ID number. Thus, the values generated
|
||||
are not particularly useful for cryptographic applications, but they
|
||||
are in general much better than the typical output of the usual
|
||||
multiplicative congruency generator used by most runtime libraries.
|
||||
|
||||
You may optionally specify how many random values should be generated
|
||||
by giving a I<count> argument on the command line. If you do not
|
||||
specify a count, only one random value will be generated. The results
|
||||
are output to the standard output in decimal notation, one value per
|
||||
line.
|
||||
|
||||
=head1 RESTRICTIONS
|
||||
|
||||
As stated above, B<prng> uses the C library's rand() function to seed
|
||||
the generator, so it is not terribly suitable for cryptographic
|
||||
applications. Also note that each time you run the program, a new
|
||||
seed is generated, so it is better to run it once with a I<count>
|
||||
parameter than it is to run it multiple times to generate several
|
||||
values.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Copyright (C) 1998 Michael J. Fromberger, All Rights Reserved
|
||||
Thayer School of Engineering, Dartmouth College, Hanover, NH USA
|
||||
|
||||
$Date: 2000-07-14 00:44:36 $
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
Modular Reduction
|
||||
|
||||
Usually, modular reduction is accomplished by long division, using the
|
||||
mp_div() or mp_mod() functions. However, when performing modular
|
||||
exponentiation, you spend a lot of time reducing by the same modulus
|
||||
again and again. For this purpose, doing a full division for each
|
||||
multiplication is quite inefficient.
|
||||
|
||||
For this reason, the mp_exptmod() function does not perform modular
|
||||
reductions in the usual way, but instead takes advantage of an
|
||||
algorithm due to Barrett, as described by Menezes, Oorschot and
|
||||
VanStone in their book _Handbook of Applied Cryptography_, published
|
||||
by the CRC Press (see Chapter 14 for details). This method reduces
|
||||
most of the computation of reduction to efficient shifting and masking
|
||||
operations, and avoids the multiple-precision division entirely.
|
||||
|
||||
Here is a brief synopsis of Barrett reduction, as it is implemented in
|
||||
this library.
|
||||
|
||||
Let b denote the radix of the computation (one more than the maximum
|
||||
value that can be denoted by an mp_digit). Let m be the modulus, and
|
||||
let k be the number of significant digits of m. Let x be the value to
|
||||
be reduced modulo m. By the Division Theorem, there exist unique
|
||||
integers Q and R such that:
|
||||
|
||||
x = Qm + R, 0 <= R < m
|
||||
|
||||
Barrett reduction takes advantage of the fact that you can easily
|
||||
approximate Q to within two, given a value M such that:
|
||||
|
||||
2k
|
||||
b
|
||||
M = floor( ----- )
|
||||
m
|
||||
|
||||
Computation of M requires a full-precision division step, so if you
|
||||
are only doing a single reduction by m, you gain no advantage.
|
||||
However, when multiple reductions by the same m are required, this
|
||||
division need only be done once, beforehand. Using this, we can use
|
||||
the following equation to compute Q', an approximation of Q:
|
||||
|
||||
x
|
||||
floor( ------ ) M
|
||||
k-1
|
||||
b
|
||||
Q' = floor( ----------------- )
|
||||
k+1
|
||||
b
|
||||
|
||||
The divisions by b^(k-1) and b^(k+1) and the floor() functions can be
|
||||
efficiently implemented with shifts and masks, leaving only a single
|
||||
multiplication to be performed to get this approximation. It can be
|
||||
shown that Q - 2 <= Q' <= Q, so in the worst case, we can get out with
|
||||
two additional subtractions to bring the value into line with the
|
||||
actual value of Q.
|
||||
|
||||
Once we've got Q', we basically multiply that by m and subtract from
|
||||
x, yielding:
|
||||
|
||||
x - Q'm = Qm + R - Q'm
|
||||
|
||||
Since we know the constraint on Q', this is one of:
|
||||
|
||||
R
|
||||
m + R
|
||||
2m + R
|
||||
|
||||
Since R < m by the Division Theorem, we can simply subtract off m
|
||||
until we get a value in the correct range, which will happen with no
|
||||
more than 2 subtractions:
|
||||
|
||||
v = x - Q'm
|
||||
|
||||
while(v >= m)
|
||||
v = v - m
|
||||
endwhile
|
||||
|
||||
|
||||
In random performance trials, modular exponentiation using this method
|
||||
of reduction gave around a 40% speedup over using the division for
|
||||
reduction.
|
||||
|
||||
------------------------------------------------------------------
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is the MPI Arbitrary Precision Integer Arithmetic
|
||||
library.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Portions created by the Initial Developer are Copyright (C) 1998, 2000
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
$Id: redux.txt,v 1.2 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
@@ -1,87 +0,0 @@
|
||||
Square Root
|
||||
|
||||
A simple iterative algorithm is used to compute the greatest integer
|
||||
less than or equal to the square root. Essentially, this is Newton's
|
||||
linear approximation, computed by finding successive values of the
|
||||
equation:
|
||||
|
||||
x[k]^2 - V
|
||||
x[k+1] = x[k] - ------------
|
||||
2 x[k]
|
||||
|
||||
...where V is the value for which the square root is being sought. In
|
||||
essence, what is happening here is that we guess a value for the
|
||||
square root, then figure out how far off we were by squaring our guess
|
||||
and subtracting the target. Using this value, we compute a linear
|
||||
approximation for the error, and adjust the "guess". We keep doing
|
||||
this until the precision gets low enough that the above equation
|
||||
yields a quotient of zero. At this point, our last guess is one
|
||||
greater than the square root we're seeking.
|
||||
|
||||
The initial guess is computed by dividing V by 4, which is a heuristic
|
||||
I have found to be fairly good on average. This also has the
|
||||
advantage of being very easy to compute efficiently, even for large
|
||||
values.
|
||||
|
||||
So, the resulting algorithm works as follows:
|
||||
|
||||
x = V / 4 /* compute initial guess */
|
||||
|
||||
loop
|
||||
t = (x * x) - V /* Compute absolute error */
|
||||
u = 2 * x /* Adjust by tangent slope */
|
||||
t = t / u
|
||||
|
||||
/* Loop is done if error is zero */
|
||||
if(t == 0)
|
||||
break
|
||||
|
||||
/* Adjust guess by error term */
|
||||
x = x - t
|
||||
end
|
||||
|
||||
x = x - 1
|
||||
|
||||
The result of the computation is the value of x.
|
||||
|
||||
------------------------------------------------------------------
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is the MPI Arbitrary Precision Integer Arithmetic
|
||||
library.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Portions created by the Initial Developer are Copyright (C) 1998, 2000
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
$Id: sqrt.txt,v 1.2 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
Squaring Algorithm
|
||||
|
||||
When you are squaring a value, you can take advantage of the fact that
|
||||
half the multiplications performed by the more general multiplication
|
||||
algorithm (see 'mul.txt' for a description) are redundant when the
|
||||
multiplicand equals the multiplier.
|
||||
|
||||
In particular, the modified algorithm is:
|
||||
|
||||
k = 0
|
||||
for j <- 0 to (#a - 1)
|
||||
w = c[2*j] + (a[j] ^ 2);
|
||||
k = w div R
|
||||
|
||||
for i <- j+1 to (#a - 1)
|
||||
w = (2 * a[j] * a[i]) + k + c[i+j]
|
||||
c[i+j] = w mod R
|
||||
k = w div R
|
||||
endfor
|
||||
c[i+j] = k;
|
||||
k = 0;
|
||||
endfor
|
||||
|
||||
On the surface, this looks identical to the multiplication algorithm;
|
||||
however, note the following differences:
|
||||
|
||||
- precomputation of the leading term in the outer loop
|
||||
|
||||
- i runs from j+1 instead of from zero
|
||||
|
||||
- doubling of a[i] * a[j] in the inner product
|
||||
|
||||
Unfortunately, the construction of the inner product is such that we
|
||||
need more than two digits to represent the inner product, in some
|
||||
cases. In a C implementation, this means that some gymnastics must be
|
||||
performed in order to handle overflow, for which C has no direct
|
||||
abstraction. We do this by observing the following:
|
||||
|
||||
If we have multiplied a[i] and a[j], and the product is more than half
|
||||
the maximum value expressible in two digits, then doubling this result
|
||||
will overflow into a third digit. If this occurs, we take note of the
|
||||
overflow, and double it anyway -- C integer arithmetic ignores
|
||||
overflow, so the two digits we get back should still be valid, modulo
|
||||
the overflow.
|
||||
|
||||
Having doubled this value, we now have to add in the remainders and
|
||||
the digits already computed by earlier steps. If we did not overflow
|
||||
in the previous step, we might still cause an overflow here. That
|
||||
will happen whenever the maximum value expressible in two digits, less
|
||||
the amount we have to add, is greater than the result of the previous
|
||||
step. Thus, the overflow computation is:
|
||||
|
||||
|
||||
u = 0
|
||||
w = a[i] * a[j]
|
||||
|
||||
if(w > (R - 1)/ 2)
|
||||
u = 1;
|
||||
|
||||
w = w * 2
|
||||
v = c[i + j] + k
|
||||
|
||||
if(u == 0 && (R - 1 - v) < w)
|
||||
u = 1
|
||||
|
||||
If there is an overflow, u will be 1, otherwise u will be 0. The rest
|
||||
of the parameters are the same as they are in the above description.
|
||||
|
||||
------------------------------------------------------------------
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is the MPI Arbitrary Precision Integer Arithmetic
|
||||
library.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Portions created by the Initial Developer are Copyright (C) 1998, 2000
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
$Id: square.txt,v 1.2 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
|
||||
|
||||
@@ -1,250 +0,0 @@
|
||||
MPI Library Timing Tests
|
||||
|
||||
Hardware/OS
|
||||
(A) SGI O2 1 x MIPS R10000 250MHz IRIX 6.5.3
|
||||
(B) IBM RS/6000 43P-240 1 x PowerPC 603e 223MHz AIX 4.3
|
||||
(C) Dell GX1/L+ 1 x Pentium III 550MHz Linux 2.2.12-20
|
||||
(D) PowerBook G3 1 x PowerPC 750 266MHz LinuxPPC 2.2.6-15apmac
|
||||
(E) PowerBook G3 1 x PowerPC 750 266MHz MacOS 8.5.1
|
||||
(F) PowerBook G3 1 x PowerPC 750 400MHz MacOS 9.0.2
|
||||
|
||||
Compiler
|
||||
(1) MIPSpro C 7.2.1 -O3 optimizations
|
||||
(2) GCC 2.95.1 -O3 optimizations
|
||||
(3) IBM AIX xlc -O3 optimizations (version unknown)
|
||||
(4) EGCS 2.91.66 -O3 optimizations
|
||||
(5) Metrowerks CodeWarrior 5.0 C, all optimizations
|
||||
(6) MIPSpro C 7.30 -O3 optimizations
|
||||
(7) same as (6), with optimized libmalloc.so
|
||||
|
||||
Timings are given in seconds, computed using the C library's clock()
|
||||
function. The first column gives the hardware and compiler
|
||||
configuration used for the test. The second column indicates the
|
||||
number of tests that were aggregated to get the statistics for that
|
||||
size. These were compiled using 16 bit digits.
|
||||
|
||||
Source data were generated randomly using a fixed seed, so they should
|
||||
be internally consistent, but may vary on different systems depending
|
||||
on the C library. Also, since the resolution of the timer accessed by
|
||||
clock() varies, there may be some variance in the precision of these
|
||||
measurements.
|
||||
|
||||
Prime Generation (primegen)
|
||||
|
||||
128 bits:
|
||||
A1 200 min=0.03, avg=0.19, max=0.72, sum=38.46
|
||||
A2 200 min=0.02, avg=0.16, max=0.62, sum=32.55
|
||||
B3 200 min=0.01, avg=0.07, max=0.22, sum=13.29
|
||||
C4 200 min=0.00, avg=0.03, max=0.20, sum=6.14
|
||||
D4 200 min=0.00, avg=0.05, max=0.33, sum=9.70
|
||||
A6 200 min=0.01, avg=0.09, max=0.36, sum=17.48
|
||||
A7 200 min=0.00, avg=0.05, max=0.24, sum=10.07
|
||||
|
||||
192 bits:
|
||||
A1 200 min=0.05, avg=0.45, max=3.13, sum=89.96
|
||||
A2 200 min=0.04, avg=0.39, max=2.61, sum=77.55
|
||||
B3 200 min=0.02, avg=0.18, max=1.25, sum=36.97
|
||||
C4 200 min=0.01, avg=0.09, max=0.33, sum=18.24
|
||||
D4 200 min=0.02, avg=0.15, max=0.54, sum=29.63
|
||||
A6 200 min=0.02, avg=0.24, max=1.70, sum=47.84
|
||||
A7 200 min=0.01, avg=0.15, max=1.05, sum=30.88
|
||||
|
||||
256 bits:
|
||||
A1 200 min=0.08, avg=0.92, max=6.13, sum=184.79
|
||||
A2 200 min=0.06, avg=0.76, max=5.03, sum=151.11
|
||||
B3 200 min=0.04, avg=0.41, max=2.68, sum=82.35
|
||||
C4 200 min=0.02, avg=0.19, max=0.69, sum=37.91
|
||||
D4 200 min=0.03, avg=0.31, max=1.15, sum=63.00
|
||||
A6 200 min=0.04, avg=0.48, max=3.13, sum=95.46
|
||||
A7 200 min=0.03, avg=0.37, max=2.36, sum=73.60
|
||||
|
||||
320 bits:
|
||||
A1 200 min=0.11, avg=1.59, max=6.14, sum=318.81
|
||||
A2 200 min=0.09, avg=1.27, max=4.93, sum=254.03
|
||||
B3 200 min=0.07, avg=0.82, max=3.13, sum=163.80
|
||||
C4 200 min=0.04, avg=0.44, max=1.91, sum=87.59
|
||||
D4 200 min=0.06, avg=0.73, max=3.22, sum=146.73
|
||||
A6 200 min=0.07, avg=0.93, max=3.50, sum=185.01
|
||||
A7 200 min=0.05, avg=0.76, max=2.94, sum=151.78
|
||||
|
||||
384 bits:
|
||||
A1 200 min=0.16, avg=2.69, max=11.41, sum=537.89
|
||||
A2 200 min=0.13, avg=2.15, max=9.03, sum=429.14
|
||||
B3 200 min=0.11, avg=1.54, max=6.49, sum=307.78
|
||||
C4 200 min=0.06, avg=0.81, max=4.84, sum=161.13
|
||||
D4 200 min=0.10, avg=1.38, max=8.31, sum=276.81
|
||||
A6 200 min=0.11, avg=1.73, max=7.36, sum=345.55
|
||||
A7 200 min=0.09, avg=1.46, max=6.12, sum=292.02
|
||||
|
||||
448 bits:
|
||||
A1 200 min=0.23, avg=3.36, max=15.92, sum=672.63
|
||||
A2 200 min=0.17, avg=2.61, max=12.25, sum=522.86
|
||||
B3 200 min=0.16, avg=2.10, max=9.83, sum=420.86
|
||||
C4 200 min=0.09, avg=1.44, max=7.64, sum=288.36
|
||||
D4 200 min=0.16, avg=2.50, max=13.29, sum=500.17
|
||||
A6 200 min=0.15, avg=2.31, max=10.81, sum=461.58
|
||||
A7 200 min=0.14, avg=2.03, max=9.53, sum=405.16
|
||||
|
||||
512 bits:
|
||||
A1 200 min=0.30, avg=6.12, max=22.18, sum=1223.35
|
||||
A2 200 min=0.25, avg=4.67, max=16.90, sum=933.18
|
||||
B3 200 min=0.23, avg=4.13, max=14.94, sum=825.45
|
||||
C4 200 min=0.13, avg=2.08, max=9.75, sum=415.22
|
||||
D4 200 min=0.24, avg=4.04, max=20.18, sum=808.11
|
||||
A6 200 min=0.22, avg=4.47, max=16.19, sum=893.83
|
||||
A7 200 min=0.20, avg=4.03, max=14.65, sum=806.02
|
||||
|
||||
Modular Exponentation (metime)
|
||||
|
||||
The following results are aggregated from 200 pseudo-randomly
|
||||
generated tests, based on a fixed seed.
|
||||
|
||||
base, exponent, and modulus size (bits)
|
||||
P/C 128 192 256 320 384 448 512 640 768 896 1024
|
||||
------- -----------------------------------------------------------------
|
||||
A1 0.015 0.027 0.047 0.069 0.098 0.133 0.176 0.294 0.458 0.680 1.040
|
||||
A2 0.013 0.024 0.037 0.053 0.077 0.102 0.133 0.214 0.326 0.476 0.668
|
||||
B3 0.005 0.011 0.021 0.036 0.056 0.084 0.121 0.222 0.370 0.573 0.840
|
||||
C4 0.002 0.006 0.011 0.020 0.032 0.048 0.069 0.129 0.223 0.344 0.507
|
||||
D4 0.004 0.010 0.019 0.034 0.056 0.085 0.123 0.232 0.390 0.609 0.899
|
||||
E5 0.007 0.015 0.031 0.055 0.088 0.133 0.183 0.342 0.574 0.893 1.317
|
||||
A6 0.008 0.016 0.038 0.042 0.064 0.093 0.133 0.239 0.393 0.604 0.880
|
||||
A7 0.005 0.011 0.020 0.036 0.056 0.083 0.121 0.223 0.374 0.583 0.855
|
||||
|
||||
Multiplication and Squaring tests, (mulsqr)
|
||||
|
||||
The following results are aggregated from 500000 pseudo-randomly
|
||||
generated tests, based on a per-run wall-clock seed. Times are given
|
||||
in seconds, except where indicated in microseconds (us).
|
||||
|
||||
(A1)
|
||||
|
||||
bits multiply square ad percent time/mult time/square
|
||||
64 9.33 9.15 > 1.9 18.7us 18.3us
|
||||
128 10.88 10.44 > 4.0 21.8us 20.9us
|
||||
192 13.30 11.89 > 10.6 26.7us 23.8us
|
||||
256 14.88 12.64 > 15.1 29.8us 25.3us
|
||||
320 18.64 15.01 > 19.5 37.3us 30.0us
|
||||
384 23.11 17.70 > 23.4 46.2us 35.4us
|
||||
448 28.28 20.88 > 26.2 56.6us 41.8us
|
||||
512 34.09 24.51 > 28.1 68.2us 49.0us
|
||||
640 47.86 33.25 > 30.5 95.7us 66.5us
|
||||
768 64.91 43.54 > 32.9 129.8us 87.1us
|
||||
896 84.49 55.48 > 34.3 169.0us 111.0us
|
||||
1024 107.25 69.21 > 35.5 214.5us 138.4us
|
||||
1536 227.97 141.91 > 37.8 456.0us 283.8us
|
||||
2048 394.05 242.15 > 38.5 788.1us 484.3us
|
||||
|
||||
(A2)
|
||||
|
||||
bits multiply square ad percent time/mult time/square
|
||||
64 7.87 7.95 < 1.0 15.7us 15.9us
|
||||
128 9.40 9.19 > 2.2 18.8us 18.4us
|
||||
192 11.15 10.59 > 5.0 22.3us 21.2us
|
||||
256 12.02 11.16 > 7.2 24.0us 22.3us
|
||||
320 14.62 13.43 > 8.1 29.2us 26.9us
|
||||
384 17.72 15.80 > 10.8 35.4us 31.6us
|
||||
448 21.24 18.51 > 12.9 42.5us 37.0us
|
||||
512 25.36 21.78 > 14.1 50.7us 43.6us
|
||||
640 34.57 29.00 > 16.1 69.1us 58.0us
|
||||
768 46.10 37.60 > 18.4 92.2us 75.2us
|
||||
896 58.94 47.72 > 19.0 117.9us 95.4us
|
||||
1024 73.76 59.12 > 19.8 147.5us 118.2us
|
||||
1536 152.00 118.80 > 21.8 304.0us 237.6us
|
||||
2048 259.41 199.57 > 23.1 518.8us 399.1us
|
||||
|
||||
(B3)
|
||||
|
||||
bits multiply square ad percent time/mult time/square
|
||||
64 2.60 2.47 > 5.0 5.20us 4.94us
|
||||
128 4.43 4.06 > 8.4 8.86us 8.12us
|
||||
192 7.03 6.10 > 13.2 14.1us 12.2us
|
||||
256 10.44 8.59 > 17.7 20.9us 17.2us
|
||||
320 14.44 11.64 > 19.4 28.9us 23.3us
|
||||
384 19.12 15.08 > 21.1 38.2us 30.2us
|
||||
448 24.55 19.09 > 22.2 49.1us 38.2us
|
||||
512 31.03 23.53 > 24.2 62.1us 47.1us
|
||||
640 45.05 33.80 > 25.0 90.1us 67.6us
|
||||
768 63.02 46.05 > 26.9 126.0us 92.1us
|
||||
896 83.74 60.29 > 28.0 167.5us 120.6us
|
||||
1024 106.73 76.65 > 28.2 213.5us 153.3us
|
||||
1536 228.94 160.98 > 29.7 457.9us 322.0us
|
||||
2048 398.08 275.93 > 30.7 796.2us 551.9us
|
||||
|
||||
(C4)
|
||||
|
||||
bits multiply square ad percent time/mult time/square
|
||||
64 1.34 1.28 > 4.5 2.68us 2.56us
|
||||
128 2.76 2.59 > 6.2 5.52us 5.18us
|
||||
192 4.52 4.16 > 8.0 9.04us 8.32us
|
||||
256 6.64 5.99 > 9.8 13.3us 12.0us
|
||||
320 9.20 8.13 > 11.6 18.4us 16.3us
|
||||
384 12.01 10.58 > 11.9 24.0us 21.2us
|
||||
448 15.24 13.33 > 12.5 30.5us 26.7us
|
||||
512 19.02 16.46 > 13.5 38.0us 32.9us
|
||||
640 27.56 23.54 > 14.6 55.1us 47.1us
|
||||
768 37.89 31.78 > 16.1 75.8us 63.6us
|
||||
896 49.24 41.42 > 15.9 98.5us 82.8us
|
||||
1024 62.59 52.18 > 16.6 125.2us 104.3us
|
||||
1536 131.66 107.72 > 18.2 263.3us 215.4us
|
||||
2048 226.45 182.95 > 19.2 453.0us 365.9us
|
||||
|
||||
(A7)
|
||||
|
||||
bits multiply square ad percent time/mult time/square
|
||||
64 1.74 1.71 > 1.7 3.48us 3.42us
|
||||
128 3.48 2.96 > 14.9 6.96us 5.92us
|
||||
192 5.74 4.60 > 19.9 11.5us 9.20us
|
||||
256 8.75 6.61 > 24.5 17.5us 13.2us
|
||||
320 12.5 8.99 > 28.1 25.0us 18.0us
|
||||
384 16.9 11.9 > 29.6 33.8us 23.8us
|
||||
448 22.2 15.2 > 31.7 44.4us 30.4us
|
||||
512 28.3 19.0 > 32.7 56.6us 38.0us
|
||||
640 42.4 28.0 > 34.0 84.8us 56.0us
|
||||
768 59.4 38.5 > 35.2 118.8us 77.0us
|
||||
896 79.5 51.2 > 35.6 159.0us 102.4us
|
||||
1024 102.6 65.5 > 36.2 205.2us 131.0us
|
||||
1536 224.3 140.6 > 37.3 448.6us 281.2us
|
||||
2048 393.4 244.3 > 37.9 786.8us 488.6us
|
||||
|
||||
------------------------------------------------------------------
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is the MPI Arbitrary Precision Integer Arithmetic
|
||||
library.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
Portions created by the Initial Developer are Copyright (C) 1998, 2000
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
use your version of this file under the terms of the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
$Id: timing.txt,v 1.2 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
|
||||
|
||||
@@ -1,640 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is multacc512 multiple-precision integer arithmetic.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Hewlett-Packard Company.
|
||||
* Portions created by Hewlett-Packard Company are
|
||||
* Copyright (C) March 1999, Hewlett-Packard Company. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* coded by: Bill Worley, Hewlett-Packard labs
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU General Public License Version 2 or later (the
|
||||
* "GPL"), in which case the provisions of the GPL are applicable
|
||||
* instead of those above. If you wish to allow use of your
|
||||
* version of this file only under the terms of the GPL and not to
|
||||
* allow others to use your version of this file under the MPL,
|
||||
* indicate your decision by deleting the provisions above and
|
||||
* replace them with the notice and other provisions required by
|
||||
* the GPL. If you do not delete the provisions above, a recipient
|
||||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*
|
||||
* This PA-RISC 2.0 function computes the product of two unsigned integers,
|
||||
* and adds the result to a previously computed integer. The multiplicand
|
||||
* is a 512-bit (64-byte, eight doubleword) unsigned integer, stored in
|
||||
* memory in little-double-wordian order. The multiplier is an unsigned
|
||||
* 64-bit integer. The previously computed integer to which the product is
|
||||
* added is located in the result ("res") area, and is assumed to be a
|
||||
* 576-bit (72-byte, nine doubleword) unsigned integer, stored in memory
|
||||
* in little-double-wordian order. This value normally will be the result
|
||||
* of a previously computed nine doubleword result. It is not necessary
|
||||
* to pad the multiplicand with an additional 64-bit zero doubleword.
|
||||
*
|
||||
* Multiplicand, multiplier, and addend ideally should be aligned at
|
||||
* 16-byte boundaries for best performance. The code will function
|
||||
* correctly for alignment at eight-byte boundaries which are not 16-byte
|
||||
* boundaries, but the execution may be slightly slower due to even/odd
|
||||
* bank conflicts on PA-RISC 8000 processors.
|
||||
*
|
||||
* This function is designed to accept the same calling sequence as Bill
|
||||
* Ackerman's "maxpy_little" function. The carry from the ninth doubleword
|
||||
* of the result is written to the tenth word of the result, as is done by
|
||||
* Bill Ackerman's function. The final carry also is returned as an
|
||||
* integer, which may be ignored. The function prototype may be either
|
||||
* of the following:
|
||||
*
|
||||
* void multacc512( int l, chunk* m, const chunk* a, chunk* res );
|
||||
* or
|
||||
* int multacc512( int l, chunk* m, const chunk* a, chunk* res );
|
||||
*
|
||||
* where: "l" originally denoted vector lengths. This parameter is
|
||||
* ignored. This function always assumes a multiplicand length of
|
||||
* 512 bits (eight doublewords), and addend and result lengths of
|
||||
* 576 bits (nine doublewords).
|
||||
*
|
||||
* "m" is a pointer to the doubleword multiplier, ideally aligned
|
||||
* on a 16-byte boundary.
|
||||
*
|
||||
* "a" is a pointer to the eight-doubleword multiplicand, stored
|
||||
* in little-double-wordian order, and ideally aligned on a 16-byte
|
||||
* boundary.
|
||||
*
|
||||
* "res" is a pointer to the nine doubleword addend, and to the
|
||||
* nine-doubleword product computed by this function. The result
|
||||
* also is stored in little-double-wordian order, and ideally is
|
||||
* aligned on a 16-byte boundary. It is expected that the alignment
|
||||
* of the "res" area may alternate between even/odd doubleword
|
||||
* boundaries for successive calls for 512-bit x 512-bit
|
||||
* multiplications.
|
||||
*
|
||||
* The code for this function has been scheduled to use the parallelism
|
||||
* of the PA-RISC 8000 series microprocessors as well as the author was
|
||||
* able. Comments and/or suggestions for improvement are welcomed.
|
||||
*
|
||||
* The code is "64-bit safe". This means it may be called in either
|
||||
* the 32ILP context or the 64LP context. All 64-bits of registers are
|
||||
* saved and restored.
|
||||
*
|
||||
* This code is self-contained. It requires no other header files in order
|
||||
* to compile and to be linkable on a PA-RISC 2.0 machine. Symbolic
|
||||
* definitions for registers and stack offsets are included within this
|
||||
* one source file.
|
||||
*
|
||||
* This is a leaf routine. As such, minimal use is made of the stack area.
|
||||
* Of the 192 bytes allocated, 64 bytes are used for saving/restoring eight
|
||||
* general registers, and 128 bytes are used to move intermediate products
|
||||
* from the floating-point registers to the general registers. Stack
|
||||
* protocols assure proper alignment of these areas.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* ====================================================================*/
|
||||
/* symbolic definitions for PA-RISC registers */
|
||||
/* in the MIPS style, avoids lots of case shifts */
|
||||
/* assigments (except t4) preserve register number parity */
|
||||
/* ====================================================================*/
|
||||
|
||||
#define zero %r0 /* permanent zero */
|
||||
#define t5 %r1 /* temp register, altered by addil */
|
||||
|
||||
#define rp %r2 /* return pointer */
|
||||
|
||||
#define s1 %r3 /* callee saves register*/
|
||||
#define s0 %r4 /* callee saves register*/
|
||||
#define s3 %r5 /* callee saves register*/
|
||||
#define s2 %r6 /* callee saves register*/
|
||||
#define s5 %r7 /* callee saves register*/
|
||||
#define s4 %r8 /* callee saves register*/
|
||||
#define s7 %r9 /* callee saves register*/
|
||||
#define s6 %r10 /* callee saves register*/
|
||||
|
||||
#define t1 %r19 /* caller saves register*/
|
||||
#define t0 %r20 /* caller saves register*/
|
||||
#define t3 %r21 /* caller saves register*/
|
||||
#define t2 %r22 /* caller saves register*/
|
||||
|
||||
#define a3 %r23 /* fourth argument register, high word */
|
||||
#define a2 %r24 /* third argument register, low word*/
|
||||
#define a1 %r25 /* second argument register, high word*/
|
||||
#define a0 %r26 /* first argument register, low word*/
|
||||
|
||||
#define v0 %r28 /* high order return value*/
|
||||
#define v1 %r29 /* low order return value*/
|
||||
|
||||
#define sp %r30 /* stack pointer*/
|
||||
#define t4 %r31 /* temporary register */
|
||||
|
||||
#define fa0 %fr4 /* first argument register*/
|
||||
#define fa1 %fr5 /* second argument register*/
|
||||
#define fa2 %fr6 /* third argument register*/
|
||||
#define fa3 %fr7 /* fourth argument register*/
|
||||
|
||||
#define fa0r %fr4R /* first argument register*/
|
||||
#define fa1r %fr5R /* second argument register*/
|
||||
#define fa2r %fr6R /* third argument register*/
|
||||
#define fa3r %fr7R /* fourth argument register*/
|
||||
|
||||
#define ft0 %fr8 /* caller saves register*/
|
||||
#define ft1 %fr9 /* caller saves register*/
|
||||
#define ft2 %fr10 /* caller saves register*/
|
||||
#define ft3 %fr11 /* caller saves register*/
|
||||
|
||||
#define ft0r %fr8R /* caller saves register*/
|
||||
#define ft1r %fr9R /* caller saves register*/
|
||||
#define ft2r %fr10R /* caller saves register*/
|
||||
#define ft3r %fr11R /* caller saves register*/
|
||||
|
||||
#define ft4 %fr22 /* caller saves register*/
|
||||
#define ft5 %fr23 /* caller saves register*/
|
||||
#define ft6 %fr24 /* caller saves register*/
|
||||
#define ft7 %fr25 /* caller saves register*/
|
||||
#define ft8 %fr26 /* caller saves register*/
|
||||
#define ft9 %fr27 /* caller saves register*/
|
||||
#define ft10 %fr28 /* caller saves register*/
|
||||
#define ft11 %fr29 /* caller saves register*/
|
||||
#define ft12 %fr30 /* caller saves register*/
|
||||
#define ft13 %fr31 /* caller saves register*/
|
||||
|
||||
#define ft4r %fr22R /* caller saves register*/
|
||||
#define ft5r %fr23R /* caller saves register*/
|
||||
#define ft6r %fr24R /* caller saves register*/
|
||||
#define ft7r %fr25R /* caller saves register*/
|
||||
#define ft8r %fr26R /* caller saves register*/
|
||||
#define ft9r %fr27R /* caller saves register*/
|
||||
#define ft10r %fr28R /* caller saves register*/
|
||||
#define ft11r %fr29R /* caller saves register*/
|
||||
#define ft12r %fr30R /* caller saves register*/
|
||||
#define ft13r %fr31R /* caller saves register*/
|
||||
|
||||
|
||||
|
||||
/* ================================================================== */
|
||||
/* functional definitions for PA-RISC registers */
|
||||
/* ================================================================== */
|
||||
|
||||
/* general registers */
|
||||
|
||||
#define T1 a0 /* temp, (length parameter ignored) */
|
||||
|
||||
#define pM a1 /* -> 64-bit multiplier */
|
||||
#define T2 a1 /* temp, (after fetching multiplier) */
|
||||
|
||||
#define pA a2 /* -> multiplicand vector (8 64-bit words) */
|
||||
#define T3 a2 /* temp, (after fetching multiplicand) */
|
||||
|
||||
#define pR a3 /* -> addend vector (8 64-bit doublewords,
|
||||
result vector (9 64-bit words) */
|
||||
|
||||
#define S0 s0 /* callee saves summand registers */
|
||||
#define S1 s1
|
||||
#define S2 s2
|
||||
#define S3 s3
|
||||
#define S4 s4
|
||||
#define S5 s5
|
||||
#define S6 s6
|
||||
#define S7 s7
|
||||
|
||||
#define S8 v0 /* caller saves summand registers */
|
||||
#define S9 v1
|
||||
#define S10 t0
|
||||
#define S11 t1
|
||||
#define S12 t2
|
||||
#define S13 t3
|
||||
#define S14 t4
|
||||
#define S15 t5
|
||||
|
||||
|
||||
|
||||
/* floating-point registers */
|
||||
|
||||
#define M fa0 /* multiplier double word */
|
||||
#define MR fa0r /* low order half of multiplier double word */
|
||||
#define ML fa0 /* high order half of multiplier double word */
|
||||
|
||||
#define A0 fa2 /* multiplicand double word 0 */
|
||||
#define A0R fa2r /* low order half of multiplicand double word */
|
||||
#define A0L fa2 /* high order half of multiplicand double word */
|
||||
|
||||
#define A1 fa3 /* multiplicand double word 1 */
|
||||
#define A1R fa3r /* low order half of multiplicand double word */
|
||||
#define A1L fa3 /* high order half of multiplicand double word */
|
||||
|
||||
#define A2 ft0 /* multiplicand double word 2 */
|
||||
#define A2R ft0r /* low order half of multiplicand double word */
|
||||
#define A2L ft0 /* high order half of multiplicand double word */
|
||||
|
||||
#define A3 ft1 /* multiplicand double word 3 */
|
||||
#define A3R ft1r /* low order half of multiplicand double word */
|
||||
#define A3L ft1 /* high order half of multiplicand double word */
|
||||
|
||||
#define A4 ft2 /* multiplicand double word 4 */
|
||||
#define A4R ft2r /* low order half of multiplicand double word */
|
||||
#define A4L ft2 /* high order half of multiplicand double word */
|
||||
|
||||
#define A5 ft3 /* multiplicand double word 5 */
|
||||
#define A5R ft3r /* low order half of multiplicand double word */
|
||||
#define A5L ft3 /* high order half of multiplicand double word */
|
||||
|
||||
#define A6 ft4 /* multiplicand double word 6 */
|
||||
#define A6R ft4r /* low order half of multiplicand double word */
|
||||
#define A6L ft4 /* high order half of multiplicand double word */
|
||||
|
||||
#define A7 ft5 /* multiplicand double word 7 */
|
||||
#define A7R ft5r /* low order half of multiplicand double word */
|
||||
#define A7L ft5 /* high order half of multiplicand double word */
|
||||
|
||||
#define P0 ft6 /* product word 0 */
|
||||
#define P1 ft7 /* product word 0 */
|
||||
#define P2 ft8 /* product word 0 */
|
||||
#define P3 ft9 /* product word 0 */
|
||||
#define P4 ft10 /* product word 0 */
|
||||
#define P5 ft11 /* product word 0 */
|
||||
#define P6 ft12 /* product word 0 */
|
||||
#define P7 ft13 /* product word 0 */
|
||||
|
||||
|
||||
|
||||
|
||||
/* ====================================================================== */
|
||||
/* symbolic definitions for HP-UX stack offsets */
|
||||
/* symbolic definitions for memory NOPs */
|
||||
/* ====================================================================== */
|
||||
|
||||
#define ST_SZ 192 /* stack area total size */
|
||||
|
||||
#define SV0 -192(sp) /* general register save area */
|
||||
#define SV1 -184(sp)
|
||||
#define SV2 -176(sp)
|
||||
#define SV3 -168(sp)
|
||||
#define SV4 -160(sp)
|
||||
#define SV5 -152(sp)
|
||||
#define SV6 -144(sp)
|
||||
#define SV7 -136(sp)
|
||||
|
||||
#define XF0 -128(sp) /* data transfer area */
|
||||
#define XF1 -120(sp) /* for floating-pt to integer regs */
|
||||
#define XF2 -112(sp)
|
||||
#define XF3 -104(sp)
|
||||
#define XF4 -96(sp)
|
||||
#define XF5 -88(sp)
|
||||
#define XF6 -80(sp)
|
||||
#define XF7 -72(sp)
|
||||
#define XF8 -64(sp)
|
||||
#define XF9 -56(sp)
|
||||
#define XF10 -48(sp)
|
||||
#define XF11 -40(sp)
|
||||
#define XF12 -32(sp)
|
||||
#define XF13 -24(sp)
|
||||
#define XF14 -16(sp)
|
||||
#define XF15 -8(sp)
|
||||
|
||||
#define mnop proberi (sp),3,zero /* memory NOP */
|
||||
|
||||
|
||||
|
||||
|
||||
/* ====================================================================== */
|
||||
/* assembler formalities */
|
||||
/* ====================================================================== */
|
||||
|
||||
#ifdef __LP64__
|
||||
.level 2.0W
|
||||
#else
|
||||
.level 2.0
|
||||
#endif
|
||||
.space $TEXT$
|
||||
.subspa $CODE$
|
||||
.align 16
|
||||
|
||||
/* ====================================================================== */
|
||||
/* here to compute 64-bit x 512-bit product + 512-bit addend */
|
||||
/* ====================================================================== */
|
||||
|
||||
multacc512
|
||||
.PROC
|
||||
.CALLINFO
|
||||
.ENTER
|
||||
fldd 0(pM),M ; multiplier double word
|
||||
ldo ST_SZ(sp),sp ; push stack
|
||||
|
||||
fldd 0(pA),A0 ; multiplicand double word 0
|
||||
std S1,SV1 ; save s1
|
||||
|
||||
fldd 16(pA),A2 ; multiplicand double word 2
|
||||
std S3,SV3 ; save s3
|
||||
|
||||
fldd 32(pA),A4 ; multiplicand double word 4
|
||||
std S5,SV5 ; save s5
|
||||
|
||||
fldd 48(pA),A6 ; multiplicand double word 6
|
||||
std S7,SV7 ; save s7
|
||||
|
||||
|
||||
std S0,SV0 ; save s0
|
||||
fldd 8(pA),A1 ; multiplicand double word 1
|
||||
xmpyu MR,A0L,P0 ; A0 cross 32-bit word products
|
||||
xmpyu ML,A0R,P2
|
||||
|
||||
std S2,SV2 ; save s2
|
||||
fldd 24(pA),A3 ; multiplicand double word 3
|
||||
xmpyu MR,A2L,P4 ; A2 cross 32-bit word products
|
||||
xmpyu ML,A2R,P6
|
||||
|
||||
std S4,SV4 ; save s4
|
||||
fldd 40(pA),A5 ; multiplicand double word 5
|
||||
|
||||
std S6,SV6 ; save s6
|
||||
fldd 56(pA),A7 ; multiplicand double word 7
|
||||
|
||||
|
||||
fstd P0,XF0 ; MR * A0L
|
||||
xmpyu MR,A0R,P0 ; A0 right 32-bit word product
|
||||
xmpyu MR,A1L,P1 ; A1 cross 32-bit word product
|
||||
|
||||
fstd P2,XF2 ; ML * A0R
|
||||
xmpyu ML,A0L,P2 ; A0 left 32-bit word product
|
||||
xmpyu ML,A1R,P3 ; A1 cross 32-bit word product
|
||||
|
||||
fstd P4,XF4 ; MR * A2L
|
||||
xmpyu MR,A2R,P4 ; A2 right 32-bit word product
|
||||
xmpyu MR,A3L,P5 ; A3 cross 32-bit word product
|
||||
|
||||
fstd P6,XF6 ; ML * A2R
|
||||
xmpyu ML,A2L,P6 ; A2 parallel 32-bit word product
|
||||
xmpyu ML,A3R,P7 ; A3 cross 32-bit word product
|
||||
|
||||
|
||||
ldd XF0,S0 ; MR * A0L
|
||||
fstd P1,XF1 ; MR * A1L
|
||||
|
||||
ldd XF2,S2 ; ML * A0R
|
||||
fstd P3,XF3 ; ML * A1R
|
||||
|
||||
ldd XF4,S4 ; MR * A2L
|
||||
fstd P5,XF5 ; MR * A3L
|
||||
xmpyu MR,A1R,P1 ; A1 parallel 32-bit word products
|
||||
xmpyu ML,A1L,P3
|
||||
|
||||
ldd XF6,S6 ; ML * A2R
|
||||
fstd P7,XF7 ; ML * A3R
|
||||
xmpyu MR,A3R,P5 ; A3 parallel 32-bit word products
|
||||
xmpyu ML,A3L,P7
|
||||
|
||||
|
||||
fstd P0,XF0 ; MR * A0R
|
||||
ldd XF1,S1 ; MR * A1L
|
||||
nop
|
||||
add S0,S2,T1 ; A0 cross product sum
|
||||
|
||||
fstd P2,XF2 ; ML * A0L
|
||||
ldd XF3,S3 ; ML * A1R
|
||||
add,dc zero,zero,S0 ; A0 cross product sum carry
|
||||
depd,z T1,31,32,S2 ; A0 cross product sum << 32
|
||||
|
||||
fstd P4,XF4 ; MR * A2R
|
||||
ldd XF5,S5 ; MR * A3L
|
||||
shrpd S0,T1,32,S0 ; A0 carry | cross product sum >> 32
|
||||
add S4,S6,T3 ; A2 cross product sum
|
||||
|
||||
fstd P6,XF6 ; ML * A2L
|
||||
ldd XF7,S7 ; ML * A3R
|
||||
add,dc zero,zero,S4 ; A2 cross product sum carry
|
||||
depd,z T3,31,32,S6 ; A2 cross product sum << 32
|
||||
|
||||
|
||||
ldd XF0,S8 ; MR * A0R
|
||||
fstd P1,XF1 ; MR * A1R
|
||||
xmpyu MR,A4L,P0 ; A4 cross 32-bit word product
|
||||
xmpyu MR,A5L,P1 ; A5 cross 32-bit word product
|
||||
|
||||
ldd XF2,S10 ; ML * A0L
|
||||
fstd P3,XF3 ; ML * A1L
|
||||
xmpyu ML,A4R,P2 ; A4 cross 32-bit word product
|
||||
xmpyu ML,A5R,P3 ; A5 cross 32-bit word product
|
||||
|
||||
ldd XF4,S12 ; MR * A2R
|
||||
fstd P5,XF5 ; MR * A3L
|
||||
xmpyu MR,A6L,P4 ; A6 cross 32-bit word product
|
||||
xmpyu MR,A7L,P5 ; A7 cross 32-bit word product
|
||||
|
||||
ldd XF6,S14 ; ML * A2L
|
||||
fstd P7,XF7 ; ML * A3L
|
||||
xmpyu ML,A6R,P6 ; A6 cross 32-bit word product
|
||||
xmpyu ML,A7R,P7 ; A7 cross 32-bit word product
|
||||
|
||||
|
||||
fstd P0,XF0 ; MR * A4L
|
||||
ldd XF1,S9 ; MR * A1R
|
||||
shrpd S4,T3,32,S4 ; A2 carry | cross product sum >> 32
|
||||
add S1,S3,T1 ; A1 cross product sum
|
||||
|
||||
fstd P2,XF2 ; ML * A4R
|
||||
ldd XF3,S11 ; ML * A1L
|
||||
add,dc zero,zero,S1 ; A1 cross product sum carry
|
||||
depd,z T1,31,32,S3 ; A1 cross product sum << 32
|
||||
|
||||
fstd P4,XF4 ; MR * A6L
|
||||
ldd XF5,S13 ; MR * A3R
|
||||
shrpd S1,T1,32,S1 ; A1 carry | cross product sum >> 32
|
||||
add S5,S7,T3 ; A3 cross product sum
|
||||
|
||||
fstd P6,XF6 ; ML * A6R
|
||||
ldd XF7,S15 ; ML * A3L
|
||||
add,dc zero,zero,S5 ; A3 cross product sum carry
|
||||
depd,z T3,31,32,S7 ; A3 cross product sum << 32
|
||||
|
||||
|
||||
shrpd S5,T3,32,S5 ; A3 carry | cross product sum >> 32
|
||||
add S2,S8,S8 ; M * A0 right doubleword, P0 doubleword
|
||||
|
||||
add,dc S0,S10,S10 ; M * A0 left doubleword
|
||||
add S3,S9,S9 ; M * A1 right doubleword
|
||||
|
||||
add,dc S1,S11,S11 ; M * A1 left doubleword
|
||||
add S6,S12,S12 ; M * A2 right doubleword
|
||||
|
||||
|
||||
ldd 24(pR),S3 ; Addend word 3
|
||||
fstd P1,XF1 ; MR * A5L
|
||||
add,dc S4,S14,S14 ; M * A2 left doubleword
|
||||
xmpyu MR,A5R,P1 ; A5 right 32-bit word product
|
||||
|
||||
ldd 8(pR),S1 ; Addend word 1
|
||||
fstd P3,XF3 ; ML * A5R
|
||||
add S7,S13,S13 ; M * A3 right doubleword
|
||||
xmpyu ML,A5L,P3 ; A5 left 32-bit word product
|
||||
|
||||
ldd 0(pR),S7 ; Addend word 0
|
||||
fstd P5,XF5 ; MR * A7L
|
||||
add,dc S5,S15,S15 ; M * A3 left doubleword
|
||||
xmpyu MR,A7R,P5 ; A7 right 32-bit word product
|
||||
|
||||
ldd 16(pR),S5 ; Addend word 2
|
||||
fstd P7,XF7 ; ML * A7R
|
||||
add S10,S9,S9 ; P1 doubleword
|
||||
xmpyu ML,A7L,P7 ; A7 left 32-bit word products
|
||||
|
||||
|
||||
ldd XF0,S0 ; MR * A4L
|
||||
fstd P1,XF9 ; MR * A5R
|
||||
add,dc S11,S12,S12 ; P2 doubleword
|
||||
xmpyu MR,A4R,P0 ; A4 right 32-bit word product
|
||||
|
||||
ldd XF2,S2 ; ML * A4R
|
||||
fstd P3,XF11 ; ML * A5L
|
||||
add,dc S14,S13,S13 ; P3 doubleword
|
||||
xmpyu ML,A4L,P2 ; A4 left 32-bit word product
|
||||
|
||||
ldd XF6,S6 ; ML * A6R
|
||||
fstd P5,XF13 ; MR * A7R
|
||||
add,dc zero,S15,T2 ; P4 partial doubleword
|
||||
xmpyu MR,A6R,P4 ; A6 right 32-bit word product
|
||||
|
||||
ldd XF4,S4 ; MR * A6L
|
||||
fstd P7,XF15 ; ML * A7L
|
||||
add S7,S8,S8 ; R0 + P0, new R0 doubleword
|
||||
xmpyu ML,A6L,P6 ; A6 left 32-bit word product
|
||||
|
||||
|
||||
fstd P0,XF0 ; MR * A4R
|
||||
ldd XF7,S7 ; ML * A7R
|
||||
add,dc S1,S9,S9 ; c + R1 + P1, new R1 doubleword
|
||||
|
||||
fstd P2,XF2 ; ML * A4L
|
||||
ldd XF1,S1 ; MR * A5L
|
||||
add,dc S5,S12,S12 ; c + R2 + P2, new R2 doubleword
|
||||
|
||||
fstd P4,XF4 ; MR * A6R
|
||||
ldd XF5,S5 ; MR * A7L
|
||||
add,dc S3,S13,S13 ; c + R3 + P3, new R3 doubleword
|
||||
|
||||
fstd P6,XF6 ; ML * A6L
|
||||
ldd XF3,S3 ; ML * A5R
|
||||
add,dc zero,T2,T2 ; c + partial P4
|
||||
add S0,S2,T1 ; A4 cross product sum
|
||||
|
||||
|
||||
std S8,0(pR) ; save R0
|
||||
add,dc zero,zero,S0 ; A4 cross product sum carry
|
||||
depd,z T1,31,32,S2 ; A4 cross product sum << 32
|
||||
|
||||
std S9,8(pR) ; save R1
|
||||
shrpd S0,T1,32,S0 ; A4 carry | cross product sum >> 32
|
||||
add S4,S6,T3 ; A6 cross product sum
|
||||
|
||||
std S12,16(pR) ; save R2
|
||||
add,dc zero,zero,S4 ; A6 cross product sum carry
|
||||
depd,z T3,31,32,S6 ; A6 cross product sum << 32
|
||||
|
||||
|
||||
std S13,24(pR) ; save R3
|
||||
shrpd S4,T3,32,S4 ; A6 carry | cross product sum >> 32
|
||||
add S1,S3,T1 ; A5 cross product sum
|
||||
|
||||
ldd XF0,S8 ; MR * A4R
|
||||
add,dc zero,zero,S1 ; A5 cross product sum carry
|
||||
depd,z T1,31,32,S3 ; A5 cross product sum << 32
|
||||
|
||||
ldd XF2,S10 ; ML * A4L
|
||||
ldd XF9,S9 ; MR * A5R
|
||||
shrpd S1,T1,32,S1 ; A5 carry | cross product sum >> 32
|
||||
add S5,S7,T3 ; A7 cross product sum
|
||||
|
||||
ldd XF4,S12 ; MR * A6R
|
||||
ldd XF11,S11 ; ML * A5L
|
||||
add,dc zero,zero,S5 ; A7 cross product sum carry
|
||||
depd,z T3,31,32,S7 ; A7 cross product sum << 32
|
||||
|
||||
ldd XF6,S14 ; ML * A6L
|
||||
ldd XF13,S13 ; MR * A7R
|
||||
shrpd S5,T3,32,S5 ; A7 carry | cross product sum >> 32
|
||||
add S2,S8,S8 ; M * A4 right doubleword
|
||||
|
||||
|
||||
ldd XF15,S15 ; ML * A7L
|
||||
add,dc S0,S10,S10 ; M * A4 left doubleword
|
||||
add S3,S9,S9 ; M * A5 right doubleword
|
||||
|
||||
add,dc S1,S11,S11 ; M * A5 left doubleword
|
||||
add S6,S12,S12 ; M * A6 right doubleword
|
||||
|
||||
ldd 32(pR),S0 ; Addend word 4
|
||||
ldd 40(pR),S1 ; Addend word 5
|
||||
add,dc S4,S14,S14 ; M * A6 left doubleword
|
||||
add S7,S13,S13 ; M * A7 right doubleword
|
||||
|
||||
ldd 48(pR),S2 ; Addend word 6
|
||||
ldd 56(pR),S3 ; Addend word 7
|
||||
add,dc S5,S15,S15 ; M * A7 left doubleword
|
||||
add S8,T2,S8 ; P4 doubleword
|
||||
|
||||
ldd 64(pR),S4 ; Addend word 8
|
||||
ldd SV5,s5 ; restore s5
|
||||
add,dc S10,S9,S9 ; P5 doubleword
|
||||
add,dc S11,S12,S12 ; P6 doubleword
|
||||
|
||||
|
||||
ldd SV6,s6 ; restore s6
|
||||
ldd SV7,s7 ; restore s7
|
||||
add,dc S14,S13,S13 ; P7 doubleword
|
||||
add,dc zero,S15,S15 ; P8 doubleword
|
||||
|
||||
add S0,S8,S8 ; new R4 doubleword
|
||||
|
||||
ldd SV0,s0 ; restore s0
|
||||
std S8,32(pR) ; save R4
|
||||
add,dc S1,S9,S9 ; new R5 doubleword
|
||||
|
||||
ldd SV1,s1 ; restore s1
|
||||
std S9,40(pR) ; save R5
|
||||
add,dc S2,S12,S12 ; new R6 doubleword
|
||||
|
||||
ldd SV2,s2 ; restore s2
|
||||
std S12,48(pR) ; save R6
|
||||
add,dc S3,S13,S13 ; new R7 doubleword
|
||||
|
||||
ldd SV3,s3 ; restore s3
|
||||
std S13,56(pR) ; save R7
|
||||
add,dc S4,S15,S15 ; new R8 doubleword
|
||||
|
||||
ldd SV4,s4 ; restore s4
|
||||
std S15,64(pR) ; save result[8]
|
||||
add,dc zero,zero,v0 ; return carry from R8
|
||||
|
||||
CMPIB,*= 0,v0,$L0 ; if no overflow, exit
|
||||
LDO 8(pR),pR
|
||||
|
||||
$FINAL1 ; Final carry propagation
|
||||
LDD 64(pR),v0
|
||||
LDO 8(pR),pR
|
||||
ADDI 1,v0,v0
|
||||
CMPIB,*= 0,v0,$FINAL1 ; Keep looping if there is a carry.
|
||||
STD v0,56(pR)
|
||||
$L0
|
||||
bv zero(rp) ; -> caller
|
||||
ldo -ST_SZ(sp),sp ; pop stack
|
||||
|
||||
/* ====================================================================== */
|
||||
/* end of module */
|
||||
/* ====================================================================== */
|
||||
|
||||
.LEAVE
|
||||
|
||||
.PROCEND
|
||||
.SPACE $TEXT$
|
||||
.SUBSPA $CODE$
|
||||
.EXPORT multacc512,ENTRY
|
||||
|
||||
.end
|
||||
@@ -1,929 +0,0 @@
|
||||
; The contents of this file are subject to the Mozilla Public
|
||||
; License Version 1.1 (the "License"); you may not use this file
|
||||
; except in compliance with the License. You may obtain a copy of
|
||||
; the License at http://www.mozilla.org/MPL/
|
||||
;
|
||||
; Software distributed under the License is distributed on an "AS
|
||||
; IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
; implied. See the License for the specific language governing
|
||||
; rights and limitations under the License.
|
||||
;
|
||||
; The Original Code is MAXPY multiple-precision integer arithmetic.
|
||||
;
|
||||
; The Initial Developer of the Original Code is the Hewlett-Packard Company.
|
||||
; Portions created by Hewlett-Packard Company are
|
||||
; Copyright (C) 1997 Hewlett-Packard Company. All Rights Reserved.
|
||||
;
|
||||
; Contributor(s):
|
||||
; coded by: William B. Ackerman
|
||||
;
|
||||
; Alternatively, the contents of this file may be used under the
|
||||
; terms of the GNU General Public License Version 2 or later (the
|
||||
; "GPL"), in which case the provisions of the GPL are applicable
|
||||
; instead of those above. If you wish to allow use of your
|
||||
; version of this file only under the terms of the GPL and not to
|
||||
; allow others to use your version of this file under the MPL,
|
||||
; indicate your decision by deleting the provisions above and
|
||||
; replace them with the notice and other provisions required by
|
||||
; the GPL. If you do not delete the provisions above, a recipient
|
||||
; may use your version of this file under either the MPL or the
|
||||
; GPL.
|
||||
|
||||
#ifdef __LP64__
|
||||
.LEVEL 2.0W
|
||||
#else
|
||||
; .LEVEL 1.1
|
||||
; .ALLOW 2.0N
|
||||
.LEVEL 2.0N
|
||||
#endif
|
||||
.SPACE $TEXT$,SORT=8
|
||||
.SUBSPA $CODE$,QUAD=0,ALIGN=4,ACCESS=0x2c,CODE_ONLY,SORT=24
|
||||
|
||||
; ***************************************************************
|
||||
;
|
||||
; maxpy_[little/big]
|
||||
;
|
||||
; ***************************************************************
|
||||
|
||||
; There is no default -- you must specify one or the other.
|
||||
#define LITTLE_WORDIAN 1
|
||||
|
||||
#ifdef LITTLE_WORDIAN
|
||||
#define EIGHT 8
|
||||
#define SIXTEEN 16
|
||||
#define THIRTY_TWO 32
|
||||
#define UN_EIGHT -8
|
||||
#define UN_SIXTEEN -16
|
||||
#define UN_TWENTY_FOUR -24
|
||||
#endif
|
||||
|
||||
#ifdef BIG_WORDIAN
|
||||
#define EIGHT -8
|
||||
#define SIXTEEN -16
|
||||
#define THIRTY_TWO -32
|
||||
#define UN_EIGHT 8
|
||||
#define UN_SIXTEEN 16
|
||||
#define UN_TWENTY_FOUR 24
|
||||
#endif
|
||||
|
||||
; This performs a multiple-precision integer version of "daxpy",
|
||||
; Using the selected addressing direction. "Little-wordian" means that
|
||||
; the least significant word of a number is stored at the lowest address.
|
||||
; "Big-wordian" means that the most significant word is at the lowest
|
||||
; address. Either way, the incoming address of the vector is that
|
||||
; of the least significant word. That means that, for little-wordian
|
||||
; addressing, we move the address upward as we propagate carries
|
||||
; from the least significant word to the most significant. For
|
||||
; big-wordian we move the address downward.
|
||||
|
||||
; We use the following registers:
|
||||
;
|
||||
; r2 return PC, of course
|
||||
; r26 = arg1 = length
|
||||
; r25 = arg2 = address of scalar
|
||||
; r24 = arg3 = multiplicand vector
|
||||
; r23 = arg4 = result vector
|
||||
;
|
||||
; fr9 = scalar loaded once only from r25
|
||||
|
||||
; The cycle counts shown in the bodies below are simply the result of a
|
||||
; scheduling by hand. The actual PCX-U hardware does it differently.
|
||||
; The intention is that the overall speed is the same.
|
||||
|
||||
; The pipeline startup and shutdown code is constructed in the usual way,
|
||||
; by taking the loop bodies and removing unnecessary instructions.
|
||||
; We have left the comments describing cycle numbers in the code.
|
||||
; These are intended for reference when comparing with the main loop,
|
||||
; and have no particular relationship to actual cycle numbers.
|
||||
|
||||
#ifdef LITTLE_WORDIAN
|
||||
maxpy_little
|
||||
#else
|
||||
maxpy_big
|
||||
#endif
|
||||
.PROC
|
||||
.CALLINFO FRAME=120,ENTRY_GR=%r4
|
||||
.ENTER
|
||||
|
||||
; Of course, real men don't use the sissy "enter" and "leave" commands.
|
||||
; They write their own stack manipulation stuff. Unfortunately,
|
||||
; that doesn't generate complete unwind info, whereas "enter" and
|
||||
; "leave" (if the documentation is to be believed) do so. Therefore,
|
||||
; we use the sissy commands. We have verified (by real-man methods)
|
||||
; that the above command generates what we want:
|
||||
; STW,MA %r3,128(%sp)
|
||||
; STW %r4,-124(%sp)
|
||||
|
||||
ADDIB,< -1,%r26,$L0 ; If N = 0, exit immediately.
|
||||
FLDD 0(%r25),%fr9 ; fr9 = scalar
|
||||
|
||||
; First startup
|
||||
|
||||
FLDD 0(%r24),%fr24 ; Cycle 1
|
||||
XMPYU %fr9R,%fr24R,%fr27 ; Cycle 3
|
||||
XMPYU %fr9R,%fr24L,%fr25 ; Cycle 4
|
||||
XMPYU %fr9L,%fr24L,%fr26 ; Cycle 5
|
||||
CMPIB,> 3,%r26,$N_IS_SMALL ; Pick out cases N = 1, 2, or 3
|
||||
XMPYU %fr9L,%fr24R,%fr24 ; Cycle 6
|
||||
FLDD EIGHT(%r24),%fr28 ; Cycle 8
|
||||
XMPYU %fr9L,%fr28R,%fr31 ; Cycle 10
|
||||
FSTD %fr24,-96(%sp)
|
||||
XMPYU %fr9R,%fr28L,%fr30 ; Cycle 11
|
||||
FSTD %fr25,-80(%sp)
|
||||
LDO SIXTEEN(%r24),%r24 ; Cycle 12
|
||||
FSTD %fr31,-64(%sp)
|
||||
XMPYU %fr9R,%fr28R,%fr29 ; Cycle 13
|
||||
FSTD %fr27,-48(%sp)
|
||||
|
||||
; Second startup
|
||||
|
||||
XMPYU %fr9L,%fr28L,%fr28 ; Cycle 1
|
||||
FSTD %fr30,-56(%sp)
|
||||
FLDD 0(%r24),%fr24
|
||||
|
||||
FSTD %fr26,-88(%sp) ; Cycle 2
|
||||
|
||||
XMPYU %fr9R,%fr24R,%fr27 ; Cycle 3
|
||||
FSTD %fr28,-104(%sp)
|
||||
|
||||
XMPYU %fr9R,%fr24L,%fr25 ; Cycle 4
|
||||
LDD -96(%sp),%r3
|
||||
FSTD %fr29,-72(%sp)
|
||||
|
||||
XMPYU %fr9L,%fr24L,%fr26 ; Cycle 5
|
||||
LDD -64(%sp),%r19
|
||||
LDD -80(%sp),%r21
|
||||
|
||||
XMPYU %fr9L,%fr24R,%fr24 ; Cycle 6
|
||||
LDD -56(%sp),%r20
|
||||
ADD %r21,%r3,%r3
|
||||
|
||||
ADD,DC %r20,%r19,%r19 ; Cycle 7
|
||||
LDD -88(%sp),%r4
|
||||
SHRPD %r3,%r0,32,%r21
|
||||
LDD -48(%sp),%r1
|
||||
|
||||
FLDD EIGHT(%r24),%fr28 ; Cycle 8
|
||||
LDD -104(%sp),%r31
|
||||
ADD,DC %r0,%r0,%r20
|
||||
SHRPD %r19,%r3,32,%r3
|
||||
|
||||
LDD -72(%sp),%r29 ; Cycle 9
|
||||
SHRPD %r20,%r19,32,%r20
|
||||
ADD %r21,%r1,%r1
|
||||
|
||||
XMPYU %fr9L,%fr28R,%fr31 ; Cycle 10
|
||||
ADD,DC %r3,%r4,%r4
|
||||
FSTD %fr24,-96(%sp)
|
||||
|
||||
XMPYU %fr9R,%fr28L,%fr30 ; Cycle 11
|
||||
ADD,DC %r0,%r20,%r20
|
||||
LDD 0(%r23),%r3
|
||||
FSTD %fr25,-80(%sp)
|
||||
|
||||
LDO SIXTEEN(%r24),%r24 ; Cycle 12
|
||||
FSTD %fr31,-64(%sp)
|
||||
|
||||
XMPYU %fr9R,%fr28R,%fr29 ; Cycle 13
|
||||
ADD %r0,%r0,%r0 ; clear the carry bit
|
||||
ADDIB,<= -4,%r26,$ENDLOOP ; actually happens in cycle 12
|
||||
FSTD %fr27,-48(%sp)
|
||||
; MFCTL %cr16,%r21 ; for timing
|
||||
; STD %r21,-112(%sp)
|
||||
|
||||
; Here is the loop.
|
||||
|
||||
$LOOP XMPYU %fr9L,%fr28L,%fr28 ; Cycle 1
|
||||
ADD,DC %r29,%r4,%r4
|
||||
FSTD %fr30,-56(%sp)
|
||||
FLDD 0(%r24),%fr24
|
||||
|
||||
LDO SIXTEEN(%r23),%r23 ; Cycle 2
|
||||
ADD,DC %r0,%r20,%r20
|
||||
FSTD %fr26,-88(%sp)
|
||||
|
||||
XMPYU %fr9R,%fr24R,%fr27 ; Cycle 3
|
||||
ADD %r3,%r1,%r1
|
||||
FSTD %fr28,-104(%sp)
|
||||
LDD UN_EIGHT(%r23),%r21
|
||||
|
||||
XMPYU %fr9R,%fr24L,%fr25 ; Cycle 4
|
||||
ADD,DC %r21,%r4,%r28
|
||||
FSTD %fr29,-72(%sp)
|
||||
LDD -96(%sp),%r3
|
||||
|
||||
XMPYU %fr9L,%fr24L,%fr26 ; Cycle 5
|
||||
ADD,DC %r20,%r31,%r22
|
||||
LDD -64(%sp),%r19
|
||||
LDD -80(%sp),%r21
|
||||
|
||||
XMPYU %fr9L,%fr24R,%fr24 ; Cycle 6
|
||||
ADD %r21,%r3,%r3
|
||||
LDD -56(%sp),%r20
|
||||
STD %r1,UN_SIXTEEN(%r23)
|
||||
|
||||
ADD,DC %r20,%r19,%r19 ; Cycle 7
|
||||
SHRPD %r3,%r0,32,%r21
|
||||
LDD -88(%sp),%r4
|
||||
LDD -48(%sp),%r1
|
||||
|
||||
ADD,DC %r0,%r0,%r20 ; Cycle 8
|
||||
SHRPD %r19,%r3,32,%r3
|
||||
FLDD EIGHT(%r24),%fr28
|
||||
LDD -104(%sp),%r31
|
||||
|
||||
SHRPD %r20,%r19,32,%r20 ; Cycle 9
|
||||
ADD %r21,%r1,%r1
|
||||
STD %r28,UN_EIGHT(%r23)
|
||||
LDD -72(%sp),%r29
|
||||
|
||||
XMPYU %fr9L,%fr28R,%fr31 ; Cycle 10
|
||||
ADD,DC %r3,%r4,%r4
|
||||
FSTD %fr24,-96(%sp)
|
||||
|
||||
XMPYU %fr9R,%fr28L,%fr30 ; Cycle 11
|
||||
ADD,DC %r0,%r20,%r20
|
||||
FSTD %fr25,-80(%sp)
|
||||
LDD 0(%r23),%r3
|
||||
|
||||
LDO SIXTEEN(%r24),%r24 ; Cycle 12
|
||||
FSTD %fr31,-64(%sp)
|
||||
|
||||
XMPYU %fr9R,%fr28R,%fr29 ; Cycle 13
|
||||
ADD %r22,%r1,%r1
|
||||
ADDIB,> -2,%r26,$LOOP ; actually happens in cycle 12
|
||||
FSTD %fr27,-48(%sp)
|
||||
|
||||
$ENDLOOP
|
||||
|
||||
; Shutdown code, first stage.
|
||||
|
||||
; MFCTL %cr16,%r21 ; for timing
|
||||
; STD %r21,UN_SIXTEEN(%r23)
|
||||
; LDD -112(%sp),%r21
|
||||
; STD %r21,UN_EIGHT(%r23)
|
||||
|
||||
XMPYU %fr9L,%fr28L,%fr28 ; Cycle 1
|
||||
ADD,DC %r29,%r4,%r4
|
||||
CMPIB,= 0,%r26,$ONEMORE
|
||||
FSTD %fr30,-56(%sp)
|
||||
|
||||
LDO SIXTEEN(%r23),%r23 ; Cycle 2
|
||||
ADD,DC %r0,%r20,%r20
|
||||
FSTD %fr26,-88(%sp)
|
||||
|
||||
ADD %r3,%r1,%r1 ; Cycle 3
|
||||
FSTD %fr28,-104(%sp)
|
||||
LDD UN_EIGHT(%r23),%r21
|
||||
|
||||
ADD,DC %r21,%r4,%r28 ; Cycle 4
|
||||
FSTD %fr29,-72(%sp)
|
||||
STD %r28,UN_EIGHT(%r23) ; moved up from cycle 9
|
||||
LDD -96(%sp),%r3
|
||||
|
||||
ADD,DC %r20,%r31,%r22 ; Cycle 5
|
||||
STD %r1,UN_SIXTEEN(%r23)
|
||||
$JOIN4
|
||||
LDD -64(%sp),%r19
|
||||
LDD -80(%sp),%r21
|
||||
|
||||
ADD %r21,%r3,%r3 ; Cycle 6
|
||||
LDD -56(%sp),%r20
|
||||
|
||||
ADD,DC %r20,%r19,%r19 ; Cycle 7
|
||||
SHRPD %r3,%r0,32,%r21
|
||||
LDD -88(%sp),%r4
|
||||
LDD -48(%sp),%r1
|
||||
|
||||
ADD,DC %r0,%r0,%r20 ; Cycle 8
|
||||
SHRPD %r19,%r3,32,%r3
|
||||
LDD -104(%sp),%r31
|
||||
|
||||
SHRPD %r20,%r19,32,%r20 ; Cycle 9
|
||||
ADD %r21,%r1,%r1
|
||||
LDD -72(%sp),%r29
|
||||
|
||||
ADD,DC %r3,%r4,%r4 ; Cycle 10
|
||||
|
||||
ADD,DC %r0,%r20,%r20 ; Cycle 11
|
||||
LDD 0(%r23),%r3
|
||||
|
||||
ADD %r22,%r1,%r1 ; Cycle 13
|
||||
|
||||
; Shutdown code, second stage.
|
||||
|
||||
ADD,DC %r29,%r4,%r4 ; Cycle 1
|
||||
|
||||
LDO SIXTEEN(%r23),%r23 ; Cycle 2
|
||||
ADD,DC %r0,%r20,%r20
|
||||
|
||||
LDD UN_EIGHT(%r23),%r21 ; Cycle 3
|
||||
ADD %r3,%r1,%r1
|
||||
|
||||
ADD,DC %r21,%r4,%r28 ; Cycle 4
|
||||
|
||||
ADD,DC %r20,%r31,%r22 ; Cycle 5
|
||||
|
||||
STD %r1,UN_SIXTEEN(%r23); Cycle 6
|
||||
|
||||
STD %r28,UN_EIGHT(%r23) ; Cycle 9
|
||||
|
||||
LDD 0(%r23),%r3 ; Cycle 11
|
||||
|
||||
; Shutdown code, third stage.
|
||||
|
||||
LDO SIXTEEN(%r23),%r23
|
||||
ADD %r3,%r22,%r1
|
||||
$JOIN1 ADD,DC %r0,%r0,%r21
|
||||
CMPIB,*= 0,%r21,$L0 ; if no overflow, exit
|
||||
STD %r1,UN_SIXTEEN(%r23)
|
||||
|
||||
; Final carry propagation
|
||||
|
||||
$FINAL1 LDO EIGHT(%r23),%r23
|
||||
LDD UN_SIXTEEN(%r23),%r21
|
||||
ADDI 1,%r21,%r21
|
||||
CMPIB,*= 0,%r21,$FINAL1 ; Keep looping if there is a carry.
|
||||
STD %r21,UN_SIXTEEN(%r23)
|
||||
B $L0
|
||||
NOP
|
||||
|
||||
; Here is the code that handles the difficult cases N=1, N=2, and N=3.
|
||||
; We do the usual trick -- branch out of the startup code at appropriate
|
||||
; points, and branch into the shutdown code.
|
||||
|
||||
$N_IS_SMALL
|
||||
CMPIB,= 0,%r26,$N_IS_ONE
|
||||
FSTD %fr24,-96(%sp) ; Cycle 10
|
||||
FLDD EIGHT(%r24),%fr28 ; Cycle 8
|
||||
XMPYU %fr9L,%fr28R,%fr31 ; Cycle 10
|
||||
XMPYU %fr9R,%fr28L,%fr30 ; Cycle 11
|
||||
FSTD %fr25,-80(%sp)
|
||||
FSTD %fr31,-64(%sp) ; Cycle 12
|
||||
XMPYU %fr9R,%fr28R,%fr29 ; Cycle 13
|
||||
FSTD %fr27,-48(%sp)
|
||||
XMPYU %fr9L,%fr28L,%fr28 ; Cycle 1
|
||||
CMPIB,= 2,%r26,$N_IS_THREE
|
||||
FSTD %fr30,-56(%sp)
|
||||
|
||||
; N = 2
|
||||
FSTD %fr26,-88(%sp) ; Cycle 2
|
||||
FSTD %fr28,-104(%sp) ; Cycle 3
|
||||
LDD -96(%sp),%r3 ; Cycle 4
|
||||
FSTD %fr29,-72(%sp)
|
||||
B $JOIN4
|
||||
ADD %r0,%r0,%r22
|
||||
|
||||
$N_IS_THREE
|
||||
FLDD SIXTEEN(%r24),%fr24
|
||||
FSTD %fr26,-88(%sp) ; Cycle 2
|
||||
XMPYU %fr9R,%fr24R,%fr27 ; Cycle 3
|
||||
FSTD %fr28,-104(%sp)
|
||||
XMPYU %fr9R,%fr24L,%fr25 ; Cycle 4
|
||||
LDD -96(%sp),%r3
|
||||
FSTD %fr29,-72(%sp)
|
||||
XMPYU %fr9L,%fr24L,%fr26 ; Cycle 5
|
||||
LDD -64(%sp),%r19
|
||||
LDD -80(%sp),%r21
|
||||
B $JOIN3
|
||||
ADD %r0,%r0,%r22
|
||||
|
||||
$N_IS_ONE
|
||||
FSTD %fr25,-80(%sp)
|
||||
FSTD %fr27,-48(%sp)
|
||||
FSTD %fr26,-88(%sp) ; Cycle 2
|
||||
B $JOIN5
|
||||
ADD %r0,%r0,%r22
|
||||
|
||||
; We came out of the unrolled loop with wrong parity. Do one more
|
||||
; single cycle. This is quite tricky, because of the way the
|
||||
; carry chains and SHRPD chains have been chopped up.
|
||||
|
||||
$ONEMORE
|
||||
|
||||
FLDD 0(%r24),%fr24
|
||||
|
||||
LDO SIXTEEN(%r23),%r23 ; Cycle 2
|
||||
ADD,DC %r0,%r20,%r20
|
||||
FSTD %fr26,-88(%sp)
|
||||
|
||||
XMPYU %fr9R,%fr24R,%fr27 ; Cycle 3
|
||||
FSTD %fr28,-104(%sp)
|
||||
LDD UN_EIGHT(%r23),%r21
|
||||
ADD %r3,%r1,%r1
|
||||
|
||||
XMPYU %fr9R,%fr24L,%fr25 ; Cycle 4
|
||||
ADD,DC %r21,%r4,%r28
|
||||
STD %r28,UN_EIGHT(%r23) ; moved from cycle 9
|
||||
LDD -96(%sp),%r3
|
||||
FSTD %fr29,-72(%sp)
|
||||
|
||||
XMPYU %fr9L,%fr24L,%fr26 ; Cycle 5
|
||||
ADD,DC %r20,%r31,%r22
|
||||
LDD -64(%sp),%r19
|
||||
LDD -80(%sp),%r21
|
||||
|
||||
STD %r1,UN_SIXTEEN(%r23); Cycle 6
|
||||
$JOIN3
|
||||
XMPYU %fr9L,%fr24R,%fr24
|
||||
LDD -56(%sp),%r20
|
||||
ADD %r21,%r3,%r3
|
||||
|
||||
ADD,DC %r20,%r19,%r19 ; Cycle 7
|
||||
LDD -88(%sp),%r4
|
||||
SHRPD %r3,%r0,32,%r21
|
||||
LDD -48(%sp),%r1
|
||||
|
||||
LDD -104(%sp),%r31 ; Cycle 8
|
||||
ADD,DC %r0,%r0,%r20
|
||||
SHRPD %r19,%r3,32,%r3
|
||||
|
||||
LDD -72(%sp),%r29 ; Cycle 9
|
||||
SHRPD %r20,%r19,32,%r20
|
||||
ADD %r21,%r1,%r1
|
||||
|
||||
ADD,DC %r3,%r4,%r4 ; Cycle 10
|
||||
FSTD %fr24,-96(%sp)
|
||||
|
||||
ADD,DC %r0,%r20,%r20 ; Cycle 11
|
||||
LDD 0(%r23),%r3
|
||||
FSTD %fr25,-80(%sp)
|
||||
|
||||
ADD %r22,%r1,%r1 ; Cycle 13
|
||||
FSTD %fr27,-48(%sp)
|
||||
|
||||
; Shutdown code, stage 1-1/2.
|
||||
|
||||
ADD,DC %r29,%r4,%r4 ; Cycle 1
|
||||
|
||||
LDO SIXTEEN(%r23),%r23 ; Cycle 2
|
||||
ADD,DC %r0,%r20,%r20
|
||||
FSTD %fr26,-88(%sp)
|
||||
|
||||
LDD UN_EIGHT(%r23),%r21 ; Cycle 3
|
||||
ADD %r3,%r1,%r1
|
||||
|
||||
ADD,DC %r21,%r4,%r28 ; Cycle 4
|
||||
STD %r28,UN_EIGHT(%r23) ; moved from cycle 9
|
||||
|
||||
ADD,DC %r20,%r31,%r22 ; Cycle 5
|
||||
STD %r1,UN_SIXTEEN(%r23)
|
||||
$JOIN5
|
||||
LDD -96(%sp),%r3 ; moved from cycle 4
|
||||
LDD -80(%sp),%r21
|
||||
ADD %r21,%r3,%r3 ; Cycle 6
|
||||
ADD,DC %r0,%r0,%r19 ; Cycle 7
|
||||
LDD -88(%sp),%r4
|
||||
SHRPD %r3,%r0,32,%r21
|
||||
LDD -48(%sp),%r1
|
||||
SHRPD %r19,%r3,32,%r3 ; Cycle 8
|
||||
ADD %r21,%r1,%r1 ; Cycle 9
|
||||
ADD,DC %r3,%r4,%r4 ; Cycle 10
|
||||
LDD 0(%r23),%r3 ; Cycle 11
|
||||
ADD %r22,%r1,%r1 ; Cycle 13
|
||||
|
||||
; Shutdown code, stage 2-1/2.
|
||||
|
||||
ADD,DC %r0,%r4,%r4 ; Cycle 1
|
||||
LDO SIXTEEN(%r23),%r23 ; Cycle 2
|
||||
LDD UN_EIGHT(%r23),%r21 ; Cycle 3
|
||||
ADD %r3,%r1,%r1
|
||||
STD %r1,UN_SIXTEEN(%r23)
|
||||
ADD,DC %r21,%r4,%r1
|
||||
B $JOIN1
|
||||
LDO EIGHT(%r23),%r23
|
||||
|
||||
; exit
|
||||
|
||||
$L0
|
||||
.LEAVE
|
||||
|
||||
; We have verified that the above command generates what we want:
|
||||
; LDW -124(%sp),%r4
|
||||
; BVE (%r2)
|
||||
; LDW,MB -128(%sp),%r3
|
||||
|
||||
.PROCEND
|
||||
|
||||
; ***************************************************************
|
||||
;
|
||||
; add_diag_[little/big]
|
||||
;
|
||||
; ***************************************************************
|
||||
|
||||
; The arguments are as follows:
|
||||
; r2 return PC, of course
|
||||
; r26 = arg1 = length
|
||||
; r25 = arg2 = vector to square
|
||||
; r24 = arg3 = result vector
|
||||
|
||||
#ifdef LITTLE_WORDIAN
|
||||
add_diag_little
|
||||
#else
|
||||
add_diag_big
|
||||
#endif
|
||||
.PROC
|
||||
.CALLINFO FRAME=120,ENTRY_GR=%r4
|
||||
.ENTER
|
||||
|
||||
ADDIB,< -1,%r26,$Z0 ; If N=0, exit immediately.
|
||||
NOP
|
||||
|
||||
; Startup code
|
||||
|
||||
FLDD 0(%r25),%fr7 ; Cycle 2 (alternate body)
|
||||
XMPYU %fr7R,%fr7R,%fr29 ; Cycle 4
|
||||
XMPYU %fr7L,%fr7R,%fr27 ; Cycle 5
|
||||
XMPYU %fr7L,%fr7L,%fr30
|
||||
LDO SIXTEEN(%r25),%r25 ; Cycle 6
|
||||
FSTD %fr29,-88(%sp)
|
||||
FSTD %fr27,-72(%sp) ; Cycle 7
|
||||
CMPIB,= 0,%r26,$DIAG_N_IS_ONE ; Cycle 1 (main body)
|
||||
FSTD %fr30,-96(%sp)
|
||||
FLDD UN_EIGHT(%r25),%fr7 ; Cycle 2
|
||||
LDD -88(%sp),%r22 ; Cycle 3
|
||||
LDD -72(%sp),%r31 ; Cycle 4
|
||||
XMPYU %fr7R,%fr7R,%fr28
|
||||
XMPYU %fr7L,%fr7R,%fr24 ; Cycle 5
|
||||
XMPYU %fr7L,%fr7L,%fr31
|
||||
LDD -96(%sp),%r20 ; Cycle 6
|
||||
FSTD %fr28,-80(%sp)
|
||||
ADD %r0,%r0,%r0 ; clear the carry bit
|
||||
ADDIB,<= -2,%r26,$ENDDIAGLOOP ; Cycle 7
|
||||
FSTD %fr24,-64(%sp)
|
||||
|
||||
; Here is the loop. It is unrolled twice, modelled after the "alternate body" and then the "main body".
|
||||
|
||||
$DIAGLOOP
|
||||
SHRPD %r31,%r0,31,%r3 ; Cycle 1 (alternate body)
|
||||
LDO SIXTEEN(%r25),%r25
|
||||
LDD 0(%r24),%r1
|
||||
FSTD %fr31,-104(%sp)
|
||||
SHRPD %r0,%r31,31,%r4 ; Cycle 2
|
||||
ADD,DC %r22,%r3,%r3
|
||||
FLDD UN_SIXTEEN(%r25),%fr7
|
||||
ADD,DC %r0,%r20,%r20 ; Cycle 3
|
||||
ADD %r1,%r3,%r3
|
||||
XMPYU %fr7R,%fr7R,%fr29 ; Cycle 4
|
||||
LDD -80(%sp),%r21
|
||||
STD %r3,0(%r24)
|
||||
XMPYU %fr7L,%fr7R,%fr27 ; Cycle 5
|
||||
XMPYU %fr7L,%fr7L,%fr30
|
||||
LDD -64(%sp),%r29
|
||||
LDD EIGHT(%r24),%r1
|
||||
ADD,DC %r4,%r20,%r20 ; Cycle 6
|
||||
LDD -104(%sp),%r19
|
||||
FSTD %fr29,-88(%sp)
|
||||
ADD %r20,%r1,%r1 ; Cycle 7
|
||||
FSTD %fr27,-72(%sp)
|
||||
SHRPD %r29,%r0,31,%r4 ; Cycle 1 (main body)
|
||||
LDO THIRTY_TWO(%r24),%r24
|
||||
LDD UN_SIXTEEN(%r24),%r28
|
||||
FSTD %fr30,-96(%sp)
|
||||
SHRPD %r0,%r29,31,%r3 ; Cycle 2
|
||||
ADD,DC %r21,%r4,%r4
|
||||
FLDD UN_EIGHT(%r25),%fr7
|
||||
STD %r1,UN_TWENTY_FOUR(%r24)
|
||||
ADD,DC %r0,%r19,%r19 ; Cycle 3
|
||||
ADD %r28,%r4,%r4
|
||||
XMPYU %fr7R,%fr7R,%fr28 ; Cycle 4
|
||||
LDD -88(%sp),%r22
|
||||
STD %r4,UN_SIXTEEN(%r24)
|
||||
XMPYU %fr7L,%fr7R,%fr24 ; Cycle 5
|
||||
XMPYU %fr7L,%fr7L,%fr31
|
||||
LDD -72(%sp),%r31
|
||||
LDD UN_EIGHT(%r24),%r28
|
||||
ADD,DC %r3,%r19,%r19 ; Cycle 6
|
||||
LDD -96(%sp),%r20
|
||||
FSTD %fr28,-80(%sp)
|
||||
ADD %r19,%r28,%r28 ; Cycle 7
|
||||
FSTD %fr24,-64(%sp)
|
||||
ADDIB,> -2,%r26,$DIAGLOOP ; Cycle 8
|
||||
STD %r28,UN_EIGHT(%r24)
|
||||
|
||||
$ENDDIAGLOOP
|
||||
|
||||
ADD,DC %r0,%r22,%r22
|
||||
CMPIB,= 0,%r26,$ONEMOREDIAG
|
||||
SHRPD %r31,%r0,31,%r3
|
||||
|
||||
; Shutdown code, first stage.
|
||||
|
||||
FSTD %fr31,-104(%sp) ; Cycle 1 (alternate body)
|
||||
LDD 0(%r24),%r28
|
||||
SHRPD %r0,%r31,31,%r4 ; Cycle 2
|
||||
ADD %r3,%r22,%r3
|
||||
ADD,DC %r0,%r20,%r20 ; Cycle 3
|
||||
LDD -80(%sp),%r21
|
||||
ADD %r3,%r28,%r3
|
||||
LDD -64(%sp),%r29 ; Cycle 4
|
||||
STD %r3,0(%r24)
|
||||
LDD EIGHT(%r24),%r1 ; Cycle 5
|
||||
LDO SIXTEEN(%r25),%r25 ; Cycle 6
|
||||
LDD -104(%sp),%r19
|
||||
ADD,DC %r4,%r20,%r20
|
||||
ADD %r20,%r1,%r1 ; Cycle 7
|
||||
ADD,DC %r0,%r21,%r21 ; Cycle 8
|
||||
STD %r1,EIGHT(%r24)
|
||||
|
||||
; Shutdown code, second stage.
|
||||
|
||||
SHRPD %r29,%r0,31,%r4 ; Cycle 1 (main body)
|
||||
LDO THIRTY_TWO(%r24),%r24
|
||||
LDD UN_SIXTEEN(%r24),%r1
|
||||
SHRPD %r0,%r29,31,%r3 ; Cycle 2
|
||||
ADD %r4,%r21,%r4
|
||||
ADD,DC %r0,%r19,%r19 ; Cycle 3
|
||||
ADD %r4,%r1,%r4
|
||||
STD %r4,UN_SIXTEEN(%r24); Cycle 4
|
||||
LDD UN_EIGHT(%r24),%r28 ; Cycle 5
|
||||
ADD,DC %r3,%r19,%r19 ; Cycle 6
|
||||
ADD %r19,%r28,%r28 ; Cycle 7
|
||||
ADD,DC %r0,%r0,%r22 ; Cycle 8
|
||||
CMPIB,*= 0,%r22,$Z0 ; if no overflow, exit
|
||||
STD %r28,UN_EIGHT(%r24)
|
||||
|
||||
; Final carry propagation
|
||||
|
||||
$FDIAG2
|
||||
LDO EIGHT(%r24),%r24
|
||||
LDD UN_EIGHT(%r24),%r26
|
||||
ADDI 1,%r26,%r26
|
||||
CMPIB,*= 0,%r26,$FDIAG2 ; Keep looping if there is a carry.
|
||||
STD %r26,UN_EIGHT(%r24)
|
||||
|
||||
B $Z0
|
||||
NOP
|
||||
|
||||
; Here is the code that handles the difficult case N=1.
|
||||
; We do the usual trick -- branch out of the startup code at appropriate
|
||||
; points, and branch into the shutdown code.
|
||||
|
||||
$DIAG_N_IS_ONE
|
||||
|
||||
LDD -88(%sp),%r22
|
||||
LDD -72(%sp),%r31
|
||||
B $JOINDIAG
|
||||
LDD -96(%sp),%r20
|
||||
|
||||
; We came out of the unrolled loop with wrong parity. Do one more
|
||||
; single cycle. This is the "alternate body". It will, of course,
|
||||
; give us opposite registers from the other case, so we need
|
||||
; completely different shutdown code.
|
||||
|
||||
$ONEMOREDIAG
|
||||
FSTD %fr31,-104(%sp) ; Cycle 1 (alternate body)
|
||||
LDD 0(%r24),%r28
|
||||
FLDD 0(%r25),%fr7 ; Cycle 2
|
||||
SHRPD %r0,%r31,31,%r4
|
||||
ADD %r3,%r22,%r3
|
||||
ADD,DC %r0,%r20,%r20 ; Cycle 3
|
||||
LDD -80(%sp),%r21
|
||||
ADD %r3,%r28,%r3
|
||||
LDD -64(%sp),%r29 ; Cycle 4
|
||||
STD %r3,0(%r24)
|
||||
XMPYU %fr7R,%fr7R,%fr29
|
||||
LDD EIGHT(%r24),%r1 ; Cycle 5
|
||||
XMPYU %fr7L,%fr7R,%fr27
|
||||
XMPYU %fr7L,%fr7L,%fr30
|
||||
LDD -104(%sp),%r19 ; Cycle 6
|
||||
FSTD %fr29,-88(%sp)
|
||||
ADD,DC %r4,%r20,%r20
|
||||
FSTD %fr27,-72(%sp) ; Cycle 7
|
||||
ADD %r20,%r1,%r1
|
||||
ADD,DC %r0,%r21,%r21 ; Cycle 8
|
||||
STD %r1,EIGHT(%r24)
|
||||
|
||||
; Shutdown code, first stage.
|
||||
|
||||
SHRPD %r29,%r0,31,%r4 ; Cycle 1 (main body)
|
||||
LDO THIRTY_TWO(%r24),%r24
|
||||
FSTD %fr30,-96(%sp)
|
||||
LDD UN_SIXTEEN(%r24),%r1
|
||||
SHRPD %r0,%r29,31,%r3 ; Cycle 2
|
||||
ADD %r4,%r21,%r4
|
||||
ADD,DC %r0,%r19,%r19 ; Cycle 3
|
||||
LDD -88(%sp),%r22
|
||||
ADD %r4,%r1,%r4
|
||||
LDD -72(%sp),%r31 ; Cycle 4
|
||||
STD %r4,UN_SIXTEEN(%r24)
|
||||
LDD UN_EIGHT(%r24),%r28 ; Cycle 5
|
||||
LDD -96(%sp),%r20 ; Cycle 6
|
||||
ADD,DC %r3,%r19,%r19
|
||||
ADD %r19,%r28,%r28 ; Cycle 7
|
||||
ADD,DC %r0,%r22,%r22 ; Cycle 8
|
||||
STD %r28,UN_EIGHT(%r24)
|
||||
|
||||
; Shutdown code, second stage.
|
||||
|
||||
$JOINDIAG
|
||||
SHRPD %r31,%r0,31,%r3 ; Cycle 1 (alternate body)
|
||||
LDD 0(%r24),%r28
|
||||
SHRPD %r0,%r31,31,%r4 ; Cycle 2
|
||||
ADD %r3,%r22,%r3
|
||||
ADD,DC %r0,%r20,%r20 ; Cycle 3
|
||||
ADD %r3,%r28,%r3
|
||||
STD %r3,0(%r24) ; Cycle 4
|
||||
LDD EIGHT(%r24),%r1 ; Cycle 5
|
||||
ADD,DC %r4,%r20,%r20
|
||||
ADD %r20,%r1,%r1 ; Cycle 7
|
||||
ADD,DC %r0,%r0,%r21 ; Cycle 8
|
||||
CMPIB,*= 0,%r21,$Z0 ; if no overflow, exit
|
||||
STD %r1,EIGHT(%r24)
|
||||
|
||||
; Final carry propagation
|
||||
|
||||
$FDIAG1
|
||||
LDO EIGHT(%r24),%r24
|
||||
LDD EIGHT(%r24),%r26
|
||||
ADDI 1,%r26,%r26
|
||||
CMPIB,*= 0,%r26,$FDIAG1 ; Keep looping if there is a carry.
|
||||
STD %r26,EIGHT(%r24)
|
||||
|
||||
$Z0
|
||||
.LEAVE
|
||||
.PROCEND
|
||||
; .ALLOW
|
||||
|
||||
.SPACE $TEXT$
|
||||
.SUBSPA $CODE$
|
||||
#ifdef LITTLE_WORDIAN
|
||||
.EXPORT maxpy_little,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=GR,LONG_RETURN
|
||||
.EXPORT add_diag_little,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,LONG_RETURN
|
||||
#else
|
||||
.EXPORT maxpy_big,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=GR,LONG_RETURN
|
||||
.EXPORT add_diag_big,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,LONG_RETURN
|
||||
#endif
|
||||
.END
|
||||
|
||||
|
||||
; How to use "maxpy_PA20_little" and "maxpy_PA20_big"
|
||||
;
|
||||
; The routine "maxpy_PA20_little" or "maxpy_PA20_big"
|
||||
; performs a 64-bit x any-size multiply, and adds the
|
||||
; result to an area of memory. That is, it performs
|
||||
; something like
|
||||
;
|
||||
; A B C D
|
||||
; * Z
|
||||
; __________
|
||||
; P Q R S T
|
||||
;
|
||||
; and then adds the "PQRST" vector into an area of memory,
|
||||
; handling all carries.
|
||||
;
|
||||
; Digression on nomenclature and endian-ness:
|
||||
;
|
||||
; Each of the capital letters in the above represents a 64-bit
|
||||
; quantity. That is, you could think of the discussion as
|
||||
; being in terms of radix-16-quintillion arithmetic. The data
|
||||
; type being manipulated is "unsigned long long int". This
|
||||
; requires the 64-bit extension of the HP-UX C compiler,
|
||||
; available at release 10. You need these compiler flags to
|
||||
; enable these extensions:
|
||||
;
|
||||
; -Aa +e +DA2.0 +DS2.0
|
||||
;
|
||||
; (The first specifies ANSI C, the second enables the
|
||||
; extensions, which are beyond ANSI C, and the third and
|
||||
; fourth tell the compiler to use whatever features of the
|
||||
; PA2.0 architecture it wishes, in order to made the code more
|
||||
; efficient. Since the presence of the assembly code will
|
||||
; make the program unable to run on anything less than PA2.0,
|
||||
; you might as well gain the performance enhancements in the C
|
||||
; code as well.)
|
||||
;
|
||||
; Questions of "endian-ness" often come up, usually in the
|
||||
; context of byte ordering in a word. These routines have a
|
||||
; similar issue, that could be called "wordian-ness".
|
||||
; Independent of byte ordering (PA is always big-endian), one
|
||||
; can make two choices when representing extremely large
|
||||
; numbers as arrays of 64-bit doublewords in memory.
|
||||
;
|
||||
; "Little-wordian" layout means that the least significant
|
||||
; word of a number is stored at the lowest address.
|
||||
;
|
||||
; MSW LSW
|
||||
; | |
|
||||
; V V
|
||||
;
|
||||
; A B C D E
|
||||
;
|
||||
; ^ ^ ^
|
||||
; | | |____ address 0
|
||||
; | |
|
||||
; | |_______address 8
|
||||
; |
|
||||
; address 32
|
||||
;
|
||||
; "Big-wordian" means that the most significant word is at the
|
||||
; lowest address.
|
||||
;
|
||||
; MSW LSW
|
||||
; | |
|
||||
; V V
|
||||
;
|
||||
; A B C D E
|
||||
;
|
||||
; ^ ^ ^
|
||||
; | | |____ address 32
|
||||
; | |
|
||||
; | |_______address 24
|
||||
; |
|
||||
; address 0
|
||||
;
|
||||
; When you compile the file, you must specify one or the other, with
|
||||
; a switch "-DLITTLE_WORDIAN" or "-DBIG_WORDIAN".
|
||||
;
|
||||
; Incidentally, you assemble this file as part of your
|
||||
; project with the same C compiler as the rest of the program.
|
||||
; My "makefile" for a superprecision arithmetic package has
|
||||
; the following stuff:
|
||||
;
|
||||
; # definitions:
|
||||
; CC = cc -Aa +e -z +DA2.0 +DS2.0 +w1
|
||||
; CFLAGS = +O3
|
||||
; LDFLAGS = -L /usr/lib -Wl,-aarchive
|
||||
;
|
||||
; # general build rule for ".s" files:
|
||||
; .s.o:
|
||||
; $(CC) $(CFLAGS) -c $< -DBIG_WORDIAN
|
||||
;
|
||||
; # Now any bind step that calls for pa20.o will assemble pa20.s
|
||||
;
|
||||
; End of digression, back to arithmetic:
|
||||
;
|
||||
; The way we multiply two huge numbers is, of course, to multiply
|
||||
; the "ABCD" vector by each of the "WXYZ" doublewords, adding
|
||||
; the result vectors with increasing offsets, the way we learned
|
||||
; in school, back before we all used calculators:
|
||||
;
|
||||
; A B C D
|
||||
; * W X Y Z
|
||||
; __________
|
||||
; P Q R S T
|
||||
; E F G H I
|
||||
; M N O P Q
|
||||
; + R S T U V
|
||||
; _______________
|
||||
; F I N A L S U M
|
||||
;
|
||||
; So we call maxpy_PA20_big (in my case; my package is
|
||||
; big-wordian) repeatedly, giving the W, X, Y, and Z arguments
|
||||
; in turn as the "scalar", and giving the "ABCD" vector each
|
||||
; time. We direct it to add its result into an area of memory
|
||||
; that we have cleared at the start. We skew the exact
|
||||
; location into that area with each call.
|
||||
;
|
||||
; The prototype for the function is
|
||||
;
|
||||
; extern void maxpy_PA20_big(
|
||||
; int length, /* Number of doublewords in the multiplicand vector. */
|
||||
; const long long int *scalaraddr, /* Address to fetch the scalar. */
|
||||
; const long long int *multiplicand, /* The multiplicand vector. */
|
||||
; long long int *result); /* Where to accumulate the result. */
|
||||
;
|
||||
; (You should place a copy of this prototype in an include file
|
||||
; or in your C file.)
|
||||
;
|
||||
; Now, IN ALL CASES, the given address for the multiplicand or
|
||||
; the result is that of the LEAST SIGNIFICANT DOUBLEWORD.
|
||||
; That word is, of course, the word at which the routine
|
||||
; starts processing. "maxpy_PA20_little" then increases the
|
||||
; addresses as it computes. "maxpy_PA20_big" decreases them.
|
||||
;
|
||||
; In our example above, "length" would be 4 in each case.
|
||||
; "multiplicand" would be the "ABCD" vector. Specifically,
|
||||
; the address of the element "D". "scalaraddr" would be the
|
||||
; address of "W", "X", "Y", or "Z" on the four calls that we
|
||||
; would make. (The order doesn't matter, of course.)
|
||||
; "result" would be the appropriate address in the result
|
||||
; area. When multiplying by "Z", that would be the least
|
||||
; significant word. When multiplying by "Y", it would be the
|
||||
; next higher word (8 bytes higher if little-wordian; 8 bytes
|
||||
; lower if big-wordian), and so on. The size of the result
|
||||
; area must be the the sum of the sizes of the multiplicand
|
||||
; and multiplier vectors, and must be initialized to zero
|
||||
; before we start.
|
||||
;
|
||||
; Whenever the routine adds its partial product into the result
|
||||
; vector, it follows carry chains as far as they need to go.
|
||||
;
|
||||
; Here is the super-precision multiply routine that I use for
|
||||
; my package. The package is big-wordian. I have taken out
|
||||
; handling of exponents (it's a floating point package):
|
||||
;
|
||||
; static void mul_PA20(
|
||||
; int size,
|
||||
; const long long int *arg1,
|
||||
; const long long int *arg2,
|
||||
; long long int *result)
|
||||
; {
|
||||
; int i;
|
||||
;
|
||||
; for (i=0 ; i<2*size ; i++) result[i] = 0ULL;
|
||||
;
|
||||
; for (i=0 ; i<size ; i++) {
|
||||
; maxpy_PA20_big(size, &arg2[i], &arg1[size-1], &result[size+i]);
|
||||
; }
|
||||
; }
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* logtab.h
|
||||
*
|
||||
* Arbitrary precision integer arithmetic library
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Michael J. Fromberger.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/* $Id: logtab.h,v 1.5 2004-04-27 23:04:36 gerv%gerv.net Exp $ */
|
||||
|
||||
const float s_logv_2[] = {
|
||||
0.000000000f, 0.000000000f, 1.000000000f, 0.630929754f, /* 0 1 2 3 */
|
||||
0.500000000f, 0.430676558f, 0.386852807f, 0.356207187f, /* 4 5 6 7 */
|
||||
0.333333333f, 0.315464877f, 0.301029996f, 0.289064826f, /* 8 9 10 11 */
|
||||
0.278942946f, 0.270238154f, 0.262649535f, 0.255958025f, /* 12 13 14 15 */
|
||||
0.250000000f, 0.244650542f, 0.239812467f, 0.235408913f, /* 16 17 18 19 */
|
||||
0.231378213f, 0.227670249f, 0.224243824f, 0.221064729f, /* 20 21 22 23 */
|
||||
0.218104292f, 0.215338279f, 0.212746054f, 0.210309918f, /* 24 25 26 27 */
|
||||
0.208014598f, 0.205846832f, 0.203795047f, 0.201849087f, /* 28 29 30 31 */
|
||||
0.200000000f, 0.198239863f, 0.196561632f, 0.194959022f, /* 32 33 34 35 */
|
||||
0.193426404f, 0.191958720f, 0.190551412f, 0.189200360f, /* 36 37 38 39 */
|
||||
0.187901825f, 0.186652411f, 0.185449023f, 0.184288833f, /* 40 41 42 43 */
|
||||
0.183169251f, 0.182087900f, 0.181042597f, 0.180031327f, /* 44 45 46 47 */
|
||||
0.179052232f, 0.178103594f, 0.177183820f, 0.176291434f, /* 48 49 50 51 */
|
||||
0.175425064f, 0.174583430f, 0.173765343f, 0.172969690f, /* 52 53 54 55 */
|
||||
0.172195434f, 0.171441601f, 0.170707280f, 0.169991616f, /* 56 57 58 59 */
|
||||
0.169293808f, 0.168613099f, 0.167948779f, 0.167300179f, /* 60 61 62 63 */
|
||||
0.166666667f
|
||||
};
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
#!/usr/linguist/bin/perl
|
||||
|
||||
#
|
||||
# make-logtab
|
||||
#
|
||||
# Generate a table of logarithms of 2 in various bases, for use in
|
||||
# estimating the output sizes of various bases.
|
||||
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the MPI Arbitrary Precision Integer Arithmetic
|
||||
# library.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Michael J. Fromberger <sting@linguist.dartmouth.edu>
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998, 2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# $Id: make-logtab,v 1.4 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
|
||||
$ARRAYNAME = $ENV{'ARRAYNAME'} || "s_logv_2";
|
||||
$ARRAYTYPE = $ENV{'ARRAYTYPE'} || "float";
|
||||
|
||||
printf("const %s %s[] = {\n %0.9ff, %0.9ff, ",
|
||||
$ARRAYTYPE, $ARRAYNAME, 0, 0);
|
||||
$brk = 2;
|
||||
for($ix = 2; $ix < 64; $ix++) {
|
||||
printf("%0.9ff, ", (log(2)/log($ix)));
|
||||
$brk = ($brk + 1) & 3;
|
||||
if(!$brk) {
|
||||
printf(" /* %2d %2d %2d %2d */\n ",
|
||||
$ix - 3, $ix - 2, $ix - 1, $ix);
|
||||
}
|
||||
}
|
||||
printf("%0.9ff\n};\n\n", (log(2)/log($ix)));
|
||||
|
||||
exit 0;
|
||||
@@ -1,133 +0,0 @@
|
||||
#!/usr/linguist/bin/perl
|
||||
|
||||
#
|
||||
# make-test-arrays
|
||||
#
|
||||
# Given a test-arrays file, which specifies the test suite names, the
|
||||
# names of the functions which perform those test suites, and
|
||||
# descriptive comments, this script generates C structures for the
|
||||
# mpi-test program. The input consists of lines of the form:
|
||||
#
|
||||
# suite-name:function-name:comment
|
||||
#
|
||||
# The output is written to the standard output. Blank lines are
|
||||
# ignored, and comments beginning with '#' are stripped.
|
||||
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Michael J. Fromberger <sting@linguist.dartmouth.edu>.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# $Id: make-test-arrays,v 1.2 2005-02-02 22:28:22 gerv%gerv.net Exp $
|
||||
#
|
||||
|
||||
# Read parameters from the environment, if available
|
||||
$NAMEVAR = $ENV{'NAMEVAR'} || "g_names";
|
||||
$COUNTVAR = $ENV{'COUNTVAR'} || "g_count";
|
||||
$FUNCVAR = $ENV{'FUNCVAR'} || "g_tests";
|
||||
$DESCVAR = $ENV{'DESCVAR'} || "g_descs";
|
||||
$FUNCLEN = 13;
|
||||
$NAMELEN = 18;
|
||||
$DESCLEN = 45;
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Suck in input from the files on the command line, or standard input
|
||||
while(<>) {
|
||||
chomp;
|
||||
s/\#.*$//;
|
||||
next if /^\s*$/;
|
||||
|
||||
($suite, $func, $desc) = split(/:/, $_);
|
||||
|
||||
$tmp = { "suite" => $suite,
|
||||
"func" => $func,
|
||||
"desc" => $desc };
|
||||
|
||||
push(@item, $tmp);
|
||||
}
|
||||
$count = scalar(@item);
|
||||
$last = pop(@item);
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Output the table of names
|
||||
print "/* Table mapping test suite names to index numbers */\n";
|
||||
printf("const int %s = %d;\n", $COUNTVAR, $count);
|
||||
printf("const char *%s[] = {\n", $NAMEVAR);
|
||||
|
||||
foreach $elt (@item) {
|
||||
printf(" \"%s\",%s/* %s%s */\n", $elt->{"suite"},
|
||||
" " x ($NAMELEN - length($elt->{"suite"})),
|
||||
$elt->{"desc"},
|
||||
" " x ($DESCLEN - length($elt->{"desc"})));
|
||||
}
|
||||
printf(" \"%s\" %s/* %s%s */\n", $last->{"suite"},
|
||||
" " x ($NAMELEN - length($last->{"suite"})),
|
||||
$last->{"desc"},
|
||||
" " x ($DESCLEN - length($last->{"desc"})));
|
||||
print "};\n\n";
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Output the driver function prototypes
|
||||
print "/* Test function prototypes */\n";
|
||||
foreach $elt (@item, $last) {
|
||||
printf("int %s(void);\n", $elt->{"func"});
|
||||
}
|
||||
print "\n";
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Output the table of functions
|
||||
print "/* Table mapping index numbers to functions */\n";
|
||||
printf("int (*%s[])(void) = {\n ", $FUNCVAR);
|
||||
$brk = 0;
|
||||
|
||||
foreach $elt (@item) {
|
||||
print($elt->{"func"}, ", ",
|
||||
" " x ($FUNCLEN - length($elt->{"func"})));
|
||||
$brk = ($brk + 1) & 3;
|
||||
print "\n " unless($brk);
|
||||
}
|
||||
print $last->{"func"}, "\n};\n\n";
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Output the table of descriptions
|
||||
print "/* Table mapping index numbers to descriptions */\n";
|
||||
printf("const char *%s[] = {\n", $DESCVAR);
|
||||
|
||||
foreach $elt (@item) {
|
||||
printf(" \"%s\",\n", $elt->{"desc"});
|
||||
}
|
||||
printf(" \"%s\"\n};\n\n", $last->{"desc"});
|
||||
|
||||
exit 0;
|
||||
|
||||
@@ -1,342 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape security libraries.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <time.h>
|
||||
#include "mpi.h"
|
||||
#include "mpi-priv.h"
|
||||
|
||||
/* #define OLD_WAY 1 */
|
||||
|
||||
/* This key is the 1024-bit test key used for speed testing of RSA private
|
||||
** key ops.
|
||||
*/
|
||||
|
||||
#define CONST const
|
||||
|
||||
static CONST unsigned char default_n[128] = {
|
||||
0xc2,0xae,0x96,0x89,0xaf,0xce,0xd0,0x7b,0x3b,0x35,0xfd,0x0f,0xb1,0xf4,0x7a,0xd1,
|
||||
0x3c,0x7d,0xb5,0x86,0xf2,0x68,0x36,0xc9,0x97,0xe6,0x82,0x94,0x86,0xaa,0x05,0x39,
|
||||
0xec,0x11,0x51,0xcc,0x5c,0xa1,0x59,0xba,0x29,0x18,0xf3,0x28,0xf1,0x9d,0xe3,0xae,
|
||||
0x96,0x5d,0x6d,0x87,0x73,0xf6,0xf6,0x1f,0xd0,0x2d,0xfb,0x2f,0x7a,0x13,0x7f,0xc8,
|
||||
0x0c,0x7a,0xe9,0x85,0xfb,0xce,0x74,0x86,0xf8,0xef,0x2f,0x85,0x37,0x73,0x0f,0x62,
|
||||
0x4e,0x93,0x17,0xb7,0x7e,0x84,0x9a,0x94,0x11,0x05,0xca,0x0d,0x31,0x4b,0x2a,0xc8,
|
||||
0xdf,0xfe,0xe9,0x0c,0x13,0xc7,0xf2,0xad,0x19,0x64,0x28,0x3c,0xb5,0x6a,0xc8,0x4b,
|
||||
0x79,0xea,0x7c,0xce,0x75,0x92,0x45,0x3e,0xa3,0x9d,0x64,0x6f,0x04,0x69,0x19,0x17
|
||||
};
|
||||
|
||||
static CONST unsigned char default_d[128] = {
|
||||
0x13,0xcb,0xbc,0xf2,0xf3,0x35,0x8c,0x6d,0x7b,0x6f,0xd9,0xf3,0xa6,0x9c,0xbd,0x80,
|
||||
0x59,0x2e,0x4f,0x2f,0x11,0xa7,0x17,0x2b,0x18,0x8f,0x0f,0xe8,0x1a,0x69,0x5f,0x6e,
|
||||
0xac,0x5a,0x76,0x7e,0xd9,0x4c,0x6e,0xdb,0x47,0x22,0x8a,0x57,0x37,0x7a,0x5e,0x94,
|
||||
0x7a,0x25,0xb5,0xe5,0x78,0x1d,0x3c,0x99,0xaf,0x89,0x7d,0x69,0x2e,0x78,0x9d,0x1d,
|
||||
0x84,0xc8,0xc1,0xd7,0x1a,0xb2,0x6d,0x2d,0x8a,0xd9,0xab,0x6b,0xce,0xae,0xb0,0xa0,
|
||||
0x58,0x55,0xad,0x5c,0x40,0x8a,0xd6,0x96,0x08,0x8a,0xe8,0x63,0xe6,0x3d,0x6c,0x20,
|
||||
0x49,0xc7,0xaf,0x0f,0x25,0x73,0xd3,0x69,0x43,0x3b,0xf2,0x32,0xf8,0x3d,0x5e,0xee,
|
||||
0x7a,0xca,0xd6,0x94,0x55,0xe5,0xbd,0x25,0x34,0x8d,0x63,0x40,0xb5,0x8a,0xc3,0x01
|
||||
};
|
||||
|
||||
|
||||
#define DEFAULT_ITERS 50
|
||||
|
||||
typedef clock_t timetype;
|
||||
#define gettime(x) *(x) = clock()
|
||||
#define subtime(a, b) a -= b
|
||||
#define msec(x) ((clock_t)((double)x * 1000.0 / CLOCKS_PER_SEC))
|
||||
#define sec(x) (x / CLOCKS_PER_SEC)
|
||||
|
||||
struct TimingContextStr {
|
||||
timetype start;
|
||||
timetype end;
|
||||
timetype interval;
|
||||
|
||||
int minutes;
|
||||
int seconds;
|
||||
int millisecs;
|
||||
};
|
||||
|
||||
typedef struct TimingContextStr TimingContext;
|
||||
|
||||
TimingContext *CreateTimingContext(void)
|
||||
{
|
||||
return (TimingContext *)malloc(sizeof(TimingContext));
|
||||
}
|
||||
|
||||
void DestroyTimingContext(TimingContext *ctx)
|
||||
{
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
void TimingBegin(TimingContext *ctx)
|
||||
{
|
||||
gettime(&ctx->start);
|
||||
}
|
||||
|
||||
static void timingUpdate(TimingContext *ctx)
|
||||
{
|
||||
|
||||
ctx->millisecs = msec(ctx->interval) % 1000;
|
||||
ctx->seconds = sec(ctx->interval);
|
||||
ctx->minutes = ctx->seconds / 60;
|
||||
ctx->seconds %= 60;
|
||||
|
||||
}
|
||||
|
||||
void TimingEnd(TimingContext *ctx)
|
||||
{
|
||||
gettime(&ctx->end);
|
||||
ctx->interval = ctx->end;
|
||||
subtime(ctx->interval, ctx->start);
|
||||
timingUpdate(ctx);
|
||||
}
|
||||
|
||||
char *TimingGenerateString(TimingContext *ctx)
|
||||
{
|
||||
static char sBuf[4096];
|
||||
|
||||
sprintf(sBuf, "%d minutes, %d.%03d seconds", ctx->minutes,
|
||||
ctx->seconds, ctx->millisecs);
|
||||
return sBuf;
|
||||
}
|
||||
|
||||
static void
|
||||
dumpBytes( unsigned char * b, int l)
|
||||
{
|
||||
int i;
|
||||
if (l <= 0)
|
||||
return;
|
||||
for (i = 0; i < l; ++i) {
|
||||
if (i % 16 == 0)
|
||||
printf("\t");
|
||||
printf(" %02x", b[i]);
|
||||
if (i % 16 == 15)
|
||||
printf("\n");
|
||||
}
|
||||
if ((i % 16) != 0)
|
||||
printf("\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static mp_err
|
||||
testNewFuncs(const unsigned char * modulusBytes, int modulus_len)
|
||||
{
|
||||
mp_err mperr = MP_OKAY;
|
||||
mp_int modulus;
|
||||
unsigned char buf[512];
|
||||
|
||||
mperr = mp_init(&modulus);
|
||||
mperr = mp_read_unsigned_octets(&modulus, modulusBytes, modulus_len );
|
||||
mperr = mp_to_fixlen_octets(&modulus, buf, modulus_len);
|
||||
mperr = mp_to_fixlen_octets(&modulus, buf, modulus_len+1);
|
||||
mperr = mp_to_fixlen_octets(&modulus, buf, modulus_len+4);
|
||||
mperr = mp_to_unsigned_octets(&modulus, buf, modulus_len);
|
||||
mperr = mp_to_signed_octets(&modulus, buf, modulus_len + 1);
|
||||
mp_clear(&modulus);
|
||||
return mperr;
|
||||
}
|
||||
|
||||
int
|
||||
testModExp( const unsigned char * modulusBytes,
|
||||
const unsigned int expo,
|
||||
const unsigned char * input,
|
||||
unsigned char * output,
|
||||
int modulus_len)
|
||||
{
|
||||
mp_err mperr = MP_OKAY;
|
||||
mp_int modulus;
|
||||
mp_int base;
|
||||
mp_int exponent;
|
||||
mp_int result;
|
||||
|
||||
mperr = mp_init(&modulus);
|
||||
mperr += mp_init(&base);
|
||||
mperr += mp_init(&exponent);
|
||||
mperr += mp_init(&result);
|
||||
/* we initialize all mp_ints unconditionally, even if some fail.
|
||||
** This guarantees that the DIGITS pointer is valid (even if null).
|
||||
** So, mp_clear will do the right thing below.
|
||||
*/
|
||||
if (mperr == MP_OKAY) {
|
||||
mperr = mp_read_unsigned_octets(&modulus,
|
||||
modulusBytes + (sizeof default_n - modulus_len), modulus_len );
|
||||
mperr += mp_read_unsigned_octets(&base, input, modulus_len );
|
||||
mp_set(&exponent, expo);
|
||||
if (mperr == MP_OKAY) {
|
||||
#if OLD_WAY
|
||||
mperr = s_mp_exptmod(&base, &exponent, &modulus, &result);
|
||||
#else
|
||||
mperr = mp_exptmod(&base, &exponent, &modulus, &result);
|
||||
#endif
|
||||
if (mperr == MP_OKAY) {
|
||||
mperr = mp_to_fixlen_octets(&result, output, modulus_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
mp_clear(&base);
|
||||
mp_clear(&result);
|
||||
|
||||
mp_clear(&modulus);
|
||||
mp_clear(&exponent);
|
||||
|
||||
return (int)mperr;
|
||||
}
|
||||
|
||||
int
|
||||
doModExp( const unsigned char * modulusBytes,
|
||||
const unsigned char * exponentBytes,
|
||||
const unsigned char * input,
|
||||
unsigned char * output,
|
||||
int modulus_len)
|
||||
{
|
||||
mp_err mperr = MP_OKAY;
|
||||
mp_int modulus;
|
||||
mp_int base;
|
||||
mp_int exponent;
|
||||
mp_int result;
|
||||
|
||||
mperr = mp_init(&modulus);
|
||||
mperr += mp_init(&base);
|
||||
mperr += mp_init(&exponent);
|
||||
mperr += mp_init(&result);
|
||||
/* we initialize all mp_ints unconditionally, even if some fail.
|
||||
** This guarantees that the DIGITS pointer is valid (even if null).
|
||||
** So, mp_clear will do the right thing below.
|
||||
*/
|
||||
if (mperr == MP_OKAY) {
|
||||
mperr = mp_read_unsigned_octets(&modulus,
|
||||
modulusBytes + (sizeof default_n - modulus_len), modulus_len );
|
||||
mperr += mp_read_unsigned_octets(&exponent, exponentBytes, modulus_len );
|
||||
mperr += mp_read_unsigned_octets(&base, input, modulus_len );
|
||||
if (mperr == MP_OKAY) {
|
||||
#if OLD_WAY
|
||||
mperr = s_mp_exptmod(&base, &exponent, &modulus, &result);
|
||||
#else
|
||||
mperr = mp_exptmod(&base, &exponent, &modulus, &result);
|
||||
#endif
|
||||
if (mperr == MP_OKAY) {
|
||||
mperr = mp_to_fixlen_octets(&result, output, modulus_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
mp_clear(&base);
|
||||
mp_clear(&result);
|
||||
|
||||
mp_clear(&modulus);
|
||||
mp_clear(&exponent);
|
||||
|
||||
return (int)mperr;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
TimingContext * timeCtx;
|
||||
char * progName;
|
||||
long iters = DEFAULT_ITERS;
|
||||
unsigned int modulus_len;
|
||||
int i;
|
||||
int rv;
|
||||
unsigned char buf [1024];
|
||||
unsigned char buf2[1024];
|
||||
|
||||
progName = strrchr(argv[0], '/');
|
||||
if (!progName)
|
||||
progName = strrchr(argv[0], '\\');
|
||||
progName = progName ? progName+1 : argv[0];
|
||||
|
||||
if (argc >= 2) {
|
||||
iters = atol(argv[1]);
|
||||
}
|
||||
|
||||
if (argc >= 3) {
|
||||
modulus_len = atol(argv[2]);
|
||||
} else
|
||||
modulus_len = sizeof default_n;
|
||||
|
||||
/* no library init function !? */
|
||||
|
||||
memset(buf, 0x41, sizeof buf);
|
||||
|
||||
if (iters < 2) {
|
||||
testNewFuncs( default_n, modulus_len);
|
||||
testNewFuncs( default_n+1, modulus_len - 1);
|
||||
testNewFuncs( default_n+2, modulus_len - 2);
|
||||
testNewFuncs( default_n+3, modulus_len - 3);
|
||||
|
||||
printf("%lu allocations, %lu frees, %lu copies\n", mp_allocs, mp_frees, mp_copies);
|
||||
rv = testModExp(default_n, 0, buf, buf2, modulus_len);
|
||||
dumpBytes((unsigned char *)buf2, modulus_len);
|
||||
|
||||
printf("%lu allocations, %lu frees, %lu copies\n", mp_allocs, mp_frees, mp_copies);
|
||||
rv = testModExp(default_n, 1, buf, buf2, modulus_len);
|
||||
dumpBytes((unsigned char *)buf2, modulus_len);
|
||||
|
||||
printf("%lu allocations, %lu frees, %lu copies\n", mp_allocs, mp_frees, mp_copies);
|
||||
rv = testModExp(default_n, 2, buf, buf2, modulus_len);
|
||||
dumpBytes((unsigned char *)buf2, modulus_len);
|
||||
|
||||
printf("%lu allocations, %lu frees, %lu copies\n", mp_allocs, mp_frees, mp_copies);
|
||||
rv = testModExp(default_n, 3, buf, buf2, modulus_len);
|
||||
dumpBytes((unsigned char *)buf2, modulus_len);
|
||||
}
|
||||
printf("%lu allocations, %lu frees, %lu copies\n", mp_allocs, mp_frees, mp_copies);
|
||||
rv = doModExp(default_n, default_d, buf, buf2, modulus_len);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "Error in modexp operation:\n");
|
||||
exit(1);
|
||||
}
|
||||
dumpBytes((unsigned char *)buf2, modulus_len);
|
||||
printf("%lu allocations, %lu frees, %lu copies\n", mp_allocs, mp_frees, mp_copies);
|
||||
|
||||
timeCtx = CreateTimingContext();
|
||||
TimingBegin(timeCtx);
|
||||
i = iters;
|
||||
while (i--) {
|
||||
rv = doModExp(default_n, default_d, buf, buf2, modulus_len);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "Error in modexp operation\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
TimingEnd(timeCtx);
|
||||
printf("%ld iterations in %s\n", iters, TimingGenerateString(timeCtx));
|
||||
printf("%lu allocations, %lu frees, %lu copies\n", mp_allocs, mp_frees, mp_copies);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,329 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is SPARC optimized Montgomery multiply functions.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Sun Microsystems Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Netscape Communications Corporation
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/* $Id: montmulf.c,v 1.7 2004-04-27 23:04:36 gerv%gerv.net Exp $ */
|
||||
|
||||
#ifdef SOLARIS
|
||||
#define RF_INLINE_MACROS 1
|
||||
#endif
|
||||
|
||||
static const double TwoTo16=65536.0;
|
||||
static const double TwoToMinus16=1.0/65536.0;
|
||||
static const double Zero=0.0;
|
||||
static const double TwoTo32=65536.0*65536.0;
|
||||
static const double TwoToMinus32=1.0/(65536.0*65536.0);
|
||||
|
||||
#ifdef RF_INLINE_MACROS
|
||||
|
||||
double upper32(double);
|
||||
double lower32(double, double);
|
||||
double mod(double, double, double);
|
||||
|
||||
void i16_to_d16_and_d32x4(const double * /*1/(2^16)*/,
|
||||
const double * /* 2^16*/,
|
||||
const double * /* 0 */,
|
||||
double * /*result16*/,
|
||||
double * /* result32 */,
|
||||
float * /*source - should be unsigned int*
|
||||
converted to float* */);
|
||||
|
||||
#else
|
||||
#ifdef MP_USE_FLOOR
|
||||
#include <math.h>
|
||||
#else
|
||||
#define floor(d) ((double)((unsigned long long)(d)))
|
||||
#endif
|
||||
|
||||
static double upper32(double x)
|
||||
{
|
||||
return floor(x*TwoToMinus32);
|
||||
}
|
||||
|
||||
static double lower32(double x, double y)
|
||||
{
|
||||
return x-TwoTo32*floor(x*TwoToMinus32);
|
||||
}
|
||||
|
||||
static double mod(double x, double oneoverm, double m)
|
||||
{
|
||||
return x-m*floor(x*oneoverm);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static void cleanup(double *dt, int from, int tlen)
|
||||
{
|
||||
int i;
|
||||
double tmp,tmp1,x,x1;
|
||||
|
||||
tmp=tmp1=Zero;
|
||||
/* original code **
|
||||
for(i=2*from;i<2*tlen-2;i++)
|
||||
{
|
||||
x=dt[i];
|
||||
dt[i]=lower32(x,Zero)+tmp1;
|
||||
tmp1=tmp;
|
||||
tmp=upper32(x);
|
||||
}
|
||||
dt[tlen-2]+=tmp1;
|
||||
dt[tlen-1]+=tmp;
|
||||
**end original code ***/
|
||||
/* new code ***/
|
||||
for(i=2*from;i<2*tlen;i+=2)
|
||||
{
|
||||
x=dt[i];
|
||||
x1=dt[i+1];
|
||||
dt[i]=lower32(x,Zero)+tmp;
|
||||
dt[i+1]=lower32(x1,Zero)+tmp1;
|
||||
tmp=upper32(x);
|
||||
tmp1=upper32(x1);
|
||||
}
|
||||
/** end new code **/
|
||||
}
|
||||
|
||||
|
||||
void conv_d16_to_i32(unsigned int *i32, double *d16, long long *tmp, int ilen)
|
||||
{
|
||||
int i;
|
||||
long long t, t1, a, b, c, d;
|
||||
|
||||
t1=0;
|
||||
a=(long long)d16[0];
|
||||
b=(long long)d16[1];
|
||||
for(i=0; i<ilen-1; i++)
|
||||
{
|
||||
c=(long long)d16[2*i+2];
|
||||
t1+=(unsigned int)a;
|
||||
t=(a>>32);
|
||||
d=(long long)d16[2*i+3];
|
||||
t1+=(b&0xffff)<<16;
|
||||
t+=(b>>16)+(t1>>32);
|
||||
i32[i]=(unsigned int)t1;
|
||||
t1=t;
|
||||
a=c;
|
||||
b=d;
|
||||
}
|
||||
t1+=(unsigned int)a;
|
||||
t=(a>>32);
|
||||
t1+=(b&0xffff)<<16;
|
||||
i32[i]=(unsigned int)t1;
|
||||
}
|
||||
|
||||
void conv_i32_to_d32(double *d32, unsigned int *i32, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
#pragma pipeloop(0)
|
||||
for(i=0;i<len;i++) d32[i]=(double)(i32[i]);
|
||||
}
|
||||
|
||||
|
||||
void conv_i32_to_d16(double *d16, unsigned int *i32, int len)
|
||||
{
|
||||
int i;
|
||||
unsigned int a;
|
||||
|
||||
#pragma pipeloop(0)
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
a=i32[i];
|
||||
d16[2*i]=(double)(a&0xffff);
|
||||
d16[2*i+1]=(double)(a>>16);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void conv_i32_to_d32_and_d16(double *d32, double *d16,
|
||||
unsigned int *i32, int len)
|
||||
{
|
||||
int i = 0;
|
||||
unsigned int a;
|
||||
|
||||
#pragma pipeloop(0)
|
||||
#ifdef RF_INLINE_MACROS
|
||||
for(;i<len-3;i+=4)
|
||||
{
|
||||
i16_to_d16_and_d32x4(&TwoToMinus16, &TwoTo16, &Zero,
|
||||
&(d16[2*i]), &(d32[i]), (float *)(&(i32[i])));
|
||||
}
|
||||
#endif
|
||||
for(;i<len;i++)
|
||||
{
|
||||
a=i32[i];
|
||||
d32[i]=(double)(i32[i]);
|
||||
d16[2*i]=(double)(a&0xffff);
|
||||
d16[2*i+1]=(double)(a>>16);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void adjust_montf_result(unsigned int *i32, unsigned int *nint, int len)
|
||||
{
|
||||
long long acc;
|
||||
int i;
|
||||
|
||||
if(i32[len]>0) i=-1;
|
||||
else
|
||||
{
|
||||
for(i=len-1; i>=0; i--)
|
||||
{
|
||||
if(i32[i]!=nint[i]) break;
|
||||
}
|
||||
}
|
||||
if((i<0)||(i32[i]>nint[i]))
|
||||
{
|
||||
acc=0;
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
acc=acc+(unsigned long long)(i32[i])-(unsigned long long)(nint[i]);
|
||||
i32[i]=(unsigned int)acc;
|
||||
acc=acc>>32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** the lengths of the input arrays should be at least the following:
|
||||
** result[nlen+1], dm1[nlen], dm2[2*nlen+1], dt[4*nlen+2], dn[nlen], nint[nlen]
|
||||
** all of them should be different from one another
|
||||
**
|
||||
*/
|
||||
void mont_mulf_noconv(unsigned int *result,
|
||||
double *dm1, double *dm2, double *dt,
|
||||
double *dn, unsigned int *nint,
|
||||
int nlen, double dn0)
|
||||
{
|
||||
int i, j, jj;
|
||||
int tmp;
|
||||
double digit, m2j, nextm2j, a, b;
|
||||
double *dptmp, *pdm1, *pdm2, *pdn, *pdtj, pdn_0, pdm1_0;
|
||||
|
||||
pdm1=&(dm1[0]);
|
||||
pdm2=&(dm2[0]);
|
||||
pdn=&(dn[0]);
|
||||
pdm2[2*nlen]=Zero;
|
||||
|
||||
if (nlen!=16)
|
||||
{
|
||||
for(i=0;i<4*nlen+2;i++) dt[i]=Zero;
|
||||
|
||||
a=dt[0]=pdm1[0]*pdm2[0];
|
||||
digit=mod(lower32(a,Zero)*dn0,TwoToMinus16,TwoTo16);
|
||||
|
||||
pdtj=&(dt[0]);
|
||||
for(j=jj=0;j<2*nlen;j++,jj++,pdtj++)
|
||||
{
|
||||
m2j=pdm2[j];
|
||||
a=pdtj[0]+pdn[0]*digit;
|
||||
b=pdtj[1]+pdm1[0]*pdm2[j+1]+a*TwoToMinus16;
|
||||
pdtj[1]=b;
|
||||
|
||||
#pragma pipeloop(0)
|
||||
for(i=1;i<nlen;i++)
|
||||
{
|
||||
pdtj[2*i]+=pdm1[i]*m2j+pdn[i]*digit;
|
||||
}
|
||||
if((jj==30)) {cleanup(dt,j/2+1,2*nlen+1); jj=0;}
|
||||
|
||||
digit=mod(lower32(b,Zero)*dn0,TwoToMinus16,TwoTo16);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
a=dt[0]=pdm1[0]*pdm2[0];
|
||||
|
||||
dt[65]= dt[64]= dt[63]= dt[62]= dt[61]= dt[60]=
|
||||
dt[59]= dt[58]= dt[57]= dt[56]= dt[55]= dt[54]=
|
||||
dt[53]= dt[52]= dt[51]= dt[50]= dt[49]= dt[48]=
|
||||
dt[47]= dt[46]= dt[45]= dt[44]= dt[43]= dt[42]=
|
||||
dt[41]= dt[40]= dt[39]= dt[38]= dt[37]= dt[36]=
|
||||
dt[35]= dt[34]= dt[33]= dt[32]= dt[31]= dt[30]=
|
||||
dt[29]= dt[28]= dt[27]= dt[26]= dt[25]= dt[24]=
|
||||
dt[23]= dt[22]= dt[21]= dt[20]= dt[19]= dt[18]=
|
||||
dt[17]= dt[16]= dt[15]= dt[14]= dt[13]= dt[12]=
|
||||
dt[11]= dt[10]= dt[ 9]= dt[ 8]= dt[ 7]= dt[ 6]=
|
||||
dt[ 5]= dt[ 4]= dt[ 3]= dt[ 2]= dt[ 1]=Zero;
|
||||
|
||||
pdn_0=pdn[0];
|
||||
pdm1_0=pdm1[0];
|
||||
|
||||
digit=mod(lower32(a,Zero)*dn0,TwoToMinus16,TwoTo16);
|
||||
pdtj=&(dt[0]);
|
||||
|
||||
for(j=0;j<32;j++,pdtj++)
|
||||
{
|
||||
|
||||
m2j=pdm2[j];
|
||||
a=pdtj[0]+pdn_0*digit;
|
||||
b=pdtj[1]+pdm1_0*pdm2[j+1]+a*TwoToMinus16;
|
||||
pdtj[1]=b;
|
||||
|
||||
/**** this loop will be fully unrolled:
|
||||
for(i=1;i<16;i++)
|
||||
{
|
||||
pdtj[2*i]+=pdm1[i]*m2j+pdn[i]*digit;
|
||||
}
|
||||
*************************************/
|
||||
pdtj[2]+=pdm1[1]*m2j+pdn[1]*digit;
|
||||
pdtj[4]+=pdm1[2]*m2j+pdn[2]*digit;
|
||||
pdtj[6]+=pdm1[3]*m2j+pdn[3]*digit;
|
||||
pdtj[8]+=pdm1[4]*m2j+pdn[4]*digit;
|
||||
pdtj[10]+=pdm1[5]*m2j+pdn[5]*digit;
|
||||
pdtj[12]+=pdm1[6]*m2j+pdn[6]*digit;
|
||||
pdtj[14]+=pdm1[7]*m2j+pdn[7]*digit;
|
||||
pdtj[16]+=pdm1[8]*m2j+pdn[8]*digit;
|
||||
pdtj[18]+=pdm1[9]*m2j+pdn[9]*digit;
|
||||
pdtj[20]+=pdm1[10]*m2j+pdn[10]*digit;
|
||||
pdtj[22]+=pdm1[11]*m2j+pdn[11]*digit;
|
||||
pdtj[24]+=pdm1[12]*m2j+pdn[12]*digit;
|
||||
pdtj[26]+=pdm1[13]*m2j+pdn[13]*digit;
|
||||
pdtj[28]+=pdm1[14]*m2j+pdn[14]*digit;
|
||||
pdtj[30]+=pdm1[15]*m2j+pdn[15]*digit;
|
||||
/* no need for cleenup, cannot overflow */
|
||||
digit=mod(lower32(b,Zero)*dn0,TwoToMinus16,TwoTo16);
|
||||
}
|
||||
}
|
||||
|
||||
conv_d16_to_i32(result,dt+2*nlen,(long long *)dt,nlen+1);
|
||||
|
||||
adjust_montf_result(result,nint,nlen);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is interface file for SPARC Montgomery multiply functions.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Sun Microsystems Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Netscape Communications Corporation
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
/* $Id: montmulf.h,v 1.4 2004-04-27 23:04:36 gerv%gerv.net Exp $ */
|
||||
|
||||
/* The functions that are to be called from outside of the .s file have the
|
||||
* following interfaces and array size requirements:
|
||||
*/
|
||||
|
||||
|
||||
void conv_i32_to_d32(double *d32, unsigned int *i32, int len);
|
||||
|
||||
/* Converts an array of int's to an array of doubles, so that each double
|
||||
* corresponds to an int. len is the number of items converted.
|
||||
* Does not allocate the output array.
|
||||
* The pointers d32 and i32 should point to arrays of size at least len
|
||||
* (doubles and unsigned ints, respectively)
|
||||
*/
|
||||
|
||||
|
||||
void conv_i32_to_d16(double *d16, unsigned int *i32, int len);
|
||||
|
||||
/* Converts an array of int's to an array of doubles so that each element
|
||||
* of the int array is converted to a pair of doubles, the first one
|
||||
* corresponding to the lower (least significant) 16 bits of the int and
|
||||
* the second one corresponding to the upper (most significant) 16 bits of
|
||||
* the 32-bit int. len is the number of ints converted.
|
||||
* Does not allocate the output array.
|
||||
* The pointer d16 should point to an array of doubles of size at least
|
||||
* 2*len and i32 should point an array of ints of size at least len
|
||||
*/
|
||||
|
||||
|
||||
void conv_i32_to_d32_and_d16(double *d32, double *d16,
|
||||
unsigned int *i32, int len);
|
||||
|
||||
/* Does the above two conversions together, it is much faster than doing
|
||||
* both of those in succession
|
||||
*/
|
||||
|
||||
|
||||
void mont_mulf_noconv(unsigned int *result,
|
||||
double *dm1, double *dm2, double *dt,
|
||||
double *dn, unsigned int *nint,
|
||||
int nlen, double dn0);
|
||||
|
||||
/* Does the Montgomery multiplication of the numbers stored in the arrays
|
||||
* pointed to by dm1 and dm2, writing the result to the array pointed to by
|
||||
* result. It uses the array pointed to by dt as a temporary work area.
|
||||
* nint should point to the modulus in the array-of-integers representation,
|
||||
* dn should point to its array-of-doubles as obtained as a result of the
|
||||
* function call conv_i32_to_d32(dn, nint, nlen);
|
||||
* nlen is the length of the array containing the modulus.
|
||||
* The representation used for dm1 is the one that is a result of the function
|
||||
* call conv_i32_to_d32(dm1, m1, nlen), the representation for dm2 is the
|
||||
* result of the function call conv_i32_to_d16(dm2, m2, nlen).
|
||||
* Note that m1 and m2 should both be of length nlen, so they should be
|
||||
* padded with 0's if necessary before the conversion. The result comes in
|
||||
* this form (int representation, padded with 0's).
|
||||
* dn0 is the value of the 16 least significant bits of n0'.
|
||||
* The function does not allocate memory for any of the arrays, so the
|
||||
* pointers should point to arrays with the following minimal sizes:
|
||||
* result - nlen+1
|
||||
* dm1 - nlen
|
||||
* dm2 - 2*nlen+1 ( the +1 is necessary for technical reasons )
|
||||
* dt - 4*nlen+2
|
||||
* dn - nlen
|
||||
* nint - nlen
|
||||
* No two arrays should point to overlapping areas of memory.
|
||||
*/
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user