/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <string.h>

void test(char *s)
{
    char from[256],to[256],msg[256],*p1,*p2,*p3,*p4,*p5;
    if(strstr(s,"PRIVMSG"))
    {
        p1 = strchr(s,':');
        p2 = strchr(p1+1,'!');
        strncpy(from,p1,p2-p1);
        from[p2-p1] = '\0';
        p3 = strchr(p2+1,' ');
        p4 = strstr(p3+1,"PRIVMSG ");
        p5 = strchr(p4+8,':');
        strncpy(to,p4+8,p5-p4-8);
        to[p5-p4-8] = '\0';
        strcpy(msg,p5+1);
        printf("<%s -> %s>  %s\r\n", from, to, msg);
    }
}

int main()
{
   test(":sigurd!sigurd@blablahost.dk PRIVMSG #minchannel :hejsa..");
   return 0;
}
