home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / dwnsrs59.zip / DOWNSORT.C < prev    next >
C/C++ Source or Header  |  1993-12-19  |  6KB  |  168 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. USHORT   collect_area(DOWNPATH _HUGE **);
  30. ULONG    collect_file(unsigned int, DOWNPATH _HUGE *);
  31. void     get_parm(int, char *[]);
  32. FILECHAIN * _HUGE *prep_sort(ULONG, FILECHAIN *);
  33. void  make_bbs(FILECHAIN * _HUGE *, DOWNPATH _HUGE *, LISTPARM *);
  34. void  make_all(FILECHAIN * _HUGE *, DOWNPATH _HUGE *, LISTPARM *);
  35. void  make_dup(FILECHAIN * _HUGE *,                   LISTPARM *);
  36. void  make_fil(FILECHAIN * _HUGE *, DOWNPATH _HUGE *, LISTPARM *);
  37. void  make_gbl(FILECHAIN * _HUGE *, DOWNPATH _HUGE *, LISTPARM *);
  38. void  make_ipf(FILECHAIN * _HUGE *, DOWNPATH _HUGE *, LISTPARM *);
  39. void  make_ip2(FILECHAIN * _HUGE *, DOWNPATH _HUGE *, LISTPARM *);
  40. void  make_new(FILECHAIN * _HUGE *, DOWNPATH _HUGE *, LISTPARM *);
  41. void  make_ok( FILECHAIN * _HUGE *, DOWNPATH _HUGE *, LISTPARM *);
  42. void  make_orp(FILECHAIN * _HUGE *, DOWNPATH _HUGE *, LISTPARM *);
  43. void  make_emi(FILECHAIN * _HUGE *, DOWNPATH _HUGE *, LISTPARM *);
  44.  
  45. /* ====================== */
  46. /*   M A I N    L I N E   */
  47. /* ====================== */
  48. int  main(int argc, char *argv[])
  49. {
  50.   DOWNPATH  _HUGE *area;                /* pointer to area-info array */
  51.   FILECHAIN * _HUGE *dm;                /* pointer to file-sort array */
  52.   LISTPARM  *ls;                        /* pointer to list specs      */
  53.   long     start_time,run_time;         /* for execution time meas.   */
  54.  
  55.   start_time = time(NULL);              /* system time at start       */
  56.   sprintf(list_title,"%s%c%c%c",PROGNAME,VERSION,SUBVERS,SUFFIX);
  57.                                         /* build default title        */
  58.   get_parm(argc, argv);                 /* system and oper. parameters*/
  59.                                         /* and display welcome msg    */
  60.   area_total_count = collect_area(&area);   /* build area array       */
  61.   if (area_total_count <= 0) {          /* no area's included         */
  62.     printf(MSG_ZF, "-area");
  63.     printf(MSG_ZP, PROGNAME);
  64.     DosExit(0, 8);
  65.     }
  66.  
  67.   if (oper_mode == VERBOSE)
  68.     fprintf(stdout, "Collecting information from %u file-area's\n",
  69.               area_total_count);
  70.   file_total_count = collect_file(area_total_count, area);
  71.   if (file_total_count == 0) {          /* no files                   */
  72.     fprintf(stdout, MSG_ZF, "");
  73.     fprintf(stdout, MSG_ZP, PROGNAME);
  74.     DosExit(0, 10);
  75.     }
  76.  
  77.   dm = prep_sort(file_total_count, first_element); /* make sort array */
  78.  
  79.   ls = lp[P_ORP].next;
  80.   while (ls != NULL) {                                 /* ORPHAN-list */
  81.     if (ls->priv <= HIDDEN)
  82.       make_orp(dm, area, ls);
  83.     ls = ls->next;
  84.     }
  85.  
  86.   ls = lp[P_DUP].next;
  87.   while (ls != NULL) {                                 /* DUP-list    */
  88.     if (ls->priv <= HIDDEN)
  89.       make_dup(dm, ls);
  90.     ls = ls->next;
  91.     }
  92.  
  93.   ls = lp[P_OK].next;
  94.   while (ls != NULL) {                                 /* OKFile      */
  95.     if (ls->priv <= HIDDEN)
  96.       make_ok(dm, area, ls);
  97.     ls = ls->next;
  98.     }
  99.  
  100.   ls = lp[P_BBS].next;
  101.   while (ls != NULL) {                                 /* BBS-list    */
  102.     if (ls->priv <= HIDDEN)
  103.       make_bbs(dm, area, ls);
  104.     ls = ls->next;
  105.     }
  106.  
  107.   ls = lp[P_NEW].next;
  108.   while (ls != NULL) {                                 /* NEW-list    */
  109.     if (ls->priv <= HIDDEN)
  110.       make_new(dm, area, ls);
  111.     ls = ls->next;
  112.     }
  113.  
  114.   ls = lp[P_EMI].next;
  115.   while (ls != NULL) {                                 /* EMI-list    */
  116.     if (ls->priv <= HIDDEN)
  117.       make_emi(dm, area, ls);
  118.     ls = ls->next;
  119.     }
  120.  
  121.   ls = lp[P_GBL].next;
  122.   while (ls != NULL) {                                 /* GBL-list    */
  123.     if (ls->priv <= HIDDEN)
  124.       make_gbl(dm, area, ls);
  125.     ls = ls->next;
  126.     }
  127.  
  128.   ls = lp[P_ALL].next;
  129.   while (ls != NULL) {                                 /* ALL-list    */
  130.     if (ls->priv <= HIDDEN)
  131.       make_all(dm, area, ls);
  132.     ls = ls->next;
  133.     }
  134.  
  135.   ls = lp[P_IPF].next;
  136.   while (ls != NULL) {                                 /* IPF-list    */
  137.     if (ls->priv <= HIDDEN)
  138.       make_ipf(dm, area, ls);
  139.     ls = ls->next;
  140.     }
  141.  
  142.   ls = lp[P_IP2].next;
  143.   while (ls != NULL) {                                 /* IPF2-list   */
  144.     if (ls->priv <= HIDDEN)
  145.       make_ip2(dm, area, ls);
  146.     ls = ls->next;
  147.     }
  148.  
  149.   ls = lp[P_FIL].next;                                 /* LAST!!!!!   */
  150.   while (ls != NULL) {                                 /* FILES.BBS   */
  151.     if (ls->priv <= HIDDEN)
  152.       make_fil(dm, area, ls);
  153.     ls = ls->next;
  154.     }
  155.  
  156.   if (oper_mode != QUIET) {
  157.     printf("\n%s version %c.%c%c by %s ",
  158.              PROGNAME,VERSION,SUBVERS,SUFFIX,AUTHOR);
  159.     run_time = time(NULL) - start_time;   /* execution time in seconds */
  160.     printf("completed in %ld minutes and %ld seconds.\n\n",
  161.           run_time/60,run_time%60);     /* report execution time */
  162.     }
  163.   else
  164.     printf("\n");
  165.  
  166.   return(0);                            /* Automatic release all storage! */
  167.   }
  168.