/*

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

*/
/*------------------------------------------------------------------------*\
|  Project Name  :   Path Development API
|  File Name     :   PathRec.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.
\*------------------------------------------------------------------------*/

#ifndef PATHREC_H
#define PATHREC_H

#include "cmapi.h"
#include "Defines.h"


#define CPATHREC_ERR_BASE					10000
#define CPATHREC_REQUIRED_PARAM_MISSING		CPATHREC_ERR_BASE + 1
#define CPATHREC_SERIAL_NUMBER_MISSING		CPATHREC_ERR_BASE + 2 
#define CPATHREC_ALLOC_FAIL					CPATHREC_ERR_BASE + 3


#include <string.h>

class CPathRec 
{
	public:
		CPathRec *NextRec;

		CPathRec();
		CPathRec( LPPATH_ENTRY_STRUCT lpPath_t, const unsigned long flag );
		~CPathRec();

		// Get the data
		LPPATH_ENTRY_STRUCT get_entry_pointer() { return &m_entry; }

		 // extracting the key
		char *get_key() const {return m_lpszKey;}

		// changing the value in an entry
		long set_entry(LPPATH_ENTRY_STRUCT lpPath_t, const unsigned long flag = 0);

		long set_entry( const char* subjectIssuer, 
						Bytes_struct* subjectSerial, 
						const char* issuerCA, 
						Bytes_struct* issuerSerial, 
						const unsigned long flag = 0 );


		// equality of keys
		bool operator==(const CPathRec&) const;
	//	bool operator==(const CPathRec *other);


		// extracting flag
		unsigned long get_flag()  { return m_flag; }
		void set_flag(long flag) { m_flag |= flag; }
		void unset_flag(long flag)
		{
			long setflag;
			memset(&setflag,0xFF,sizeof(long));
			setflag ^= flag;
			m_flag &= setflag;
		}

		void CopyFrom( CPathRec *rec );
//		char m_genTime[32];

	private:
		// information associated with a symbol
		char *m_lpszKey;
		PATH_ENTRY_STRUCT m_entry;
		unsigned long m_flag;

	friend class CPathCache;
	protected:
		long m_entryNumber;
		void FreeEntry();
};


#endif
