home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / emacs-19.28-src.tgz / tar.out / fsf / emacs / src / amiga_processes.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  2KB  |  99 lines

  1. #include <exec/types.h>
  2. #include <exec/execbase.h>
  3. #include <exec/memory.h>
  4. #include <dos/dos.h>
  5. #include <dos/dosextens.h>
  6. #include <dos/dostags.h>
  7. #include <proto/exec.h>
  8. #include <proto/dos.h>
  9. #include <clib/alib_protos.h>
  10. #include <signal.h>
  11. #undef signal
  12. #include <ios1.h>
  13. #include <string.h>
  14. #include <errno.h>
  15. #include <stdio.h>
  16. #include <internal/vars.h>
  17.  
  18. #include "config.h"
  19. #include "lisp.h"
  20. #include "amiga.h"
  21. #include "emacssignal.h"
  22.  
  23. #ifdef USE_PROTOS
  24. #include "protos.h"
  25. #endif
  26.  
  27. extern struct ExecBase *SysBase;
  28.  
  29. int amiga_process_stack_size;
  30.  
  31. /* A few emacs support functions */
  32. /* ----------------------------- */
  33.  
  34. wait_for_termination (pid)
  35.      int pid;
  36. {
  37.   while (1)
  38.     {
  39.       sigsetmask (sigmask (SIGCHLD));
  40.       if (0 > kill (pid, 0))
  41.         {
  42.       sigsetmask (SIGEMPTYMASK);
  43.       break;
  44.     }
  45.       sigpause (SIGEMPTYMASK);
  46.     }
  47. }
  48.  
  49. char *amiga_path(void)
  50. {
  51.   char *path, *pp, name[128];
  52.   int pathsize;
  53.   struct CommandLineInterface *cli;
  54.   BPTR lock;
  55.   long l, *lp, nlen;
  56.  
  57.   pathsize = 128;
  58.   path = (char *)xmalloc(pathsize);
  59.  
  60.   strcpy(path, ".");
  61.   pp = path + 1;
  62.  
  63.   if (!(cli = (struct CommandLineInterface *)((long)_us->pr_CLI << 2)))
  64.     return path;
  65.  
  66.   l = (long)cli->cli_CommandDir;
  67.   while (l) {
  68.     *pp++ = ',';
  69.     l <<= 2;
  70.     lp = (long *)l;
  71.     lock = (BPTR)*(lp + 1);
  72.     NameFromLock(lock, name, 128);
  73.     nlen = strlen(name);
  74.     if (pp + nlen + 5 >= path + pathsize)
  75.       {
  76.     char *newpath;
  77.  
  78.     pathsize = 2 * pathsize + nlen;
  79.     newpath = (char *)xrealloc(path);
  80.     pp = newpath + (pp - path);
  81.     path = newpath;
  82.       }
  83.     memcpy(pp, name, nlen);
  84.     pp += nlen;
  85.     l = *lp;
  86.   }
  87.   /* Use of +5 above guarantees that there is enough space for c: */
  88.   strcpy(pp, ",c:");
  89.  
  90.   return path;
  91. }
  92.  
  93. void syms_of_amiga_processes(void)
  94. {
  95.   amiga_process_stack_size = 0;
  96.   DEFVAR_INT("amiga-process-stack-size", &amiga_process_stack_size,
  97.      "Size of stack for called processes. 0 means same size as emacs stack.");
  98. }
  99.