home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / JOE_SOUR.LHA / Sources.lha / Amiexpress / Priestlist / userlist7.c
Encoding:
C/C++ Source or Header  |  1995-08-03  |  9.8 KB  |  354 lines

  1. #include <AE.Includes/doorheader.h>
  2. #include <AE.Includes/glue.h>
  3.  
  4. #include <string.h>
  5. #include <proto/exec.h>
  6. #include <dos/dos.h>
  7. #include <ctype.h>
  8. #include <time.h>
  9.  
  10. #define Ver "$VER: PRiEST-Userlist! 1.7 (25-10-94) - ©1994 H!-TEX / G-SUS"
  11.  
  12. #define sm sendmessage
  13. #define pm prompt
  14. #define gu getuserstring
  15. #define pu putuserstring
  16.  
  17. #define Beep 0x07
  18.  
  19. /***[ SubRoutines ]**********************************************************/
  20.  
  21. void start(int);
  22. void GetAEinfo(void);
  23. void GetDate(char);
  24. void end(void);
  25. void DExit(void);
  26. void LastCommand(void);
  27. struct User *Loaddata(struct User *p,int *max);
  28. char *Byteconv(double byte);
  29. void aufbau1(struct User *p,int i);
  30. void aufbau2(int fast);
  31. void part2(struct User *p,int i);
  32.  
  33. /***[ Global Variables ]*****************************************************/
  34.  
  35. int  Node,num;
  36. struct User {
  37.  char    Name[31],Pass[9],Location[30],PhoneNumber[13];
  38.  USHORT  Slot_Number;
  39.  USHORT  Sec_Status,
  40.      Sec_Board,                   /* File or Byte Ratio */
  41.      Sec_Library,                 /* Ratio              */
  42.      Sec_Bulletin,                /* Computer Type      */
  43.      Messages_Posted;
  44.  /* Note ConfYM = the last msg you actually read, ConfRead is the same ?? */
  45.  ULONG   NewSinceDate, ConfRead1, ConfRead2, ConfRead3, ConfRead4,
  46.          ConfRead5;
  47.  UWORD   XferProtocol, Filler2;
  48.  UWORD   Lcfiles,BadFiles; 
  49.  ULONG   AccountDate;
  50.  UWORD   ScreenType, Filler1;
  51.  char    Conference_Access[10];
  52.  USHORT  Uploads, Downloads, ConfRJoin, Times_Called;
  53.  long    Time_Last_On, Time_Used, Time_Limit, Time_Total;
  54.  ULONG   Bytes_Download, Bytes_Upload, Daily_Bytes_Limit, Daily_Bytes_Dld;
  55.  char    Expert;
  56.  ULONG   ConfYM1, ConfYM2, ConfYM3, ConfYM4, ConfYM5, ConfYM6, ConfYM7,
  57.          ConfYM8, ConfYM9;
  58.  long    BeginLogCall;
  59.  UBYTE   Protocol, UUCPA, LineLength, New_User;
  60.  };
  61. /***[ Main ]*****************************************************************/
  62.  
  63. void main (int argc,char *argv[]) 
  64. {
  65.   if(argc!=2)
  66.   {
  67.     printf("\n %s \n",Ver);
  68.     exit(0);
  69.   }
  70.   Node=atoi(argv[1]);
  71.   Register(argv[1][0]-'0');
  72.   putuserstring("G^SUS Userlist",177);
  73.   start(Node);
  74.   DExit();
  75. }
  76. /****************************************************************************/
  77.  
  78. void start(int node)
  79.  
  80.  
  81. { struct User *p,*q=NULL;
  82.   int i,new=0,merk=0,max=0,fast=1;
  83.   ULONG slot,anz=0,maxline,rahmenu=12,rahmeno=1,cursor=0,cur=1;
  84.   char line[400],line2[2],line3[3];
  85.   pu (line,501);
  86.   gu (line3,122);
  87.   pu ("80",122);
  88.   PutInfo (0,122);
  89.   maxline=atoi(line);
  90.   
  91.   q=Loaddata(q,&max);
  92.   if (q==NULL)
  93.     {
  94.     sm ("  sORRY sOMETHINGS wRONG",1);
  95.     DExit(); 
  96.     }
  97.   
  98.   printf(line2,1);
  99.   aufbau2(fast);
  100.   gu (line,104);
  101.   slot=atoi(line);
  102. do { if (merk==0) sm("H",0);
  103.      if (merk==1) sm("H",0);
  104.   for (i=rahmeno;i<=rahmenu;i++)
  105.     {p=q+i-1; 
  106.     if (merk==0)
  107.    { if (p->Slot_Number!=0)
  108.       {anz++;
  109.       if (cursor+rahmeno==i)
  110.         sm("C",0); 
  111.       else
  112.         sm("C",0);
  113.       sprintf (line,"[%3d]",p->Slot_Number);
  114.       sm (line,0);
  115.       if (p->New_User==NULL)
  116.     sprintf (line," %-19.19s",p->Name);
  117.       else
  118.         {
  119.          sprintf (line,"*%-19.19s",p->Name);
  120.          new++;
  121.     }
  122.       sm (line,0);
  123.       sprintf (line," %-19.19s ",p->Location);
  124.       sm (line,1);}
  125.     
  126. }
  127.  
  128.    if (merk==1)
  129.    { if (p->Slot_Number!=0)
  130.       {
  131.       anz++;
  132.       if (cursor+rahmeno==i)
  133.         sm("C",0); 
  134.       else
  135.         sm("C",0);
  136.       sprintf (line,"[%3d]",p->Slot_Number);
  137.       sm (line,1);}
  138.    }
  139.    if (merk==2)
  140.    {  if (fast==0)
  141.       {sm ("4HFast Mode: oN ",0);}
  142.       else
  143.       {sm ("4HFast Mode: oFF",0);}
  144.    }   
  145. }
  146. if (fast==1) {aufbau1(q,cursor+rahmeno-1);}
  147. hotkey("",line2);
  148. merk=3;
  149. sm ("1H",0);
  150. if (line2[0]==3) if (rahmenu+13<max) {rahmeno+=12;rahmenu+=12;merk=0;} else if (rahmenu<max) {rahmenu=max;rahmeno=rahmenu-11;merk=0;} else {cursor=11;merk=0;} 
  151. if (line2[0]==2) if (rahmeno>12) {rahmeno-=12;rahmenu-=12;merk=0;} else if (rahmenu>12) {rahmeno=1;rahmenu=rahmeno+11;merk=0;} else {cursor=0;merk=0;}
  152. if (line2[0]==5) if (rahmeno+cursor<max) if (cursor>=rahmenu-rahmeno) {merk=0;rahmenu++;rahmeno++;cur++;} else {merk=1;cursor++;cur++;}
  153. if (line2[0]==4) if (cursor) {merk=1;cursor--;cur--;} else if (rahmeno>1) {merk=0;rahmeno--;rahmenu--;cur--;}
  154. if (line2[0]==' ') {part2(q,cursor+rahmeno-1);aufbau2(fast);merk=0;}
  155. if (line2[0]=='f' || line2[0]=='F') {merk=2;if (fast==1) fast=0; else fast=1;}
  156.  
  157.  
  158. } while (line2[0]!=13);
  159.  
  160.     pu (line3,122);
  161.     PutInfo (0,122);
  162. }
  163.  
  164.  
  165.  
  166. void part2(struct User *p,int i)
  167. {char ch[2],line[200],dummy[15],dummy2[10],dummy3[10];
  168.  p+=i; 
  169.  sm ("c",0);
  170.  
  171.  
  172.           sm ("        .----------------------------------------------------------------.",1);
  173.  sprintf(line,"        | Handle: %-19.19s      Location: %-20.20s|",p->Name,p->Location);
  174.  sm (line,1);
  175.           sm ("        ·----------------------------------------------------------------·",1);
  176.  sprintf(line,"        | sLOT: %4d       aXX lEVEL: %3d  cONF aXX: %-10.10s          |",p->Slot_Number,p->Sec_Status,p->Conference_Access);
  177.  sm (line,1);
  178.  
  179.           sm ("        |                                                                |",1);
  180.  sprintf(line,"        | cALLS: %5d   mESSAGES: %5d                                 |",p->Times_Called,p->Messages_Posted);
  181.  sm (line,1);
  182.           sm ("        |                                                                |",1);
  183.  sprintf(line,"        | uL bYTES: %10d  uL fILES: %4d  bYTE lIMIT: %10d |",p->Bytes_Upload,p->Uploads,p->Daily_Bytes_Limit);
  184.  sm (line,1);
  185.           sm ("        |                                                                |",1);
  186.  sprintf(line,"        | dL bYTES: %10d  dL fILES: %4d  tODAY dOWN: %8d     |",p->Bytes_Download,p->Downloads,p->Daily_Bytes_Dld);
  187.  sm (line,1);
  188.           sm ("        |                                                                |",1);
  189.  
  190.  if (!p->Sec_Library) {sprintf(dummy,"dISABLED ");sprintf(dummy2,"dISABLED ");}
  191.  else {if (p->Sec_Board==0) sprintf(dummy,"%s","bYTE     "); 
  192.        else if (p->Sec_Board==1) sprintf(dummy,"%s","bYTE/fILE");
  193.        else if (p->Sec_Board==2) sprintf(dummy,"%s","fILE     ");
  194.        sprintf (dummy3,"1:%d",p->Sec_Library);
  195.        sprintf (dummy2,"%-9.9s",dummy3);
  196.       }
  197.        
  198.  sprintf(line,"        | rATIO tYPE: %s rATIO: %s                         |",dummy,dummy2);
  199.  sm (line,1);
  200.           sm ("        `----------------------------------------------------------------'",1);
  201.           sm ("",0);
  202.  hotkey("",ch);
  203. }
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223. /****************************************************************************/
  224. void DExit(void)
  225. {
  226.   ShutDown();
  227.   end();
  228. }
  229. void end (void)
  230. {
  231.   exit(0);
  232. }
  233.  
  234.  
  235. void aufbau1(struct User *p,int i)
  236. {  char line[400];
  237.  
  238.  
  239.  
  240.  
  241. p+=i;
  242.  
  243.  
  244.       sprintf (line,"3H[%3d",p->Slot_Number);
  245.       sm (line,0);
  246.       if (p->New_User==NULL)    
  247.         sprintf (line," %-19.19s",p->Name);
  248.       else
  249.          sprintf (line,"*%-19.19s",p->Name);
  250.       sm (line,0);
  251.       sprintf (line," %-19.19s",p->Location);
  252.       sm (line,0);
  253.       sm (Byteconv((double)p->Bytes_Upload),0);
  254.       sm (" ",0);
  255.       sm (Byteconv((double)p->Bytes_Download),0);
  256.       sprintf (line," %4d %4d",p->Times_Called,p->Messages_Posted);
  257.       sm (line,1);
  258.     
  259.  
  260.  
  261. }
  262.  
  263. void aufbau2(int fast)
  264. { int i;
  265.   sm("c",0);
  266.   sm ("p",0);
  267.   sm (" .-----------------------------------------------.-------------------------.",1);
  268.   for (i=0;i<12;i++)
  269.   sm (" |C|C|",1);
  270.   
  271.   sm ("1H ·-----------------------------------------------´-------------------------·",1);     
  272.   sm (" | sLOT ",0);
  273.   sm ("      hANDLE        ",0);
  274.   sm ("     lOCATION       ",0);
  275.   sm ("   uL    ",0);
  276.   sm ("   dL    ",0);
  277.   sm ("cALL ",0);
  278.   sm ("mAIL|",1);
  279.   sm (" |C|",1);
  280.   sm (" `-------------------------------------------------------------------------´",1);
  281.     
  282.  
  283.  
  284. if (fast==0)
  285.       {sm ("4HFast Mode: oN ",0);}
  286.       else
  287.       {sm ("4HFast Mode: oFF",0);}
  288.    
  289.  
  290.  
  291.   sm ("3HJust use Cursor keys",0);
  292.   sm ("2HCall these G-SUS Boards",0);
  293.   sm ("4HOtOrInOlArIngOIAtrA",0);
  294.   sm ("6HCAFE BANGLADESH",0);
  295.   sm ("55H)) bAUD bOILER ((",0);
  296.   sm ("59HScumWhere",0);
  297.   sm ("50H·-------------------------·",0);
  298.   sm ("52HUserlist by H!-TEX/G-SUS",0);
  299. }
  300.  
  301. struct User *Loaddata(struct User *p,int *max)
  302. {
  303.   FILE *fp;
  304.   struct User *q;
  305.   int j;
  306.   if ((fp=fopen("bbs:USER.DATA","r"))!=NULL)
  307.     {
  308.      if ((p=realloc(p,sizeof(struct User)))!=NULL)
  309.        {q=p;
  310.         fseek(fp,0,SEEK_SET);
  311.         j=0;
  312.         do 
  313.           {if ((q=realloc(q,(j+1)*sizeof(struct User)))!=NULL)
  314.              {
  315.              p=q;
  316.              p+=j;
  317.              fread(p,sizeof(struct User),1,fp);
  318.              if (p->Slot_Number!=0)
  319.                {j++;}
  320.              }
  321.           } while (!feof(fp));
  322.         fclose(fp);
  323.        } else return NULL;       
  324.         *max=j-1;            
  325.         return (q);
  326.      } else return NULL;
  327. return (q);
  328. }
  329. char *Byteconv(double byte)
  330. {  double bytenum;
  331.    int nr;
  332.    char line[400];
  333.   if (byte>=1073741824)
  334.         { bytenum=(byte/1073741824.0);
  335.           nr=1; }
  336.         else if (byte>=1048576)
  337.         { bytenum=(byte/1048576.0);
  338.           nr=2; }
  339.         else
  340.         { bytenum=(byte/1024.0);
  341.           nr=3;}
  342.            
  343.         if (nr==1)
  344.           sprintf (line,"%6.2f%2s",bytenum,"gB");
  345.         else if (nr==2) 
  346.           sprintf (line,"%6.1f%2s",bytenum,"mB");
  347.         else if (nr==3)
  348.           sprintf (line,"%6.1f%2s",bytenum,"kB");
  349.  return (line);       
  350. }
  351. void LastCommand(void)
  352. {
  353. }
  354.