View Single Post
  #2   (View Single Post)  
Old 23rd October 2009
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Default

Strange as it all seems, this is working fine, reading the binary from a save file.
PHP Code:
#include <fstream>
#include <stdlib.h>

class snmpjoblog
{   
public:
    
char unknown1[8];
    
int jobCounter;
    
int unknown6;
    
char userName[40];
    
char computerName[20];
//8< snip other fields

    
int  Retrievechar *HostNameint requestJobCounter );
    
std::istreamRetrieve(std::istreaminStream );
};  

std::istreamsnmpjoblog::Retrievestd::istreaminStream )
{

    
inStream.read( (char *)thissizeof(snmpjoblog) );
    return 
inStream;
}

int main(int argcchar **argv)
{
    
snmpjoblog trap;
    
ifstream file;
    
file.openargv[1], ios::in );
    
trap.Retrievefile );
    
cout << "reading " << sizeoftrap) << " bytes of " << argv[2] << "\n";
    
cout << "Job counter = " << ntohltrap.jobCounter) << endl;
    
cout << "User name = " << trap.userName << endl;
    
cout << "computername = " << trap.computerName << endl;
    
file.close();
    return 
0;

(note : some headers may be missing)

I still cannot believe that this is a good thing - I mean, the class is overwriting itself!
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.
Reply With Quote