/* Calculates the delays of the given input file argv[1], and then
   spits out a listing of node properties after running the RC_Timing function
   on it.

   Output format is as follows:
   This, Parent, Left, Right, Length, Delay, Capacitance, Resistance, 
   Tree_Capacitance, ...? 
*/

#include <malloc.h>
#include <stdio.h>
#include "delay.h"

int main (int argc, char * argv[])
{
  FILE * fp = fopen(argv[1],"r");
  if (NULL == fp)
    {
      fprintf(stderr, "File %s couldn't be opened!\n",
	      argv[1]);
      return -1;
    }

  RC_Load(fp);
  RC_Timing(fp);

  int i;
  for (i=0; i< G_Nodecount; i++)
    {
      printf("%d %ld %ld %ld %g %g %g %g %g\n",
	     i+1,
	     
	     G_Tree_Ptr[i].Parent_Ptr ?
	     (long int) (G_Tree_Ptr[i].Parent_Ptr - G_Tree_Ptr + 1): -1,
	     
	     G_Tree_Ptr[i].Left_Ptr ?
	     (long int) (G_Tree_Ptr[i].Left_Ptr - G_Tree_Ptr + 1): -1,
	     
	     G_Tree_Ptr[i].Right_Ptr ?
	     (long int) (G_Tree_Ptr[i].Right_Ptr - G_Tree_Ptr + 1): -1,

	     G_Tree_Ptr[i].Length,
	     G_Tree_Ptr[i].Delay,
	     G_Tree_Ptr[i].Capacitance,
	     G_Tree_Ptr[i].Resistance,
	     G_Tree_Ptr[i].Tree_Capacitance);
    }

  free(G_Tree_Ptr);
  fclose(fp);

  return 0;
}
