River Tarnell wrote:
PS: I cringe every time I see someone "parsing" IRC lines with things like strncmp(line, "PRIVMSG ", 8) or strstr(line, " :"). The IRC protocol is very simple, and tokenising it properly is really not that difficult. (Every argument is separated by a space; if the first byte of the argument is ":", remove it and stop splitting.)
You forget the first argument, where a leading : means that it is a full name (the only one you will ever see as a client). Except the PING, which has no sender (it's always the local server), all command follow the pattern: <sender> <action> <parameters> The action can be performed by a "user" (joining a channel, sending a message...) in which case it is the sender, or it may be a numeric where the sender is a server. The number of parameters depend on the action, with the last one taking up to the end of line if beginning by : Theoretically, some arguments should be counted from the beginning and others from the end, thus allowing new parameters to be added in the middle. In the practise, the client format is fixed and that isn't really relevant.