egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Changed end of line char from \n to \0

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Modules & Programming
View previous topic :: View next topic  
Author Message
NetRider
Voice


Joined: 17 May 2005
Posts: 2

PostPosted: Tue May 17, 2005 7:38 pm    Post subject: Changed end of line char from \n to \0 Reply with quote

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.

thanks
Back to top
View user's profile Send private message
Galadhrim
Op


Joined: 11 Apr 2003
Posts: 123
Location: Netherlands, Enschede

PostPosted: Sat May 21, 2005 4:01 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sat May 21, 2005 10:13 am    Post subject: Reply with quote

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 Smile.
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
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
Galadhrim
Op


Joined: 11 Apr 2003
Posts: 123
Location: Netherlands, Enschede

PostPosted: Sat May 21, 2005 11:08 am    Post subject: Reply with quote

\0 means null in a string Smile often used to make sure that memory space is really empty.
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sat May 21, 2005 6:22 pm    Post subject: Reply with quote

Galadhrim wrote:
\0 means null in a string Smile 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 ^^):
Quote:
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', ...

So just give it a try... Smile.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
Galadhrim
Op


Joined: 11 Apr 2003
Posts: 123
Location: Netherlands, Enschede

PostPosted: Sun May 22, 2005 3:50 pm    Post subject: Reply with quote

strange book... I learned that \0 is not needed but can prevent certain unwanted "features".
Back to top
View user's profile Send private message
arcane
Master


Joined: 30 Jan 2003
Posts: 280
Location: Germany

PostPosted: Mon May 23, 2005 3:11 am    Post subject: Reply with quote

hm.. maybe not for strings with fixed length, but it is definitely needed for strings with varying length.
_________________
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Mon May 23, 2005 3:41 am    Post subject: Reply with quote

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? Smile

but seems it's either working or he has lost intrest in it Wink.

PS: the book is 10 years old, but I somehow doubt C has changed that much since then.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
arcane
Master


Joined: 30 Jan 2003
Posts: 280
Location: Germany

PostPosted: Mon May 23, 2005 5:53 am    Post subject: Reply with quote

De Kus wrote:
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? Smile

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 Wink).

De Kus wrote:
PS: the book is 10 years old, but I somehow doubt C has changed that much since then.

doubt that as well Wink
_________________
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon May 23, 2005 11:46 am    Post subject: Reply with quote

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.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
arcane
Master


Joined: 30 Jan 2003
Posts: 280
Location: Germany

PostPosted: Tue May 24, 2005 7:50 am    Post subject: Reply with quote

yes, but
Sir_Fz wrote:
(but you don't need to put it)

let's say "you don't always need to put it" Wink
there are some functions that require a string to be "null-terminated".
_________________
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
Back to top
View user's profile Send private message Visit poster's website
NetRider
Voice


Joined: 17 May 2005
Posts: 2

PostPosted: Sat May 28, 2005 5:46 pm    Post subject: Reply with quote

Thanks for the help guys.

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.
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sun May 29, 2005 12:41 pm    Post subject: Reply with quote

from RFC1459 (Internet Relay Chat protocol):

Quote:

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)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Modules & Programming All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber