Skip to content

Commit

Permalink
CELS: now program works ok with rep&storing methods:
Browse files Browse the repository at this point in the history
Arc.exe create a -mrep:8m -dmrep 2

git-svn-id: https://freearc.svn.sourceforge.net/svnroot/freearc@455 3a4f7f31-9599-433d-91b1-573e8b61252c
  • Loading branch information
bulatz committed Jul 26, 2009
1 parent 97b9e48 commit 90e7bdb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 26 deletions.
18 changes: 0 additions & 18 deletions Compression.hs
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,6 @@ compressionDeleteTempCompressors = filter (/="tempfile")
----- (De)compression of data stream -----
----------------------------------------------------------------------------------------------------

{-
compress method callback - óïàêîâàòü äàííûå
decompress method callback - ðàñïàêîâàòü äàííûå
method :: CompressionMethod - àëãîðèòì óïàêîâêè
callback "read" buf size - ïðî÷èòàòü âõîäíûå äàííûå â áóôåð `buf` äëèíîé `size`
Âîçâðàùàåò 0 - êîíåö äàííûõ
<0 - ïðåðâàòü (ðàñ)ïàêîâêó (îøèáêà èëè áîëüøå äàííûõ íå íóæíî)
>0 - êîë-âî ïðî÷èòàííûõ áàéò
callback "write" buf size - çàïèñàòü âûõîäíûå äàííûå
Âîçâðàùàåò <0 - ïðåðâàòü (ðàñ)ïàêîâêó (îøèáêà èëè áîëüøå äàííûõ íå íóæíî)
>=0 - âñ¸ îê
Ïðè âîçâðàùåíèè èç ýòîé ôóíêöèè äàííûå äîëæíû áûòü "èñïîëüçîâàíû", ïîòîìó ÷òî
(ðàñ)ïàêîâùèê ìîæåò íà÷àòü çàïèñü íîâûõ äàííûõ íà òî æå ìåñòî
Âõîäíûå è âûõîäíûå áóôåðà âûäåëÿþòñÿ è îñâîáîæäàþòñÿ (ðàñ)ïàêîâùèêîì
-}

-- |Ïðîöåäóðû óïàêîâêè äëÿ ðàçëè÷íûõ àëãîðèòìîâ ñæàòèÿ.
freearcCompress num method | isFakeMethod method = eat_data
freearcCompress num method = CompressionLib.compress method
Expand All @@ -264,7 +247,6 @@ freearcCompress num method = CompressionLib.compress me
freearcDecompress num method | isFakeMethod method = impossible_to_decompress -- ýòè òèïû ñæàòûõ äàííûõ íå ïîäëåæàò ðàñïàêîâêå
freearcDecompress num method = CompressionLib.decompress method

{-# NOINLINE eat_data #-}
-- |×èòàåì âñ¸, íå ïèøåì íè÷åãî, à CRC ñ÷èòàåòñÿ â äðóãîì ìåñòå ;)
eat_data callback = do
allocaBytes aBUFFER_SIZE $ \buf -> do -- èñïîëüçóåì `alloca`, ÷òîáû àâòîìàòè÷åñêè îñâîáîäèòü âûäåëåííûé áóôåð ïðè âûõîäå
Expand Down
16 changes: 11 additions & 5 deletions Compression/CELS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ int CELS_Call (TABI_ELEMENT* params)
char *service = p._str("service");

// ==== AUTO-SERVICE ======================================
// Ignore zero parameter to some Set* services
if (strequ (service, "SetCompressionMem") || strequ (service, "SetDecompressionMem") || strequ (service, "SetDictionary") || strequ (service, "SetBlockSize"))
// Ignore zero mem parameter to Set* services
if (start_with (service, "Set") && isupper(service[3]))
if (p._int("mem",1)==0)
return p._return(p._str("method"));
if (start_with (service, "Limit")) return p._return(p._str("method")); // to do: get & set
Expand All @@ -135,9 +135,15 @@ int CELS_Call (TABI_ELEMENT* params)
// Find appropriate method to service this call
for (int i=0; i<methodsCount; i++)
{
int x = methodsTable[i](params);
if (x!=FREEARC_ERRCODE_NOT_IMPLEMENTED)
return x;
try
{
int x = methodsTable[i](params);
if (x!=FREEARC_ERRCODE_NOT_IMPLEMENTED)
return x;
}
catch (...)
{
}
}
return FREEARC_ERRCODE_NOT_IMPLEMENTED;
}
Expand Down
2 changes: 1 addition & 1 deletion Compression/CELS.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ int CELS_Call (TABI_ELEMENT* params);

#define QUASIWRITE(size) \
{ \
callback(TABI_DYNAMAP("request","quasiwrite") ("size",size)); \
callback(TABI_DYNAMAP("request","quasiwrite") ("bytes",size)); \
}

#define ReturnErrorCode(x) \
Expand Down
2 changes: 1 addition & 1 deletion Compression/REP/cels-rep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ int rep_server (TABI_ELEMENT* params)
}

// Register REP method in CELS
//int rep_register = CELS_Register(rep_server);
int rep_register = CELS_Register(rep_server);

}
2 changes: 1 addition & 1 deletion Compression/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ $(TEMPDIR)/Common.o: Common.cpp Common.h Compression.h makefile
$(TEMPDIR)/CompressionLibrary.o: CompressionLibrary.cpp Common.h Compression.h makefile
$(GCC) -c $(CFLAGS) -o $*.o $<

$(TEMPDIR)/CELS.o: CELS.cpp CELS.h Common.h makefile
$(TEMPDIR)/CELS.o: CELS.cpp CELS.h _TABI/tabi.h Common.h makefile
$(GCC) -c $(CFLAGS) -fexceptions -o $*.o $<

0 comments on commit 90e7bdb

Please sign in to comment.