/*******************************************************************/
/*
   <MODULE>
        <NAME>MAIN MODULE</NAME>
        <FILENAME>URNE.C</FILENAME>
        <HISTORY>
                <MODIFICATION>
                        <DATE></DATE>
                        <AUTHOR></AUTHOR>
                        <DESCRIPTION></DESCRIPTION>
                </MODIFICATION>
        </HISTORY>
   </MODULE>
*/

/*******************************************************************/

/********************** INCLUDE FILES *******************************/
#include "defs.h"

#include <ctype.h>
#include <conio.h>
#include <fcntl.h>
#include <graphics.h>
#include <io.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <dos.h>
#include <BIOS.H>

#include "..\LibUrne\LibUrne.h"
#include "fullspec.h"
#include "api-fst.h"
#include "alg-fst.h"

#include "urne.h"

/*Urn jites com definition*/
#define _PORT_BAUDRATE      COM_B9600
#define _PORT_FORMAT        COM_F8BOP1S
#define _PORT_DTR           1
#define _PORT_RTS           1
#define _PORT_HANDSHAKE     0

/*******************************************************************/

unsigned long far *utimer = (unsigned long *) 0x46C;

#define _WAITL { unsigned long inc;                     \
 for(inc=*utimer;*utimer - inc < (unsigned long) 5;);    \
			}

/***************************************************************************/
s_Parameters gsParamMgnCdUrne;

int Cmpt_Gen,Cmpt_Gen_Val;

int C_VOTE_MAX_BYTE = 0;
int BATTERY;
int Total_Erreur_Eprom = 0;
char Chemin_R[25];
char Chemin_D[25];
char Minicodage[] = "4630";
int FEram, FEdsk;
int Additionne;
char LANGUE;
char GCOLOR;
char COLOR;
int iDiskId ;/*Disk number*/
char CMinipassword[12];
char fullPassword[11];
char CLEF_URNE[_CLEF_MAX_BYTE+1];
extern szMessage *pszMessage_Point;
char System_Used[9];
unsigned char szDataFloppy[50];
boolean bErrWrite_Ram, bErrRead_Ram;
boolean bErrRead, bErrWrite;
boolean bEncodeV, bNoSupMode;
boolean bStart, bRecount_Mode;
boolean bReading_Loop, /*<< 9.01c*/bWriteData_Ram/*>>*/;

/****************************************************************************/
/* Vote counters */
extern int  *piNOMBRE_VOTES1, *piNOMBRE_VOTES2, *piNOMBRE_VOTES3;
extern int  *piNOMBRE_NATIO_VOTES1, *piNOMBRE_NATIO_VOTES2, *piNOMBRE_NATIO_VOTES3;
extern int  *piNOMBRE_STR_VOTES1, *piNOMBRE_STR_VOTES2, *piNOMBRE_STR_VOTES3;
extern int iMAXDISK;
extern char JETON_ETENDU[_JETON_ETENDU_MAX_BYTE+1];
extern char JETON[_JETON_MAX_BYTE+1];
/***************************************************************************/
/* << 9.01c */
/* << 9.03*/
/*extern void Control_Keyboard(void);*/
/* >> */
/* 9.01c >> */
/*
   <FUNCTION>
		<NAME>Demande_Identite</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>Ask password containing 10 digits</DESCRIPTION>
        <PARAMETER>
			<NAME>pzClef</NAME>
			<TYPE>char *</TYPE>
			<IO>INOUT</IO>
			<DESCRIPTION>Parameter by reference containing password</DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>boolean</TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
boolean Demande_Identite(char *pzClef, boolean bRequire)
{
	int iCpt, itouche;
	char sztmp[16], car, choix;

	Lcd_Affiche(0, 0, "");
	Lcd_Affiche(1, 0, "");

	strcpy(sztmp, "..........     ");
	if(strcmp(System_Used,"JITES") == 0)
	{
		Lcd_Affiche(0, 0, pszMessage_Point[29]);
		Lcd_Affiche(1, 5, sztmp);
	}
	else
	{
		Video_Screen(SCR_PWD);
		Lcd_Affiche(0, 5, sztmp);
	}


	iCpt = 0;

	while(iCpt < _CLEF_MAX_BYTE)
	{
		itouche = Getch(COLOR);
		if((itouche >= 48) && (itouche <= 57))
		{
			car = itouche;
			pzClef[iCpt] = car;
			sztmp[iCpt] = pzClef[iCpt];
			if(strcmp(System_Used,"JITES") == 0)
				Lcd_Affiche(1, 5, sztmp);
			else
				Lcd_Affiche(0, 5, sztmp);
			iCpt += 1;
		}

		if((itouche == 8) && (iCpt > 0))
		{
			iCpt -= 1;
			pzClef[iCpt] = ' ';
			sztmp[iCpt] = '.';
			if(strcmp(System_Used,"JITES") == 0)
				Lcd_Affiche(1, 5, sztmp);
			else
				Lcd_Affiche(0, 5, sztmp);
		}

		if(!bRequire)
		{
			if((strcmp(System_Used,"JITES") == 0) && ((itouche == 78)))
				return false;

			if((strcmp(System_Used,"DIGIVOTE") == 0) &&(itouche == 27))
				return false;
		}

	}
	pzClef[_CLEF_MAX_BYTE] = '\0';

	return true;

} /* Demande_Identite */
/****************************************************************************/
/*
   <FUNCTION>
		<NAME>Select_Language_ID</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Determine the language identifier between two choices
		</DESCRIPTION>
		<PARAMETER>
			<NAME>_cID_Lang</NAME>
			<TYPE>char</TYPE>
			<IO>IN</IO>
			<DESCRIPTION>the language identifier</DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>int</TYPE>
			<DESCRIPTION>return language identifier</DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
/* << 9.01c
int Select_Language_ID(char _cID_Lang)
{
  char choix;
  int iRes;
  char buff1[16], buff2[16];

  switch(_cID_Lang)
  {
    case '5':  / French <> German /
		if(strcmp(System_Used,"JITES") == 0)
		{
			Lcd_Affiche(0,0, "1 -> FRANCAIS");
			Lcd_Affiche(1,0, "3 -> DEUTSCH ");
		}
		else
		{
			setfillstyle(SOLID_FILL,WHITE);
			bar(0,0,639,479);
			setcolor(BLACK);
			settextjustify(CENTER_TEXT, CENTER_TEXT);
			settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);
			outtextxy(320, 235, "1 -> FRANCAIS");
			outtextxy(320, 245, "3 -> DEUTSCH ");
		}

		choix = ' ';

		while(choix != '1' && choix != '3')
			choix = Getch(COLOR);
		if(choix == '1') iRes = 1;
		if(choix == '3') iRes = 3;
		break;


    case '6':  / French <> Dutch /
		if(strcmp(System_Used,"JITES") == 0)
		{
			Lcd_Affiche(0,0, "1 -> FRANCAIS  ");
			Lcd_Affiche(1,0, "2 -> NEDERLANDS");
		}
		else
		{
			setfillstyle(SOLID_FILL,WHITE);
			bar(0,0,639,479);
			setcolor(BLACK);
			settextjustify(CENTER_TEXT, CENTER_TEXT);
			settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);
			outtextxy(320, 235, "1 -> FRANCAIS  ");
			outtextxy(320, 245, "2 -> NEDERLANDS");
		}

      choix = ' ';

      while(choix != '1' && choix != '2')
        choix = Getch(COLOR);
      if(choix == '1') iRes = 1;
      if(choix == '2') iRes = 2;
      break;

    default:
      iRes = 1;
  }

  return iRes;
}
*/
int Select_Language_ID(char _cID_Lang)
{
	char choix;
	int iRes;
	char buff1[16], buff2[16];

	/* Languages available */
	switch(_cID_Lang)
	{
		case '5':  /* French <> German */
			strcpy(buff1, "1 -> FRANCAIS");
			strcpy(buff2, "3 -> DEUTSCH ");
			break;
		case '6':  /* French <> Dutch */
			strcpy(buff1, "1 -> FRANCAIS  ");
			strcpy(buff2, "2 -> NEDERLANDS");
			break;
		case '8':  /* German <> French */
			strcpy(buff1, "3 -> DEUTSCH ");
			strcpy(buff2, "1 -> FRANCAIS");
			break;
	}

	/* Display */
	if(strcmp(System_Used,"JITES") == 0)
	{
		Lcd_Affiche(0,0, buff1);
		Lcd_Affiche(1,0, buff2);
	}
	else
	{
		setfillstyle(SOLID_FILL,WHITE);
		bar(0,0,639,479);
		setcolor(BLACK);
		settextjustify(CENTER_TEXT, CENTER_TEXT);
/* << 9.05 */
/*  settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);*/
  settextstyle(SMALL_FONT, HORIZ_DIR, 4);
/* 9.05 >> */
		outtextxy(320, 235, buff1);
		outtextxy(320, 245, buff2);
	}

	choix = ' ';

	/* Selection */
	switch(_cID_Lang)
	{
		case '5':  /* French <> German */
			while(choix != '1' && choix != '3')
				choix = Getch(COLOR);
			break;
		case '6':  /* French <> Dutch */
			while(choix != '1' && choix != '2')
				choix = Getch(COLOR);
			break;
		case '8':  /* German <> French */
			while(choix != '1' && choix != '3')
				choix = Getch(COLOR);
			break;
	}

	switch(choix)
	{
		case '1':
			iRes = 1;
			break;
		case '2':
			iRes = 2;
			break;
		case '3':
			iRes = 3;
			break;
		default:
			iRes = 1;
  }

  return iRes;
}
/* 9.01c >> */

