home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / MacPerl 5.1.3 / Mac_Perl_513_src / perl5.002 / miniperlmain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-27  |  1.6 KB  |  98 lines  |  [TEXT/MPS ]

  1. /*
  2.  * "The Road goes ever on and on, down from the door where it began."
  3.  */
  4.  
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8.  
  9. #include "EXTERN.h"
  10. #include "perl.h"
  11.  
  12. #ifdef __cplusplus
  13. }
  14. #  define EXTERN_C extern "C"
  15. #else
  16. #  define EXTERN_C extern
  17. #endif
  18.  
  19. static void xs_init _((void));
  20. static PerlInterpreter *my_perl;
  21.  
  22. int
  23. #ifdef CAN_PROTOTYPE
  24. main(int argc, char **argv, char **env)
  25. #else
  26. main(argc, argv, env)
  27. int argc;
  28. char **argv;
  29. char **env;
  30. #endif
  31. {
  32.     int exitstatus;
  33.  
  34.     PERL_SYS_INIT(&argc,&argv);
  35.  
  36.     perl_init_i18nl14n(1);
  37.  
  38. #if !defined(macintosh) || !defined(MULTIPLICITY)
  39.     if (!do_undump) {
  40. #endif
  41. #ifdef macintosh
  42.     if (!gDebugLogName || !(gPerlDbg = fopen(gDebugLogName, "w")))
  43.          gPerlDbg = stderr;
  44. #endif
  45. #ifdef MALLOC_LOG
  46.     MallocLog("Allocating...\n");
  47. #endif
  48.     my_perl = perl_alloc();
  49.     if (!my_perl)
  50.         exit(1);
  51. #ifdef MALLOC_LOG
  52.     MallocLog("Constructing...\n");
  53. #endif
  54.     perl_construct( my_perl );
  55. #if !defined(macintosh) || !defined(MULTIPLICITY)
  56.     }
  57. #endif
  58.  
  59. #ifdef MALLOC_LOG
  60.     MallocLog("Parsing...\n");
  61. #endif
  62.     exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL );
  63.     if (!exitstatus) {
  64.  
  65. #ifdef MALLOC_LOG
  66.     MallocLog("Running...\n");
  67. #endif
  68.     exitstatus = perl_run( my_perl );
  69.     
  70.     }
  71.  
  72. #ifdef MALLOC_LOG
  73.     MallocLog("Destructing...\n");
  74. #endif
  75.     perl_destruct( my_perl );
  76. #ifdef MALLOC_LOG
  77.     MallocLog("Freeing...\n");
  78. #endif
  79.     perl_free( my_perl );
  80. #ifdef MALLOC_LOG
  81.     MallocLog("That's all, folks...\n");
  82. #endif
  83.  
  84.     PERL_SYS_TERM();
  85.  
  86.     exit( exitstatus );
  87. }
  88.  
  89. /* Register any extra external extensions */
  90.  
  91. /* Do not delete this line--writemain depends on it */
  92.  
  93. static void
  94. xs_init()
  95. {
  96.   dXSUB_SYS;
  97. }
  98.