Simple IRCd (need ideas) - 16/10/10 05:05 AM
I make a simple IRC server on mIRC. There is a many ready-made servers (find at www.mircscripts.org) and the problem at all one - $chr(32) (space), because it uses %variable, tokenize etc...
I'm using binary variables and have no problems with the implementation, I have already started to do specific commands - ping/pong, user, nick.
Source code http://83.143.33.145/scripts/ircd.mrc
nice? identd, dns, ping. thats all. You also can testing current server /server -m 83.143.33.145 194 or /run telnet 83.143.33.145 194
But I need ideas of how best to glue the binary variables (from client) and a text (server generate commands)...
Example, /PING [:]<parameters> command.
We have no more problem with spaces, but code should be beautiful As I said, - need ideas to "gluing" binary variables and text.
Maybe make /parser <sock> <many text &bvar text &bvar> authomation?..
I'm using binary variables and have no problems with the implementation, I have already started to do specific commands - ping/pong, user, nick.
Source code http://83.143.33.145/scripts/ircd.mrc
Quote:
[15:56:15] * Connecting to localhost (194)
-
[15:56:15] -eggdrop.sigma- *** $Software: mIRC 7.14 $
[15:56:15] -eggdrop.sigma- *** Looking up your hostname...
[15:56:16] -eggdrop.sigma- *** Checking Identd...
[15:56:16] -eggdrop.sigma- *** Found your hostname (LOCAL).
[15:56:16] -eggdrop.sigma- *** Got Identd response (_0x538F2191__), using instead username.
-
[15:56:15] -eggdrop.sigma- *** $Software: mIRC 7.14 $
[15:56:15] -eggdrop.sigma- *** Looking up your hostname...
[15:56:16] -eggdrop.sigma- *** Checking Identd...
[15:56:16] -eggdrop.sigma- *** Found your hostname (LOCAL).
[15:56:16] -eggdrop.sigma- *** Got Identd response (_0x538F2191__), using instead username.
nice? identd, dns, ping. thats all. You also can testing current server /server -m 83.143.33.145 194 or /run telnet 83.143.33.145 194
But I need ideas of how best to glue the binary variables (from client) and a text (server generate commands)...
Example, /PING [:]<parameters> command.
Code:
; ping command. ; if $isalias(ircd/ping) returns $true ; calls /ircd/ping <sockname> <parameters offset> <length> ; else sent 'unknown command' by parser in SOCKREAD event alias ircd/ping { ; $+(&,%sock) - traffic/commands from user ; %offset for parameters ; %0 length with CR/LF (/breplaced to 0 byte) var %sock = $1, %offset = $2, %0 = $3 - 1 ; check for ':' if ($bvar($+(&,%sock),%offset) == 58) var %offset = %offset + 1, %0 = %0 - 1 ; if length > 0 if (%0 > 0) { ; works fine, but i thinks thats is not pretty. ; need ideas for gluing binary variables and text :) bunset $+(&,$1,/,ping) ; generate IRC command: $+(:,$host) PONG $host : bset -t $+(&,$1,/,ping) 1 $+(:,$host) PONG $host : ; copy user's parameters to end bcopy $+(&,$1,/,ping) $calc($bvar($+(&,$1,/,ping),0) + 1) $+(&,$1) %offset %0 ; adding CRLF bset $+(&,$1,/,ping) $calc($bvar($+(&,$1,/,ping),0) + 1) 13 10 ; and sent to user ircdsock %sock $+(&,$1,/,ping) } }
We have no more problem with spaces, but code should be beautiful As I said, - need ideas to "gluing" binary variables and text.
Maybe make /parser <sock> <many text &bvar text &bvar> authomation?..