Hey,
I installed my own version of undernet ircu server.
In order to allow a flash chat client to connect, I had to change the end of line character from \n to \0
It now looks like:
mb->msg[mb->length++] = '\r'; /* add \r\n to buffer */ mb->msg[mb->length++] = '\0';
mb->msg[mb->length++] = '\n';
mb->msg[mb->length] = '\0'; /* not strictly necessary */
The bold line was added by me, and now mirc works fine, and the flash client works fine. but eggdrop has problems.
I enabled raw log in eggdrop, and saw that eggdrop receive all data, it can see a user joining, parting and also joins its own channels.
But it still shows its not on a channel. also it doesnt react on any text sent from the server. no modes, no join parts and so on.
Could someone help me modify eggdrop to react on these, or maybe a fix to the server code I submitted, so it can allow both flash clients and eggdrop.
i would say that the fault is in the Flash client rather than the IRCu code, since mIRC and eggdrop both work with the original code.
I don't see how your code adds anything as the \r\n is meant to be together rather than separated. \r is a carriage return and \n new line. Separating these will work under Windows but not under Linux I guess. Seeing as the snippit you gave already had a line with \0 in it I cannot see how the first \0 works.
okay my guess:
if I correctly remeber my programming times, \0 indicates the end of a string. Sooo, lets see, your buffer ending will look like:
0D 00 0A 00
however, for eggdrop the end of a line is 0A, but the bot will stop phrasing the string at the first 00... its the end of the string !!! so it will never phrase 0A (\n) so it never sees the EOL and probably just discards the string .
solution: remove the first 00 again. try to remove the 0D instead, mIRC should even work with 0A line ends. Or try to add a double 00 at the end or switch 0D and 0A in your orignal version. Meaning try these:
\r \n \0 (maybe it was something else, verification makes wise)
\n \0
\n \0 \r \0
Galadhrim wrote:\0 means null in a string often used to make sure that memory space is really empty.
just for I took out my old C book, and it clearly says that strings REQUIRE to be terminated with \0!
Im triing to translate (im too lazy to write better english ^^):
It seems that in the above array while saving the string "Zeichenkette" one array element - the 13th - keeps unused. But actually you need for saving strings not only 12, but 13 array elements, because in the diffrence to data objects of other types strings must be terminated wtih a special character. This character which marks the end of a string is the zero character '\0', ...
arcane wrote:hm.. maybe not for strings with fixed length, but it is definitely needed for strings with varying length.
a string with a fixed length is called "constant" and isn't saved in a "variable" (or better a char array), is it?
no. a "constant" is basically a variable with unchanging content. a "variable" is basically everything, you can store values in.
as for C: unless you don't use a special "string" class, every string is a char array (well, in that string class as well, but you don't see that while coding ).
De Kus wrote:PS: the book is 10 years old, but I somehow doubt C has changed that much since then.
If you have an array of 20 elements (char string), this array can take for example 19 characters and the last element would be \0 (but you don't need to put it). So if you want to check the end of the string you can check if it's equal to \0.
I found it would be easier to write a simle proxy in perl, which would just remove the \0 from the string sent by the server, rather than experimenting with the eggdrop code.
IRC messages are always lines of characters terminated with a CR-LF
(Carriage Return - Line Feed) pair, and these messages shall not
exceed 512 characters in length, counting all characters including
the trailing CR-LF. Thus, there are 510 characters maximum allowed
for the command and its parameters. There is no provision for
continuation message lines.
i.e. your server is no longer compliant with the IRC protocol, whereas eggdrop tries to be (compliant)