/****************************************************************************/
/*
   <FUNCTION>
		<NAME>Language_ID</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Determine the language identifier from machvots.Tbl file
		</DESCRIPTION>
		<PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>int</TYPE>
			<DESCRIPTION>return language identifier</DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
int Language_ID()
{
	FILE *fps;
	char szbufs[33], cID_Lang;
	int iRet;

	fps = fopen("a:machvots.Tbl","rt");
	if(fps != NULL)
	{

		fgets(szbufs,32,fps);
		fclose(fps);

		/* Init Code Language*/
		cID_Lang = szbufs[15];
		switch(cID_Lang)
		{
			case '0': /* Dutch only */
			case '2': /* Dutch (French) */
			case '4': /* Dutch <> French */
				iRet =  2;
				break;

			case '1': /* French (Dutch) */
			case '7': /* French only */
				iRet = 1;
				break;

			case '5': /* French <> German */
			case '6': /* French <> Dutch */
/* << 9.01c */
			case '8': /* French <> German */
/* 9.01c >> */
				iRet = Select_Language_ID(cID_Lang);
				break;

			case '3': /* German only */
				iRet = 3;
				break;

			default:
				iRet = 1;
		}
	}
	else
		iRet = 1;

	return iRet;
}

/****************************************************************************/
/*
   <FUNCTION>
		<NAME>Read_File</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Read file containing messages and load them into the buffer of messages
		</DESCRIPTION>
        <PARAMETER>
			<NAME>pzFileName, iNum</NAME>
			<TYPE>char *, int</TYPE>
			<IO>INOUT, IN</IO>
			<DESCRIPTION>First parameter is filename, second parameter is messages file identifier</DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>void</TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Read_File(char *pzFileName,int iNum)
{
	char szbufm[45];
	int i, j;
	FILE *fpm;

	while((fpm = fopen(pzFileName,"rt")) == NULL)
	{
		Lcd_Affiche(0,0,"MESSAGE ERROR OTHER");
		Lcd_Affiche(1,0,"DISK AND PRESS KEY");
		Getch(COLOR);
		Lcd_Affiche(0,0," A MOMENT PLEASE");
		Lcd_Affiche(1,0," ");
	}

	i = 0;
	if((iNum == 1) || (iNum == 2) || (iNum == 3))
	{
		while((fgets(szbufm,30,fpm) != NULL))
		{
			szbufm[24] = 0x00;
			for(j=23;(j > 4) && (szbufm[j] < 32);)
			{
				szbufm[j] = 0x20;
				j--;
			}

			strcpy(pszMessage_Point[i],szbufm + 4);
			i++;
		}
	}
	else if((iNum == 4))
	{
		while((fgets(szbufm,sizeof(szbufm),fpm) != NULL))
		{
			szbufm[44] = 0x00;
			for(j=43;(j > 4) && (szbufm[j] < 32);)
			{
				szbufm[j] = 0x20;
				j--;
			}

			strcpy(pszMessage_Point[i],szbufm + 4);
			i++;
		}
	}

	if(fpm)
		fclose(fpm);
}
/****************************************************************************/
/*
   <FUNCTION>
		<NAME>Load_Message</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Select messages file to load, and call Read_File function
		</DESCRIPTION>
        <PARAMETER>
			<NAME>iNum</NAME>
			<TYPE>int</TYPE>
			<IO>IN</IO>
			<DESCRIPTION>parameter by value is the messages file identifier</DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>void</TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Load_Message(int iNum)
{
	switch(iNum)
	{
		case 1 :
			Read_File("a:MSG_1",1);
			break;

		case 2 :
			Read_File("a:MSG_2",2);
			break;

		case 3 :
			Read_File("a:MSG_3",3);
			break;

		case 4 :
			Read_File("a:MSG_4",4);
			break;
    }


}
/****************************************************************************/
/*
   <FUNCTION>
		<NAME>Nb_Scrut_From_IND</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Determine the number of polls from urne.IND file
		</DESCRIPTION>
        <PARAMETER>
			<NAME>Nothing</NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>int</TYPE>
			<DESCRIPTION>return the number of polls</DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
int Nb_Scrut_From_IND()
{
  char  Buffer[32];
  int   iNbCharact = 31;
  FILE *Fichier;

  Fichier = fopen("a:\\URNE.IND", "rt");
  if(Fichier == NULL)
    return(-1);

  if(fread(Buffer, 1, iNbCharact, Fichier) != iNbCharact)
  {
	/* << 9.01b */
	fclose(Fichier);
	/* >> */
	return(-1);
  }
  /* << 9.01b */
  fclose(Fichier);
  /* >> */
  Buffer[31] = 0X00;

  return(atoi(Buffer+30));
}
/*******************************************************************************/
/*
   <FUNCTION>
		<NAME>Verifie_Urne</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Check if the password which have been encoded is the same as first password
		</DESCRIPTION>
        <PARAMETER>
			<NAME>pzClef</NAME>
			<TYPE>char *</TYPE>
			<IO>INOUT</IO>
			<DESCRIPTION>parameter by reference containing password</DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>int</TYPE>
			<DESCRIPTION>return true if the two passwords are identical, otherwise return false</DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
int Verifie_Urne(char *pzClef)
{
  if (strcmp(pzClef, CLEF_URNE) == 0)

	 return(true);
  else
	 return(false);
}

/***********************************************/

/*
   <FUNCTION>
		<NAME>Init_Systeme</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Initialize system and test peripheral device (validator card reader , urn card reader)
		</DESCRIPTION>
        <PARAMETER>
			<NAME>psParamMgnCdValid, psParamMgnCdUrne, psPcType</NAME>
			<TYPE>s_Parameters*, s_Parameters*, s_PcType*</TYPE>
			<IO>INOUT, INOUT, INOUT</IO>
			<DESCRIPTION>
			type s_Parameters is defined in system.h; type s_PcType is defined in StrType.h
			</DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>boolean</TYPE>
			<DESCRIPTION>return true or false</DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
boolean Init_Systeme(s_Parameters* psParamMgnCdValid, s_Parameters* psParamMgnCdUrne,s_PcType* psPcType)
{
	int i,fd_crc;
	unsigned char tab_verif[16], szTempo[61];
	unsigned char far *pointy;

	if(psPcType->iPcType >= MAV_JITES_1 && psPcType->iPcType <= MAV_JITES_2)
	{
		/* Only jites system*/
		pointy = (uchar * ) 0xC0000087;
		for(i = 0;i < 15;i++)
			tab_verif[i] = *pointy++;
		tab_verif[i] = 0x00;

		if ((strcmp(tab_verif,"Voting Terminal")) == 0)
		{
			outp(0x308,0xf4);
			while(1)
			{
				putch(0x07);
				Lcd_Affiche(0,0, pszMessage_Point[125]);
				Lcd_Affiche(1,0, pszMessage_Point[7]);
				Wait_Time(1);
			}
		}
	}
	else if(psPcType->iPcType >= MAV_DIGIVOTE_1 && psPcType->iPcType <= MAV_DIGIVOTE_2) //Attention juste pour les teste
	{
		/*Only Digivote system*/
		putch(0x07);
		Lcd_Affiche(0,0, pszMessage_Point[65]);
		Wait_Time(1);
	}
	else
	{
		if (!Lecteur_1_Init(psParamMgnCdValid) || !Lecteur_2_Init(psParamMgnCdUrne))
		{
			Lcd_Affiche(0,0, pszMessage_Point[30]);
			Lcd_Affiche(1,0, pszMessage_Point[7]);
			Boucle_Erreur();
		}

		if(psPcType->iPcType >= URNE_JITES_1 && psPcType->iPcType <= URNE_JITES_2)
		{
			/*Only jites system*/

			pointy = (uchar * ) 0xFE9D0022;
			for(i = 0;i < 13;i++)
				tab_verif[i] = *pointy++;
			tab_verif[i] = 0x00;
			if ((strcmp(tab_verif,"Version 1.0.1")) == 0)
			{
				EPROM_SEG =  0xC000;
				timing    =  2000;
			}
			else
			{
				pointy = (uchar * ) 0xC7FC0019;
				for(i = 0;i < 13;i++)
					tab_verif[i] = *pointy++;
				tab_verif[i] = 0x00;
				if ((strcmp(tab_verif,"Version 2.0.0")) == 0)
				{
					EPROM_SEG =  0xD000;
					timing    = 3000;
				}
				else
				{
					Lcd_Affiche(0,0, pszMessage_Point[66]);
					Boucle_Erreur();
				}

			}

			Lcd_Affiche(1,0, "V:");
			Lcd_Affiche(1,4, tab_verif);
			Wait_Time(4);

		}
		else
		{
			timing = 2000;
		}

		if (!Eprom_Init())
		{
			Lcd_Affiche(0,0, pszMessage_Point[2]);
			Lcd_Affiche(1,0, pszMessage_Point[7]);
			Boucle_Erreur();
		}

		Lcd_Init();
		return true;
	}
	return false;

} /* Init_Systeme */

