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

   Array I4 arrtype[5];

   Array Any arranytype[5];

End;


main(argc,argv)
   int argc;
   char *argv[];
{
   Data (sample) inst;
   arrtype arr_s, arr_r;
   arranytype arrany_s, arrany_r;

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

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

   arr_s[0] = 0x1234;
   arr_s[1] = 0x5678;
   arr_s[2] = 0x9abc;
   arr_s[3] = 0xdef0;
   arr_s[4] = 0xffff;

   EncodeAny(sample, I4, arrany_s[0], arr_s[0]);
   EncodeAny(sample, I4, arrany_s[1], arr_s[1]);
   EncodeAny(sample, I4, arrany_s[2], arr_s[2]);
   EncodeAny(sample, I4, arrany_s[3], arr_s[3]);
   EncodeAny(sample, I4, arrany_s[4], arr_s[4]);

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

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

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

   Bind_STUB(inst,argv[1],"r",Asn_1_ber);
   Decode inst
      {
	 On arranytype => (arrany_r);
      }
   Unbind(inst);

   DecodeAny(sample, I4, arr_r[0], arrany_r[0]);
   DecodeAny(sample, I4, arr_r[1], arrany_r[1]);
   DecodeAny(sample, I4, arr_r[2], arrany_r[2]);
   DecodeAny(sample, I4, arr_r[3], arrany_r[3]);
   DecodeAny(sample, I4, arr_r[4], arrany_r[4]);

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

   if (arr_s[0] != arr_r[0] ||
       arr_s[1] != arr_r[1] ||
       arr_s[2] != arr_r[2] ||
       arr_s[3] != arr_r[3] ||
       arr_s[4] != arr_r[4]) {
      printf("   array values were bad\n");
      exit(1);
   }

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