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 Retrieve( char *HostName, int requestJobCounter );
std::istream& Retrieve(std::istream& inStream );
};
std::istream& snmpjoblog::Retrieve( std::istream& inStream )
{
inStream.read( (char *)this, sizeof(snmpjoblog) );
return inStream;
}
int main(int argc, char **argv)
{
snmpjoblog trap;
ifstream file;
file.open( argv[1], ios::in );
trap.Retrieve( file );
cout << "reading " << sizeof( trap) << " bytes of " << argv[2] << "\n";
cout << "Job counter = " << ntohl( trap.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!