/* Code style: -*- linux-c -*- */
/* File : xfw/find/display.c */
/* this program is simply to use recursion to dump out the linked list */
/* generated by the network tree build */

#include <stdio.h>
#include "range.h"

#include <Xm/Xm.h>
#include <Xm/Label.h>
#include <Xm/PushB.h>
#include <Xm/ScrolledW.h>
#include "Tree.h"

void dump_tree(Widget parent,
              struct node *curr_node,
              Widget super_node)
{
 /* Xwindows stuff */
 Widget w;             /* tree node */
 char   buf[200];      /* text to stuff in it */

 struct range *range;
 int list;

 /*
    Create a widget for the node, specifying the
    given super_node constraint.
 */


 printf("Curr node address = 0x%x (%s)\n", &curr_node, ip_to_str(curr_node->ip));

 printf("Curr node out [0] = 0x%x\n", curr_node->out[0]);
 printf("Curr node out [1] = 0x%x\n", curr_node->out[1]);
 printf("Curr node out [2] = 0x%x\n", curr_node->out[2]);
 printf("Curr node out [3] = 0x%x\n", curr_node->out[3]);
 printf("Curr node out [4] = 0x%x\n", curr_node->out[4]);

 for (list = 0 ; list < MAXROUTER; list++) {
   printf("list in loop is %d\n", list);
   if (curr_node->out[list] == NULL) return; /* jump out! another naughty */


   sprintf (buf, "IP: %s", ip_to_str(curr_node->out[list]->ip) );

   w = XtVaCreateManagedWidget (buf, xmPushButtonWidgetClass,
                                parent,
                                XmNsuperNode, super_node,
                                NULL );

   printf("list now = %d\n", list);

   dump_tree(parent, curr_node->out[list], w);

 }

}