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