Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

ContributeMsg.cc

00001 /*
00002  * Copyright 2003 Michael A. Marsh, Cornell University. All rights reserved.
00003  * This software is released under the modified BSD license.
00004  * See the file LICENSE in the top-level directory for details.
00005  */
00006 //
00007 // $Id: ContributeMsg.cc,v 1.3 2004/05/19 15:56:23 mmarsh Exp $
00008 //
00009 // $Log: ContributeMsg.cc,v $
00010 // Revision 1.3  2004/05/19 15:56:23  mmarsh
00011 // Added copyright and license statements.
00012 //
00013 // Revision 1.2  2003/11/04 22:31:45  mmarsh
00014 // *** empty log message ***
00015 //
00016 //
00017 
00018 #include "Message.h"
00019 
00020 using namespace CODEX_APSS;
00021 
00022 ContributeMsg::ContributeMsg() :
00023    Message( false )
00024 {
00025 }
00026 
00027 ContributeMsg::ContributeMsg( const CODEX_ASN1::Integer& version,
00028                               const CODEX_ASN1::Integer& coordinator,
00029                               const CODEX_ASN1::Integer& contributor,
00030                               const EstablishedArray& evidence ) :
00031    Message( true ),
00032    m_version( version ),
00033    m_coordinator( coordinator ),
00034    m_contributor( contributor ),
00035    m_evidence( evidence )
00036 {
00037 }
00038 
00039 ContributeMsg::ContributeMsg( const ContributeMsg& aOther ) :
00040    Message( aOther.m_initialized ),
00041    m_version( aOther.m_version ),
00042    m_coordinator( aOther.m_coordinator ),
00043    m_contributor( aOther.m_contributor ),
00044    m_evidence( aOther.m_evidence )
00045 {
00046 }
00047 
00048 void
00049 ContributeMsg::operator=( const ContributeMsg& aOther )
00050 {
00051    m_initialized = aOther.m_initialized;
00052    m_version = aOther.m_version;
00053    m_coordinator = aOther.m_coordinator;
00054    m_contributor = aOther.m_contributor;
00055    m_evidence = aOther.m_evidence;
00056 }
00057 
00058 int
00059 ContributeMsg::marshal( unsigned char ** pp ) const
00060 {
00061    int r=0;
00062    int ret=0;
00063    unsigned char * p;
00064 
00065    ret += m_version.marshal(0);
00066    ret += m_coordinator.marshal(0);
00067    ret += m_contributor.marshal(0);
00068    ret += m_evidence.marshal(0);
00069    M_ASN1_I2D_seq_total();
00070    m_version.marshal(&p);
00071    m_coordinator.marshal(&p);
00072    m_contributor.marshal(&p);
00073    m_evidence.marshal(&p);
00074    M_ASN1_I2D_finish();
00075 }
00076 
00077 void*
00078 ContributeMsg::unmarshal( void* bogus, unsigned char ** pp, long length )
00079 {
00080    if ( m_initialized )
00081    {
00082       return NULL;
00083    }
00084    if ( (NULL == pp) || (NULL == *pp) )
00085    {
00086       return NULL;
00087    }
00088    ASN1_CTX c;
00089    c.pp = pp;
00090    c.q = *pp;
00091    c.error = ERR_R_NESTED_ASN1_ERROR;
00092    int i;
00093 
00094    M_ASN1_D2I_Init();
00095    M_ASN1_D2I_start_sequence();
00096    M_ASN1_D2I_get(i, m_version.unmarshal);
00097    M_ASN1_D2I_get(i, m_coordinator.unmarshal);
00098    M_ASN1_D2I_get(i, m_contributor.unmarshal);
00099    M_ASN1_D2I_get(i, m_evidence.unmarshal);
00100    if ( !asn1_Finish(&c) )
00101    {
00102       return NULL;
00103    }
00104    *pp=c.p;
00105    m_initialized = true;
00106    return this;
00107   err: // needed by ASN.1 macros
00108    return NULL;
00109 }

Generated on Wed Jun 2 16:32:54 2004 for COrnell Data EXchange (CODEX) by doxygen1.2.18