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

    Real(20,5)	Real20_5type;

    Record 
    {
       Real(20,5) 	<Optional 1.23 Default 4.56>	real20_5r1;
       BitString(17) 	<Optional 01011000010110000 
			 Default 10101000101010001>	bs17r2;
    } rectype;

   Invoke ike 52 Integer(2);

End;


main(argc,argv)
   int argc;
   char *argv[];
{
   rectype rec_s, rec_r;
   Data (sample) inst;
   int l1;
   Real20_5type realdefault = 4.56;
   static struct {
      unsigned long len;
      unsigned char val[17];
   } bsdefault = { 17, {0xa8,0xa8,0x80}};

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

   rec_s.real20_5r1 = 1.23;
   rec_s.bs17r2.len = 17;
   rec_s.bs17r2.val[0] = 0x58;
   rec_s.bs17r2.val[1] = 0x58;
   rec_s.bs17r2.val[2] = 0x58;

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

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

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

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

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

   if (realdefault != rec_r.real20_5r1) {
      printf("   rec_r.real20_5r1 value was bad\n");
      exit(1);
   }
   if (!__ROr_cmpP_BitString(&bsdefault,&(rec_r.bs17r2),(l1=17,&l1) ,0)) {
      printf("   rec_r.bs17r2 value was bad\n");
      exit(1);
   }

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