/* -*- Mode: C -*-
 * $Header: /home/gene/library/website/docsrc/lizard/src/RCS/opaque-out.c,v 395.1 2008/04/20 17:25:55 gene Exp $
 *
 * Copyright (c) 2003, 2005 Gene Michael Stover.  All rights reserved.
 *
 * To STDOUT, write a single block of 4 XDR-encoded opaque octets.
 */

/* Standard C */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include <rpc/rpc.h>                    /* XDR & RPC */
#include <gc.h>                         /* Boehm collector */

int main ()
{
  int rc = 0;
  XDR xdrs;
  static char arr[] = { 1, 2, 3, 4 };

  xdrstdio_create (&xdrs, stdout, XDR_ENCODE);

  /* write four octets */
  if (xdr_opaque (&xdrs, arr, 4)) {
    /* write three octets */
    if (xdr_opaque (&xdrs, arr, 3)) {
      /* success */
    } else {
      printf ("\n%s:%d: xdr_opaque failed", __FILE__, __LINE__);
      rc = 3;
    }
  } else {
    printf ("\n%s:%d: xdr_opaque failed", __FILE__, __LINE__);
    rc = -42;
  }
  xdr_destroy (&xdrs);
  return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}

/* --- end of file --- */
