home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / emacs-18.59-src.tgz / emacs-18.59-src.tar / fsf / emacs18 / src / amiga_processes.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  2KB  |  95 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. extern struct ExecBase *SysBase;
  24.  
  25. int amiga_process_stack_size;
  26.  
  27. /* A few emacs support functions */
  28. /* ----------------------------- */
  29.  
  30. wait_for_termination (pid)
  31.      int pid;
  32. {
  33.   while (1)
  34.     {
  35.       sigsetmask (sigmask (SIGCHLD));
  36.       if (0 > kill (pid, 0))
  37.         {
  38.       sigsetmask (SIGEMPTYMASK);
  39.       break;
  40.     }
  41.       sigpause (SIGEMPTYMASK);
  42.     }
  43. }
  44.  
  45. char *amiga_path(void)
  46. {
  47.   char *path, *pp, name[128];
  48.   int pathsize;
  49.   struct CommandLineInterface *cli;
  50.   BPTR lock;
  51.   long l, *lp, nlen;
  52.  
  53.   pathsize = 128;
  54.   path = (char *)xmalloc(pathsize);
  55.  
  56.   strcpy(path, ".");
  57.   pp = path + 1;
  58.  
  59.   if (!(cli = (struct CommandLineInterface *)((long)_us->pr_CLI << 2)))
  60.     return path;
  61.  
  62.   l = (long)cli->cli_CommandDir;
  63.   while (l) {
  64.     *pp++ = ',';
  65.     l <<= 2;
  66.     lp = (long *)l;
  67.     lock = (BPTR)*(lp + 1);
  68.     NameFromLock(lock, name, 128);
  69.     nlen = strlen(name);
  70.     if (pp + nlen + 5 >= path + pathsize)
  71.       {
  72.     char *newpath;
  73.  
  74.     pathsize = 2 * pathsize + nlen;
  75.     newpath = (char *)xrealloc(path);
  76.     pp = newpath + (pp - path);
  77.     path = newpath;
  78.       }
  79.     memcpy(pp, name, nlen);
  80.     pp += nlen;
  81.     l = *lp;
  82.   }
  83.   /* Use of +5 above guarantees that there is enough space for c: */
  84.   strcpy(pp, ",c:");
  85.  
  86.   return path;
  87. }
  88.  
  89. void syms_of_amiga_processes(void)
  90. {
  91.   amiga_process_stack_size = 0;
  92.   DEFVAR_INT("amiga-process-stack-size", &amiga_process_stack_size,
  93.      "Size of stack for called processes. 0 means same size as emacs stack.");
  94. }
  95.