/*****************************************************************/
/**                                                             **/
/**             (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;

   Integer(4) I4;

   Invoke inv3 5
      Any,Integer(2),Any;

End;


main(argc,argv)
   int argc;
   char *argv[];
{
   Control (sample) inst1;
   I4 i_s1, i_r1;
   I4 i_s2, i_r2;
   Integer(2) i2_s, i2_r;
   Any encoded_any1, decoded_any1;
   Any encoded_any2, decoded_any2;

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

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

   i_s1 = 123;
   i_s2 = 345;
   i2_s = 45;
   EncodeAny(sample, I4, encoded_any1, i_s1);
   EncodeAny(sample, I4, encoded_any2, i_s2);

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

   Bind_STUB(inst1,argv[1],"w",Asn_1_ber);
   Give inst1
      inv3(encoded_any1, i2_s, encoded_any2);
   Unbind(inst1);

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

   Bind_STUB(inst1,argv[1],"r",Asn_1_ber);
   Accept inst1
   {
      On inv3(decoded_any1, i2_r, decoded_any2);
   }
   Unbind(inst1);

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

   DecodeAny(sample, I4, i_r1, decoded_any1);
   DecodeAny(sample, I4, i_r2, decoded_any2);

   if (i_s1 != i_r1) {
      printf("   i_r1 value was bad\n");
      exit(1);
   }
   if (i2_s != i2_r) {
      printf("   i2_r 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);
}
