X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;ds=sidebyside;f=modules%2Ferl%2Feuphorik_common.erl;fp=modules%2Ferl%2Feuphorik_common.erl;h=12ac9cb566a434ae716f74683a6bcc4020b05491;hb=fa5ea78cb2bd127b797f161d9bc922469a55375d;hp=0000000000000000000000000000000000000000;hpb=beb0e9617b60e39a0493926a563574bb9cd9765b;p=euphorik.git
diff --git a/modules/erl/euphorik_common.erl b/modules/erl/euphorik_common.erl
new file mode 100644
index 0000000..12ac9cb
--- /dev/null
+++ b/modules/erl/euphorik_common.erl
@@ -0,0 +1,36 @@
+% coding: utf-8
+% Copyright 2008 Grégory Burri
+%
+% This file is part of Euphorik.
+%
+% Euphorik is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Euphorik is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with Euphorik. If not, see .
+%
+% Module avec plein de bordel utile à l'intérieur
+% @author G.Burri
+
+-module(euphorik_common).
+-export([serialize_ip/1, unserialize_ip/1]).
+
+
+serialize_ip(undefined) ->
+ "";
+serialize_ip(IP) ->
+ lists:flatten(io_lib:format("~w.~w.~w.~w", tuple_to_list(IP))).
+
+
+unserialize_ip(IP) ->
+ case io_lib:fread("~d.~d.~d.~d", IP) of
+ {ok, [A, B, C, D], []} -> {A, B, C, D};
+ _ -> erreur
+ end.