/****************************************************************************/
/*
   <FUNCTION>
		<NAME>Disk_Num</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Check if file that indicates floppy number exists and retun a number
		</DESCRIPTION>
        <PARAMETER>
			<NAME>Nothing</NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>int</TYPE>
			<DESCRIPTION>return floppy number, otherwise return 0</DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
int Disk_Num()
{

    if (access("a:1.DSK",0) == 0)
		return 1;

	if (access("a:2.DSK",0) == 0)
		return 2;

	if (access("a:3.DSK",0) == 0)
		return 3;
	/*<< 9.01c*/
	if (access("a:4.DSK",0) == 0)
		return 4;
  /*>>  */
	return 0;
}
/****************************************************************************/
/*
   <FUNCTION>
		<NAME>Get_INSCODE</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Get commune identifier from machvots.ind file
		</DESCRIPTION>
        <PARAMETER>
			<NAME>pzStr</NAME>
			<TYPE>char *</TYPE>
			<IO>INOUT</IO>
			<DESCRIPTION>parameter by reference containing commune identifier</DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>void</TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Get_INSCODE(char * pzStr)
{
	FILE *fps;
	char szbufs[25], szMsgError[70];
	int i;

	fps = fopen("a:machvots.ind","rt");
	if(fps != NULL)
	{
		fgets(szbufs,25,fps);
		fclose(fps);
		for (i=0; i < 5; i++)
			pzStr[i] = szbufs[16+i];
		pzStr[5] = '\0';
	}
	else
	{
		sprintf(szMsgError,"Error opening file a:machvots.ind in Get_INSCODE function.\nFile source %s\n", __FILE__);
		Erreur(szMsgError);
	}


}


/****************************************************************************/
/*
   <FUNCTION>
		<NAME>Test_Ep</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Display a message that ask to load file contents FE_DSK into EPROM
		</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>int</TYPE>
			<DESCRIPTION>return true ou false according to the user choice</DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
int Test_Ep()
{
  char choix;

  Lcd_Affiche(0,0,pszMessage_Point[32]);
  Lcd_Affiche(1,0,pszMessage_Point[33]);

  choix = ' ';

  while((choix != 'O') && (choix != 'J') && (choix != 'N'))
				choix = Getch(COLOR);
  if ((choix == 'O') || (choix == 'J') )
	  return(true);
  else
	  return(false);
}
/****************************************************************************/
/*
   <FUNCTION>
		<NAME>Ouverture_Urne</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Called at the first execution of the program, when the vote starts.
		Write opening data, extended token and poll structure into FE_RAM/FE_DSK files
		or EPROM
		</DESCRIPTION>
        <PARAMETER>
			<NAME>bInd</NAME>
			<TYPE>boolean</TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>void</TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Ouverture_Urne(boolean bInd)
{
	  if(bInd)
	  {
		Lcd_Affiche(0,0, pszMessage_Point[37]);
		Lcd_Affiche(1,0, pszMessage_Point[38]);
		Wait_Time(1);
	  }

	  Encode_E_Variable((long)_E_OUVERTURE, true);
	  Check_Read_Write();
	  OUVERTURE = true;

	  if(SUPPORT != 'N')
	  {
		Encode_E_Var_String((long)_E_JETON_ETENDU, JETON_ETENDU,
						  _JETON_ETENDU_MAX_BYTE);
		Check_Read_Write();
	  }

	  if(SUPPORT != 'N')
	  {
		Encode_E_Var_String((long)_E_PAR_PLACE,Buffer_Par,strlen(Buffer_Par));
		Check_Read_Write();
	  }
} /* Ouverture */

