cerr << "Last message: " << Decode (msgcode) << " eid:"; if ( msg . exists (F_EID) ) cerr << msg . getField (F_EID);
cerr << "Last message: " << Decode (msgcode) << " iid:"; if ( msg . exists (F_IID) ) cerr << msg . getField (F_IID);
int main (int argc, char ** argv){  ifstream msgfile;                        // the message file, if applicable  Message_t msg;                           // the current message  NCode_t msgcode;                         // current message NCode  streampos lastpos;                       // last tellg pos  map<NCode_t, LongPair_t> sums;           // message count and size sums  long int c1, c2;  //-- Parse the command line arguments  ParseArgs (argc, argv);  //-- BEGIN: MAIN EXCEPTION CATCH  try {  //-- Open the message file  msgfile . open (OPT_MessageName . c_str( ));  if ( !msgfile )    AMOS_THROW_IO ("Could not open message file " + OPT_MessageName);  lastpos = msgfile . tellg( );  //-- Parse the message file  while ( (msgcode = msg . skip (msgfile)) != NULL_NCODE )    {      sums [msgcode] . first ++;      sums [msgcode] . second += msgfile . tellg( ) - lastpos;      lastpos = msgfile . tellg( );    }  }  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( );  printf ("%5s %9s %12s %12s\n", "NCODE", "COUNT", "SIZE", "AVG");  printf ("-----------------------------------------\n");  c1 = c2 = 0;  map<NCode_t, LongPair_t>::iterator mi;  for ( mi = sums . begin( ); mi != sums . end( ); mi ++ )    {      printf ("%5s %9ld %12ld %12ld\n",	      Decode (mi -> first) . c_str( ),	      mi -> second . first,	      mi -> second . second,	      SafeIntDiv (mi -> second . second, mi -> second . first));      c1 += mi -> second . first;      c2 += mi -> second . second;    }  printf ("-----------------------------------------\n");  printf ("      %9ld %12ld %12ld\n",	  (long int)c1, (long int)c2, SafeIntDiv (c2, c1));  return EXIT_SUCCESS;}