buff = (char *) SafeRealloc (buff, size); msgstreamp -> seekg (-size, ifstream::cur); msgstreamp -> read (buff, size);
{ buff_size = size; buff = (char *) SafeRealloc (buff, buff_size); } msgfile . seekg (-size, ifstream::cur); msgfile . read (buff, size);
int main (int argc, char ** argv){  Message_t msg;                           // the current message  istream * msgstreamp;                    // the message file stream  ifstream msgfile;                        // the message file, if applicable  NCode_t msgcode;                         // current message NCode  streampos spos;                          // begin of the curr record  char * buff = NULL;                      // record buffer  streamsize size;                         // size of curr record  streamsize buff_size = 0;                // size of curr record buffer  //-- Parse the command line arguments  ParseArgs (argc, argv);    //-- BEGIN: MAIN EXCEPTION CATCH  try {  //-- Open the message file  if ( OPT_MessageName . empty( ) )    msgstreamp = &cin;  else    {      msgfile . open (OPT_MessageName . c_str( ));      if ( !msgfile )	AMOS_THROW_IO ("Could not open message file " + OPT_MessageName);      msgstreamp = &msgfile;    }  //-- Parse the message file  while ( msgstreamp -> good( ) )    {      while ( msgstreamp -> get( ) != '{' )	if ( !msgstreamp -> good( ) )	  break;      msgstreamp -> putback ('{');      spos = msgstreamp -> tellg( );      msgcode = msg . skip (*msgstreamp);      if ( OPT_ExtractCodes . exists (msgcode) )	{	  size = msgstreamp -> tellg( ) - spos;	  if ( size > buff_size )	    buff = (char *) SafeRealloc (buff, size);	  msgstreamp -> seekg (-size, ifstream::cur);	  msgstreamp -> read (buff, size);	  cout . write (buff, size);	}    }  }  catch (Exception_t & e) {  //-- On error, print debugging information  cerr << "Last message: " << Decode (msgcode) << " eid:";  if ( msg . exists (F_EID) )    cerr << msg . getField (F_EID);  cerr << "\nERROR: -- Fatal AMOS Exception --\n" << e;  return EXIT_FAILURE;  }  //-- END: MAIN EXCEPTION CATCH  msgfile . close( );  return EXIT_SUCCESS;}