Innovative Logic Corp.

CTCP Version 1

Klaus Zeuge
Troy Rollo
Ben Mesander
May 1993

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

QUOTING EXAMPLES

There are three levels of messages. The highest level (H) is the text on the user-to-client level. The middle layer (M) is on the level where CTCP quoting has been applied to the H-level message. The lowest level (L) is on the client-to-server level, where low level quoting has been applied to the M-level message.

The following relations are true, with lowQuote(message) being a function doing the low level quoting, lowDequote(message) the low level dequoting function, ctcpQuote(message) the CTCP level quoting function, ctcpDequote(message) the CTCP level dequoting function, and ctcpExtract(message) the function which removes all CTCP messages from a message:

	L = lowQuote(M)
	M = ctcpDequote(L)

	M = ctcpQuote(H)
	H = ctcpDequote(ctcpExtract(M))

When sending a CTCP message embedded in normal text:

	M = ctcpQuote(H1) || '\001' || ctcpQuote(X) || '\001' || ctcpQuote(H2)

Note: The operator || denotes string concatenation.

Of course, there might be zero or more normal text messages and zero or more CTCP messages mixed.

- --- Example 1 -----------------------------------------------------------------

A user (called actor) wanting to send the string:

	Hi there!\nHow are you?

to user victim, i.e. a message where the user has entered an inline newline (how this is done, if at all, differs from client to client), will result internaly in the client in the command:

	PRIVMSG victim :Hi there!\nHow are you? \K?

which will be CTCP quoted into:

	PRIVMSG victim :Hi there!\nHow are you? \\K?

which in turn will be low level quoted into:

	PRIVMSG victim :Hi there!\020nHow are you? \\K?

and sent to the server after appending a newline at the end.

This will arrive on victim's side as:

	:actor PRIVMSG victim :Hi there!\020nHow are you? \\K?

(where the \\K would look similar to OK in SIS D47 et. al.) which after low level dequoting becomes:

	:actor PRIVMSG victim :Hi there!\nHow are you? \\K?

and after CTCP dequoting:

	:actom PRIVMSG victim :Hi there!\nHow are you? \K?

How this is displayed differs from client to client, but it suggested that a line break should occour between the words "there" and "How".

- --- Example 2 -----------------------------------------------------------------

If actor's client wants to send the string "Emacs wins" this might become the string "\n\t\big\020\001\000\\:" when being SED-encrypted [SED is a simple encryption protocol between IRC clients implemented with CTCP. I don't have any reference for it -- Ben] using some key, so the client starts by CTCP-quoting this string into the string "\n\t\big\020\\a\000\\\\:" and builds the M-level message:

	PRIVMSG victim :\001SED \n\t\big\020\\a\000\\\\:\001

which after low level quoting becomes:

	PRIVMSG victim :\001SED \020n\t\big\020\020\\a\0200\\\\:\001

which will be sent to the server, with a newline tacked on.

On victim's side, the string:

	:actor PRIVMSG victim :\001SED \020n\t\big\020\020\\a\0200\\\\:\001

will be received from the server and low level dequoted into:

	:actor PRIVMSG victim :\001SED \n\t\big\020\\a\000\\\\:\001

whereafter the string "\n\t\big\020\\a\000\\\\:" will be extracted and first CTCP dequoted into "\n\t\big\020\001\000\\:" and then SED decoded getting back "Emacs wins" when using the same key.

- --- Example 3 -----------------------------------------------------------------

If the user actor wants to query the USERINFO of user victim, and is in the middle of a conversation, the client may decide to tack on USERINFO request on the end of a normal text message. Let's say actor wants to send the textmessage "Say hi to Ron\n\t/actor" and the CTCP request "USERINFO" to victim:

	PRIVMSG victim :Say hi to Ron\n\t/actor

plus:

	USERINFO

which after CTCP quoting become:

	PRIVMSG victim :Say hi to Ron\n\t/actor

plus:

	USERINFO

which gets merged into:

	PRIVMSG victim :Say hi to Ron\n\t/actor\001USERINFO\001

and after low level quoting:

	PRIVMSG victim :Say hi to Ron\020n\t/actor\001USERINFO\001

and sent off to the server.

On victim's side, the message:

	:actor PRIVMSG victim :Say hi to Ron\020n\t/actor\001USERINFO\001

arrives. This gets low level dequoted into:

	:actor PRIVMSG victim :Say hi to Ron\n\t/actor\001USERINFO\001

and thereafter split up into:

	:actor PRIVMSG victim :Say hi to Ron\n\t/actor

plus:

	USERINFO

After CTCP dequoting both, the message:

	:actor PRIVMSG victim :Say hi to Ron\n\t/actor

gets displayed, while the CTCP command:

	USERINFO

gets replied to. The reply might be:

	USERINFO :CS student\n\001test\001

which gets CTCP quoted into:

	USERINFO :CS student\n\\atest\\a

and sent in a NOTICE as it is a reply:

	NOTICE actor :\001USERINFO :CS student\n\\atest\\a\001

and low level quoted into:

	NOTICE actor :\001USERINFO :CS student\020n\\atest\\a\001

after which is it sent to victim's server.

When arriving on actor's side, the message:

	:victim NOTICE actor :\001USERINFO :CS student\020n\\atest\\a\001

gets low level dequoted into:

	:victim NOTICE actor :\001USERINFO :CS student\n\\atest\\a\001

At this point, all CTCP replies get extracted, giving 1 CTCP reply and no normal NOTICE:

	USERINFO :CS student\n\\atest\\a

The remaining reply gets CTCP dequoted into:

	USERINFO :CS student\n\001test\001

and presumly displayed to user actor.


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.