home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / c / path.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  2.1 KB  |  102 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: path.c,v 1.6 1996/10/04 17:09:44 digulla Exp $
  4.     $Log: path.c,v $
  5.     Revision 1.6  1996/10/04 17:09:44  digulla
  6.     More readable way to access arguments
  7.  
  8.     Revision 1.5  1996/10/04 14:35:41  digulla
  9.     Make "path x: ADD" work as expected. "path x:" works now, too
  10.  
  11.     Revision 1.4  1996/09/17 16:43:01  digulla
  12.     Use general startup code
  13.  
  14.     Revision 1.3  1996/09/13 17:52:11  digulla
  15.     Use IPTR
  16.  
  17.     Revision 1.2  1996/08/01 17:40:45  digulla
  18.     Added standard header for all files
  19.  
  20.     Desc:
  21.     Lang:
  22. */
  23. #include <exec/memory.h>
  24. #include <clib/exec_protos.h>
  25. #include <dos/dosextens.h>
  26. #include <clib/dos_protos.h>
  27.  
  28. UBYTE Buffer[4096];
  29.  
  30. int main (int argc, char ** argv)
  31. {
  32.     struct RDArgs *rda;
  33.     IPTR args[6]={ 0, 0, 1, 0, 0, 0 };
  34. #define ARG_Path    ((STRPTR *)args[0])
  35. #define ARG_Add     ((BOOL)args[1])
  36. #define ARG_Show    ((BOOL)args[2])
  37. #define ARG_Reset    ((BOOL)args[3])
  38. #define ARG_Remove    ((BOOL)args[4])
  39. #define ARG_Quiet    ((BOOL)args[5])
  40.  
  41.     IPTR parg[1];
  42.  
  43.     rda=ReadArgs("PATH/M,ADD/S,SHOW/S,RESET/S,REMOVE/S,QUIET/S",args,NULL);
  44.     if(rda!=NULL)
  45.     {
  46.     STRPTR *names=ARG_Path;
  47.     BPTR *cur, *next;
  48.     struct CommandLineInterface *cli;
  49.     cli=Cli();
  50.     if (*names)
  51.     {
  52.         /* Search last entry */
  53.         cur=&cli->cli_CommandDir;
  54.         while (cur[0])
  55.         cur=(BPTR *)BADDR(cur[0]);
  56.  
  57.         while(*names!=NULL)
  58.         {
  59.         next=(BPTR *)AllocVec(2*sizeof(BPTR),MEMF_ANY);
  60.         next[1]=Lock(*names,SHARED_LOCK);
  61.         if(!next[1])
  62.         {
  63.             FreeVec(next);
  64.             break;
  65.         }
  66.         cur[0]=MKBADDR(next);
  67.         cur=next;
  68.         if(!ARG_Quiet)
  69.             VPrintf("%s added.\n",(ULONG *)names);
  70.         names++;
  71.         }
  72.         cur[0] = 0;
  73.     }
  74.     else
  75.     {
  76.         BPTR l;
  77.  
  78.         l = Lock ("", SHARED_LOCK);
  79.         if (l)
  80.         {
  81.         NameFromLock (l, Buffer, sizeof (Buffer));
  82.         parg[0] = (IPTR) Buffer;
  83.         VPrintf ("Current Directory: %s\n", parg);
  84.         UnLock (l);
  85.         }
  86.  
  87.         cur=(BPTR *)BADDR(cli->cli_CommandDir);
  88.         while(cur)
  89.         {
  90.         NameFromLock (cur[1], Buffer, sizeof (Buffer));
  91.         parg[0] = (IPTR) Buffer;
  92.         VPrintf ("%s\n", parg);
  93.         cur=(BPTR *)BADDR(cur[0]);
  94.         }
  95.         VPrintf ("C:\n", NULL);
  96.     }
  97.  
  98.     FreeArgs(rda);
  99.     }
  100.     return 0;
  101. }
  102.