home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 13 / MA_Cover_13.bin / source / c / stefanb_src / dospath / src / wbpath.c < prev   
Encoding:
C/C++ Source or Header  |  1996-08-25  |  1.7 KB  |  53 lines

  1. /*
  2.  * wbpath.c  V1.0
  3.  *
  4.  * Copy path from Workbench process
  5.  *
  6.  * (c) 1996 Stefan Becker
  7.  */
  8.  
  9. #include "dospath.h"
  10.  
  11. __geta4 struct PathListEntry *CopyWorkbenchPathList(
  12.                               __A0 struct WBStartup *wbs,
  13.                               __A1 struct PathListEntry **anchor,
  14.                               __A6 struct DOSPathBase *dpb)
  15. {
  16.  struct Process       *wbproc;
  17.  struct PathListEntry *rc     = NULL;
  18.  
  19.  DEBUGLOG(kprintf("CopyWB: WBS 0x%08lx List 0x%08lx Base 0x%08lx\n",
  20.                   wbs, anchor, dpb);)
  21.  
  22.  /* Get a pointer to the Workbench task */
  23.  if ((wbproc = (struct Process *)(
  24.  
  25.  /* Has a Workbench startup message been supplied? */
  26.        wbs ?
  27.  
  28.  /* Yes, get the Workbench task from the reply port of the message   */
  29.  /*                                                                  */
  30.  /* NOTE: This is the correct method to get access to the Workbench  */
  31.  /*       process' command path when started from the Workbench. The */
  32.  /*       WB has to wait until your program finishes and replies the */
  33.  /*       WBStartup message. Thus all pointers stay valid while we   */
  34.  /*       copy the path list.                                        */
  35.  
  36.         wbs->sm_Message.mn_ReplyPort->mp_SigTask :
  37.  
  38.  /* No, search for a task called "Workbench" in the system.   */
  39.  /* This is a little bit insecure, because we can't Forbid()! */
  40.         FindTask("Workbench")))) {
  41.  
  42.   DEBUGLOG(kprintf("CopyWB: WBProc 0x%08lx\n", wbproc);)
  43.  
  44.   /* Get the path from the process and copy it */
  45.   rc = CopyPathList(GetProcessPathList(wbproc), anchor, dpb);
  46.  }
  47.  
  48.  DEBUGLOG(kprintf("CopyWB: Result 0x%08lx\n", rc);)
  49.  
  50.  /* Return pointer to head of copied path list */
  51.  return(rc);
  52. }
  53.