/***********************************************/
/*
   <FUNCTION>
		<NAME>Test_Contenu_Urne</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Display the results of the vote when the computer is started again
		and the poll not closed. Ask the user if the votes must be taken again
		</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>void</TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Test_Contenu_Urne()
{
 int i, status, iNum;
 boolean test, bExit, bLoop;
 char Clef[11],/* << 9.03*/ /*strtmp[21]*/strtmp[25] /* >>*/, szTempo[61],choix;

 if(*piNOMBRE_VOTES1 > 0)
 {
	bLoop = true;
	while(bLoop)
	{
		Lcd_Affiche(0,0," ");
		if(*piNOMBRE_VOTES1 > 1)
		 sprintf(strtmp,pszMessage_Point[88] , *piNOMBRE_VOTES1);
		else
		 sprintf(strtmp,pszMessage_Point[110] , *piNOMBRE_VOTES1);

		Lcd_Affiche(0, 0, strtmp);
		if(strcmp(System_Used,"JITES") == 0)
			Lcd_Affiche(1,0, pszMessage_Point[41]);
		else
			Lcd_Affiche(1,0, pszMessage_Point[97]);


		choix = ' ';
		while((choix != 'O') && (choix != 'J') && (choix != 'N'))
			choix = Getch(COLOR);

		if ((choix == 'O') || (choix == 'J'))
		{
			Lcd_Affiche(0,0,pszMessage_Point[39]);
			Lcd_Affiche(1,0,pszMessage_Point[40]);
			Wait_Time(2);
			bLoop = false;
		}
		else
		{
			if((strcmp(System_Used,"JITES") == 0) && (SUPPORT == 'R'))
			{
				/* stop process if it's jites system and recording support is the floppy*/
				Lcd_Affiche(1,0, pszMessage_Point[7]);
				Boucle_Erreur();
			}

			Lcd_Affiche(0,0, pszMessage_Point[42]);
			if(strcmp(System_Used,"JITES") == 0)
				Lcd_Affiche(1,0, pszMessage_Point[21]);
			else
				Lcd_Affiche(1,0, pszMessage_Point[94]);

			choix = ' ';
			while((choix != 'O') && (choix != 'J') && (choix != 'N'))
				choix = Getch(COLOR);

			if ((choix == 'O') || (choix == 'J'))
			{
				bExit = false;

				for (test = false,i = 0; i < 3 && (! test); i++)
				{
					test = Demande_Identite(Clef,false);
					if(!test)
					{
						bExit = true;
						break;
					}
					else
						test = Verifie_Urne(Clef);

				}
				if(strcmp(System_Used,"DIGIVOTE") == 0)
					Video_Screen(SCR_START);

				if(test)
				{
					Lcd_Affiche(0,0, pszMessage_Point[43]);
					Lcd_Affiche(1,0, pszMessage_Point[40]);

					if(strcmp(System_Used,"JITES") == 0)
					{
						status = Eprom_Flash();
						if(!status)
						{
							Lcd_Affiche(0,0, pszMessage_Point[44]);
							Lcd_Affiche(1,0,"");
							Boucle_Erreur();
						}

						Eprom_Ram_Load();
						Encode_E_Var_String(400L,"JITES", 5);
						Check_Read_Write();
						Ouverture_Urne(false);
					}
					else
					{
						iNum = Disk_Num();
						while(iNum != iDiskId)
						{
							sprintf(szTempo,pszMessage_Point[114],iDiskId);
							iNum = Change_Disque(szTempo,true);
						}

						Init_Disk();
						Disk_Ram_Load();
						Ouverture_Urne(false);
					}

					bLoop = false;
				}
				else if(!bExit)
				{
					Lcd_Affiche(0,0, pszMessage_Point[54]);
					Boucle_Erreur();
				}
			}
			else
			{
				Lcd_Affiche(0,0,pszMessage_Point[124]);
				if(strcmp(System_Used,"JITES") == 0)
					Lcd_Affiche(1,0,pszMessage_Point[21]);
				else
					Lcd_Affiche(1,0,pszMessage_Point[94]);

				choix = ' ';
				while((choix != 'O') && (choix != 'J') && (choix != 'N'))
					choix = Getch(COLOR);

				if ((choix == 'O') || (choix == 'J'))
				{
					bExit = false;

					for (test = false,i = 0; i < 3 && (! test); i++)
					{
						test = Demande_Identite(Clef,false);
						if(!test)
						{
							bExit = true;
							break;
						}
						else
							test = Verifie_Urne(Clef);
					}

					if(strcmp(System_Used,"DIGIVOTE") == 0)
						Video_Screen(SCR_START);

					if(test)
					{
						SUPPORT = 'N'; /*switch to the mode without recording*/
						bNoSupMode = true;
						bLoop = false;
					}
					else if(!bExit)
					{
						Lcd_Affiche(0,0, pszMessage_Point[54]);
						Boucle_Erreur();
					}
				}
			}
		}
	}
 }
} /* Test_Contenu_Urne */
/***********************************************/
/*
   <FUNCTION>
		<NAME>Test_Contenu_Urne2</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Called when the poll is opened or closed and extended token is different from
		that of the polling station
		</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>void</TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Test_Contenu_Urne2()
{
	 int i, status, iNum;
	 boolean test, bExit, bLoop;
	 char Clef[11], strtmp[21], szTempo[61],choix;

    bLoop = true;
	while(bLoop)
	{
		if(strcmp(System_Used,"JITES") == 0)
		{
			Lcd_Affiche(0, 0, pszMessage_Point[55]);
			Lcd_Affiche(1, 0, pszMessage_Point[56]);
			Wait_Time(2);
			Lcd_Affiche(0,0, pszMessage_Point[41]);
			Lcd_Affiche(1,0, " ");
		}
		else
		{
			sprintf(szTempo,"%s%s",pszMessage_Point[55],pszMessage_Point[56]);
			Lcd_Affiche(0, 0, szTempo);
			Lcd_Affiche(1,0, pszMessage_Point[97]);
		}

		choix = ' ';
		while((choix != 'O') && (choix != 'J') && (choix != 'N'))
			choix = Getch(COLOR);

		if ((choix == 'O') || (choix == 'J'))
		{
			if((strcmp(System_Used,"JITES") == 0) && (SUPPORT == 'R'))
			{
				/* stop process if it's jites system and recording support is the floppy*/
				Lcd_Affiche(1,0, pszMessage_Point[7]);
				Boucle_Erreur();
			}

			Lcd_Affiche(0,0, pszMessage_Point[42]);
			if(strcmp(System_Used,"JITES") == 0)
				Lcd_Affiche(1,0, pszMessage_Point[21]);
			else
				Lcd_Affiche(1,0, pszMessage_Point[94]);

			choix = ' ';
			while((choix != 'O') && (choix != 'J') && (choix != 'N'))
				choix = Getch(COLOR);

			if ((choix == 'O') || (choix == 'J'))
			{
				bExit = false;

				for (test = false,i = 0; i < 3 && (! test); i++)
				{
					test = Demande_Identite(Clef,false);
					if(!test)
					{
						bExit = true;
						break;
					}
					else
						test = Verifie_Urne(Clef);
				}

				if(strcmp(System_Used,"DIGIVOTE") == 0)
					Video_Screen(SCR_START);

				if(test)
				{
					Lcd_Affiche(0,0, pszMessage_Point[43]);
					Lcd_Affiche(1,0, pszMessage_Point[40]);

					if(strcmp(System_Used,"JITES") == 0)
					{
						status = Eprom_Flash();
						if(!status)
						{
							Lcd_Affiche(0,0, pszMessage_Point[44]);
							Lcd_Affiche(1,0,"");
							Boucle_Erreur();
						}

						Eprom_Ram_Load();
						Encode_E_Var_String(400L,"JITES", 5);
						Check_Read_Write();
					}
					else
					{
						iNum = Disk_Num();
						while(iNum != iDiskId)
						{
							sprintf(szTempo,pszMessage_Point[114],iDiskId);
							iNum = Change_Disque(szTempo,true);
						}

						Init_Disk();
						Disk_Ram_Load();
					}
					bLoop = false;
				}
				else if(!bExit)
				{
					Lcd_Affiche(0,0, pszMessage_Point[54]);
					Boucle_Erreur();
				}
			}
		}
		else
		{
			Lcd_Affiche(0,0,pszMessage_Point[124]);
			if(strcmp(System_Used,"JITES") == 0)
				Lcd_Affiche(1,0,pszMessage_Point[21]);
			else
				Lcd_Affiche(1,0,pszMessage_Point[94]);

			choix = ' ';
			while((choix != 'O') && (choix != 'J') && (choix != 'N'))
				choix = Getch(COLOR);

			if ((choix == 'O') || (choix == 'J'))
			{
				bExit = false;

				for (test = false,i = 0; i < 3 && (! test); i++)
				{
					test = Demande_Identite(Clef,false);
					if(!test)
					{
						bExit = true;
						break;
					}
					else
						test = Verifie_Urne(Clef);
				}

				if(strcmp(System_Used,"DIGIVOTE") == 0)
					Video_Screen(SCR_START);

				if(test)
				{
					SUPPORT = 'N'; /*switch to the mode without recording*/
					bNoSupMode = true;
					bLoop = false;
				}
				else if(!bExit)
				{
					Lcd_Affiche(0,0, pszMessage_Point[54]);
					Boucle_Erreur();
				}
			}
		}
	}
} /* Test_Contenu_Urne2 */


/***************************************************************************/
/*
   <FUNCTION>
		<NAME>Test_Eprom</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Check if JITES inscription is present in the EPROM and compares if the election date
		contained in the token of the polling station registered in the EPROM corresponding
		to the election date contained in the token obtained from the file urne.tbl.
		Check if the EPROM contains other characters than FF when the token don't exists
		</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>int</TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
int Test_Eprom()
{
 char tab_Epror[10];
 char tab_Dat_Epr[7];
 char tab_Dat_Dsk[7];
 char Jeton_E[_JETON_ETENDU_MAX_BYTE+1];
 int status;
 long  Dat_Dsk, Dat_Epr;

  Recupere_E_Var_String(400L, tab_Epror, 5,false);
  if((strcmp("JITES",tab_Epror)) != 0)
  {
     Lcd_Affiche(0,0,pszMessage_Point[8]);
	 Lcd_Affiche(1,0,pszMessage_Point[9]);

     status = Eprom_Flash();
     if (!status)
	 {
	   Lcd_Affiche(0,0, pszMessage_Point[44]);
	   Lcd_Affiche(1,0,"");
	   Boucle_Erreur();
	 }
     Eprom_Ram_Load();
	 Encode_E_Var_String(400L,"JITES", 5);
	 Check_Read_Write();
  }
  else
   {
     Recupere_E_Var_String(_E_JETON_ETENDU, Jeton_E,_JETON_ETENDU_MAX_BYTE,false);
     tab_Dat_Epr[0] = Jeton_E[13];
     tab_Dat_Epr[1] = Jeton_E[14];
     tab_Dat_Epr[2] = Jeton_E[11];
     tab_Dat_Epr[3] = Jeton_E[12];
     tab_Dat_Epr[4] = Jeton_E[9];
     tab_Dat_Epr[5] = Jeton_E[10];
     tab_Dat_Epr[6] = 0x00;

     tab_Dat_Dsk[0] = JETON_ETENDU[13];
     tab_Dat_Dsk[1] = JETON_ETENDU[14];
     tab_Dat_Dsk[2] = JETON_ETENDU[11];
     tab_Dat_Dsk[3] = JETON_ETENDU[12];
     tab_Dat_Dsk[4] = JETON_ETENDU[9];
     tab_Dat_Dsk[5] = JETON_ETENDU[10];
     tab_Dat_Dsk[6] = 0x00;

     Dat_Dsk = atol(tab_Dat_Dsk);
     Dat_Epr = atol(tab_Dat_Epr);
     if(( Dat_Epr < Dat_Dsk ) && ( Dat_Epr > 0))
     {
		status = Eprom_Flash();
		if (!status)
		{
			Lcd_Affiche(0,0, pszMessage_Point[44]);
			Lcd_Affiche(1,0,"");
			Boucle_Erreur();
		}
		Eprom_Ram_Load();
		Encode_E_Var_String(400L,"JITES", 5);
		Check_Read_Write();
     }
	 else
	 {
		 Recupere_E_Variable(_E_FERMETURE, &FERMETURE, false);
		 Recupere_E_Variable(_E_OUVERTURE, &OUVERTURE, false);
		 if((strlen(Jeton_E) != 15) || (!FERMETURE && !OUVERTURE))
		 {
			status = Check_EPROM();
			if(!status)
			{
				status = Eprom_Flash();
				if (!status)
				{
					Lcd_Affiche(0,0, pszMessage_Point[44]);
					Lcd_Affiche(1,0,"");
					Boucle_Erreur();
				}
				Eprom_Ram_Load();
				Encode_E_Var_String(400L,"JITES", 5);
				Check_Read_Write();
			}
		 }
	 }
   }
 return(0);
} /*Test_Eprom */

