home *** CD-ROM | disk | FTP | other *** search
-
- // EXPRPT.SCR -- Maximus-CBCS User Expiry Reporter -- Version 1.01
- //
- // Script program for MUL - the Maximus User Language
- // MUL is (C) Copyright 1990-93 by CodeLand Australia
- //
- // ExpRpt writes an account expiry text file report. This script is
- // based on the EXPRPT executable included in the UEDit v2.01 archive,
- // originally written for Brian Wendt of 3:640/205. This is a slightly
- // simplified version, to provide as clear an example of report writing
- // as possible. Specifically the ascii delimited output format option
- // is not supported in this script.
- //
- // USAGE: MUL -pExpRpt [ /# ]
- //
- // /P<#> Paginate report to # lines per page
- // /E Report expiry records only
-
- char *banner="EXPRPT v1.01"; // Script banner
- char *desc="Maximus User Expiry Reporter"; // Description
- char *ufile = "USER.BBS"; // User file path and name
- char *rptfile = "EXPRPT.RPT"; // Report file path and name
-
- int page=0; // Paginate lines per page
- long rp=NULL; // Report file file handle
- int expiry_only=0; // Report Expiry records only flag
-
- main (int argc, char *arg1, char *arg2) // Main program
- {
- int i, count=1, page_num=1;
- char *p, back[10], exp[40];
-
- printf ("\n%s - %s\n",banner,desc); // Announce
- getcmdline (argc,arg1,arg2); // Get the command line
-
- sprintf (back,"%c%c%c%c",8,8,8,8); // Notify setup
-
- // Open user file
- if (!BaseOpenR (ufile)) {
- printf ("\nERROR opening user file %s\n",ufile);
- saybibi (); exit ();
- }
-
- // Open report file
- if ((rp=fopen (rptfile,"w"))==NULL) {
- printf ("\nERROR opening report file %s\n",rptfile);
- BaseClose (); saybibi (); exit ();
- }
-
- printf ("\nWriting report file \"%s\"\n\n",rptfile);
-
- // Sort the records
- BaseSort (IDX_LNAME); // Sort by last name ascending
-
- printf ("Processing record 0001"); // Notify
- prt_hdr (page_num++); // Output page header
-
- for (i=2;i<=BaseCount ();++i) { // For all records except Sysop
- if(!BaseRead (i)) break; // Read record, abort on error
-
- if (!(i%10)) // Notify
- printf ("%s%04u",back,i);
-
- if (have_expiry ()) { // Only report expiry records
- fprintf (rp,"%-30s %s %s %s\n", // Output data
- USRname,
- DateToStr (USRludate),
- BasePrivStr (USRpriv),
- get_expiry (exp)
- );
-
- if(page && ++count>page) { // Check paging
- fprintf (rp,"%c",0x0C); // Page feed
- prt_hdr (page_num++); // Output page header
- count=1;
- }
- }
- }
-
- if (page) fprintf (rp,"%c",0x0C); // Final page feed
- printf ("%s%04u\n",back,i); // Notify cleanup
-
- fclose (rp); // Close report file
- BaseClose (); // Close the user base
-
- saybibi (); // Was it good for you too?
- }
-
- prt_hdr (int page_num) // Output a page header
- {
- fprintf (rp,"\n ACCOUNT EXPIRY REPORT %s\n",
- DateToStr (SysDate ()));
-
- fprintf (rp," ---------------------\n");
- if (page) fprintf (rp," Page %3u\n",page_num);
- else fprintf (rp,"\n");
- fprintf (rp,"--------------------------------------------------------------------------------\n");
- fprintf (rp,"Name LastCall Access Expy Value Action Demote\n");
- fprintf (rp,"------------------------------ -------- --------- ---- -------- ------ ---------\n");
- }
-
- have_expiry () // Return expiry status
- {
- return !expiry_only || (And (USRxpflag,XP_DATE) || And (USRxpflag,XP_TIME));
- }
-
- get_expiry (char *str) // Build Expiry information string
- {
- char buf[20];
-
- // Get the Expiry type string
- strcpy (str,BaseXpTypStr (USRxpflag));
-
- if (USRxpflag == XP_NONE) return str; // Allows a quick exit
-
- // Get the expiry type data
- if (And (USRxpflag,XP_DATE)) {
- strcat (str," "); strcat (str,DateToStr (USRxpdate));
-
- // Get the expiry action string
- strcat (str," "); strcat (str,BaseXpActStr (USRxpflag));
-
- // Get the expiry action data
- if (And (USRxpflag,XP_DEMOTE)) {
- strcat (str," "); strcat (str,BasePrivStr (USRxppriv));
- }
- }
- else if (And (USRxpflag,XP_TIME)) {
- sprintf (buf,"%8lu",USRxpmins);
- strcat (str," "); strcat (str,buf);
-
- // Get the expiry action string
- strcat (str," "); strcat (str,BaseXpActStr (USRxpflag));
-
- // Get the expiry action data
- if (And (USRxpflag,XP_DEMOTE)) {
- strcat (str," "); strcat (str,BasePrivStr (USRxppriv));
- }
- }
-
- return str;
- }
-
- // Get the command line
- getcmdline (int argc, char *arg1, char *arg2)
- {
- if (argc) {
- if (arg1[0] == '/') {
- if (arg1[1] == 'p' || arg1[1] == 'P') {
- page=atoi (arg1+2);
- if (!page) page=55;
- }
- else if (arg1[1] == 'e' || arg1[1] == 'E') {
- ++expiry_only;
- }
- }
- }
- if (argc>1) {
- if (arg2[0] == '/') {
- if (arg2[1] == 'p' || arg2[1] == 'P') {
- page=atoi (arg2+2);
- if (!page) page=55;
- }
- else if (arg2[1] == 'e' || arg2[1] == 'E') {
- ++expiry_only;
- }
- }
- }
-
- if (page) {
- if (page<8) page=1;
- else page=page-7;
- }
- }
-
- // Byebye
- saybibi ()
- {
- puts ("\nExpRpt done!\n");
- }
-
- // End of script
-
-