/**************************************************************************
<MODULE NAME>
<FILENAME></FILENAME>
<HISTORY>
	<MODIFICATION>
		<DATE></DATE>
		<ATHOR></ATHOR>
		<DESCRIPTION>
		</DESCRIPTION>
	</MODIFICATION>
</HISTORY>
</MODULE NAME>
**************************************************************************/


/**************************************************************************
INCLUDE FILE
**************************************************************************/
#include <stdio.h>

/**************************************************************************
LOCAL VARIABLES
Always start with « static »-keyword
**************************************************************************/

/**************************************************************************
<METHOD>
	<CLASS>CFloppy</CLASS>
	<NAME>CFloppy</NAME>
	<TYPE > LOCAL  GLOBAL </TYPE>
	<DESCRIPTION></DESCRIPTION>
	<PARAMETERS>
		<PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO> IN | OUT | INOUT</ IO >
			<DESCRIPTION>
			</DESCRIPTION>
		</PARAMETER>
	</PARAMETERS>
</METHOD>
**************************************************************************/
CFloppy::CFloppy()
{
	;
}


/**************************************************************************
<METHOD>
	<CLASS>CFloppy</CLASS>
	<NAME>~CFloppy</NAME>
	<TYPE > LOCAL | GLOBAL </TYPE>
	<DESCRIPTION></DESCRIPTION>
	<PARAMETERS>
		<PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO> IN | OUT | INOUT</ IO >
			<DESCRIPTION>
			</DESCRIPTION>
		</PARAMETER>
	</PARAMETERS>
</METHOD>
**************************************************************************/
CFloppy::~CFloppy()
{
	;
}

/**************************************************************************
<METHOD>
	<CLASS>CFloppy</CLASS>
	<NAME></NAME>
	<TYPE >LOCAL | GLOBAL</TYPE>
	<DESCRIPTION></DESCRIPTION>
	<PARAMETERS>
		<PARAMETER>
			<NAME></NAME>
			<TYPE></TYPE>
			<IO> IN | OUT | INOUT</ IO >
			<DESCRIPTION>
			</DESCRIPTION>
		</PARAMETER>
	</PARAMETERS>
	<RETURNS>
		<TYPE></TYPE>
		<DESCRIPTION>
		</DESCRIPTION>
	</RETURNS>
</METHOD>
**************************************************************************/




static void tpcv_floppy()
{
    /*** Write a file on a formatted floppy and read it back.
         Of course, first delete a possible old corresponding file on the
         floppy...
    ***/
    static uchar msg[4096];
    int i;
    char *fn = "A:pcvote.tst";
    FILE *fp;

    for (i=0; i < sizeof(msg); i++)
        msg[i] = (uchar) i;
    if (detailed_test && (w_message("Insert a formatted floppy disk", 0) & 0xff) == 0x1b)
    {
        test_failed = -1;
        return;
    }

    w_wrstr("Removing old file", &wn_tpcv);
    remove(fn);
    if ((fp=fopen(fn, "r")) != NULL)
    {
        fclose(fp);
        display_error("Can't remove existing file on floppy!",
                      "Can't remove file");
        test_failed = 1;
    }
    else
    {
        w_wrstr("Write file", &wn_tpcv);
        if ((fp=fopen(fn, "wb")) == NULL)
        {
            display_error("Can't create output file", "Can't create file");
            test_failed = 1;
        }
        else
        {
            if (fwrite(msg, sizeof(msg), 1, fp) != 1)
            {
                display_error("Write error", 0);
                test_failed = 1;
            }
            fclose(fp);
            memset(msg, 0, sizeof(msg));
            if (!test_failed)
            {
                w_wrstr("Reading file", &wn_tpcv);
                if ((fp=fopen(fn, "rb")) == NULL)
                {
                    display_error("Can't read input file", "Can't read file");
                    test_failed = 1;
                }
                else
                {
                    if (fread(msg, sizeof(msg), 1, fp) != 1)
                    {
                        display_error("Read error", 0);
                        test_failed = 1;
                    }
                    fclose(fp);
                    if (!test_failed)
                    {
                        w_wrstr("Comparing...", &wn_tpcv);
                        for (i=0; i < sizeof(msg); i++)
                            if (msg[i] != (uchar) i)
                                break;
                        utt_delay(2);
                        if (i < sizeof(msg))
                        {
                            display_error("Data verify error", 0);
                            test_failed = 1;
                        }
                    }
                }
            }
        }
    }
}