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

Error err_none 5 ;

Error err_one 6
   Integer(2);

End;


main(argc,argv)
   int argc;
   char *argv[];
{
   Control (sample) inst1;
   Integer(2) int2_s = 3;
   Integer(2) int2_r;
   int none_received1 = 0;
   int none_received2 = 0;
   int one_received = 0;

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


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

   Bind_STUB(inst1,argv[1],"w",Asn_1_ber);
   Give inst1 {
      err_none();
      err_none();
      err_one(int2_s);
      err_one(int2_s);
   }
   Unbind(inst1);

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

   Bind_STUB(inst1,argv[1],"r",Asn_1_ber);
   Accept inst1
   {
      On err_none()
	 none_received1 = 1;
   }
   Accept inst1
   {
      On err_none(...)
	 none_received2 = 1;
   }
   Accept inst1
   {
      On err_one(...)
	 one_received = 1;
   }
   Accept inst1
   {
      On err_one(int2_r,...);
   }
   Unbind(inst1);

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

   if (none_received1 != 1) {
      printf("   err_none() was not received\n");
      exit(1);
   }
   if (none_received2 != 1) {
      printf("   err_none(...) was not received\n");
      exit(1);
   }
   if (one_received != 1) {
      printf("   err_one(...) was not received\n");
      exit(1);
   }
   if (int2_r != int2_s) {
      printf("   int_r had a bad value\n");
      exit(1);
   }

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