home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / biblioteki / c_library / extrdargs / test.c < prev    next >
C/C++ Source or Header  |  1977-12-31  |  2KB  |  124 lines

  1. /*
  2. ** $PROJECT: FinalReadArgs() test
  3. **
  4. ** $VER: test.c 0.1 (04.09.94)
  5. **
  6. ** by
  7. **
  8. ** Stefan Ruppert , Windthorststraße 5 , 65439 Flörsheim , GERMANY
  9. **
  10. ** (C) Copyright 1994
  11. ** All Rights Reserved !
  12. **
  13. ** $HISTORY:
  14. **
  15. ** 04.09.94 : 000.001 :  initial
  16. */
  17.  
  18. #include "extrdargs.h"
  19.  
  20. #include <intuition/intuition.h>
  21.  
  22. #include <clib/dos_protos.h>
  23. #include <clib/icon_protos.h>
  24. #include <clib/intuition_protos.h>
  25.  
  26. #include <proto/dos.h>
  27. #include <proto/icon.h>
  28. #include <proto/intuition.h>
  29.  
  30. #include <debug.h>
  31.  
  32. #define TEMPLATE     "FILES/M/A,VERBOSE/S"
  33.  
  34. enum {
  35.    ARG_FILES,
  36.    ARG_VERBOSE,
  37.    ARG_MAX};
  38.  
  39. STRPTR filetypes[] = {
  40.    "pipe",
  41.    "linkfile",
  42.    "file",
  43.    NULL,
  44.    NULL,
  45.    NULL,
  46.    "root",
  47.    "dir",
  48.    "softlink",
  49.    "linkdir",
  50.    NULL};
  51.  
  52. LONG main(LONG ac,STRPTR *av)
  53. {
  54.    struct ExtRDArgs eargs = {NULL};
  55.    LONG para[ARG_MAX];
  56.    LONG error;
  57.    LONG i;
  58.  
  59.    for(i = 0 ; i < ARG_MAX ; i++)
  60.       para[i] = 0;
  61.  
  62.    eargs.erda_Template      = TEMPLATE;
  63.    eargs.erda_Parameter     = para;
  64.    eargs.erda_FileParameter = 0;
  65.    eargs.erda_Window        = "CON:////Test ExtReadArgs() from Workbench/WAIT/CLOSE";
  66.  
  67.    if((error = ExtReadArgs(ac,av,&eargs)) == 0)
  68.    {
  69.       struct FileInfoBlock *fib;
  70.  
  71.       D(bug("finalargs : %ld\n",eargs.erda_Flags & ERDAF_WORKBENCH));
  72.  
  73.       if((fib = AllocDosObject(DOS_FIB,NULL)))
  74.       {
  75.          STRPTR *files = (STRPTR *) para[ARG_FILES];
  76.          BPTR lock;
  77.  
  78.          while(*files)
  79.          {
  80.             if((lock = Lock(*files,SHARED_LOCK)))
  81.             {
  82.                if(Examine(lock,fib))
  83.                {
  84.                   Printf ("%-32s ",fib->fib_FileName);
  85.  
  86.                   if(para[ARG_VERBOSE])
  87.                      Printf ("%8ld (%s)",fib->fib_Size,filetypes[fib->fib_DirEntryType + 5]);
  88.  
  89.                   PutStr("\n");
  90.                }
  91.                UnLock(lock);
  92.             }
  93.             files++;
  94.          }
  95.  
  96.          FreeDosObject(DOS_FIB,fib);
  97.       }
  98.    }
  99.    ExtFreeArgs(&eargs);
  100.  
  101.    if(!error)
  102.       error = IoErr();
  103.  
  104.    if(error)
  105.       if(eargs.erda_Flags & ERDAF_WORKBENCH)
  106.       {
  107.          UBYTE buffer[100];
  108.          struct EasyStruct es = {
  109.             sizeof(struct EasyStruct),
  110.             0,
  111.             "Test",
  112.             "%s",
  113.             "End"};
  114.  
  115.          Fault(error,"Test",buffer,sizeof(buffer));
  116.  
  117.          EasyRequest(NULL,&es,NULL,buffer);
  118.       } else
  119.          PrintFault(error,"Test");
  120.  
  121.    return((error == 0) ? RETURN_OK : RETURN_FAIL);
  122. }
  123.  
  124.