/* Time-stamp: <96/11/28 11:18:56 john> */
/*
# Purpose: program to generate the index files for the search facility; called from <a href="#indexer.cgi">indexer.cgi</a>
*/
#include <stdio.h>
#include "attr.h"

int main(argc, argv)
     int argc;
     char * argv [];
{
  int i;
  char *type;
  char type_buf[1024];

#if 0
  printf("<p>Sorry, no indexer yet!</p>\n");
#else
  if (argc < 2)
    {
      printf("Usage: indexer type names-without-dot-attr > indexfile\n");
    }

  type = argv[1];

  sprintf(type_buf, "%ss", type);

  for (i = 2; i < argc; i++)
    {
      struct entry *entries = NULL;
      struct entry *this;
      char *attr_file_name = argv[i];
      int printed_header = 0;
     
      if (!read_data(type_buf,
		     attr_file_name,
		     &entries, NULL,
		     default_check_entry, 1, 1, 0))
	{
	  printf("failed=\"true\"\n");
	}
   
      for (this = entries;
	   this != NULL;
	   this = this->next)
	{
	  if (strcmp(this->type, type) == 0)
	    {
	      char *val;

	      if (!printed_header)
		{
		  printf("file=\"%s\"\n\n", attr_file_name);
		  printed_header = 1;
		}

	      printf("name=\"%s\"\n", this->name);
	      val = get_attr(this, "opening-times");

	      if (val != NULL)
		{
		  printf("opening-times=\"%s\"\n", val);
		}

	      val = get_attr(this, "provides");
	      if (val != NULL)
		{
		  printf("provides=\"%s\"\n", val);
		}
	      val = get_attr(this, "kind");
	      if (val != NULL)
		{
		  printf("kind=\"%s\"\n", val);
		}

	      printf("\n");
	    }
	}

      free_entries(entries);
    }
#endif
  exit(0);
}

/* end of indexer.c */
