/* Main-Header File inserted by GenCodeC */
/* Libraries */
#include <libraries/mui.h>
#include <libraries/gadtools.h> /* for BARLABEL in MenuItem */

/* Prototypes */
#include <clib/muimaster_protos.h>
#include <clib/exec_protos.h>
#include <clib/alib_protos.h>
#include <clib/dos_protos.h>


/*  Pragmas  */
#include <pragma/muimaster_lib.h>
#include <pragma/exec_lib.h>

/*  Ansi  */
#include <stdlib.h>
#include <stdio.h>
#include <wbstartup.h>
/* GenCodeC header end */

/* Include generated by GenCodeC */
#include "faxGUI.c"

/* Declarations for libraries (inserted by GenCodeC) */
struct Library * MUIMasterBase;
struct Library * LocaleBase;

void init( void )
{
        if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
        {
                printf("Can't Open MUIMaster Library\n");
                exit(20);
        }
        if (!(LocaleBase = OpenLibrary("locale.library",38)))
        {
                printf("Can't Open Locale Library\n");
                printf("Built-in Language will be used !!!\n");
        }
        OpenAppCatalog(NULL,NULL);
}

void end( void )
{
        CloseAppCatalog();
        if (LocaleBase)
                CloseLibrary(LocaleBase);
        CloseLibrary(MUIMasterBase);
        exit(0);
}


int main(int argc, char *argv[])
{
        struct ObjApp * App = NULL;     /* Object */
        BOOL    running = TRUE;
        ULONG   signal;

        /* Program initialisation : generated by GenCodeC */
        init();

        /* Create Object : generated by GenCodeC */
        if (!(App = CreateApp()))
        {
                printf("Can't Create App\n");
                end();
        }

        while (running)
        {
                switch (DoMethod(App->App,MUIM_Application_Input,&signal))
                {
                        case MUIV_Application_ReturnID_Quit:
                                running = FALSE;
                                break;

                        case BT_PRINTER:
                                      system("run >nil: server");
                                      break;
                        case BT_SPOOLER:
                                      system("run >nil: spooler");
                                      break;
                        case BT_LOGBOOK:
                                      system("run >nil: logbook");
                                      break;
                        case BT_CONFIG:
                                      system("run >nil: config");
                                      break;
                        case BT_DESK:
                                      system("execute faxdesk");
                                      break;
                        
                }
                if (running && signal) Wait(signal);
        }
        DisposeApp(App);
        end();
}