/****************************************************************************/
/*
   <FUNCTION>
		<NAME>Write_Data_Disk</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Write cipher results of the election and EPROM or FE_RAM contents on the floppy
		</DESCRIPTION>
        <PARAMETER>
			<NAME>iNum</NAME>
			<TYPE>int</TYPE>
			<IO>IN</IO>
			<DESCRIPTION>Parameter by value is the number of the start floppy</DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE></TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Write_Data_Disk(int iNum)
{
    int iDif, iCpt, iRes, iDsk, iCount;
    char szTempo[21];
    boolean bIndic, bExit;
    char choix;

	Lcd_Affiche(0,0,pszMessage_Point[12]);
	Lcd_Affiche(1,0," ");

    if (iNum > 0)
    {
       iDif = iNum - 1;
       iCpt = iNum; /* disk number */
    }
    else
    {
       iDif = 0;
       iCpt = 1;
    }

    bIndic = 1;

    do
    {
		iDsk = 0;
		choix = ' ';
		bExit = 0;

		if(bIndic == 1)
		{

			/*      write crc      */
			iRes = Crc_Rijndael("W","3","c:","a:");
			if(iRes == -1)
			{
				Lcd_Affiche(0,0, pszMessage_Point[27]);
				Lcd_Affiche(1,0, pszMessage_Point[14]);
				Getch(COLOR);
			}

			if(SUPPORT == 'E')
				Backup_Eprom_Disk("a:FE_Dsk");
			else if(iCpt != iNum)
			{
				Backup_Ram_Disk("a:FE_Dsk");
			}
			/*<< 9.01c*/
			Encrypte_Fe_Dsk();
			/*>> */
		}

		iCpt++;
		if (iCpt <= iMAXDISK)
		{
			iCount = 0;
			while(!bExit)
			{
				if(iCount < 3)
				{
					iCount++;
					sprintf(szTempo,pszMessage_Point[114],iCpt);
					Lcd_Affiche(0,0, szTempo);
					Lcd_Affiche(1,0, pszMessage_Point[62]);

					Getch(COLOR);
					iDsk = Disk_Num();
					if(iDsk == iCpt)
					{
						bIndic = 1;
						bExit  = 1;
					}
					else if((iDsk <= iMAXDISK) && (iDsk > iCpt))
					{
						sprintf(szTempo,pszMessage_Point[123],iDsk);
						Lcd_Affiche(0,0, szTempo);
						Lcd_Affiche(1,0, pszMessage_Point[35]);
						choix = ' ';
						while((choix != 'O') && (choix != 'J') && (choix != 'N'))
							choix = Getch(COLOR);
						if((choix == 'O') || (choix == 'J'))
						{
							iCpt = iDsk;
							bIndic = 1;
							bExit  = 1;
						}
					}

				}
				else
				{
					bIndic = 0;
					bExit  = 1;
				}
			}
		}

    }
    while(iCpt <= iMAXDISK);

    /* if start disk number is up to 1 */
    if(iDif > 0)
    {
       for(iCpt = 1; iCpt <= iDif; iCpt++)
       {
			iDsk = 0;
			choix = ' ';
			bExit = 0;

			iCount = 0;
			while(!bExit)
			{
				if(iCount < 3)
				{
					iCount++;
					sprintf(szTempo,pszMessage_Point[114],iCpt);
					Lcd_Affiche(0,0, szTempo);
					Lcd_Affiche(1,0, pszMessage_Point[62]);

					Getch(COLOR);
					iDsk = Disk_Num();
					if(iDsk == iCpt)
					{
						bIndic = 1;
						bExit  = 1;
					}
					else if((iDsk <= iMAXDISK) && (iDsk > iCpt) && (iCpt < iDif))
					{
						sprintf(szTempo,pszMessage_Point[123],iDsk);
						Lcd_Affiche(0,0, szTempo);
						Lcd_Affiche(1,0, pszMessage_Point[35]);
						choix = ' ';
						while((choix != 'O') && (choix != 'J') && (choix != 'N'))
							choix = Getch(COLOR);
						if((choix == 'O') || (choix == 'J'))
						{
							iCpt = iDsk;
							bIndic = 1;
							bExit  = 1;
						}
					}

				}
				else
				{
					bIndic = 0;
					bExit  = 1;
				}
			}

			if(bIndic == 1)
			{
				/*      write crc      */
				iRes = Crc_Rijndael("W","3","c:","a:");
				if(iRes == -1)
				{
					Lcd_Affiche(0,0, pszMessage_Point[27]);
					Lcd_Affiche(1,0, pszMessage_Point[14]);
					Getch(COLOR);
				}
				if(SUPPORT == 'E')
					Backup_Eprom_Disk("a:FE_Dsk");
				else
					Backup_Ram_Disk("a:FE_Dsk");

				/*<< 9.01c*/
			  Encrypte_Fe_Dsk();
			  /*>> */
			}

       }
    }

}

