Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ComputedMsg.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: ComputedMsg.cc,v 1.3 2004/05/19 15:56:23 mmarsh Exp $
00008 //
00009 // $Log: ComputedMsg.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 ComputedMsg::ComputedMsg() :
00023    Message( false )
00024 {
00025 }
00026 
00027 ComputedMsg::ComputedMsg( const LabelType& shareLabel,
00028                           const CODEX_ASN1::Integer& computor ) :
00029    Message( true ),
00030    m_shareLabel( shareLabel ),
00031    m_computor( computor )
00032 {
00033 }
00034 
00035 ComputedMsg::ComputedMsg( const ComputedMsg& aOther ) :
00036    Message( aOther.m_initialized ),
00037    m_shareLabel( aOther.m_shareLabel ),
00038    m_computor( aOther.m_computor )
00039 {
00040 }
00041 
00042 void
00043 ComputedMsg::operator=( const ComputedMsg& aOther )
00044 {
00045    m_initialized = aOther.m_initialized;
00046    m_shareLabel = aOther.m_shareLabel;
00047    m_computor = aOther.m_computor;
00048 }
00049 
00050 int
00051 ComputedMsg::marshal( unsigned char ** pp ) const
00052 {
00053    int r=0;
00054    int ret=0;
00055    unsigned char * p;
00056 
00057    ret += m_shareLabel.marshal(0);
00058    ret += m_computor.marshal(0);
00059    M_ASN1_I2D_seq_total();
00060    m_shareLabel.marshal(&p);
00061    m_computor.marshal(&p);
00062    M_ASN1_I2D_finish();
00063 }
00064 
00065 void*
00066 ComputedMsg::unmarshal( void* bogus, unsigned char ** pp, long length )
00067 {
00068    if ( m_initialized )
00069    {
00070       return NULL;
00071    }
00072    if ( (NULL == pp) || (NULL == *pp) )
00073    {
00074       return NULL;
00075    }
00076    ASN1_CTX c;
00077    c.pp = pp;
00078    c.q = *pp;
00079    c.error = ERR_R_NESTED_ASN1_ERROR;
00080    int i;
00081 
00082    M_ASN1_D2I_Init();
00083    M_ASN1_D2I_start_sequence();
00084    M_ASN1_D2I_get(i, m_shareLabel.unmarshal);
00085    M_ASN1_D2I_get(i, m_computor.unmarshal);
00086    if ( !asn1_Finish(&c) )
00087    {
00088       return NULL;
00089    }
00090    *pp=c.p;
00091    m_initialized = true;
00092    return this;
00093   err: // needed by ASN.1 macros
00094    return NULL;
00095 }

Generated on Fri May 6 17:38:58 2005 for COrnell Data EXchange (CODEX) by  doxygen 1.4.1