]> git.saurik.com Git - redis.git/blame_incremental - client-libraries/erlang/src/proto.erl
Erlang client synched with Valentiono's repo
[redis.git] / client-libraries / erlang / src / proto.erl
... / ...
CommitLineData
1-module(proto).
2
3-export([parse/2]).
4
5parse(empty, "+OK") ->
6 ok;
7parse(empty, "+PONG") ->
8 pong;
9parse(empty, ":0") ->
10 false;
11parse(empty, ":1") ->
12 true;
13parse(empty, "-" ++ Message) ->
14 {error, Message};
15parse(empty, "$-1") ->
16 {read, nil};
17parse(empty, "*-1") ->
18 {hold, nil};
19parse(empty, "$" ++ BulkSize) ->
20 {read, list_to_integer(BulkSize)};
21parse(read, "$" ++ BulkSize) ->
22 {read, list_to_integer(BulkSize)};
23parse(empty, "*" ++ MultiBulkSize) ->
24 {hold, list_to_integer(MultiBulkSize)};
25parse(empty, Message) ->
26 convert(Message).
27
28convert(":" ++ Message) ->
29 list_to_integer(Message);
30% in case the message is not OK or PONG it's a
31% real value that we don't know how to convert
32% to an atom, so just pass it as is and remove
33% the +
34convert("+" ++ Message) ->
35 Message;
36convert(Message) ->
37 Message.
38