home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / asm_programming / MJRDEVEL.ARC / TYPUACC.C < prev    next >
Text File  |  1989-03-01  |  6KB  |  159 lines

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *   TYPUACC.C                                                             *
  4.  *                                                                         *
  5.  *   Copyright (C) 1986-1989  by GALACTICOMM, Inc.  All Rights Reserved.   *
  6.  *                                                                         *
  7.  *   This is the account file formatter (human-readable output) mainline.  *
  8.  *                                                                         *
  9.  *                                            - T. Stryker 10/20/86        *
  10.  *                                                                         *
  11.  ***************************************************************************/
  12.  
  13. #include "stdio.h"
  14. #include "setjmp.h"
  15. #include "btvstf.h"
  16. #include "majorbbs.h"
  17. #include "usracc.h"
  18. #include "portable.h"
  19. #include "fkcode.h"
  20.  
  21. extern jmp_buf disaster;      /* master error-recovery longjmp save block  */
  22.  
  23. main(argc,argv)
  24. int argc;
  25. char *argv[];
  26. {
  27.      BTVFILE *fp;
  28.      struct usracc acct;
  29.      long numact,numpai,numale,numfem,usetot,usefre,usepai,useavl;
  30.      static char *filnam={"usracc.dat"};
  31.      static FILE *outf=stdout;
  32.      static int pagbrk=0,line;
  33.      static char outnam[129]={""};
  34.      static char repnam[]={"User Account Report"};
  35.      char c;
  36.  
  37.      fprintf(stderr,"%s for The Major BBS\n",repnam);
  38.      fprintf(stderr,"(C) Copyright 1989 Galacticomm Inc.\n\n");
  39.      if (setjmp(ADDR_OFdisaster)) {
  40.           exit(1);
  41.      }
  42.      if (argc > 1 && strcmp(argv[1],"?") == 0) {
  43.           fprintf(stderr,"Where do you want to send the %s?\n",repnam);
  44.           fprintf(stderr,"\n");
  45.           fprintf(stderr,"   (1) to your Screen\n");
  46.           fprintf(stderr,"   (2) to your Printer\n");
  47.           fprintf(stderr,"   (3) to a Disk File\n");
  48.           fprintf(stderr,"\n");
  49.           fprintf(stderr,"Please choose a number (or 0 to exit):  ");
  50.           while (1) {
  51.                switch (getchc()) {
  52.                case F1:
  53.                case '1':
  54.                     pagbrk=22;
  55.                     fprintf(stderr,"1\n\n");
  56.                     break;
  57.                case F2:
  58.                case '2':
  59.                     strcpy(outnam,"PRN");
  60.                     fprintf(stderr,"2\n\nPrinting the %s...",repnam);
  61.                     break;
  62.                case F3:
  63.                case '3':
  64.                     fprintf(stderr,"3\nFile name:  ");
  65.                     scanf("%s",outnam);
  66.                     fprintf(stderr,"\nWriting the %s to \"%s\"...",repnam,outnam);
  67.                     break;
  68.                case F10:
  69.                case '0':
  70.                     fprintf(stderr,"\n");
  71.                     exit(0);
  72.                default:
  73.                     continue;
  74.                }
  75.                break;
  76.           }
  77.      }
  78.      if (outnam[0] != '\0') {
  79.           if ((outf=fopen(outnam,FOPWA)) == NULL) {
  80.                catastro("CANNOT OPEN OUTPUT FILE \"%s\"",outnam);
  81.           }
  82.      }
  83.      numact=0L;
  84.      numpai=0L;
  85.      numale=0L;
  86.      numfem=0L;
  87.      usetot=0L;
  88.      usefre=0L;
  89.      usepai=0L;
  90.      useavl=0L;
  91.      fp=opnbtv(filnam,sizeof(struct usracc));
  92.      setbtv(fp);
  93.      if (!qlobtv(0)) {
  94.           catastro("User account file is empty!");
  95.      }
  96.      do {
  97.           if (pagbrk > 0 && (line+=6) >= pagbrk) {
  98.                fprintf(stderr,"<< hit any key to continue >>");
  99.                getchc();
  100.                fprintf(stderr,"\n\n");
  101.                line=0;
  102.           }
  103.           gcrbtv(&acct,0);
  104.           fprintf(outf,"USER-ID: %-10s PASSWORD: %-10s SYS: %d%s  CRT: %2dx%2d  AGE: %2d  SEX: %c\n",
  105.              acct.userid,acct.psword,acct.systyp,
  106.              ((acct.ansifl&ANSON) ? "(A)" : "   "),
  107.              acct.scnwid,acct.scnlen,acct.age,acct.sex);
  108.           fprintf(outf,"%-48s %30s\n",acct.usrnam,acct.usrad1);
  109.           fprintf(outf,"%s, %s   Phone: %s\n",
  110.              acct.usrad2,acct.usrad3,acct.usrpho);
  111.           fprintf(outf,"Created %s, Last Used %s   Non-live time: %ld minutes\n",
  112.              acct.credat,acct.usedat,acct.frescu/60L);
  113.           fprintf(outf,"CREDITS:      %ld total      %ld paid      %ld available\n\n",
  114.              acct.tcktot,acct.tckpai,acct.tckavl);
  115.           numact+=1;
  116.           if (acct.tckpai != 0L) {
  117.                numpai+=1;;
  118.           }
  119.           if (acct.sex == 'M') {
  120.                numale+=1;
  121.           }
  122.           else {
  123.                numfem+=1;
  124.           }
  125.           usetot+=acct.frescu+(acct.tcktot-acct.tckavl);
  126.           usefre+=acct.frescu;
  127.           usepai+=max(0L,acct.tckpai-acct.tckavl);
  128.           useavl+=min(acct.tckpai,acct.tckavl);
  129.      } while (qnxbtv());
  130.      if (pagbrk > 0 && (line+=10) >= pagbrk) {
  131.           fprintf(stderr,"<< hit any key for summary >>");
  132.           getchc();
  133.           fprintf(stderr,"\n");
  134.      }
  135.      clsbtv(fp);
  136.  
  137.      fprintf(outf,"\14\nTotal Accounts:  %ld\n",numact);
  138.      fprintf(outf,"Paying Accounts: %ld\n",numpai);
  139.      fprintf(outf,"Male Accounts:   %ld\n",numale);
  140.      fprintf(outf,"Female Accounts: %ld\n",numfem);
  141.      fprintf(outf,"\nTotal Usage:          %ld user-hours\n",usetot/3600L);
  142.      fprintf(outf,"Total Non-Live Usage: %ld user-hours\n",usefre/3600L);
  143.      fprintf(outf,"Total Paid Usage:     %ld user-hours\n",usepai/3600L);
  144.      fprintf(outf,"Total Paid Time Left: %ld user-hours\n",useavl/3600L);
  145.      fclose(outf);
  146.      fprintf(stderr,"\nEnd of report.\n");
  147.      exit(0);
  148. }
  149.  
  150. char *catfix1()
  151. {
  152.      return("");
  153. }
  154.  
  155. char *catfix2()
  156. {
  157.      return("");
  158. }
  159.