#ifndef __INC_POS_PLIB_STARTCODE_C
#define __INC_POS_PLIB_STARTCODE_C
/*******************************************************************
 $CRT 16 Mar 1996 : hb

 $AUT Holger Burkarth
 $DAT >>StartCode.c<<   08 Mar 1997    09:52:45 - (C) ProDAD
*******************************************************************/

/**
 mcpp:cppc -pc -c p:pLib/StartCode.c -o p:pLib/StartCode.o
 mcpp:cppc -pp -c p:pLib/StartCode.c -o p:pLib/StartCodeCPP.o
**/

#define __COMPUTER_AMIGA 1
#define NOMYDEBUG

#include "p:pDOS/Process.h"
#include "p:pProto/pExec2.h"
#include "p:pDOS/DosBase.h"
#include "p:pExec/Diagnos.h"
#include "p:pExec/TstTags.h"

struct pOS_FileHandle *pstd__in, *pstd__out, *pstd__err;


#ifdef __cplusplus
 extern "C" VOID InitModules();
 extern "C" VOID CleanupModules();
 extern "C" int main(VOID);
#else
 int main(VOID);
#endif

void Entry(_R_LB struct pOS_DosBase*,_R_A0 const struct pOS_SegmentLst*);


struct pOS_ExecBase        *gb_ExecBase;
struct pOS_ExecLibFunction *gb_ExecLib;
struct pOS_DosBase         *gb_DosBase;

static const struct pOS_TagItem gb_TstTags[]=
{
  EXTSTTAG_MainOSID, pOS_MAINOSID,
  TAG_END
};


/*----------------------------------
-----------------------------------*/
void entry(_R_LB struct pOS_DosBase* dos,_R_A0 const struct pOS_SegmentLst* segm,
           register __d0 ULONG id)
{
  if(id == 'pOS\0') Entry(dos,segm);
}


/*----------------------------------
-----------------------------------*/
void Entry(_R_LB struct pOS_DosBase* dos,_R_A0 const struct pOS_SegmentLst* segm)
{
#ifndef __pOS_EXECPRECODE
 #error hier fehlt etwas
#endif

  extern struct pOS_ExecBase        *gb_ExecBase;
  extern struct pOS_ExecLibFunction *gb_ExecLib;
  extern struct pOS_DosBase         *gb_DosBase;

  gb_DosBase =dos;
  gb_ExecBase=(struct pOS_ExecBase*)dos->ExecBase;
  gb_ExecLib =dos->dos_Exec2Private;
  {
    struct pOS_Process *const Proc=(struct pOS_Process*)pOS_FindTask(NULL);
    pstd__in =Proc->pr_CIS;
    pstd__out=Proc->pr_COS;
    pstd__err=Proc->pr_CES;
  }

/*\
*** Wrong OS Version ?
\*/
  if(!pOS_ExecCheckA(gb_TstTags)) return;


#ifdef __cplusplus
  InitModules();
  main();
  CleanupModules();
#else
  main();
#endif
}



#endif