/* Creates graph.idx, to speed up reading of hlp file */
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
#include "int32.h"
main()
{
	FILE *f,*fi;
	int32 lvl;
	int32 p;
	int slen;
	char buff[200];

#ifdef __TURBOC__
	f = fopen("exe\\graph.hlp","r");
	fi = fopen("exe\\graph.idx","wb");
#else
	f = fopen("graph.hlp","r");
	fi = fopen("graph.idx","wb");
#endif
	if (f==NULL) die("Unable to open exe\graph.hlp for input \n");
	if (fi==NULL) die("Unable to open exe\graph.idx  for output \n");
	for (;!feof(f);) {
	  if (fgets(buff,190,f)!=NULL) {
		p = ftell(f);
		lvl = buff[0]-'0';
		if (lvl>0 && lvl<9)  {
			slen=strlen(buff);
			fwrite(&slen,sizeof(slen),1,fi);
			fwrite(buff,1,slen,fi);
			fwrite(&p,sizeof(p),1,fi);
		}
	  }
	}
	fclose(fi); fclose(f);
#ifndef VMS
	return 0;
#else
	return 1;
#endif
}
die(char *s)
{
	printf("Dieing {%s} \n",s);
	exit(1);
}


