Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#365565 - 19/12/2015 20:47 Gotta love Erlang
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5680
Loc: London, UK
Parsing the empeg's "/empeg/var/database3" file:

Code:
dump_database(_Tags, <<>>) ->
    % end of database
    ok;
dump_database(Tags, <<Index:8, Rest/binary>>) when Index =:= 16#FF ->
    % end of record
    io:format("-------\n"),
    dump_database(Tags, Rest);
dump_database(Tags, <<Index:8, Length:8, Data:Length/binary, Rest/binary>>) ->
    Tag = array:get(Index, Tags),
    io:format("~B (~s) = ~p (~B)\n", [Index, Tag, Data, Length]),
    dump_database(Tags, Rest).
_________________________
-- roger

Top
#365566 - 20/12/2015 00:39 Re: Gotta love Erlang [Re: Roger]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Partial credit to the guys who designed the database in such a way that it was that simple to parse. smile
_________________________
Tony Fabris

Top
#366355 - 26/03/2016 20:18 Re: Gotta love Erlang [Re: tfabris]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5680
Loc: London, UK
I'll probably never get around to finishing it, but: https://github.com/rlipscombe/eplode
_________________________
-- roger

Top