//=========================================================================
// Summary  :
// Filename : _dumpConfig.cc
// Author   : marsh
// Project  :
// Revision : 1
// Created  : 2000/08/19
// Modified : 2000/08/19
//=========================================================================
// Description :
//=========================================================================

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

#include "Syslog.h"
#include "VehicleConfigurationIF.h"

main( int argc, char **argv )
{
	VehicleConfigurationIF::DeviceInfo devInfo;

	if( (argc > 1) && (strlen( argv[1] ) > 0) ) {

	     try {

		  VehicleConfigurationIF *_vconfig = new VehicleConfigurationIF("dumpConfig");

		  short index = _vconfig->findProcess( argv[1] );

		  if( index < 0 ) {
		       fprintf( stderr, "Unable to find server: %s\n",
				argv[2] );
		       exit(0);
		  }

		  short ifCount = _vconfig->getInterfaceCount( index );
		  VehicleConfigurationIF::Name pName, ifName;
		  pid_t pid = _vconfig->getPID(index);
		  _vconfig->getIFName( index, ifName );
		  _vconfig->getProcessName( index, pName );

		  printf("Component: %s    IF: %s    PID: %d\n", pName, ifName, pid );
		  printf("Interfaces registered: %d\n", ifCount );

		  for ( short i=0; i<ifCount; i++)
		  {
		       _vconfig->getInterface( index, i, ifName );
		       printf("    Has interface (%d): %s\n", i, ifName );
		  }

	     }
	     catch(Exception e) {
		  fprintf(stderr, "dumpInterfaces -- Caught: %s\n", e.msg );
		  fprintf(stderr, "Is vehicleConfigurationServer running?\n");
	     }
	     catch(...) {
		  fprintf(stderr, "dumpInterfaces -- Caught unknown error\n");
		  fprintf(stderr, "Is vehicleConfigurationServer running?\n");
	     }
	} else {

	     // Print usage
	     fprintf(stderr, "Usage: dumpInterface <componentName>\n");

	}


}
