/*

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 a portion of the Path Development API developed
by CygnaCom Solutions, Inc.

Portions created by CygnaCom Solutions, Inc. are Copyright (C) CygnaCom 
Solutions, Inc. All Rights Reserved.

Contributor(s): ______________________________________.

http://www.cygnacom.com

*/

/*

  **** Include this file with the .lib for static linking.  ****

  */
/*------------------------------------------------------------------------*\
|  Project Name  :   Path Development API
|  File Name     :   cpl.h
|  Creation Date :   May 17, 1999
|  Author        :   Matt Cooper (mcooper@cygnacom.com)
|  Last Mode Date:   May 17, 1999
|  Modification History:
|--------------------------------------------------------------------------
|
|     Known Bugs:   None
|                   
|--------------------------------------------------------------------------
| Cryptographic devices and technical data regarding them are subject to
| Federal Government export controls as specified in Title 22, Code of
| Federal Regulations, Parts 121 through 128.  Cryptographic devices
| implementing the Data Encryption Standard (DES) and technical data
| regarding them must comply with these Federal regulations
|--------------------------------------------------------------------------
| Copyright (c) 1999, CygnaCom Solutions, Inc.
| All Rights Reserved.
\*------------------------------------------------------------------------*/

#if !defined(_CPL_HEADER_FILE_INCLUDED)
#define _CPL_HEADER_FILE_INCLUDED

#include "cmapi.h"

#ifndef VX /* Added by Masanori Satake. */
// This error base WILL change and more errors will likely be added
#endif
#define CPL_ERR_BASE						40000
#define CPL_LIBRARY_NOT_INIT				CPL_ERR_BASE + 1
#define CPL_ALLOC_FAILURE					CPL_ERR_BASE + 2
#define CPL_PARAM_MISSING					CPL_ERR_BASE + 3
#define CPL_PTR_INVALID						CPL_ERR_BASE + 4
#define CPL_PATH_MUST_BE_NULL				CPL_ERR_BASE + 5
#define CPL_INVALID_SESSION_HANDLE			CPL_ERR_BASE + 6
#define CPL_NO_SUCH_SESSION					CPL_ERR_BASE + 7
#define CPL_NO_MORE_SESSIONS				CPL_ERR_BASE + 8
#define CPL_UNEXPECTED_ERROR				CPL_ERR_BASE + 9
#define CPL_INVALID_PARAM					CPL_ERR_BASE + 10
#define CPL_DECODE_CERT_FAIL				CPL_ERR_BASE + 11
#define CPL_WRONG_ISSUER					CPL_ERR_BASE + 12
#define CPL_NO_MORE_PATHS					CPL_ERR_BASE + 13
#define CPL_INVALID_ISSUER					CPL_ERR_BASE + 14
#define CPL_DUPLICATE_ISSUER				CPL_ERR_BASE + 15
#define CPL_CACHE_DISK_PATH_MISSING			CPL_ERR_BASE + 16
#define CPL_CACHE_FILE_READ_FAIL			CPL_ERR_BASE + 17
#define CPL_CACHE_FILE_WRITE_FAIL			CPL_ERR_BASE + 18
#define CPL_PATH_CACHE_ERROR				CPL_ERR_BASE + 19
#define CPL_CERT_CACHE_ERROR				CPL_ERR_BASE + 20
#define CPL_LOAD_LIBRARY_CMAPI_FAIL			CPL_ERR_BASE + 21
#define CPL_CMAPI_ERROR						CPL_ERR_BASE + 22
#define CPL_CALLBACK_PTRS_MISSING			CPL_ERR_BASE + 23
#define CPL_EXCEPTION_CAUGHT				CPL_ERR_BASE + 24


#ifndef ULONG
#define ULONG unsigned long
#endif

#ifndef NULL
#define NULL 0x0000
#endif

#ifndef VX /* Added by Masanori Satake. */
//The last path returned was verified
#endif
#define CPL_LAST_PATH_VALID		1
#define CPL_LAST_PATH_INVALID	2


typedef struct CertPath_struct
{
    Cert_struct *cert;
    Bytes_struct asn1cert;
    struct CertPath_struct *next;
} CertPath_struct;

typedef struct
{
	char** rootDN;
	char** acceptableAlgOIDArray;
	char** acceptablePolicySetArray;
	ExtGetObjFuncPtr getCerts;
	ExtFreeObjFuncPtr freeCerts;
	void* callbackHandle;
	short boundsMask;
} CPL_SESSION_INFO;

typedef CPL_SESSION_INFO *	LPCPL_SESSION_INFO;


#ifdef _cplusplus
extern "C"
{
#endif

long CM_IMPORT CPL_InitializeLibrary( char* diskCacheDirectory );

long CM_IMPORT CPL_BeginPathDevelopment(	long* session, 
											char* subjectDN,
											CPL_SESSION_INFO *sessionInfo,
											CertPath_struct *partialPath,
											int inhibitPolicyMapping,
											int requireExplicitPolicy,
											char** desiredAlgOIDArray, 
											unsigned short keyUsage, 
											Bytes_struct* skid		);

long CM_IMPORT CPL_DoPathDevelopment(	long session, 
										CPL_SESSION_INFO * sessionInfo,
										CertPath_struct **certPath   );

long CM_IMPORT CPL_EndPathDevelopment(	long session, 
										CPL_SESSION_INFO *sessionInfo,
										CertPath_struct **certPath,
										int pathStatus   );

long CM_IMPORT CPL_TerminateLibrary();

#ifdef _cplusplus
}
#endif

#endif
