#include <stdio.h>
#include "starpasr.h"
#include "datablk.h"
#include "pasrmain.h"
#include "iterator.h"

main(argc, argv)
int argc;
char** argv;
{

  id iter, iter1, current;
  char *file, *dataname, *itemname;
  // the following variables are needed by the star parser.

  // progName=*argv;
  // fileList=argv+1;
  // nFiles=argc-1;
  starParser=[WDCStarParser alloc];

  if (argc==4){
    file=*(argv+1);
    dataname=*(argv+2);
    itemname=*(argv+3);
  }
  else {
    printf("usage: %s filename blockname itemname\n", argv[0]);
    exit(1);
  }

  [starParser parseStarFile:file];
  if (iter=[[[starParser getStarFileNamed:file] getDataItem:dataname]
	    getAllDataItems :itemname]){
    iter=[[WDCListIterator alloc] initFrom: iter];
    iter1=[WDCListIterator alloc];
    while ([iter goNext]){
      current=[[[iter getCurrentObject] getContent] getValue];
      if ([current isMemberOfClassNamed:"WDCString"])
	printf("%s\n", [current cStringValue]);
      else if ([current isKindOfClassNamed:"WDCString"]){
	[iter1 initFrom: current];
	while ([iter1 goNext])
	  printf("%s\n", [[iter1 getCurrentObject] cStringValue]);
      }
    }
  }
  else
    printf("Can not locate such information\n");
  return 0;
}
  