/***************************************************************************/
/*
   <FUNCTION>
		<NAME>Fermeture_Urne</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Call when the vote is being closed. Ask and check the password
		</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>int</TYPE>
			<DESCRIPTION>return true or false according to the checking of the password</DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
int Fermeture_Urne()
{
  int test, i, iNum;
  boolean bExit, bCanSave, bExitLoop;
  int Clef_Id, fd2;
  char Clef[11];
  char choix;
  char tab_Epror[10], strtmp[21], szTempo[65];

  bReading_Loop = false;

  if(strcmp(System_Used,"DIGIVOTE") == 0)
	Video_Screen(SCR_URNE);

  Lcd_Affiche(0,0, pszMessage_Point[45]);
  if(strcmp(System_Used,"JITES") == 0)
	Lcd_Affiche(1,0, pszMessage_Point[21]);
  else
	Lcd_Affiche(1,0, pszMessage_Point[94]);

  choix = Getch(COLOR);

  if((strcmp(System_Used,"JITES") == 0) && (choix == '8'))
  {
      Battery_Off();
      Lcd_Affiche(0,0, pszMessage_Point[46]);
      Lcd_Affiche(1,0, pszMessage_Point[47]);
      Boucle_Erreur();
  }

  while((choix != 'O') && (choix != 'J') && (choix != 'N'))
		choix = Getch(COLOR);

  if((SUPPORT == 'N') && ((choix == 'O') || (choix == 'J')))
  {
	  test = false;
	  bExit = false;

      for (i = 0; i < 3 && (! test); i++)
	  {
		   test = Demande_Identite(Clef,false);
		   if(!test)
		   {
				bExit = true;
				break;
		   }
		   else
				test = Verifie_Urne( Clef);
	  }

	  if(strcmp(System_Used,"DIGIVOTE") == 0)
		Video_Screen(SCR_URNE);

	  if(test)
	  {
		return(true);
	  }
	  else if(!bExit)
	  {
		Lcd_Affiche(0,0, pszMessage_Point[59]);
		Lcd_Affiche(1,0, pszMessage_Point[14]);
		Getch(COLOR);
	  }

	  bStart = false;
	  return(false);
  }


  if (((choix == 'O') || (choix == 'J')) && (*piNOMBRE_VOTES1 > 10))
  {
      COLOR = _ON_NO_LED;
      Light_LED(COLOR);
      test = false;
	  bExit = false;

      for (i = 0; i < 3 && (! test); i++)
	  {
		   test = Demande_Identite(Clef,false);
		   if(!test)
		   {
				bExit = true;
				break;
		   }
		   else
				test = Verifie_Urne( Clef);
	  }

	  if(strcmp(System_Used,"DIGIVOTE") == 0)
		Video_Screen(SCR_URNE);

      if(test)
      {
			if(strcmp(System_Used,"JITES") == 0)
			{
				Recupere_E_Var_String(400L, tab_Epror, 5,false);
				if(strcmp("JITES",tab_Epror)!= 0)
					Ram_Eprom_Load();
			}

			if(SUPPORT != 'N')
			{
				bExitLoop = false;
				bCanSave = true;
				i = 0;

				while(!bExitLoop && (i < 3))
				{
					sprintf(strtmp,pszMessage_Point[114],iDiskId);
					Lcd_Affiche(0,0, strtmp);
					Lcd_Affiche(1,0,pszMessage_Point[62]);

					Getch(COLOR);
					iNum = Disk_Num() ;
					if(iNum == 0)
					{
					  iNum = Change_Disque(pszMessage_Point[122],false);
					  if(strcmp(System_Used,"JITES") == 0)
					  {
						Lcd_Affiche(0,0, " ");
						Lcd_Affiche(1,0, " ");
					  }
					}

					if(iNum == iDiskId)
						bExitLoop = true;

					i += 1;
				}

				iDiskId = iNum;

				if(SUPPORT == 'E')
				{
					if(Compare_Ram_Eprom() != 0)
						bCanSave = false;
				}

				if(SUPPORT == 'R')
				{
					if((access(Chemin_D, 0) == 0) && bExitLoop)
					{
						if(Compare_Ram_Disk() != 0)
						  bCanSave = false;

					}
					else
					{
						Ram_Disk_Load();
					}
				}

				Lcd_Affiche(0,0, pszMessage_Point[48]);
				Lcd_Affiche(1,0, pszMessage_Point[49]);

				if(bCanSave)
				{
					Encode_E_Variable((long)_E_FERMETURE, true);
					Check_Read_Write();
					Recupere_Nb_Cartes();
					Transfert_Table_PCC("C:TABLE.URN");
				}
				else
				{
					Lcd_Affiche(0,0, pszMessage_Point[63]);
					Lcd_Affiche(1,0, pszMessage_Point[7]);
					Boucle_Erreur();
				}
			}

			Additionne = true;

			COLOR = _OFF_NO_LED;
			return(true);
      }
	  else if(!bExit)
	  {
		Lcd_Affiche(0,0, pszMessage_Point[59]);
		Lcd_Affiche(1,0, pszMessage_Point[14]);
		Getch(COLOR);
	  }
  }

  if (((choix == 'O') || (choix == 'J')) && (*piNOMBRE_VOTES1 <= 10))
  {
	  sprintf(strtmp,pszMessage_Point[19],11);
	  if(strcmp(System_Used,"JITES") == 0)
	  {
		Lcd_Affiche(0,0, strtmp);
		Lcd_Affiche(1,0, pszMessage_Point[28]);
		Wait_Time(4);
	  }
	  else
	  {
		sprintf(szTempo,"%s %s",strtmp,pszMessage_Point[28]);
		Lcd_Affiche(0,0, szTempo);
		Lcd_Affiche(1,0, pszMessage_Point[14]);
		Getch(COLOR);
	  }
  }

  bStart = false;

  return(false);
} /* */
/********************************************************************/
/*
   <FUNCTION>
		<NAME>Display_Screen_Info</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Display data on the screen
		</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE></TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Display_Screen_Info()
{
	char szBuffer[11], szbuf[6], cyear[3], cmonth[3], cday[3];

	Video_Affiche(I, JETON_ETENDU);
	Get_INSCODE(szbuf);
	Video_Affiche(C,szbuf);
	strncpy(szbuf,JETON_ETENDU+6,3);
	szbuf[3] = '\0';
	Video_Affiche(B, szbuf);

	strncpy(cday,JETON_ETENDU+9,2);
	cday[2] = '\0';

	strncpy(cmonth,JETON_ETENDU+11,2);
	cmonth[2] = '\0';

	strncpy(cyear,JETON_ETENDU+13,2);
	cyear[2] = '\0';

	sprintf(szBuffer,"%s/%s/20%s",cday,cmonth,cyear);
	szBuffer[10] = '\0';
	Video_Affiche(D, szBuffer);
}
/*******************************************************************/
/*
   <FUNCTION>
		<NAME>Make_Noise</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>Carray out a son</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE></TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Make_Noise ( SOUND_TYPE Type)
{
   switch( Type)
   {
      case SOUND1:
      {
         sound( 2000);
         delay( 3000);
         break;
      }
      case NO_ALARMBOX:
      {
         sound( 440);
         delay( 1000);
         break;
      }
      default:
      {
         if(strcmp(System_Used,"JITES") != 0)
		 {
			 sound( 2000);
			 delay( 2000);
		 }
		 else
		 {
			putch(0x07);
		 }
         break;
      }
   }
   nosound();
}

/*******************************************************************/
/*
   <FUNCTION>
		<NAME>main function</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE></TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/

void main()
{
	/*
	The modifications are indicated by the beacons /* << 9.01b */  /* >> */
	/* The modified modules are: URNE\URNE.C, Urne\URNBE.C, URNE\PCURNE.C, URNE\EPROM.C
		COMP\GRAPH\SCR_URNE.C
	*/
	/*
	The modifications are indicated by the beacons /* << 9.01c */  /* >> */
	/* The modified modules are: URNE\URNE.C, URNE\PCURNE.C, URNE\EPROM.C, URNE\VARIABLE.C, URNE\ERREUR.C,
								 URNE\LECTEUR.C, URNE\URNE.H, URNE\EPROM.H, URNE\VARIABLE.H, URNE\LECTEUR.H,
	*/
	int i,j, iDskNum, iNbScrut, iNum;
	unsigned short usCptVote, usLang_ID;
	boolean test, bIndic;
	char Clef[12],stat,cport,c;
	char szBuffer[70], *pzScrutin;
	char Jeton_E[_JETON_ETENDU_MAX_BYTE+1];
	char choix;

	s_Parameters sParamMgnCdValid;
	s_PcType sPcType;

  /*Init global variables*/
  bEncodeV = false;
  bNoSupMode = false;
  bStart = true;
  bRecount_Mode = false;
  bReading_Loop = false;
  bWriteData_Ram = false;
  SAUVE_TO_EPROM    = false;
  DEMANDE_FERMETURE = false;
  Additionne = false;
  FERMETURE = false;

  COLOR   = _OFF_NO_LED;

  strcpy(Chemin_R,"c:\FE_Ram");
  strcpy(Chemin_D,"a:\FE_Dsk");

  harderr(handler);
  Init_Graph();


	sPcType = LoadDefinitionFile();

	if(sPcType.iStatus == -1)
	{
		sprintf(szBuffer,"INIT. ERROR CODE -1 in Main function.\nFile source %s\n", __FILE__);
		Erreur(szBuffer);
		Boucle_Erreur();
	}

	if(InitLibrary(sPcType.iPcType))
	{
		sprintf(szBuffer,"INIT. ERROR CODE -3 in Main function.\nFile source %s\n", __FILE__);
		Erreur(szBuffer);
		Boucle_Erreur();
	}

	if(sPcType.iPcType >= URNE_JITES_1 && sPcType.iPcType <= URNE_JITES_2)
	{
		/* only jites machine */
		cport = inp(0x61);       /*           PARITEE            */
		cport = cport | 0x08;    /*                              */
		outp(0x61,cport);        /*                              */
		strcpy(System_Used,"JITES");
		SUPPORT = 'E';

		/* initialize Magnetic reader card */
				/*Validator*/
		sParamMgnCdValid.iPort = COM_1;
		sParamMgnCdValid.iSetting = _PORT_FORMAT;
		sParamMgnCdValid.iBaudrate = _PORT_BAUDRATE;
		sParamMgnCdValid.uiHandshake = _PORT_HANDSHAKE;
		sParamMgnCdValid.iDtr = _PORT_DTR;
		sParamMgnCdValid.iRts = _PORT_RTS;
				/*Urn*/
		gsParamMgnCdUrne.iIoAddr = 0x3E8;
		gsParamMgnCdUrne.iIrq = 5;

	}
	else
	{
/* << 9.01c */
		/* Keyboard handler */
		Control_Keyboard();
/* 9.01c >> */
		/*This Digivote machine*/
		/* << 9.01b */
		/*
		Video_Affiche(V, _Version);
		Video_Affiche(H, "DIGIVOTE");
		*/
		/* 9.01b >> */
		SUPPORT = 'R';
		strcpy(System_Used,"DIGIVOTE");

		/* initialize Magnetic reader card */
		sParamMgnCdValid.iPort = 1;
		sParamMgnCdValid.iSetting = _COM_CHR7 | _COM_STOP1 | _COM_EVENPARITY | _COM_9600;

		/* initialize Magnetic reader card */
		gsParamMgnCdUrne.iPort = 0;
		gsParamMgnCdUrne.iSetting = _COM_CHR7 | _COM_STOP1 | _COM_EVENPARITY | _COM_9600;

	}

  usLang_ID = Language_ID();
  iNbScrut = Nb_Scrut_From_IND();
  if(iNbScrut == -1)
  {
	Lcd_Affiche(0,0, "INIT. ERROR CODE -4");
	Lcd_Affiche(1,0, "PREVENT ASSISTANCE");
	Boucle_Erreur();
  }

  Video_Init(usLang_ID, iNbScrut);
  Video_Screen(SCR_START);
