home *** CD-ROM | disk | FTP | other *** search
- /* ============================================================= */
- /* Rob Hamerling's MAXIMUS download file scan and sort utility */
- /* -> DOWNSORT.C */
- /* -> Mainline */
- /* */
- /* When compiled with IBM C Set/2 compiler, a 32-bit OS/2 */
- /* version will be generated (via compiler variable __32BIT__) */
- /* When compiled by MicroSoft C compiler 6.00a a 16-bit program */
- /* will be generated. */
- /* ============================================================= */
-
- #define INCL_BASE
- #include <os2.h>
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
-
- #include "..\max\mstruct.h"
- #include "downsort.h"
- #include "downfpro.h"
-
- /* prototypes of local functions */
-
- unsigned int collect_area(struct _downpath huge **);
- unsigned int collect_file(unsigned int, struct _downpath huge *);
- void get_parm(int, char *[]);
- struct _filechain **prep_sort(unsigned int, struct _filechain *);
- void make_bbs(struct _filechain **, struct _downpath huge *, unsigned int);
- void make_all(struct _filechain **, struct _downpath huge *, unsigned int);
- void make_dup(struct _filechain **, unsigned int);
- void make_fil(struct _filechain **, struct _downpath huge *, unsigned int);
- void make_gbl(struct _filechain **, struct _downpath huge *, unsigned int);
- void make_ipf(struct _filechain **, struct _downpath huge *, unsigned int);
- void make_ip2(struct _filechain **, struct _downpath huge *, unsigned int);
- void make_new(struct _filechain **, struct _downpath huge *, unsigned int);
- void make_ok( struct _filechain **, struct _downpath huge *, unsigned int);
- void make_orp(struct _filechain **, struct _downpath huge *, unsigned int);
- void make_emi(struct _filechain **, struct _downpath huge *, unsigned int);
-
- /* ====================== */
- /* M A I N L I N E */
- /* ====================== */
- void main(int argc, char *argv[])
- {
- struct _downpath huge *area; // pointer to area-info arrays
- struct _filechain **dm; // pointer to file-sort array
- unsigned int i; // counters
- long start_time,run_time; // for execution time measurement
- #define MAX_FILES 16350
-
- start_time = time(NULL); // system time at start
- sprintf(list_title,"%s%c%c%c",PROGNAME,VERSION,SUBVERS,SUFFIX);
- // build default title
- get_parm(argc, argv); // system and oper. parameters
- // and display welcome msg
- area_total_count = collect_area(&area); // build area array
- if (area_total_count <= 0) { // no area's included
- printf(MSG_ZF, "-area");
- printf(MSG_ZP, PROGNAME);
- DosExit(8, 0);
- }
-
- if (oper_mode == VERBOSE)
- printf("\nCollecting information from %u file-area's",
- area_total_count);
- file_total_count = collect_file(area_total_count, area);
- if (file_total_count == 0) { // no files
- printf(MSG_ZF,"");
- printf(MSG_ZP,PROGNAME);
- DosExit(10,0);
- }
- if (file_total_count > MAX_FILES) { // array must fit in segment!
- printf(MSG_ZY, MAX_FILES, PROGNAME);
- DosExit(10,0);
- }
-
- dm = prep_sort(file_total_count, first_element); // make sort array
-
- if (lp[P_ORP].priv[0] <= HIDDEN) // ORPHAN-report
- make_orp(dm, area, 0);
-
- if (lp[P_DUP].priv[0] <= HIDDEN) // DUP-report
- make_dup(dm, 0);
-
- for (i=0; i<10 && lp[P_OK].priv[i] <= HIDDEN; i++) // OKFile(s)
- make_ok(dm, area, i);
-
- if (lp[P_BBS].priv[0] <= HIDDEN) // BBS-list
- make_bbs(dm, area, 0);
-
- for (i=0; i<10 && lp[P_NEW].priv[i] <= HIDDEN; i++) // NEW-list(s)
- make_new(dm, area, i);
-
- for (i=0; i<10 && lp[P_EMI].priv[i] <= HIDDEN; i++) // EMI-list(s)
- make_emi(dm, area, i);
-
- for (i=0; i<10 && lp[P_GBL].priv[i] <= HIDDEN; i++) // GBL-list(s)
- make_gbl(dm, area, i);
-
- for (i=0; i<10 && lp[P_ALL].priv[i] <= HIDDEN; i++) // ALL-list(s)
- make_all(dm, area, i);
-
- for (i=0; i<10 && lp[P_IPF].priv[i] <= HIDDEN; i++) // IPF-list(s)
- make_ipf(dm, area, i);
-
- for (i=0; i<10 && lp[P_IP2].priv[i] <= HIDDEN; i++) // IPF2-list(s)
- make_ip2(dm, area, i);
-
- if (lp[P_FIL].priv[0] <= HIDDEN) // FILES.BBS
- make_fil(dm, area, 0);
-
- if (oper_mode != QUIET) {
- printf("\n%s version %c.%c%c by %s ",
- PROGNAME,VERSION,SUBVERS,SUFFIX,AUTHOR);
- run_time = time(NULL) - start_time; // execution time in seconds
- printf("completed in %ld minutes and %ld seconds.\n\n",
- run_time/60,run_time%60); // report execution time
- }
- else
- printf("\n");
-
- DosExit(0,0); // Automatic release all storage!
- }
-