[DGD] buffer maintenance
David Jackson
atari_x at bellsouth.net
Sun Sep 19 12:07:09 CEST 2004
I will have to check, but I'm pretty sure that GurbaLib and LIMA have
excellent LPC examples of a working Intermud-3 Protocol.
-David Jackson
At 02:24 AM 9/19/2004, you wrote:
>Hey All,
>
>I'm fooling around with the Intermud-3 Protocol. I've gotten my imud3
>daemon to connect to the router and send a "startup-req-3" packet. The
>problem I'm having is with the string buffer I use to hold incoming
>data.
>
>When some subset of the string data in the buffer can be turned into a
>IMUD-3 packet, I want to remove that data from the buffer. One can
>recognize a packet's end by looking for a string matching "})\000".
>
>Please, I'd like to hear your advice on how to search my buffer for the
>lastIndexOf("})\000") and then remove the data preceeding it from the
>buffer. The way that I've come up with seems terribly inefficient and,
>also, seems not to work. :)
>
>Any psuedo code would be appreciated.
>
>Thanks,
>John
>
>/*
> * Name: trimBuffer()
> * Purpose: removes from the buffer data which has been handled.
> * Parameters: none
> * Returns: none
> */
>void trimBuffer()
>{
> int i;
>
> // trim until all complete packets are removed.
> while( sscanf( inBuffer, "})\000" ) != 0 )
> {
> for( i=0; i<strlen(inBuffer)-3; i++ )
> {
> // do we have a complete packet at "i"?
> if( inBuffer[i..i+2] == "})\000" )
> {
> // remove everything before and including "\000"
> inBuffer = inBuffer[i+2..strlen(inBuffer)-1];
>
> // we've messed with inBuffer!
> break;
> }
> }
> }
>}
>
>---=[Example Buffer]=---
>^@^@^@c({"startup-reply",5,"*gjs",0,"No Place Special",0,({({"*gjs","1
>98.144.203.194 9000",}),}),48092,})^@^@^@^GR({"mudlist",5,"*gjs",0,"No
>Place Special",0,10533552,(["YourWor
>ld":0,"Darenok":({0,"24.6.231.86",5555,0,0,"CoffeeMud v4.6.0","CoffeeMud
>v4.6.0"
>,"CoffeeMud v4.6.0","CoffeeMud","Open to the
>public","",(["locate":1,"channel":1
>,"who":1,"finger":1,"tell":1,]),([]),}),"FunMUD":({0,"213.112.214.42",4096,4446,
>4447,"FunMUD v0.01","FunMUD","DGD DGD 1.2.65","LPMud","Mudlib
>Development","info
>@mud.fjortis.nu",(["locate":1,"channel":1,"who":1,"ftp":4445,"tell":1,]),([]),})
>,"Tattered Sails":0,"Lands of
>Liranos":({0,"68.214.91.39",5555,0,0,"CoffeeMud v4
>.6.1","CoffeeMud v4.6.1","CoffeeMud v4.6.1","CoffeeMud","Open to the
>public","",
>(["locate":1,"channel":1,"who":1,"finger":1,"tell":1,]),([]),}),"Aeternus
>Build
>Port":({-1,"66.169.23.166",4050,0,0,"Chronicles
>1.20a","Chronicles","AFKMud","13
>C","Development","orion_elder at charter.net",(["channel":1,"emoteto":1,"finger":1,
>"rcp":0,"smtp":0,"locate":1,"url":"Not
>configured","pop3":0,"auth":0,"amrcp":0,"
>beep":1,"nntp":0,"ucache":1,"http":0,"mail":0,"news":0,"file":0,"who":1,"tell":1
>,"ftp":0,]),0,}),"Darkland":({-1,"69.151.64.240",3000,3005,0,"DarkSkylib
>.5","Di
>scworld","MudOS v22.2b12-DS","LP","Mudlib
>Development","user at host.com",(["locate
>":1,"channel":1,"emoteto":1,"who":1,"finger":1,"http":3080,"ftp":3021,"tell":1,]
>),([]),}),"Skylarks_Place":({0,"203.111.75.195",4242,8765,0,"Discworld
>17.0a","S
>kylarks_Place","FluffOS
>v1.22","LPMud","Development","none",(["channel":1,"emote
>to":1,"finger":1,"http":80,"locate":1,"who":1,"ftp":4444,"tell":1,"auth":1,]),0,}),"Dream.o
>f.the.nation":({-1,"222.156.192.26",4000,4008,4012,"Eastern Stories
>2.1.3a","Eas
>tern Stories 2.1.3a","MudOS
>v22.2b14-msr(RW)","LPmud","Developing","msr at muds.net
>",(["channel":1,"emoteto":1,"rcp":0,"finger":1,"smtp":0,"locate":1,"auth":1,"nnt
>p":0,"ucache":1,"news":1,"http":0,"mail":1,"file":1,"who":1,"amcp":0,"ftp":0,"te
>ll":1,]),0,}),"Dark Forest
>Bld":0,]),})^@^@^@^G356({"mudlist",5,"*gjs",0,"No Pla
>ce
>Special",0,10533553,(["1stMud-1476488617":({0,"24.237.3.43",5000,0,0,"1stMud
>4.5.3","1stMud","1stMud I3 Driver
>2.40","1stMud","Beta","admin at firstmud.com",(["
>beep":1,"channel":1,"emoteto":1,"ucache":1,"mail":1,"finger":1,"news":1,"file":1
>,"locate":1,"who":1,"tell":1,"auth":1,]),(["url":"firstmud.com:5001","time":"Fri
> Sep 17 20:21:01 2004",]),}),"MogMUD":0,"Shattered
>Realms":({-1,"130.236.227.234
>",4001,0,0,"SRlib v1.5 (FRlib IVb)","SR","MudOS v22.2b9 DEV","LP","open
>to playe
>rs","lords at shattered-realms.morth.org",(["channel":1,"finger":1,"mail":1,"http":
>8080,"smtp":3007,"who":1,"pop3":3008,"ftp":3010,"tell":1,]),0,}),"1stMud-5536362
>08":({0,"24.237.3.43",3785,0,0,"1stMud 4.5.3","1stMud","1stMud I3 Driver
>2.40","
>1stMud","Beta","admin at firstmud.com",(["beep":1,"channel":1,"emoteto":1,"ucache":
>1,"mail":1,"finger":1,"news":1,"file":1,"locate":1,"who":1,"tell":1,"auth":1,]),
>(["url":"firstmud.com:3786","time":"Fri Sep 17 20:30:40
>2004",]),}),"Darkened":(
>{-1,"82.113.130.200",300
>
>
>_________________________________________________________________
>List config page: http://list.imaginary.com/mailman/listinfo/dgd
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list