/* << 9.01b */
  if(strcmp(System_Used,"DIGIVOTE") == 0)
  {
	Video_Affiche(V, _Version);
	Video_Affiche(H, "DIGIVOTE");
  }
/* 9.01b >> */

  if (!Alloc_Mem())
  {
	  Lcd_Affiche(0,0, "NOT ENOUGH MEMORY");
	  Lcd_Affiche(1,0, "PREVENT ASSISTANCE");
	  Boucle_Erreur();
  }
  Load_Message(usLang_ID);

  /*<< 9.01c*/
  /*if(((SUPPORT == 'R') && (access(Chemin_D, 0) == 0)) || (SUPPORT == 'E'))
		Recupere_E_Variable(_E_FERMETURE, &FERMETURE, false);

  if(!FERMETURE && (SUPPORT != 'N'))
  {
	iDiskId = Disk_Num() ;
	if(iDiskId == 0)
	{
		Lcd_Affiche(0,0, pszMessage_Point[122]);
		Lcd_Affiche(1,0, pszMessage_Point[7]);
		Boucle_Erreur();
	}
  }*/
  /*>> */

  while((Lit_Fichier_ARR("A:URNE.TBL")) != _PAS_ERREUR)
  {
	  Lcd_Affiche(0, 0, pszMessage_Point[25]);
	  Lcd_Affiche(1,0,  pszMessage_Point[14]);
	  Getch(COLOR);
  }

  for (i = 0, test = false; (i < 3) && (! test); i++)
  {
		Demande_Identite(fullPassword,true);
		if(strcmp(System_Used,"DIGIVOTE") == 0)
			Video_Screen(SCR_START);

		if(Verifie_Password())
		{
			strcpy(CLEF_URNE,fullPassword);
			CMinipassword[0] = fullPassword[0];
			CMinipassword[1] = fullPassword[2];
			CMinipassword[2] = fullPassword[4];
			CMinipassword[3] = fullPassword[6];
			CMinipassword[4] = 0x00;
			strcat(CMinipassword,Minicodage);

			while(!Demande_Mac());

			while((access("a:urne.tbl", 0)) != 0)
			{

				Lcd_Affiche(0,0, pszMessage_Point[12]);
				Lcd_Affiche(1,0,"");
			}

			Lcd_Affiche(0,0, pszMessage_Point[12]);
			Lcd_Affiche(1,0,"");

			j = Crc_Rijndael("r","2","a:","a:");

			if(j == -1)
			   test = false;
		    else
			   test = true;

		}
  }

	if(!test)
	{
		Lcd_Affiche(0,0, pszMessage_Point[54]);
		Boucle_Erreur();
	}

	while((Lit_Fichier_PCC("C:URNE.TBL")) != _PAS_ERREUR)
	{
		Lcd_Affiche(0, 0, pszMessage_Point[3]);
		Lcd_Affiche(1,0,  pszMessage_Point[7]);
		Getch(COLOR);
	}

	if(strcmp(System_Used,"DIGIVOTE") == 0)
		Display_Screen_Info();

	Lcd_Affiche(0,0, pszMessage_Point[53]);
	Lcd_Affiche(1,0,"");
	Calcul_Jeton(JETON_ETENDU, JETON);

	if(Init_Systeme(&sParamMgnCdValid, &gsParamMgnCdUrne, &sPcType) == 0)
	{
		Lcd_Affiche(0,0, pszMessage_Point[26]);
		Lcd_Affiche(1,0, pszMessage_Point[7]);

		Boucle_Erreur();
	}

	if(strcmp(System_Used,"JITES") == 0)
		Battery_Ok();  /* check the state of the batteries */

  /*<< 9.01c*/
  if((access("a:FE_DSK.CRP", 0)) == 0)
	  /*<< 9.03*/
  {
	  /*Decrypte_Fe_Dsk();*/
	  i = Decrypte_Fe_Dsk();
	  if(i == -1)
	  {
		Lcd_Affiche(0,0,pszMessage_Point[11]);
		Lcd_Affiche(1,0,pszMessage_Point[7]);
		Boucle_Erreur();
	  }
  }
	  /* >> */

  if(((SUPPORT == 'R') && (access(Chemin_D, 0) == 0)) || (SUPPORT == 'E'))
		Recupere_E_Variable(_E_FERMETURE, &FERMETURE, false);

  /* << 9.03*/
  /*if(!FERMETURE && (SUPPORT != 'N'))
  {*/
  iDiskId = Disk_Num() ;
  if(iDiskId == 0)
  {
		Lcd_Affiche(0,0, pszMessage_Point[122]);
		Lcd_Affiche(1,0, pszMessage_Point[7]);
		Boucle_Erreur();
  }
  /*}*/
  /*>> */

	if (!FERMETURE)
	{
		choix = ' ';
		while((choix != '1') && (choix != '9'))
		{
			Lcd_Affiche(0,0,pszMessage_Point[51]);
			Lcd_Affiche(1,0,pszMessage_Point[52]);

			choix = Getch(COLOR);

			if(choix == '9')
			{
				Lcd_Affiche(0,0,pszMessage_Point[128]);
				if(strcmp(System_Used,"JITES") == 0)
					Lcd_Affiche(1,0,pszMessage_Point[21]);
				else
					Lcd_Affiche(1,0,pszMessage_Point[94]);

				choix = ' ';
				while((choix != 'O') && (choix != 'J') && (choix != 'N'))
					choix = Getch(COLOR);
				if((choix == 'O') || (choix == 'J'))
				{
					for (i = 0, test = false; i < 3 && (! test); i++)
					  {
						   test = Demande_Identite(Clef,false);
						   if(!test)
								break;
						   else
								test = Verifie_Urne( Clef);
					  }

					if(strcmp(System_Used,"DIGIVOTE") == 0)
						Video_Screen(SCR_START);

					if(test)
					{
						choix = '9';
						bRecount_Mode = true;
					}
				}
			}
		}

		iNum = Disk_Num();
		while(iNum != iDiskId)
		{
			sprintf(szBuffer,pszMessage_Point[114],iDiskId);
			iNum = Change_Disque(szBuffer,true);
		}

		if(SUPPORT != 'N')
			Init_CheckVote(choix);
	}

	Lecteur_Put_Tempo();

	if(SUPPORT != 'N')
		Switch_Support();

	if((strcmp(System_Used,"JITES") == 0) && (SUPPORT == 'E'))
		Test_Eprom();

	if(SUPPORT != 'N')
	{
		Recupere_E_Var_String(_E_JETON_ETENDU, Jeton_E,_JETON_ETENDU_MAX_BYTE,true);
		Recupere_E_Variable(_E_FERMETURE, &FERMETURE, true);
		Recupere_E_Variable(_E_OUVERTURE, &OUVERTURE, true);
		Recupere_Nb_Cartes();

		pzScrutin = (char *)malloc(strlen(Buffer_Par));
		if(pzScrutin == NULL)
		{
		  Lcd_Affiche(0,0, pszMessage_Point[121]);
		  Lcd_Affiche(1,0, pszMessage_Point[7]);
		  Boucle_Erreur();
		}
		Recupere_E_Var_String((long)_E_PAR_PLACE,pzScrutin,strlen(Buffer_Par),true);

		if ((FERMETURE || OUVERTURE ) && ((strcmp(JETON_ETENDU, Jeton_E) != 0) ||
			(strcmp(Buffer_Par, pzScrutin) != 0)))
			 Test_Contenu_Urne2();

		if(pzScrutin != NULL)
		{
			free(pzScrutin);
			pzScrutin = NULL;
		}

		Recupere_E_Variable(_E_FERMETURE, &FERMETURE, true);
		Recupere_Nb_Cartes();
		if ( FERMETURE )
		{
			/*<< 9.01c*/
			Encrypte_Fe_Dsk();
			/*>> */

			if(strcmp(System_Used,"JITES") == 0)
				Lcd_Affiche(0,0, pszMessage_Point[67]);
			else
				Video_Affiche(OG,pszMessage_Point[67]);

			for(usCptVote = 1;true;)
			{
				if(SUPPORT != 'N')
				{
					Display_Votes_Counters(&usCptVote,1);
					if(strcmp(System_Used,"JITES") == 0)
						Lcd_Affiche(0,0, pszMessage_Point[67]);
					Wait_Time(3);
					if((c = Kbhit(COLOR,2000)) == '2')
						Ecriture_force();
				}
			}
		}

		Recupere_E_Variable(_E_OUVERTURE, &OUVERTURE, true);
		if (! OUVERTURE)
		{
			Ouverture_Urne(true);
		}
		else
		{
			Test_Contenu_Urne();
		}

	}

 if(strcmp(System_Used,"JITES") == 0)
 {
	 Battery_On();
	 COLOR = _ON_GREEN;
 }

 test = true;
 while (test)
 {
	 if(bRecount_Mode)
	 {
		Lcd_Affiche(0,0, "");
		Lcd_Affiche(1,0, "");
		if(strcmp(System_Used,"DIGIVOTE") == 0)
			Video_Screen(SCR_RECOMPT);
	 }
	 else if(strcmp(System_Used,"DIGIVOTE") == 0)
		Video_Screen(SCR_GEN);

     Boucle_Lecteur(&sPcType);
     test = !Fermeture_Urne();
 }

 if(strcmp(System_Used,"DIGIVOTE") == 0)
 {
	Video_Screen(SCR_URNE);
	if(MULTI_ELEC == 'P')
	{
		Video_Affiche(CNX, " ");
		Video_Affiche(CEX, " ");
	}
 }

 if(SUPPORT != 'N')
 {
    Write_Data_Disk(iDiskId);
 }

 if(strcmp(System_Used,"JITES") == 0)
 {
	 Battery_Off();
	 Lcd_Affiche(0,0, pszMessage_Point[67]);
	 Lcd_Affiche(1,0, " ");
 }
 else
 {
	 Lcd_Affiche(0,0, " ");
	 Lcd_Affiche(1,0, " ");
	 Video_Affiche(OG,pszMessage_Point[67]);
 }

 for(usCptVote = 1;true;)
 {
	if(SUPPORT != 'N')
	{
		Display_Votes_Counters(&usCptVote,1);
		if(strcmp(System_Used,"JITES") == 0)
			Lcd_Affiche(0,0, pszMessage_Point[67]);
		Wait_Time(3);
		if((c = Kbhit(COLOR,2000)) == '2')
			Ecriture_force();
	}
 }
 /*Free_Mem(); not used*/

} /* main */
/*******************************************************************/
/*
   <FUNCTION>
		<NAME>Ecriture_force</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Write cipher results of the election and EPROM or FE_RAM contents on additional floppy
		</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE></TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Ecriture_force()
{

 char strtmp[21],choix,c, szMsgError[80];
 int  i, fd2;

 Lcd_Affiche(0,0, pszMessage_Point[58]);
 if(strcmp(System_Used,"JITES") == 0)
	Lcd_Affiche(1,0, pszMessage_Point[21]);
 else
	 Lcd_Affiche(1,0, pszMessage_Point[94]);

 choix = ' ';
 while((choix != 'O') && (choix != 'J') && (choix != 'N'))
       choix = Getch(COLOR);

 if((choix == 'O') || (choix == 'J'))
 {
	 Lcd_Affiche(0,0, pszMessage_Point[12]);
	 Lcd_Affiche(1,0, pszMessage_Point[13]);

	 remove("a:BE");
	 remove("a:TABLE.URN");
	 remove("a:URNE.IND");

	 Down_Load_Ind();
	 Load_Floppy();

	 if(Additionne == false)
	 {
	  Transfert_Table_PCC("C:TABLE.URN");
	  Additionne = true;
	 }
	 else
	   while((Ecrit_Table_PCC("C:TABLE.URN")) != _PAS_ERREUR)
		{
		  Lcd_Affiche(0,0, pszMessage_Point[36]);
		  Lcd_Affiche(1,0, pszMessage_Point[14]);
		  Getch(COLOR);
		  Lcd_Affiche(0,0, "");
		  Lcd_Affiche(1,0," ");
		}

	 i = Crc_Rijndael("W","3","c:","a:");
	 if(i == -1)
	 {
		Lcd_Affiche(0,0, pszMessage_Point[27]);
		Lcd_Affiche(1,0, pszMessage_Point[14]);
		Getch(COLOR);
	 }
	 /*<< 9.01c*/
	 else
	 /*>>*/
	 {
		 if(SUPPORT == 'E')
			Backup_Eprom_Disk("a:FE_Dsk");
		 else
			Backup_Ram_Disk("a:FE_Dsk");
		 /*<< 9.01c*/
		 Encrypte_Fe_Dsk();
		 Lcd_Affiche(0,0, pszMessage_Point[82]);
		 Lcd_Affiche(1,0, pszMessage_Point[14]);
		 Getch(COLOR);
		 /*>>*/
	 }
 }

}
/******************************************************************************/
/*
   <FUNCTION>
		<NAME>Load_Floppy</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Create the file Floppy.be on the floppy disk
		</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE></TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Load_Floppy()
{
	char szFileName[12], szMsgError[80];
	int iRes;
	FILE *Fichier;

	strcpy(szFileName,"a:Floppy.be");

	if((Fichier = fopen(szFileName, "wb")) == NULL)
	{
		sprintf(szMsgError,"Error opening file %s in Load_Floppy function.\nFile source: %s\n",
							szFileName, __FILE__);
		Erreur(szMsgError);
	}
	else
	{
		iRes = fwrite(szDataFloppy, strlen(szDataFloppy), 1 , Fichier);
		if(iRes != 1)
		{
			sprintf(szMsgError,"Error writing to the file %s in Load_Floppy function.\nFile source: %s\n",
						szFileName, __FILE__);
			Erreur(szMsgError);
		}

		fclose(Fichier);
	}
}

/*******************************************************************************/
/*
   <FUNCTION>
		<NAME>Battery_Ok</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>Test the state of the batteries</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE></TYPE>
			<DESCRIPTION></DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
void Battery_Ok()
{
  char c,choix;

  c = ReadBatteryState();
  if(c  == 0x1F)
	 {
		Lcd_Affiche(0,0, pszMessage_Point[68]);
		Lcd_Affiche(1,0," ");

		Battery_Off();
		BATTERY = 1;
	 }
  else
	 {
		Lcd_Affiche(0,0,pszMessage_Point[69]);
		Lcd_Affiche(1,0,pszMessage_Point[35]);

		Battery_Off();
		choix = ' ';
		BATTERY = 0;
		while((choix != 'O') && (choix != 'J') && (choix != 'N'))
				choix = Getch(COLOR);
		if (choix == 'N')
	    {
	        Lcd_Affiche(0,0, pszMessage_Point[70]);
	        Lcd_Affiche(1,0, pszMessage_Point[71]);
	        Boucle_Erreur();
	    }
	  }
} /* Battery_Ok */

/*******************************************************************/
/*
   <FUNCTION>
		<NAME>Demande_Mac</NAME>
        <TYPE>LOCAL</TYPE>
		<DESCRIPTION>
		Check if Floppy.be file exists and execute Initialise_Rijndael function
		</DESCRIPTION>
        <PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO></IO>
			<DESCRIPTION></DESCRIPTION>
		</PARAMETER>
		<RETURN>
			<TYPE>int</TYPE>
			<DESCRIPTION>return true or false according the result of the function Initialise_Rijndael </DESCRIPTION>
		</RETURN>
   </FUNCTION>
*/
int Demande_Mac()
{
  int test;

  if((access("a:Floppy.be", 0)) == 0)
  {
	 test = Initialise_Rijndael();
	 Initialise_RijndaelMini();
	 if (test)
		return(true);
     else
		return(false);
  }

return(false);
}

/*******************************************************************/
/*       END OF MAIN MODULE URNE.C                                 */
/*******************************************************************/
