home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 553.lha / listcom_v1.0 / listcom.c < prev    next >
C/C++ Source or Header  |  1991-09-09  |  2KB  |  95 lines

  1. ;/* ListCom.c
  2. lc -tr ListCom.c
  3. blink with ListCom.lnk
  4. quit
  5. */
  6. /*************************************************************************/
  7. /* List Comment    Version 0.2a   Release 8.11  Created: August 11, 1991 */
  8. /* ©1991  John Bianchi            Bianchi Computer Systems               */
  9. /*************************************************************************/
  10.  
  11. #include <proto/all.h>
  12. #include <libraries/dos.h>
  13. #include <string.h>
  14.  
  15. UBYTE *prog = "ListCom";
  16. UBYTE *ver  = "1.0";
  17. UBYTE *vers = "\0$VER: ListComment 1.0 (10.8.91)";
  18. UBYTE *CopyRight = "©1991 John Bianchi   All Rights Reserved";
  19.  
  20. struct DosLibrary *DOSBase = NULL;
  21. struct FileInfoBlock fi;
  22.  
  23. main (argc, argv)
  24. int argc;
  25. char *argv[];
  26.  
  27. {
  28.    long lock;
  29.    int error;
  30.    char filepath[100],filecomment[80];
  31.    int found=FALSE;
  32.    unsigned int l;
  33.    
  34.    printf("%s  %s    %s\n",prog,ver,CopyRight);
  35.  
  36.    if(argc >=4)
  37.      printf("Error: too many arguments\n");
  38.  
  39.    if(argc <= 1 || argc >= 4 || strcmp(argv[1],"?") == 0)
  40.     {
  41.      printf("TEMPLATE: %s <path> <comment>\n",prog);
  42.      exit(FALSE);
  43.     }
  44.  
  45.    strcpy(filepath, argv[1]);
  46.    strcpy(filecomment, argv[2]);
  47.  
  48.    lock = Lock(filepath, ACCESS_READ);
  49.  
  50.    if(!lock)
  51.       {
  52.          printf("ERROR: Can't get a Lock on: %s\n",filepath);
  53.          exit(FALSE);
  54.       }
  55.  
  56.    l=strlen(filecomment);
  57.  
  58.    if(Examine(lock, &fi))
  59.       do
  60.         if(*fi.fib_Comment)
  61.         {
  62.             if(strnicmp(fi.fib_Comment,filecomment,l) == 0)
  63.             {
  64.               if(found == FALSE)
  65.               {
  66.                 printf("\n%-30s %9s : %s\n","NAME","SIZE/DIR","COMMENT");
  67.       found=TRUE;
  68.               } 
  69.               printf("%-30s ",fi.fib_FileName);
  70.  
  71.               if(fi.fib_DirEntryType > 0)
  72.                 printf("directory");
  73.               else
  74.                 printf("%9ld",fi.fib_Size);
  75.  
  76.               printf(" : %s\n",fi.fib_Comment);
  77.             }
  78.          }
  79.       while(ExNext(lock, &fi));
  80.  
  81.    error = IoErr();
  82.  
  83.    if(error != ERROR_NO_MORE_ENTRIES)
  84.       {
  85.       printf("Error %d occurred!\n", error);
  86.       exit(FALSE);
  87.       }
  88.    if(found == FALSE)
  89.       printf("no files listed\n");
  90.  
  91.    exit(TRUE);
  92.  
  93. }
  94.  
  95.