home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
com
/
bbs
/
downsrt
/
source
/
downsort.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-16
|
9KB
|
193 lines
/* ============================================================= */
/* Rob Hamerling's MAXIMUS download file scan and sort utility */
/* ============================================================= */
// #define DEBUG_MODE
#define INCL_BASE
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "downsort.h"
/* Global variables definitions all in mainline-module */
/* Submodules will get external declarations via downsort.h */
char PROGNAME[] = "DOWNSORT"; // program name (and filenames)
char VERSION = '5'; // current version
char SUBVERS = '1'; // current release
char SUFFIX = ' '; // development suffix
char PROGDESC[] = "DOWNload file SORT and list utility";
char AUTHOR[] = "Rob Hamerling"; // program author
char CITY[] = "Vianen, The Netherlands";
char PHONE[] = "Phone 31.3473.72136 (voice)";
char FIDO[] = "Fido-net 2:512/4.1098";
char MAX[] = "MAXIMUS CBCS";
char MSG_MEM[] = "\nInsufficient memory, %s terminated\n";
char MSG_SRT[] = "\nSorting %u files from %u directories for %s";
char MSG_RST[] = "\nRe-sorting first %u entries on filename";
char MSG_TRL[] = "\n Include-file - %s - not found!";
char MSG_REC[] = "\n file entries written to: %s";
char OPEN_FAIL[] = "\nCould not open file: %s\n";
char DESC_MISS[] = "\n Description file %s not found";
char HS[] = "────────────────────────────────────────";
char HD[] = "════════════════════════════════════════";
char FN[] = "Filename";
char AC[] = "Area";
char DT[] = "Date";
char SZ[] = "Size";
char DS[] = "Description";
char FP[] = "FilePath";
char EMPTY[] = ""; // empty string
char NDS[46] = "--- no description available ---";
char ORPHAN[46] = "************ ORPHAN ************";
char BAK[] = "BAK"; // backup file extension
char CFG[] = "CFG"; // config "
char *priv_name[] = {"Twit"," ","Disgrace","Limited","Normal",
"Worthy","Privil","Favored","Extra","Clerk",
"AsstSysop"," ","Sysop","Hidden"};
char today[26]; // output timestamp
char list_title[21] = ""; // ALL/IPF/NEW/GBL BLOCK title
char *pre_title[MAXTIT]= {NULL,NULL,NULL,NULL,NULL, // ptrs to pretitles
NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL};
char *sub_title[MAXTIT]= {NULL,NULL,NULL,NULL,NULL, // ptrs to subtitles
NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL};
char *bot_lines[MAXTIT]= {NULL,NULL,NULL,NULL,NULL, // ptrs to bottomlines
NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL};
USHORT title_lines[] = {0,3,5,4,5}; // # of lines per title-font
// See DOWNFNT.C for 'real' table.
char areadat_path[128] = "AREA.DAT"; // (default) AREA.DAT filespec
char cfg_path[128] = "DOWNSORT.CFG";// (default) config filespec
char filesbbs_path[128]= ""; // path to FILES.bbs output
char oper_mode = ' '; // V: verbose: talk a lot
// Q: only error messages
// H: display help-screen
USHORT area_count = 0; // number of download directories
USHORT file_count = 0; // counter for number of files
ULONG byte_count = 0; // counter for file sizes
int MAX_level = 0; // version of MAX from AREA.DAT
int ABS_MAX_priv = TWIT; // overall max report-privilege
struct _filechain *first_element = NULL; // ptr first chain element
struct _COUNTRYCODE c_code; // country code buffer
struct _COUNTRYINFO c_info; // country information buffer
struct _listparm lp[] = {
{ // BBS-list (P_BBS)
{HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,
HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1},
FONT2, 65535, TIMESTAMP, TRUNC, ' ',
"DOWNSORT", "BBS", NULL},
{ // FILES.BBS (P_FIL)
{HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,
HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1},
FONT2, 65535, ALPHA, TRUNC, ' ',
"FILES", "BBS", NULL},
{ // GBL-list (P_GBL)
{HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,
HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1},
FONT2, 65535, ALPHA, WRAP, ' ',
"DOWNSORT", "G~", NULL},
{ // NEW-list (P_NEW)
{HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,
HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1},
FONT2, 65535, TIMESTAMP, TRUNC, ' ',
"DOWNSORT", "N~", NULL},
{ // ALL-list (P_ALL)
{HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,
HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1},
FONT2, 65535, ALPHA, WRAP, ' ',
"DOWNSORT", "A~", NULL},
{ // IPF-list (P_IPF)
{HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,
HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1},
FONT2, 65535, ALPHA, WRAP, ' ',
"DOWNSORT", "I~", NULL},
{ // ORP-list (P_ORP)
{HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,
HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1,HIDDEN+1},
FONT2, 65535, ALPHA, TRUNC, ' ',
"DOWNSORT", "ORP", NULL},
};
/* ====================== */
/* M A I N L I N E */
/* ====================== */
int main(argc,argv)
int argc;
char *argv[];
{
struct _downpath *area; // pointer to area-info arrays
struct _filechain **dm; // pointer to file-sort array
USHORT i; // counter
long start_time,run_time; // for execution time measurement
start_time = time(NULL); // system time at start
sprintf(list_title,"%s%c%c%c",PROGNAME,VERSION,SUBVERS,SUFFIX);
// default title
get_parm(argc,argv); // system and oper. parameters
// and display welcome msg
if (oper_mode == VERBOSE)
printf("\nCollecting file-area information");
area_count = collect_down(&area); // build arrays with area-info
if (oper_mode == VERBOSE)
printf("\nCollecting download file information");
file_count = collect_file(area_count,area); // collect all file info
if (file_count == 0) { // no files
printf("\nNot a single file falls withing report criteria, or");
printf("\nno download paths found at all, %s terminated\n",PROGNAME);
exit(10);
}
dm = prep_sort(file_count,first_element); // make sort array
if (lp[P_ORP].priv[0] <= HIDDEN) // OPRHAN-report
make_orp(dm);
if (lp[P_BBS].priv[0] <= HIDDEN) // BBS-list
make_bbs(dm,lp[P_BBS].max_fil,lp[P_BBS].priv[0]);
for (i=0; i<10 && lp[P_NEW].priv[i] <= HIDDEN; i++) // NEW-list(s)
make_new(dm,lp[P_NEW].max_fil,lp[P_NEW].priv[i]);
for (i=0; i<10 && lp[P_GBL].priv[i] <= HIDDEN; i++) // GBL-list(s)
make_gbl(dm,lp[P_GBL].priv[i]);
for (i=0; i<10 && lp[P_ALL].priv[i] <= HIDDEN; i++) // ALL-list(s)
make_all(dm,area,lp[P_ALL].priv[i]);
for (i=0; i<10 && lp[P_IPF].priv[i] <= HIDDEN; i++) // IPF-list(s)
make_ipf(dm,area,lp[P_IPF].priv[i]);
if (lp[P_FIL].priv[0] <= HIDDEN) // FILES.BBS
make_fil(dm,lp[P_FIL].priv[0]);
printf("\n");
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
return(0); // OS will release all storage!
}