home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <netdb.h>
- #include <sys/types.h>
- #include <sys/syslog.h>
- #include <netinet/in.h>
- #include <lineread.h>
-
- //#include <intuition/intuition.h>
-
- #include <proto/dos.h>
- #include <proto/exec.h>
- //#include <proto/intuition.h>
-
- char user[15];
- char host[20];
- char msg[40];
- char Title[80];
-
- struct sockaddr_in his_addr;
- long addrlen;
- struct LineRead lr;
-
- //struct IntuitionBase *IntuitionBase;
- //struct EasyStruct es={
- // sizeof(struct EasyStruct),
- // 0,
- // NULL,NULL,"Ok"
- //};
-
- extern long server_socket;
- long gethostname(char *,long len);
-
- void main(void)
- {
- fd_set readfds;
- int length,i;
-
- if(server_socket==-1) exit(20);
-
- // IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0);
- // if(!IntuitionBase) exit(20);
-
- addrlen = sizeof (his_addr);
- if(getpeername(0,(struct sockaddr *)&his_addr, &addrlen)<0) exit(20);
-
- // drie regels ophalen van het formaat
- // HOST hostname:20
- // USER username:10
- // MSG message:40
-
- initLineRead(&lr,server_socket,RL_LFREQNUL,160);
- FD_ZERO(&readfds);
-
- i=0;
- while((i&7)!=7)
- {
- FD_SET(server_socket,&readfds);
- if(select(server_socket+1,&readfds,NULL,NULL,NULL)<0) exit(20);
- if(FD_SET(server_socket,&readfds))
- {
- length=lineRead(&lr);
- if(length==-1) exit(20);
- if(lr.rl_Line)
- {
- if(!strncmp("HOST ",lr.rl_Line,5))
- {
- strncpy(host,lr.rl_Line+5,sizeof(host));
- host[sizeof(host)-1]='\0';
- i|=1;
- }
- if(!strncmp("USER ",lr.rl_Line,5))
- {
- strncpy(user,lr.rl_Line+5,sizeof(user));
- user[sizeof(user)-1]='\0';
- i|=2;
- }
- if(!strncmp("MSG ",lr.rl_Line,4))
- {
- strncpy(msg,lr.rl_Line+4,sizeof(msg));
- msg[sizeof(msg)-1]='\0';
- i|=4;
- }
- }
- }
- }
- CloseSocket(server_socket);
-
- // sprintf(Title,"Message from: %s",inet_ntoa(his_addr.sin_addr));
- // es.es_Title=Title;
- // es.es_TextFormat="%s: %s\n%s";
- // EasyRequest(NULL,&es,0,host,user,msg);
-
- syslog(LOG_INFO,"%s@%s(%s): %s",user,host,inet_ntoa(his_addr.sin_addr),msg);
- }
-