diff options
author | mrm <mrm@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-08-20 20:09:13 +0000 |
---|---|---|
committer | mrm <mrm@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-08-20 20:09:13 +0000 |
commit | 20892d58993c70d1dfeeee91d4781bdba4fc29d3 (patch) | |
tree | 2e3f2d04fd20cb48c89ee7ce361b32b4600e733c /ASNMP | |
parent | 8f35ed65ca60d4be0d1a4206e09ef91b8099401a (diff) | |
download | ATCD-20892d58993c70d1dfeeee91d4781bdba4fc29d3.tar.gz |
fixed constructor to initialize two state vars (output_) and error_status_
Diffstat (limited to 'ASNMP')
-rw-r--r-- | ASNMP/asnmp/pdu.cpp | 23 | ||||
-rw-r--r-- | ASNMP/asnmp/pdu.h | 8 |
2 files changed, 17 insertions, 14 deletions
diff --git a/ASNMP/asnmp/pdu.cpp b/ASNMP/asnmp/pdu.cpp index 39ad25b8bd1..cf3df561e3d 100644 --- a/ASNMP/asnmp/pdu.cpp +++ b/ASNMP/asnmp/pdu.cpp @@ -36,7 +36,8 @@ //=====================[ constructor no args ]========================= Pdu::Pdu( void): vb_count_(0), pdu_type_(0), validity_(FALSE), -error_index_(0), request_id_(0), notify_timestamp_(0) +error_index_(0), request_id_(0), notify_timestamp_(0), error_status_(0), +output_(0) { } @@ -83,7 +84,7 @@ validity_(FALSE), error_index_(0), request_id_(0), notify_timestamp_(0) Pdu::~Pdu() { delete_all_vbs(); - delete [] output; + delete [] output_; } @@ -154,20 +155,20 @@ char * Pdu::to_string() for ( int z = 0; z < vb_count_; z++) size += ACE_OS::strlen(vbs_[z]->to_string()); - ACE_NEW_RETURN(output, char[size], ""); + ACE_NEW_RETURN(output_, char[size], ""); // print pdu header info - sprintf(output, "pdu: valid: %d type:%d, req:%d, cnt: %d, err stat: %d \ + sprintf(output_, "pdu: valid: %d type:%d, req:%d, cnt: %d, err stat: %d \ err idx: %d\n", validity_, pdu_type_, request_id_, vb_count_, error_status_, error_index_ ); // now append vb pairs in this object for ( z = 0; z < vb_count_; z++) { - ACE_OS::strcat(output, vbs_[z]->to_string()); - ACE_OS::strcat(output, "\n\t"); + ACE_OS::strcat(output_, vbs_[z]->to_string()); + ACE_OS::strcat(output_, "\n\t"); } - return output; + return output_; } @@ -297,18 +298,18 @@ char *Pdu::agent_error_reason() char *val = bad.to_string_value(); const int HDR_SZ = 100; - if (!output) { + if (!output_) { int size = ACE_OS::strlen(pmsg) + ACE_OS::strlen(id) + ACE_OS::strlen(val); - ACE_NEW_RETURN(output, char[size + HDR_SZ], ""); + ACE_NEW_RETURN(output_, char[size + HDR_SZ], ""); } - ACE_OS::sprintf(output, + ACE_OS::sprintf(output_, "FAIL PDU REPORT: pdu id: %d vb cnt: %d vb idx: %d \n\ msg: %s vb oid: %s value: %s", get_request_id(), n_vbs, get_error_index(), pmsg, id, val); - return output; + return output_; } //=====================[ set the error status ]========================== diff --git a/ASNMP/asnmp/pdu.h b/ASNMP/asnmp/pdu.h index 234580cec00..e97b5f984d2 100644 --- a/ASNMP/asnmp/pdu.h +++ b/ASNMP/asnmp/pdu.h @@ -63,6 +63,8 @@ public: Pdu& operator+=( Vb &vb); // append a vb to the pdu + // TODO: add Pdu& operator-=(const Vb &vb); + int get_vblist( Vb* pvbs, const int pvb_count); // extract all Vbs from Pdu @@ -116,8 +118,8 @@ public: int valid() const; // returns validity of Pdu instance - int trim(const int position=1); - // trim off the last vb, if present + int trim(const int count=1); + // trim off count vbs from the end of the vb list int delete_vb( const int position); // delete a Vb anywhere within the Pdu @@ -179,7 +181,7 @@ public: Oid notify_enterprise_; private: - char *output; + char *output_; // buffer for to_string() }; |