home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Beijing Paradise BBS Backup
/
PARADISE.ISO
/
software
/
BBSDOORW
/
MUL100.ZIP
/
CALLERS.SCR
< prev
next >
Wrap
Text File
|
1993-02-01
|
8KB
|
186 lines
// CALLERS.SCR -- Maximus Today's Callers Report Generator -- Version 1.00
//
// Script program for MUL - the Maximus User Language
// MUL is (C) Copyright 1990-93 by CodeLand Australia
// CALLERS scans the Maximus USER.BBS file, and writes an 'avatar' *.BBS
// file for online display. It lists all accounts accessed for the current
// date, in time sorted order. There are no command line parameters, edit
// the following entries to suit your system.
char *rfile = "C:\\BBS\\MISC\\CALLERS.BBS"; // Path & name of report file
//char *ufile = "USER.BBS"; // Path & name of Maximus user file
char *ufile = "C:\\BBS\\USER.BBS"; // Path & name of Maximus user file
// AVAILABLE COLOUR CONSTANTS
// Foreground & Background:
// BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LGREY
// Foreground ONLY:
// DGREY, LBLUE, LGREEN, LCYAN, LRED, LMAGENTA, YELLOW, WHITE
char COLOURHEAD = WHITE; // Report headline colour
char COLOURHUND = LRED; // Report underline colour
char COLOURBOXB = CYAN; // Report box colour
char COLOURLABL = LCYAN; // Report box label colour
char COLOURLABB = BLUE; // Report box label bg colour
char COLOUROPT1 = YELLOW; // Highlight colour one
char COLOUROPT2 = LGREEN; // Highlight colour two
char COLOURDATA = LGREY; // Report data colour
char *banner = "CALLERS v1.00"; // Script banner
char *desc = "Today's Callers Reporter"; // Description
char MCLS=0x0C; // Avatar 'clear screen'
char MENTER=0x01; // Maximus 'press enter'
long fp; // Report file handle
main () // Main program
{
printf ("\n%s - %s\n\n",banner,desc); // Announce
if (!BaseOpenR (ufile)) {
printf ("ERROR opening user file %s\n",ufile);
saybibi (); exit ();
}
sortufile (); // Sort in date order
writereport (); // Write output report
BaseClose (); // Close the user base
saybibi (); // Was it good for you too?
}
sortufile () // Sort in date order
{
printf ("Collecting today's callers ");
BaseSort (IDX_DATE); // Sort the base by last call date
printf ("\n");
}
readerror () // Report a user base read problem
{
printf ("\nERROR reading user file\n");
fclose (fp); return;
}
writereport () // Write the .BBS report file
{
int i, rec=1, calls=0;
long ttime=0;
char colourhead[5], colourhund[5], colourboxb[5], colourdata[5];
char colouropt1[5], colouropt2[5], colourlabl[5];
char *head=" - TODAY'S CALLERS REPORT - ";
char *line=" ─────────────────────────────────────────────\n";
char *b1 = "┌───────────────────────────┬───────────";
char *b2 = "───────────────┬───────┬───────┬──────┐\n";
char *c1 = "├───────────────────────────┼───────────";
char *c2 = "───────────────┼───────┼───────┼──────┤\n";
char *d1 = "└───────────────────────────┴───────────";
char *d2 = "───────────────┴───────┴───────┴──────┘\n";
fp=fopen (rfile,"wb"); // Open report file
if (fp==NULL) return;
printf ("Writing report file \"%s\" ",rfile);
// The Avt() function returns a pointer to a static character array
// containing the requested avatar characters. The following strcpy's
// save the requested strings for later use. This IS specifically
// required to allow more than one colour sequence as an (f)printf
// parameter. The unseen trap that this avoids, is that all function
// call parameter data is interpreted at _function call_ time. The
// result of multiple avt() references in a (f)printf parameter list
// is that the data from the _last_ avt() call would be used for all
// references <grumble>.
// Get avatar colour strings
strcpy (colourhead,Avt (COLOURHEAD)); strcpy (colourhund,Avt (COLOURHUND));
strcpy (colourboxb,Avt (COLOURBOXB)); strcpy (colourdata,Avt (COLOURDATA));
strcpy (colouropt1,Avt (COLOUROPT1)); strcpy (colouropt2,Avt (COLOUROPT2));
strcpy (colourlabl,Avt (COLOURLABL,COLOURLABB));
// Output CLS, MoreOff, heading and underline
fputc (MCLS,fp);
fprintf (fp,"%s MUL v%s%s%s\n",
colourhead,VERSN,head,DateToStr (SysDate ()));
fprintf (fp,"%s%s",colourhund,line);
fprintf (fp,"%s%s%s",colourboxb,b1,b2); // Output box top
// Output box heading
fprintf (fp,"│%s CALLER %s",colourlabl,colourboxb);
fprintf (fp,"│%s LOCATION %s",colourlabl,colourboxb);
fprintf (fp,"│%s CALLS %s",colourlabl,colourboxb);
fprintf (fp,"│%s LOGON %s",colourlabl,colourboxb);
fprintf (fp,"│%s USED %s│\n",colourlabl,colourboxb);
fprintf(fp,"%s%s",c1,c2); // Output box divider
// Output first data line
while (TRUE) {
if (!BaseRead (rec++)) { readerror(); return; } // Find record
if (!BaseDaysLCall () && USRpriv!=SYSOP) {
fprintf (fp,"│ %s",colouropt2);
fprintf (fp,"%-25s %s│ %s",USRname,colourboxb,colouropt2);
fprintf (fp,"%-24s %s│ %s",USRcity,colourboxb,colouropt2);
fprintf (fp,"%5u %s│ %s",USRcalls,colourboxb,colouropt2);
fprintf (fp,"%5s %s│ %s",
TimeToStr (USRlutime),colourboxb,colouropt2);
fprintf (fp,"%4u %s│\n",USRtimetoday,colourboxb);
ttime=ttime+USRtimetoday;
++calls;
break;
}
if (rec > BaseCount()) break;
}
// Output the remaining data
while (TRUE) {
if (rec > BaseCount()) break;
if (!BaseRead (rec++)) { readerror(); return; } // Find record
if (BaseDaysLCall ()) break;
if (USRpriv!=SYSOP) {
fprintf (fp,"│ %s",colourdata);
fprintf (fp,"%-25s %s│ %s",USRname,colourboxb,colourdata);
fprintf (fp,"%-24s %s│ %s",USRcity,colourboxb,colourdata);
fprintf (fp,"%5u %s│ %s",USRcalls,colourboxb,colourdata);
fprintf (fp,"%5s %s│ %s",
TimeToStr (USRlutime),colourboxb,colourdata);
fprintf (fp,"%4u %s│\n",USRtimetoday,colourboxb);
ttime=ttime+USRtimetoday;
++calls;
}
}
fprintf(fp,"%s%s",c1,c2); // Output box divider
// Totals
fprintf (fp,"│ %s",colourhead);
fprintf (fp,"Totals %s%5u calls %s│",colouropt1,calls,colourboxb);
fprintf (fp," │ │ │");
fprintf (fp,"%s%5lu %s│\n",colouropt1,ttime,colourboxb);
// Output lower box border
fprintf (fp,"%s%s%s",colourboxb,d1,d2);
// Press Enter prompt and CLS
fprintf (fp,"%s%c",Avt (WHITE,BLACK),MENTER);
fprintf (fp,"%s%c",Avt (LGREY,BLACK),MCLS);
fclose (fp); // Close report file
putch ('\n'); // End notify
}
// Byebye
saybibi ()
{
puts ("\nCallers done!\n");
}
// End of script