#ifdef AIX_PROD
/* @(#)06    1.4  src/examples/pubsex/binop/client.c, examples.src, os2dce21.dss, 960602a.1 1/11/96 10:46:45 */
/*
 *   COMPONENT_NAME: examples.src
 *
 *   FUNCTIONS: do_calls
 *              main
 *
 *   ORIGINS: 72
 *
 */
#endif /* AIX_PROD */

#include <dce/dce_error.h>
#include <dce/rpc.h>
#include <stdlib.h>
#include <stdio.h>
#include "binop.h"

#define CALLS_PER_PASS 100

extern int do_calls(rpc_binding_handle_t h);

int main(int ac, char*av[])
{
    rpc_binding_handle_t     bh;
    error_status_t           st;
    idl_char                 *string_binding;
    int                      pass, passes, failures = 0;
    if (ac != 3)  {
        fprintf(stderr, "Usage: %s address passes\n",av[0]);
        exit (1);
    }
    passes = atoi (av[2]);
    string_binding = (idl_char *) av[1];

    rpc_binding_from_string_binding(string_binding, &bh, &st);

    printf("Bound to %s\n",string_binding);


       for (pass = 0; pass < passes; pass++)  {
           printf("PASS %d\n", pass);
           failures += do_calls(bh);
       }

       printf("Summary: %d passes, %d failures\n", passes, failures);
    return (0);
}

int do_calls(rpc_binding_handle_t h)
{
         idl_long_int i, n;
         int failures;

         failures = 0;
         for (i=1; i <= CALLS_PER_PASS; i++) {
              binop_add(h, i, i, &n);
              if (n != i+i) {
                  printf("Two times %ld is NOT %ld\n", i, n);
                  fflush(stdout);

                  if (failures == 0) failures = 1;
              }
          }
          return(failures);
}
