home *** CD-ROM | disk | FTP | other *** search
- /************************************************/
- /***/
- #define REVISION "V1.0" /***/
- #define REVDATE "(17.02.96)" /***/
- #define PROGNAME "TopDL" /***/
- #define NAME "Announce" /***/
- #define AUTHOR "Joe Cool" /***/
- /***/
- /************************************************/
-
- #include <exec/types.h>
- #include <exec/ports.h>
- #include <exec/memory.h>
- #include <dos/dos.h>
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/alib_protos.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include "aedoor.h"
- #include "express.h"
- static const char VersionTag[] = "\0$VER: "PROGNAME" "REVISION" "REVDATE"";
- #define ws WriteStr
-
- void Start(int node);
- char *Nodes_get(void);
- char *Mainline(void);
- char *handleget(void);
- char *timenow (VOID);
-
- void main(int argc, char *argv[])
- {
- int Node=0;
- char buffer[200];
- if(argc<2)
- {
- printf("Sorry, %s must be called from S!X or /X\n",argv[0]);
- exit(0);
- }
-
- Node=atoi(argv[1]);
- Register(Node);
-
- XIM_Msg->Command=140;
- CheckMessage();
- SetTaskPri(FindTask(0),atol(XIM_Msg->String));
-
- Start(Node);
- ShutDown();
-
- }
-
-
-
-
- void Start(Node)
- {
- char buffer[255],
- buffer2[255],
- time[10],
- *pointer=NULL;
- long counter=0,
- counter2=0,
- count=0,
- number=0,
- numberreal=0,
- numberuse=0;
- BPTR fh=NULL,
- lock=NULL;
- BOOL success=FALSE;
- struct FileInfoBlock *fib=NULL;
- struct User *users=NULL,
- *userpointer=NULL;
- int *sort_who=NULL,
- temp_who,
- max,
- lines;
- ULONG *sort_inh=NULL,
- temp_inh,
- gig,meg,kb,b;
- float up_total=0,
- files_total=0,
- calls_total=0;
-
- SendStrDataCmd(177,"TopDl V1.0",0);
- SendStrDataCmd(DT_LINELENGTH,"",1);
- lines=atoi(XIM_Msg->String);
- strcpy(time,timenow());
-
-
- ws("c",1);
- ws(".-------------------------.",1);
- ws("|TopDl V1.0 ©1996 Joe Cool|",1);
- ws("+-------------------------+-------------------------------------------------.",1);
- ws("| Name Group/Location Download-Bytes Files Call |",1);
- ws("+---------------------------------------------------------------------------+",1);
-
-
-
-
-
-
-
-
- fib=(struct FileInfoBlock *)AllocDosObject(DOS_FIB,NULL);
- if (!fib) ShutDown();
-
- lock = Lock( "bbs:User.Data",ACCESS_READ );
- success = Examine( lock, fib);
- users=(struct User *) malloc(fib->fib_Size);
- if (!users) ShutDown();
- fh = OpenFromLock(lock);
- Read(fh, users, fib->fib_Size);
- Close(fh);
- number=fib->fib_Size/sizeof(struct User);
- userpointer=users;
-
- for (counter=0;counter<number;counter++)
- {
- if (userpointer->Slot_Number) numberreal++;
- userpointer++;
-
- }
-
-
- sort_who=malloc(numberreal*sizeof(int));
- sort_inh=malloc(numberreal*sizeof(ULONG));
-
- count=0;
- userpointer=users;
- for (counter=0;counter<number;counter++)
- {
- if (userpointer->Slot_Number)
- {
- if (userpointer->Bytes_Download)
- {
- sort_who[count]=userpointer->Slot_Number;
- sort_inh[count]=userpointer->Bytes_Download;
- count++;
- }
- up_total+=(float)userpointer->Bytes_Download;
- files_total+=(float)userpointer->Downloads;
- calls_total+=(float)userpointer->Times_Called;
-
- }
- userpointer++;
- }
- numberuse=count;
-
- for (counter=numberuse-1;counter>=0;counter--)
- {
- for (counter2=1;counter2<=counter;counter2++)
- if (sort_inh[counter2-1]<sort_inh[counter2])
- {
- temp_inh=sort_inh[counter2-1];
- sort_inh[counter2-1]=sort_inh[counter2];
- sort_inh[counter2]=temp_inh;
- temp_who=sort_who[counter2-1];
- sort_who[counter2-1]=sort_who[counter2];
- sort_who[counter2]=temp_who;
- }
- }
-
- if (numberuse<(lines-13)) max=numberuse; else max=(lines-13);
-
- for (counter=0;counter<max;counter++)
- {
- userpointer=users;
- userpointer+=(sort_who[counter]-1);
- b =sort_inh[counter];
- kb =b/1000;
- meg=kb/1000;
- gig=meg/1000;
-
- gig=gig%1000;
- meg=meg%1000;
- kb = kb%1000;
- b = b%1000;
-
- if (gig) sprintf(buffer, "%2d.%3.3d.%3.3d.%3.3d",gig,meg,kb,b);
- else
- if (meg) sprintf(buffer, " %3d.%3.3d.%3.3d",meg,kb,b);
- else
- if (kb) sprintf(buffer, " %3d.%3.3d",kb,b);
- else
- if (b) sprintf(buffer, " %3d",b);
-
-
-
-
- sprintf(buffer2, "|%2d) %-19.19s %-20.20s %s %4d %4d |",counter+1,userpointer->Name,userpointer->Location,buffer,userpointer->Uploads,userpointer->Times_Called);
- ws(buffer2,1);
- }
- ws("+---------------------------------------------------------------------------+",1);
- sprintf(buffer,"| Time: %s Total Down kBytes: %5.0f Files: %5.0f Calls: %5.0f |",time,up_total/(1024*1024),files_total,calls_total);
- ws (buffer,1);
- ws("`---------------------------------------------------------------------------'",1);
-
- }
- char *Nodes_get(void)
- {
- SendStrDataCmd(ACTIVE_NODES,"",0);
- return(XIM_Msg->String);
- }
- char *Mainline(void)
- {
- SendStrDataCmd(BB_MAINLINE,"",0);
- return(XIM_Msg->String);
- }
- char *timenow()
- {
- struct timerequest *TimerIO;
- struct MsgPort *TimerMP;
- struct Message *TimerMSG;
- LONG error;
- ULONG hrs,secs,mins;
- char buffer[50];
-
- TimerMP = CreatePort(0,0);
- if(!TimerMP) return(NULL);
- TimerIO = (struct timerequest *)CreateExtIO(TimerMP,sizeof(struct timerequest));
- if (!TimerIO) return(NULL);
- error=OpenDevice(TIMERNAME,UNIT_VBLANK,(struct IORequest *)TimerIO,0L);
- if (error) return (NULL);
- TimerIO->tr_node.io_Command = TR_GETSYSTIME;
- DoIO((struct IORequest *) TimerIO);
- secs=TimerIO->tr_time.tv_secs;
- mins=secs/60;
- hrs=mins/60;
- secs=secs%60;
- mins=mins%60;
- hrs=hrs%24;
- CloseDevice((struct IORequest *) TimerIO);
- DeleteExtIO((struct IORequest *) TimerIO);
- DeletePort(TimerMP);
- sprintf(buffer,"%2.2d:%2.2d:%2.2d",hrs,mins,secs);
- return(buffer);
- }
-