/* ********************************************************************
 * *                                                                  *
 * *    Pipe function to convert a 7.27 IRIS POM Header file to       *
 * *                         7.28 format                              *
 * *                                                                  *
 * ********************************************************************
 * File: utils/examples/PomHeader728.C
 *
 *                        COPYRIGHT (c) 2002  BY
 *          SIGMET INCORPORATED, WESTFORD MASSACHUSETTS, U.S.A.
 * 
 * THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
 * ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
 * INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
 * COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
 * OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
 * TRANSFERED.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "sigtypes.h"

struct pom_save_sends727
{
  UINT4 iptype;
  char  spname[16];
  UINT4 ioutput[16];
};

struct pom_save_sends728
{
  UINT4 iptype;
  char  spname[16];
  UINT4 ioutput[24];  /* Only change is we have raised the number of output devices */
};

int main(int iArgc, char *sArgv[])
{
  struct pom_save_sends727 Save727;
  struct pom_save_sends728 Save728;
  int iCount, iOutput;

  memset( &Save728, 0, sizeof(Save728) );

  iCount = fread(  &Save727, 1, sizeof(Save727), stdin );
  while (iCount==sizeof(Save727))
    {
      Save728.iptype = Save727.iptype;
      memcpy(Save728.spname, Save727.spname, 16 );
      // fprintf( stderr, "Converting ptype:%d, pname:%s\n", Save728.iptype, Save728.spname );
      for (iOutput=0; iOutput<16; iOutput++)
	Save728.ioutput[iOutput] = Save727.ioutput[iOutput];

      iCount = fwrite( &Save728, 1, sizeof(Save728), stdout );
      if (iCount != sizeof(Save728)) fprintf( stderr, "Bad write\n" );
      iCount = fread(  &Save727, 1, sizeof(Save727), stdin );
    }
  exit( EXIT_SUCCESS );
}


