#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <exec/types.h>
#include <exec/exec.h>
#include "exec/execbase.h"
#include "devices/timer.h"
#include <libraries/dos.h>
#include <proto/dos.h>
#include <proto/exec.h>

/************************/
/* Constants and Macros */
/************************/
typedef struct IOStdReq   IOSTDREQUEST;
typedef struct MsgPort    MSGPORT;
typedef struct IORequest  IOREQUEST;

/***************************/
/* Structures and Typedefs */
/***************************/

/**************/
/* Prototypes */
/**************/

/********************/
/* Global Variables */
/********************/

/**********************************************************************/
/*                                                                    */
/**********************************************************************/
int
main()
{
    MSGPORT       *mp;
    IOSTDREQUEST  *ior;
    int            result;

    /*************************************/
    /* Create a Private I/O Message Port */
    /*************************************/
    if ((mp = CreatePort(NULL, 0)) == 0) {
        printf("Unable to Create a Private I/O Port.\n");
        return 10;
    }

    /************************************/
    /* Setup the I/O Read Request Block */
    /************************************/
    ior = CreateStdIO(mp);
    if (ior == NULL) {
        DeletePort(mp);
        printf("CreateStdIO Function Failed.\n");
        return 10;
    }

    /**********************************/
    /* Open the Desired Serial Device */
    /**********************************/
    if (result = OpenDevice("Example.device", 0L, (IOREQUEST *)ior, 0L)) {
        printf("OpenDevice Function Failed, Error %u (0x%02X).\n",
            result, result);

        DeleteStdIO(ior);
        DeletePort(mp);
        return 10;
    }

    printf("The Open Succeeded, Press Any Key to Continue!\n");
    getchar();

    CloseDevice((IOREQUEST *)ior);
    DeleteStdIO(ior);
    DeletePort(mp);

    return 0;
}
/**********************************************************************/
/*                                                                    */
/**********************************************************************/

