home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / IncPOS.lzx / pLib / MainCode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-18  |  2.6 KB  |  121 lines

  1. #ifndef __INC_POS_PLIB_MAINCODE_C
  2. #define __INC_POS_PLIB_MAINCODE_C
  3. /*******************************************************************
  4.  $CRT 17 Mar 1996 : hb
  5.  
  6.  $AUT Holger Burkarth
  7.  $DAT >>MainCode.c<<   08 Mar 1997    09:55:06 - (C) ProDAD
  8. *******************************************************************/
  9.  
  10. /***
  11.  mcpp:cppc -pc -c p:pLib/MainCode.c -o p:pLib/MainCode.o
  12.  mcpp:cppc -pp -c p:pLib/MainCode.c -o p:pLib/MainCodeCPP.o
  13. ***/
  14.  
  15. #define __COMPUTER_AMIGA 1
  16. #define NOMYDEBUG
  17.  
  18. #include "p:proto/pExec2.h"
  19. #include "p:proto/pDOS2.h"
  20.  
  21. #include "p:pDOS/DosBase.h"
  22. #include "p:pDOS/ArgTags.h"
  23. #include "p:pDOS/DosArgs.h"
  24. #include "p:pDOS/Process.h"
  25. #include "p:pExec/Diagnos.h"
  26. #include "p:pExec/TstTags.h"
  27.  
  28. struct pOS_FileHandle *pstd__in, *pstd__out, *pstd__err;
  29. SLONG gb_Error;
  30.  
  31. #ifdef __cplusplus
  32.  extern "C" VOID InitModules();
  33.  extern "C" VOID CleanupModules();
  34.  extern "C" int main(int argc,char* argv[]);
  35. #else
  36.  int main(int argc,char* argv[]);
  37. #endif
  38.  
  39. void Entry(_R_LB struct pOS_DosBase*,_R_A0 const struct pOS_SegmentLst*);
  40.  
  41.  
  42.  
  43. struct pOS_ExecBase        *gb_ExecBase;
  44. struct pOS_ExecLibFunction *gb_ExecLib;
  45. struct pOS_DosBase         *gb_DosBase;
  46.  
  47.  
  48.  
  49. static const struct pOS_TagItem gb_TstTags[]=
  50. {
  51.   EXTSTTAG_MainOSID, pOS_MAINOSID,
  52.   TAG_END
  53. };
  54.  
  55.  
  56. /*----------------------------------
  57. -----------------------------------*/
  58. void entry(_R_LB struct pOS_DosBase* dos,_R_A0 const struct pOS_SegmentLst* segm,
  59.            register __d0 ULONG id)
  60. {
  61.   if(id == 'pOS\0') Entry(dos,segm);
  62. }
  63.  
  64.  
  65. /*----------------------------------
  66. -----------------------------------*/
  67. void Entry(_R_LB struct pOS_DosBase* dos,_R_A0 const struct pOS_SegmentLst* segm)
  68. {
  69.   struct pOS_DosArgs* Args;
  70.   ULONG Area[1]={0};
  71.  
  72. #ifndef __pOS_EXECPRECODE
  73.  #error hier fehlt etwas
  74. #endif
  75.  
  76.   extern struct pOS_ExecBase        *gb_ExecBase;
  77.   extern struct pOS_ExecLibFunction *gb_ExecLib;
  78.   extern struct pOS_DosBase         *gb_DosBase;
  79.  
  80.   gb_DosBase =dos;
  81.   gb_ExecBase=(struct pOS_ExecBase*)dos->ExecBase;
  82.   gb_ExecLib =dos->dos_Exec2Private;
  83.  
  84. /*\
  85. *** Wrong OS Version ?
  86. \*/
  87.   if(!pOS_ExecCheckA(gb_TstTags)) return;
  88.  
  89.   {
  90.     struct pOS_Process* Proc=(struct pOS_Process*)pOS_FindTask(NULL);
  91.     pstd__in =Proc->pr_CIS;
  92.     pstd__out=Proc->pr_COS;
  93.     pstd__err=Proc->pr_CES;
  94.   }
  95.  
  96.   Args=pOS_ReadDosArgsA("/M",Area,sizeof(Area)/sizeof(ULONG),NULL);
  97.   if(Args) {
  98.     CHAR **Argv=(CHAR**)Area[0];
  99.     UWORD  Argc;
  100.  
  101.     for(Argc=0; Argv[Argc]; ++Argc);
  102.  
  103. #ifdef __cplusplus
  104.     InitModules();
  105. #endif
  106.  
  107.     main(Argc+1,&Argv[-1]);
  108.  
  109. #ifdef __cplusplus
  110.     CleanupModules();
  111. #endif
  112.  
  113.     pOS_DeleteDosArgs(Args);
  114.   }
  115.   else gb_Error=DOSFAIL_FAIL;
  116.   pOS_ExitProcess(gb_Error);
  117. }
  118.  
  119.  
  120. #endif
  121.