home *** CD-ROM | disk | FTP | other *** search
- /************************************************/
- /***/
- #define REVISION "1.0" /***/
- #define REVDATE "16.02.96" /***/
- #define PROGNAME "Announce" /***/
- #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 "semis.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;
- 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],
- time[40],
- handle[50];
- long counter=0;
- BOOL node[10],
- logon=FALSE,
- logoff=FALSE;
- APTR Singles[32];
- struct SinglePort *Singleport=NULL;
- struct MultiPort *MPort=NULL;
- BPTR fileptr=NULL;
-
-
- ws("",1);
- ws("Announce V1.0 ©1996 Joe Cool",1);
-
- strcpy (time,timenow());
- SendStrDataCmd(177,"JoeAnnounce",0);
- SendStrDataCmd(DT_NAME,"",1);
- strcpy(handle,XIM_Msg->String);
-
- SendStrDataCmd(BB_MAINLINE,"",1);
- strcpy(buffer,XIM_Msg->String);
- if (!strcmp("annon",buffer)) logon=TRUE;
- if (!strcmp("annoff",buffer)) logoff=TRUE;
-
-
-
- GetDT(531,"\0");
- MPort=(struct MultiPort *)XIM_Msg->Semi;
-
-
-
- strcpy(buffer,Nodes_get());
- for (counter=0;counter<10;counter++)
- if (buffer[counter]=='X') node[counter]=TRUE; else node[counter]=FALSE;
- node[Node]=FALSE;
-
- for (counter=0;counter<10;counter++)
- {
- ObtainSemaphore((struct SignalSemaphore *)MPort);
- Singles[counter]=MPort->MyNode[counter].s;
- ReleaseSemaphore((struct SignalSemaphore *)MPort);
-
- if (node[counter])
- {
- ObtainSemaphore((struct SignalSemaphore *)Singles[counter]);
- Singleport=(struct SinglePort *)Singles[counter];
- ReleaseSemaphore((struct SignalSemaphore *)Singles[counter]);
-
- if (Singleport->Status!=22 && ((logoff) || (logon)))
- {
- sprintf(buffer,"bbs:node%d/OLM.Message.txt",counter);
- fileptr = Open( buffer, MODE_READWRITE );
- Seek( fileptr, 0, OFFSET_END );
- if (logoff) sprintf(buffer,"(%s) %s logged off!\n",time,handle);
- if (logon) sprintf(buffer,"(%s) %s logged into Node %d!\n",time,handle,Node);
- FPuts(fileptr,buffer);
- FPuts(fileptr,"\n");
- Close(fileptr);
- }
- }
- }
-
- }
- 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;
- 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);
- }
-