home *** CD-ROM | disk | FTP | other *** search
- /************************************************/
- /***/
- #define REVISION "1.1" /***/
- #define REVDATE "13.02.96" /***/
- #define PROGNAME "OLM" /***/
- #define NAME "Olm" /***/
- #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"
- #include <proto/FileID.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);
-
- 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],
- mainline[255],
- handle[50],
- arg[4][10],
- *pointer=NULL;
- long counter=0;
- BOOL node[10],
- nodeexist=FALSE;
- struct SinglePort *Single=NULL;
- struct MultiPort *MPort;
- BPTR fileptr=NULL,
- fileptr2=NULL;
-
-
- ws("",1);
- ws("Olm V1.1 ©1996 Joe Cool",0);
-
- SendStrDataCmd(ENVSTAT,"28",0);
- SendStrDataCmd(DT_NAME,"",1);
- strcpy(handle,XIM_Msg->String);
-
- strcpy(buffer,Nodes_get());
- for (counter=0;counter<10;counter++)
- if (buffer[counter]=='X') node[counter]=TRUE; else node[counter]=FALSE;
-
- strcpy(buffer,Mainline());
- strcpy(mainline,buffer);
- arg[0][0]=0;
- arg[1][0]=0;
- arg[2][0]=0;
- arg[3][0]=0;
- sscanf(buffer,"%s %10s %10s",arg[0],arg[1],arg[2]);
- strcpy(arg[3],arg[1]);
-
- if (arg[1][0] && isdigit(arg[1][0]))
- if (atoi(arg[1])<10 && atoi(arg[1])>-1)
- if (node[atoi(arg[1])])
- nodeexist=TRUE;
- if (!nodeexist)
- {
- arg[2][0]=0;
- strcpy(arg[1],Prompt(1,"...Node :"));
- if (atoi(arg[1])<10 && atoi(arg[1])>-1 && isdigit(arg[1][0]))
- if (node[atoi(arg[1])])
- nodeexist=TRUE;
- }
- if (!nodeexist) ShutDown();
- if (atoi(arg[1])==Node)
- {
- ws("...Wanna send a olm to yourself?",1);
- ShutDown();
- }
- GetDT(531,"\0");
- MPort=(struct MultiPort *)XIM_Msg->Semi;
- {
- ObtainSemaphore((struct SignalSemaphore *)MPort);
- Single=(struct SinglePort *)MPort->MyNode[atoi(arg[1])].s;
- ReleaseSemaphore((struct SignalSemaphore *)MPort);
- }
-
-
- if (Single->Status==22)
- {
- ws("...Nobody online!",1);
- ShutDown();
- }
- counter=0;
- if (arg[2][0])
- {
- pointer=strstr(mainline,arg[0]);
- pointer=strstr(pointer,arg[3]);
- pointer++;
- for (;isspace(pointer[0]);pointer++);
- sprintf(buffer,"bbs:node%d/OLM.Message.txt",atoi(arg[1]));
- fileptr = Open( buffer, MODE_READWRITE );
- Seek( fileptr, 0, OFFSET_END );
- sprintf(buffer,"Got OLM from: %s Node: %d\n",handle,Node);
- FPuts(fileptr, buffer);
- FPuts(fileptr, "\n");
- FPuts(fileptr, pointer );
- FPuts(fileptr, "\n");
- FPuts(fileptr, "\n");
-
- Close(fileptr);
- ws ("...sent successful!",1);
-
-
- }
- else
- {
- ws("",1);
- sprintf(buffer,"t:olmfrom%d",Node);
- DeleteFile( buffer );
- SendStrDataCmd(JH_EF,buffer,0);
- if (XIM_Msg->Data==-1) ShutDown();
- fileptr2 = Open( buffer, MODE_OLDFILE );
- if (!fileptr2) ShutDown();
-
- sprintf(buffer,"bbs:node%d/OLM.Message.txt",atoi(arg[1]));
- fileptr = Open( buffer, MODE_READWRITE );
- Seek( fileptr, 0, OFFSET_END );
- FPuts(fileptr,"\n");
- sprintf(buffer,"Got OLM from: %s Node: %d\n",handle,Node);
- FPuts(fileptr, buffer);
- FPuts(fileptr, "\n");
- while(FGets(fileptr2, buffer, 200))
- {
- FPuts(fileptr,buffer);
- }
- FPuts(fileptr, "\n");
- Close(fileptr2);
- Close(fileptr);
- sprintf(buffer,"t:olmfrom%d",Node);
- DeleteFile( buffer );
- ws ("",1);
- ws ("",1);
- ws ("OLM sent successful",1);
-
- }
-
- ShutDown();
-
- }
- char *Nodes_get(void)
- {
- SendStrDataCmd(ACTIVE_NODES,"",0);
- return(XIM_Msg->String);
- }
- char *Mainline(void)
- {
- SendStrDataCmd(BB_MAINLINE,"",0);
- return(XIM_Msg->String);
- }
-