home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / MacPerl 5.0.3 / MacPerl Source ƒ / Perl5 / perldispatch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-30  |  3.1 KB  |  203 lines  |  [TEXT/MPS ]

  1. /* DISPATCH_START */
  2. #define MAC_CONTEXT
  3. #define MP_EXT
  4. #define MP_INIT(x) = x
  5.  
  6. #include <time.h>
  7. #include <stdio.h>
  8. #include <Folders.h>
  9. #include <Events.h>
  10. #include <OSUtils.h>
  11. #include <LowMem.h>
  12. #include <GUSI.h>
  13. #include <TFileSpec.h>
  14. #include <TFileGlob.h>
  15. #include <fp.h>
  16. #include <LowMem.h>
  17.  
  18. #define MEM_SIZE    Size_t
  19.  
  20. #include "config.h"
  21. #include "handy.h"
  22. #include "macish.h"
  23. #include "SubLaunch.h"
  24. /* DISPATCH_END */
  25. /* DISPATCH_START */
  26. #define ROOT_UID    0
  27. #define ROOT_GID    0
  28. int
  29. (getuid)(void)
  30. {
  31.     return ROOT_UID;
  32. }
  33.  
  34. int
  35. (geteuid)(void)
  36. {
  37.     return ROOT_UID;
  38. }
  39.  
  40. int
  41. (getgid)(void)
  42. {
  43.     return ROOT_GID;
  44. }
  45.  
  46. int
  47. (getegid)(void)
  48. {
  49.     return ROOT_GID;
  50. }
  51.  
  52. int
  53. (setuid)(int uid)
  54.     return (uid==ROOT_UID?0:-1);
  55. }
  56.  
  57. int
  58. setgid(int gid)
  59.     return (gid==ROOT_GID?0:-1); 
  60. }
  61.  
  62. #undef execv
  63.  
  64. (execv)()
  65. {
  66.     croak("execv() not implemented on the Macintosh");
  67. }
  68.  
  69. #undef execvp
  70.  
  71. (execvp)()
  72. {
  73.     croak("execvp() not implemented on the Macintosh");
  74. }
  75.  
  76. kill()
  77. {
  78.     croak("kill() not implemented on the Macintosh");
  79. }
  80. /* DISPATCH_END */
  81. /* DISPATCH_START */
  82. struct tm * gmtime(const time_t * timer)
  83. {
  84.     MachineLocation     loc;
  85.     struct tm *            swatch;
  86.     long                delta;
  87.     time_t                rolex;
  88.     
  89.     ReadLocation(&loc);
  90.     
  91.     if (!loc.latitude && !loc.longitude)
  92.         return localtime(timer);    /* This is incorrect unless you live in Greenwich */
  93.     
  94.     delta = loc.u.gmtDelta & 0xFFFFFF;
  95.     
  96.     if (delta & 0x800000)
  97.         delta = (long) ((unsigned long) delta | 0xFF000000);
  98.         
  99.     rolex = (unsigned long) ((long) *timer - delta);
  100.     
  101.     swatch = localtime(&rolex);
  102.     
  103.     swatch->tm_isdst = (loc.u.dlsDelta & 0x80) != 0;
  104.     
  105.     return swatch;
  106.  }
  107. /* DISPATCH_END */
  108. /* DISPATCH_START */
  109. pid_t (getpid)()
  110. {
  111.     return 1;
  112. }
  113. /* DISPATCH_END */
  114. /* DISPATCH_START */
  115. #include <Types.h>
  116. #include <Memory.h>
  117. #include <Files.h>
  118.  
  119. #include <stdarg.h>
  120.  
  121. #include "icemalloc.h"
  122.  
  123. #define mNEWPTR(size)            ( NewPtr ( (size) ) )
  124. #define mDISPOSPTR(ptr)            ( DisposPtr ( (ptr) ) )
  125.  
  126. _mem_pool    _mem_system_pool = {
  127.     0,                        /* id */
  128.     SUGGESTED_BLK_SIZE,        /* pref_blk_size */
  129.     0,                        /* blk_list */
  130.     0,                        /* next */
  131. #ifdef _PM_STATS
  132.     0,                        /* total_memory */
  133.     0,                        /* total_storage */
  134.     0,                        /* total_malloc */
  135.     0,                        /* max_blk_size */
  136.     0.0,                    /* ave_req_size */
  137.     0,                        /* ave_req_total */
  138.     0.0,                    /* ave_blk_size */
  139.     0,                        /* ave_blk_total */
  140. #endif
  141.     };
  142. _mem_pool_ptr                _mem_pool_forest = & _mem_system_pool;
  143.  
  144. #define DEBUG
  145. /* DISPATCH_END */
  146. /* DISPATCH_START */
  147. void    *
  148. malloc (size_t size )
  149. {
  150.     _mem_pool_ptr    pool;
  151.     char *            mem;
  152.  
  153.     pool = _default_mem_pool;
  154.     if (pool == (_mem_pool_ptr)0)
  155.         return (char *)0;
  156.     
  157.     mem = pool_malloc(pool, size);
  158.     
  159. #ifdef MALLOC_LOG
  160.     MallocLog("%d %d\n", (int) mem, (int) size); 
  161. #endif
  162.  
  163.     return mem;
  164. }
  165. /* DISPATCH_END */
  166. /* DISPATCH_START */
  167. void free(void * ptr)
  168. {
  169.     
  170. #ifdef MALLOC_LOG
  171.     MallocLog("%d\n", (int) ptr); 
  172. #endif
  173.     
  174.     pool_free((char *) ptr);
  175. }
  176. /* DISPATCH_END */
  177. /* DISPATCH_START */
  178. void * realloc(void * old, u_long size)
  179. {
  180.     void *            nu;
  181.     
  182.     nu = malloc(size);
  183.     
  184.     if (!old || !nu)
  185.         return nu;
  186.     
  187.     memcpy(nu, old, size);
  188.     
  189.     free(old);
  190.     
  191.     return nu;
  192. }
  193. /* DISPATCH_END */
  194. /* DISPATCH_START */
  195. void *
  196. calloc(u_long nmemb, u_long size)
  197. {
  198.     return malloc(nmemb*size);
  199. }
  200. /* DISPATCH_END */
  201.