home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / DWNSRS56.ZIP / DOWNSORT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-10  |  4.9 KB  |  126 lines

  1. /* ============================================================= */
  2. /*  Rob Hamerling's MAXIMUS download file scan and sort utility  */
  3. /*  -> DOWNSORT.C                                                */
  4. /*  -> Mainline                                                  */
  5. /*                                                               */
  6. /*  When compiled with IBM C Set/2 compiler, a 32-bit OS/2       */
  7. /*  version will be generated (via compiler variable __32BIT__)  */
  8. /*  When compiled by MicroSoft C compiler 6.00a a 16-bit program */
  9. /*  will be generated.                                           */
  10. /* ============================================================= */
  11.  
  12. #define INCL_BASE
  13. #include <os2.h>
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include <time.h>
  19.  
  20. #include "..\max\mstruct.h"
  21. #include "downsort.h"
  22. #include "downfpro.h"
  23.  
  24. /* prototypes of local functions */
  25.  
  26. unsigned int collect_area(struct _downpath huge **);
  27. unsigned int collect_file(unsigned int, struct _downpath huge *);
  28. void     get_parm(int, char *[]);
  29. struct _filechain **prep_sort(unsigned int, struct _filechain *);
  30. void  make_bbs(struct _filechain **, struct _downpath huge *, unsigned int);
  31. void  make_all(struct _filechain **, struct _downpath huge *, unsigned int);
  32. void  make_dup(struct _filechain **, unsigned int);
  33. void  make_fil(struct _filechain **, struct _downpath huge *, unsigned int);
  34. void  make_gbl(struct _filechain **, struct _downpath huge *, unsigned int);
  35. void  make_ipf(struct _filechain **, struct _downpath huge *, unsigned int);
  36. void  make_ip2(struct _filechain **, struct _downpath huge *, unsigned int);
  37. void  make_new(struct _filechain **, struct _downpath huge *, unsigned int);
  38. void  make_ok( struct _filechain **, struct _downpath huge *, unsigned int);
  39. void  make_orp(struct _filechain **, struct _downpath huge *, unsigned int);
  40. void  make_emi(struct _filechain **, struct _downpath huge *, unsigned int);
  41.  
  42. /* ====================== */
  43. /*   M A I N    L I N E   */
  44. /* ====================== */
  45. void  main(int argc, char *argv[])
  46. {
  47.   struct  _downpath huge *area;             // pointer to area-info arrays
  48.   struct  _filechain **dm;              // pointer to file-sort array
  49.   unsigned int i;                       // counters
  50.   long     start_time,run_time;         // for execution time measurement
  51. #define MAX_FILES 16350
  52.  
  53.   start_time = time(NULL);              // system time at start
  54.   sprintf(list_title,"%s%c%c%c",PROGNAME,VERSION,SUBVERS,SUFFIX);
  55.                                         // build default title
  56.   get_parm(argc, argv);                 // system and oper. parameters
  57.                                         // and display welcome msg
  58.   area_total_count = collect_area(&area);   // build area array
  59.   if (area_total_count <= 0) {          // no area's included
  60.     printf(MSG_ZF, "-area");
  61.     printf(MSG_ZP, PROGNAME);
  62.     DosExit(8, 0);
  63.     }
  64.  
  65.   if (oper_mode == VERBOSE)
  66.     printf("\nCollecting information from %u file-area's",
  67.               area_total_count);
  68.   file_total_count = collect_file(area_total_count, area);
  69.   if (file_total_count == 0) {          // no files
  70.     printf(MSG_ZF,"");
  71.     printf(MSG_ZP,PROGNAME);
  72.     DosExit(10,0);
  73.     }
  74.   if (file_total_count > MAX_FILES) {   // array must fit in segment!
  75.     printf(MSG_ZY, MAX_FILES, PROGNAME);
  76.     DosExit(10,0);
  77.     }
  78.  
  79.   dm = prep_sort(file_total_count, first_element); // make sort array
  80.  
  81.   if (lp[P_ORP].priv[0] <= HIDDEN)      // ORPHAN-report
  82.     make_orp(dm, area, 0);
  83.  
  84.   if (lp[P_DUP].priv[0] <= HIDDEN)      // DUP-report
  85.     make_dup(dm, 0);
  86.  
  87.   for (i=0; i<10 && lp[P_OK].priv[i] <= HIDDEN; i++) // OKFile(s)
  88.     make_ok(dm, area, i);
  89.  
  90.   if (lp[P_BBS].priv[0] <= HIDDEN)      // BBS-list
  91.     make_bbs(dm, area, 0);
  92.  
  93.   for (i=0; i<10 && lp[P_NEW].priv[i] <= HIDDEN; i++) // NEW-list(s)
  94.     make_new(dm, area, i);
  95.  
  96.   for (i=0; i<10 && lp[P_EMI].priv[i] <= HIDDEN; i++) // EMI-list(s)
  97.     make_emi(dm, area, i);
  98.  
  99.   for (i=0; i<10 && lp[P_GBL].priv[i] <= HIDDEN; i++) // GBL-list(s)
  100.     make_gbl(dm, area, i);
  101.  
  102.   for (i=0; i<10 && lp[P_ALL].priv[i] <= HIDDEN; i++) // ALL-list(s)
  103.     make_all(dm, area, i);
  104.  
  105.   for (i=0; i<10 && lp[P_IPF].priv[i] <= HIDDEN; i++) // IPF-list(s)
  106.     make_ipf(dm, area, i);
  107.  
  108.   for (i=0; i<10 && lp[P_IP2].priv[i] <= HIDDEN; i++) // IPF2-list(s)
  109.     make_ip2(dm, area, i);
  110.  
  111.   if (lp[P_FIL].priv[0] <= HIDDEN)      // FILES.BBS
  112.     make_fil(dm, area, 0);
  113.  
  114.   if (oper_mode != QUIET) {
  115.     printf("\n%s version %c.%c%c by %s ",
  116.              PROGNAME,VERSION,SUBVERS,SUFFIX,AUTHOR);
  117.     run_time = time(NULL) - start_time;   // execution time in seconds
  118.     printf("completed in %ld minutes and %ld seconds.\n\n",
  119.           run_time/60,run_time%60);     // report execution time
  120.     }
  121.   else
  122.     printf("\n");
  123.  
  124.   DosExit(0,0);                         // Automatic release all storage!
  125.   }
  126.