Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / diskimage / dms / u_rle.c
blobe990e1248cbbed0c5a932406895fc7746dbf4809
1 /*
2 * xDMS v1.3 - Portable DMS archive unpacker - Public Domain
3 * Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
5 * Run Length Encoding decompression function used in most
6 * modes after decompression by other algorithm
8 */
10 #include "xdms.h"
12 UWORD Unpack_RLE (struct xdms_data *xdms, UBYTE *in, UBYTE *out, UWORD origsize) {
13 UWORD n;
14 UBYTE a,b, *outend;
16 outend = out+origsize;
17 while (out<outend){
18 if ((a = *in++) != 0x90)
19 *out++ = a;
20 else if (!(b = *in++))
21 *out++ = a;
22 else {
23 a = *in++;
24 if (b == 0xff) {
25 n = *in++;
26 n = (UWORD)((n<<8) + *in++);
27 } else
28 n = b;
29 if (out+n > outend) return 1;
30 memset(out,a,(size_t) n);
31 out += n;
34 return 0;