mIRC Home    About    Download    Register    News    Help

Print Thread
Saved Hashtable format? #268958 21/05/21 05:26 PM
Joined: Apr 2010
Posts: 966
F
FroggieDaFrog Offline OP
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
Does anyone know the exact format used when saving a hashtable to file?

The reason I ask is I would like to write an output from a COM to file for mIRC to load and manipulate


I am SReject
My Stuff
Re: Saved Hashtable format? [Re: FroggieDaFrog] #268959 21/05/21 07:40 PM
Joined: Jan 2004
Posts: 1,614
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,614
The default format is simply a text file where the odd lines are the itemnames and the even lines are their text data, with lines ending with $crlf. If there's an odd number of lines, it's ignoring that last line.

I'm assuming you don't want to mess with creating the file in .ini format, where additional complicated rules apply, including ;comments.

If the format is going to be &binary, that will be 1 of 2 different formats, depending on whether it's -b or -B, with -b supporting length only up to 65535. The itemnames are case-insensitive only as far as a-zA-Z, since the next example creates 26 items fewer than 65535 items:

//hfree -w test | var %i 1 | while (%i isnum 1-65535) { hadd -m test $+(item,$chr(%i)) 1 | inc %i } | echo -a $hget(test,0).item

It allows creating itemnames that can't be created from the /hadd command, and which can't be deleted due to containing a space:, unless you use a wildcard which has the potential of deleting extra items.

//write -c test.hsh item name | write test.hsh data | hfree -w test | hload -m test test.hsh | hdel -s test $hget(test,1).item | echo -a $hget(test,1).item

For -b binary format it's little-endian:

uint16 length of itemname in bytes
itemname itself
uint16 length of data
data itself

For -B binary it's the same except for the length fields being uint32's

Re: Saved Hashtable format? [Re: maroon] #268960 21/05/21 07:46 PM
Joined: Apr 2010
Posts: 966
F
FroggieDaFrog Offline OP
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
Originally Posted by maroon
uint16/32 - length of itemn in bytes
itemname
uint16/32 - length of data
data

The info I was looking for. thank you


I am SReject
My Stuff