/*****************************************************************/
/**                                                             **/
/**             (C) Copyright 1992 the Regents of the           **/
/**        University of California.  All Rights Reserved.      **/
/**                                                             **/
/**        This work was produced under the sponsorship of      **/
/**         the U.S. Department of Energy.  The Government      **/
/**                retains certain rights therein.              **/
/**                                                             **/
/**                         Written by                          **/
/**         Distributed Programming Environments Project        **/
/**           Computer Software and Networking Division,        **/
/**                   Livermore Computer Center,                **/
/**            Lawrence Livermore National Laboratory           **/
/**                                                             **/
/*****************************************************************/

Interface sample Noautotag;

   Record {
      Any <Context 0> r1;
      Any <Context 1> r2;
   } rec_two_any;

   Integer(4) I4;

End;


main(argc,argv)
   int argc;
   char *argv[];
{
   Integer(2) t1;
   Data (sample) inst;
   I4 i_s1, i_r1;
   I4 i_s2, i_r2;
   rec_two_any rec_s, rec_r;

   if (argc != 2)
      exit(1);   

/**************** initialization **********************/

   i_s1 = 123;
   i_s2 = -123;
   EncodeAny(sample, I4, rec_s.r1, i_s1);
   EncodeAny(sample, I4, rec_s.r2, i_s2);

/***************** send it out ************************/

   Bind_STUB(inst,argv[1],"w",Asn_1_ber);
   Encode inst
   {
      rec_s => rec_two_any;
   }
   Unbind(inst);

/***************** receive it back ********************/

   Bind_STUB(inst,argv[1],"r",Asn_1_ber);
   Decode inst
      {
	 On rec_two_any => (rec_r);
      }
   Unbind(inst);
   DecodeAny(sample, I4, i_r1, rec_r.r1);
   DecodeAny(sample, I4, i_r2, rec_r.r2);

/***************** report results *********************/

   if (i_s1 != i_r1) {
      printf("   i_r1 value was bad\n");
      exit(1);
   }
   if (i_s2 != i_r2) {
      printf("   i_r2 value was bad\n");
      exit(1);
   }

   printf("test completed\n");
   return (0);
}
