/* (c) Copyright 1987 Michael Goetz								*/
/*																			*/
/*				File:		  initia										*/
/*				Returns:	  void										*/
/*				Parameters:												*/
/*																			*/
/*																			*/

#include <string.h>

#include "advm.h"
#include "values.h"
#include "string.h"
#include "units.h"
#include "rprime.h"


void initia ()

{
	int i,j,k,cmp,x;
	char temp [5];

	nxtini = 0;
	nxtobj = 1000;
	nxtpla = 2000;
	nxtver = 3000;
	nxttxt = 4000;
	nxtlab = 5000;
	nxtrep = 6000;
	nxtvar = 7000;
	nxtnul = 8000;
	inunit = inmain;
	for (i=0; i<56; i++)
		{
		strncpy(zopt[i], zoptn[i], 4);
		zopt[i][4] = 0;
		optval[i] = i+1;
		}
	for (i=0; i<55; i++)
		{
		k = i;
		for (j=i+1; j<56; j++)
			{
			if (cmp = strcmp(zopt[j],zopt[k]))
				{
				if (cmp < 0)
					k = j;
				}
			else
				{
				printf ("--Undestinguishable options: %-8.8s %8.8s\n",
							zoptn[optval[j]-1], zoptn[optval[k]-1]);
				strcpy(zopt[k], "ZZZZ");
				k = j;
				}
			}
		if (i == k)
			continue;
		strcpy(temp, zopt[i]);
		strcpy(zopt[i], zopt[k]);
		strcpy(zopt[k], temp);
		x = optval[i];
		optval[i] = optval[k];
		optval[k] = x;
		}
	zfid[0] = 0;
	for (i=50, rehshn=0; rehshn < 10; i++)
		{
		if (!rprime(i, 2000))
			continue;
		if (rehshn)
			{
			for (j=0; j<rehshn; j++)
				if (!rprime(rehshv[j],i))
					break;
			if (j < rehshn)
				continue;
			}
		rehshv[rehshn++] = i;
		}
	for (i=0; i<=2000; i++)
		zname[i][0] = 0;
	listed = TRUE;
}

