Innovative Logic Corp.

CTCP Version 1

Klaus Zeuge
Troy Rollo
Ben Mesander
May 1993

The Client-To-Client Protocol (CTCP)
Version One

LOW LEVEL QUOTING

Even though messages to and from IRC servers cannot contain NUL, NL, or CR, it still might be desirable to send ANY character (in so called "middle level messages") between clients. In order for this to be possible, those three characters have to be quoted. Therefore a quote character is needed. Of course, the quote character itself has to be quoted too, since it is in-band.

	M-QUOTE	::= '\020'

(Ie a CNTRL/P).

When sending a middle level message, if there is a character in the set { NUL, NL, CR, M-QUOTE } present in the message, that character is replaced by a two character sequence according to the following table:

	NUL	--> M-QUOTE '0'
	NL	--> M-QUOTE 'n'
	CR	--> M-QUOTE 'r'
	M-QUOTE	--> M-QUOTE M-QUOTE

When receiving a low level message, if there is a M-QUOTE, look at the next character, and replace those two according to the following table to get the corresponding middle level message:

	M-QUOTE '0'	--> NUL
	M-QUOTE 'n'	--> NL
	M-QUOTE 'r'	--> CR
	M-QUOTE M-QUOTE	--> M-QUOTE

If the character following M-QUOTE is not any of the listed characters, that is an error, so drop the M-QUOTE character from the message, optionally warning the user about it. For example, a string 'x' M-QUOTE 'y' 'z' from a server dequotes into 'x 'y' 'z'.

Before low level quoting, a message to the server (and in the opposite direction: after low level dequoting, a message from the server) looks like:

	M-LINE	::= CHARS*

TAGGED DATA

To send both extended data and query/reply pairs between clients, an extended data format is needed. The extended data are sent in the text part of a middle level message (and after low level quoting, in the text part of the low level message).

To send extended data inside the middle level message, we need some way to delimit it. This is done by starting and ending extended data with a delimiter character, defined as:

	X-DELIM	::= '\001'

As both the starting and ending delimiter looks the same, the first X-DELIM is called the odd delimiter, and the one that follows, the even delimiter. The next one after that, an odd delimiter, then and even, and so on.

When data are quoted (and conversely, before being dequoted) any number of characters of any kind except X-DELIM can be used in the extended data inside the X-DELIM pair.

	X-CHR	::= '\000' | '\002' .. '\377'

An extended message is either empty (nothing between the odd and even delimiter), has one or more non-space characters (any character but '\040') or has one or more non-space characters followed by a space followed by zero or more characters.

	X-N-AS	::= '\000'  | '\002' .. '\037' | '\041' .. '\377'
	SPC	::= '\040'
	X-MSG	::= | X-N-AS+ | X-N-AS+ SPC X-CHR*

Note: Here `+' is used to denote "one or more of the previous class of characters", and `*' is used to denote "zero or more of the previous class of characters".

The characters up until the first SPC (or if no SPC, all of the X-MSG) is called the tag of the extended message. The tag is used to denote what kind of extended data is used.

The tag can be *any* string of characters, and if it contains alphabetics, it is case sensitive, so upper and lower case matters.

Extended data is only valid in PRIVMSG and NOTICE commands. If the extended data is a reply to a query, it is sent in a NOTICE, otherwise it is sent in a PRIVMSG. Both PRIVMSG and NOTICE to a user and to a channel may contain extended data.

The text part of a PRIVMSG or NOTICE might contain zero or more extended messages, intermixed with zero or more chunks of non-extended data.


PREVIOUS PAGE | TABLE OF CONTENTS | NEXT PAGE

Comments about this page? Send them to webmaster (at) invlogic.com.

Return to Innovative Logic's Home Page.
Last modified: 17-Sep-2004 01:04PM.
Pages copyright ©1996-1997, Innovative Web Creations.
All rights reserved.