From 9adab0ea874213d321c481d2d3a296d38a5aa280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 4 Jan 2012 01:56:38 +0100 Subject: [PATCH] Move the PRS compression library into a separate application --- apps/egs/priv/egs_drv.so | Bin 18398 -> 0 bytes apps/egs/src/egs_files.erl | 2 +- apps/egs/src/egs_quests_db.erl | 2 +- apps/{egs => prs}/c_src/prs.c | 0 .../c_src/egs_prs_drv.c => prs/c_src/prs_drv.c} | 2 +- apps/prs/src/prs.app.src | 11 +++++++++++ apps/{egs/src/egs_prs.erl => prs/src/prs.erl} | 5 +++-- rebar.config | 3 ++- 8 files changed, 19 insertions(+), 6 deletions(-) delete mode 100755 apps/egs/priv/egs_drv.so rename apps/{egs => prs}/c_src/prs.c (100%) rename apps/{egs/c_src/egs_prs_drv.c => prs/c_src/prs_drv.c} (96%) create mode 100644 apps/prs/src/prs.app.src rename apps/{egs/src/egs_prs.erl => prs/src/prs.erl} (91%) diff --git a/apps/egs/priv/egs_drv.so b/apps/egs/priv/egs_drv.so deleted file mode 100755 index 383ae8376b52743af173c53a9664137b1b5cf2bc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18398 zcmcIs3w%`7nLl?Xj~fz_fdEDj90e?_Wx^X&&|n-K6fouCqT+9uB$H$`nThj)R3foK zWz15O)+*c5UF^Co?Y0(M%a0b<2DOUaZj1F%*0pWwtBKle6l^I{v;Xg$^WC{~GqnDG zyFD=X`@aA8IFEbox#!+v!1Df@j2epJqno9yMB04J*U)oVA3x1OB#+OA*j z?Of2Y?z)-Z+j(S3YT#cf<~aPO5rcFNeq->Xyi4#a$L~D+O7S}vzY6>)jaNiaRf_SO zgkPn`&PJv{K~3$^22(Yq?m_3B%0cJEnI;3EI#3%>ea7O)bp&fA@~2o7gUWPFJY3c# zJX6e>M#=XJ3a$bq^;9P+1I405Wv6;m*(fh6r#*2w32Qw6+x~Z6_#$hjnMK(fDUz?-B2f?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i%1APP^yedb!rq-rv zj0KxpWA&ldpnUBU45hZoWx>{PGTi7}yzr6*f)v3><2I5O3H9cvG1b=A!TI>tUL~_x zxo*W8e~=~0hWTtR@*R`RC3m5W*S+LYq+E5>3zgZGLWySA|Kt*-Z~mes3uw8CYJK(U z>#kg}I(Xg6mFxW*f*V#`x!O;)Z%o93Eum;*D?a^KO`(f*)eUP`tXWm7RvR5(>eIp& zFF_ISSSYhE+1XX2*WjFgks!|>A5ed#z_yf@Cqq?8^%n}%+Gg%wHK?hve`rquoa=A4 zzdfM-!~q#`vu9WLq*)~QFC8dL{kH(9y7uKk`xpP#8nKL$^QRBg9}LJXru+i|Dnsip RE$F`^Kv`y&D%Iae_+Qi>jGh1h diff --git a/apps/egs/src/egs_files.erl b/apps/egs/src/egs_files.erl index d46413b..0130277 100644 --- a/apps/egs/src/egs_files.erl +++ b/apps/egs/src/egs_files.erl @@ -506,7 +506,7 @@ nbl_pack_files([], {AccH, AccD, AccP, _FilePos, _PtrIndex}) -> {BinD3, CompressedDataSize} = if BinDSize < 16#800 -> {BinD, 0}; true -> - BinD2 = egs_prs:compress(BinD), + BinD2 = prs:compress(BinD), BinD2Size = byte_size(BinD2), {BinD2, BinD2Size} end, diff --git a/apps/egs/src/egs_quests_db.erl b/apps/egs/src/egs_quests_db.erl index 90f6f04..1da71ba 100644 --- a/apps/egs/src/egs_quests_db.erl +++ b/apps/egs/src/egs_quests_db.erl @@ -106,7 +106,7 @@ handle_call({zone_nbl, QuestID, ZoneID}, _From, State=#state{quests=QuestsCache, {Set0, SetPtrs} = egs_files:load_set_rel(ZoneDir ++ io_lib:format("set_r~b.conf", [0]), AreaID, Maps, FilePos), ScriptBin = egs_files:load_script_bin(ZoneDir ++ "script.es"), ScriptBinSize = byte_size(ScriptBin), - ScriptBin2 = egs_prs:compress(ScriptBin), + ScriptBin2 = prs:compress(ScriptBin), ScriptBinSize2 = byte_size(ScriptBin2), ScriptBin3 = << ScriptBinSize:32/little, ScriptBinSize2:32/little, 0:32, 1:32/little, 0:96, ScriptBin2/binary >>, TextBin = egs_files:load_text_bin(ZoneDir ++ "text.bin.en_US.txt"), diff --git a/apps/egs/c_src/prs.c b/apps/prs/c_src/prs.c similarity index 100% rename from apps/egs/c_src/prs.c rename to apps/prs/c_src/prs.c diff --git a/apps/egs/c_src/egs_prs_drv.c b/apps/prs/c_src/prs_drv.c similarity index 96% rename from apps/egs/c_src/egs_prs_drv.c rename to apps/prs/c_src/prs_drv.c index f95b701..a4199b4 100644 --- a/apps/egs/c_src/egs_prs_drv.c +++ b/apps/prs/c_src/prs_drv.c @@ -71,4 +71,4 @@ static ErlNifFunc nif_funcs[] = { {"compress", 1, compress_nif} }; -ERL_NIF_INIT(egs_prs, nif_funcs, load, reload, upgrade, unload) +ERL_NIF_INIT(prs, nif_funcs, load, reload, upgrade, unload) diff --git a/apps/prs/src/prs.app.src b/apps/prs/src/prs.app.src new file mode 100644 index 0000000..7320265 --- /dev/null +++ b/apps/prs/src/prs.app.src @@ -0,0 +1,11 @@ +%%-*- mode: erlang -*- +{application, prs, [ + {description, "PRS compression library."}, + {vsn, "0.1.0"}, + {modules, []}, + {registered, []}, + {applications, [ + kernel, + stdlib + ]} +]}. diff --git a/apps/egs/src/egs_prs.erl b/apps/prs/src/prs.erl similarity index 91% rename from apps/egs/src/egs_prs.erl rename to apps/prs/src/prs.erl index c59c1c1..0c6fd98 100644 --- a/apps/egs/src/egs_prs.erl +++ b/apps/prs/src/prs.erl @@ -17,12 +17,13 @@ %% You should have received a copy of the GNU Affero General Public License %% along with EGS. If not, see . --module(egs_prs). +-module(prs). -export([init/0, compress/1]). -on_load(init/0). init() -> - erlang:load_nif("priv/egs_drv", 0). + PrivDir = code:priv_dir(prs), + erlang:load_nif(PrivDir ++ "/prs_drv", 0). compress(_SrcBin) -> erlang:nif_error(not_loaded). diff --git a/rebar.config b/rebar.config index c7a9389..5c2777a 100644 --- a/rebar.config +++ b/rebar.config @@ -1,6 +1,7 @@ {sub_dirs, [ "apps/egs", - "apps/egs_patch" + "apps/egs_patch", + "apps/prs" ]}. {dialyzer_opts, [src, {warnings, [ behaviours,