home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PSION / COMMS / PSIONMAI / PMFULLSO / SUNMAIL / COMPLIST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-05  |  1.1 KB  |  48 lines

  1. /* shuffle the list of files in a meta file (in argv[1]) down so they are all
  2.    numbered concurrentley sod all error handling in here though
  3.    print the number of files operated on on the standard output for future use */
  4. #include "project.h"
  5. #include <string.h>
  6. #include <stdio.h>
  7. extern struct ll * inlist ;
  8. main(argc, argv)
  9. int argc ;
  10. char * argv[] ;
  11. {
  12.     char fname[100] , tmp[1024] ;
  13.     int i, count ;
  14.     struct ll *llptr ;
  15.  
  16.     if (argc != 2)
  17.     {
  18.         fprintf(stderr, "Usage: complistfiles matafile\n") ;
  19.         exit(1) ;
  20.     }
  21.     llinit() ;
  22.     /* load in the meta file */
  23.     readmeta(argv[1], inlist) ;
  24.  
  25.     count = 0 ;
  26.     
  27.     /* shuffle the files down */
  28.     for (i = 1; i <= inlist->count ; i ++)
  29.     {
  30.         /* get the ll entry we are dealing with */
  31.         llptr = llnofind(i, inlist) ;
  32.         sprintf(fname, INSKELETON, count) ;
  33.         if (strcmp(fname, llptr->datafile) == 0)
  34.         {
  35.             count ++ ;
  36.             continue ;
  37.         }
  38.         sprintf(tmp, "mv %s %s", llptr->datafile, fname) ;
  39.         system(tmp) ;
  40.         count ++ ;
  41.     }
  42.     /* free the linked list */
  43.     llfree(inlist) ;
  44.     /* note the meta file will be rebuilt anyway so ignore it */
  45.     printf("%d", count) ;
  46. }
  47.  
  48.